当前位置: 首页>>代码示例>>Java>>正文


Java WorkflowDocument.addSearchableDefinition方法代码示例

本文整理汇总了Java中org.kuali.rice.kew.api.WorkflowDocument.addSearchableDefinition方法的典型用法代码示例。如果您正苦于以下问题:Java WorkflowDocument.addSearchableDefinition方法的具体用法?Java WorkflowDocument.addSearchableDefinition怎么用?Java WorkflowDocument.addSearchableDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.kew.api.WorkflowDocument的用法示例。


在下文中一共展示了WorkflowDocument.addSearchableDefinition方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpSearchableDoc

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
 * Sets up a doc for searching with ranged queries
 */
protected WorkflowDocument setUpSearchableDoc() {
    String documentTypeName = "SearchDocTypeRangeSearchDataType";
	DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);
    String userNetworkId = "rkirkend";
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(userNetworkId), documentTypeName);

    /*
     *   Below we are using the keys and values from the custom searchable attribute classes' static constants but
     *   this is only for convenience as those should always be valid values to test for.
     */
    // adding string searchable attribute
    WorkflowAttributeDefinition.Builder stringXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStringRange");
    stringXMLDef.addPropertyDefinition(TestXMLSearchableAttributeString.SEARCH_STORAGE_KEY, TestXMLSearchableAttributeString.SEARCH_STORAGE_VALUE);
    workflowDocument.addSearchableDefinition(stringXMLDef.build());
    // adding long searchable attribute
    WorkflowAttributeDefinition.Builder longXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStdLongRangeInclusive");
    longXMLDef.addPropertyDefinition(TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY, TestXMLSearchableAttributeLong.SEARCH_STORAGE_VALUE.toString());
    workflowDocument.addSearchableDefinition(longXMLDef.build());
    // adding float searchable attribute
    WorkflowAttributeDefinition.Builder floatXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStdFloatRangeInclusive");
    floatXMLDef.addPropertyDefinition(TestXMLSearchableAttributeFloat.SEARCH_STORAGE_KEY, TestXMLSearchableAttributeFloat.SEARCH_STORAGE_VALUE.toString());
    workflowDocument.addSearchableDefinition(floatXMLDef.build());
    // adding string searchable attribute
    WorkflowAttributeDefinition.Builder dateXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStdDateTimeRangeInclusive");
    dateXMLDef.addPropertyDefinition(TestXMLSearchableAttributeDateTime.SEARCH_STORAGE_KEY, DocumentSearchInternalUtils
            .getDisplayValueWithDateOnly(TestXMLSearchableAttributeDateTime.SEARCH_STORAGE_VALUE));
    workflowDocument.addSearchableDefinition(dateXMLDef.build());

    workflowDocument.setTitle("Routing style");
    workflowDocument.route("routing this document.");

    return WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(userNetworkId), workflowDocument.getDocumentId());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:37,代码来源:StandardGenericXMLSearchableAttributeRangesTest.java

示例2: testXMLStandardSearchableAttributeWithInvalidValue

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testXMLStandardSearchableAttributeWithInvalidValue() throws Exception {
    String documentTypeName = "SearchDocTypeStandardSearchDataType";
    String userNetworkId = "rkirkend";
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(userNetworkId), documentTypeName);

    /*
     *   Below we are using the keys and values from the custom searchable attribute classes' static constants but
     *   this is only for convenience as those should always be valid values to test for.
     */
    // adding string value in what should be a long searchable attribute
    WorkflowAttributeDefinition.Builder longXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStdLong");
    longXMLDef.addPropertyDefinition(TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY, "123x23");
    workflowDocument.addSearchableDefinition(longXMLDef.build());

    workflowDocument.setTitle("Routing style");
    try {
        workflowDocument.route("routing this document.");
        fail("Document should be unroutable with invalid searchable attribute value");
    } catch (Exception e) {
        e.printStackTrace();
    }
    /*
     * The call to TestUtilities below is needed because when exception routing spawns a new thread (see
     * TestExceptionRoutingServiceImpl class) the next test will begin before the exception thread is complete and
     * cause errors. This was originally discovered because the test method
     * testXMLStandardSearchableAttributesWithDataType() would run and get errors loading xml data for workgroups
     * perhaps because the exception thread was keeping the cache around and now allowing it to be cleared?
     */
    TestUtilities.waitForExceptionRouting();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:31,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例3: testSearchableAttributeWithQuickfinder

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
 * Tests the resolution to issues EN-95, KULWF-757, KULOWF-52 whereby the use of a quickfinder is causing
 * NullPointers when searching for documents.
 */
@Test public void testSearchableAttributeWithQuickfinder() throws Exception {
    String documentTypeName = "AttributeWithQuickfinderDocType";
    String key = "chart";
    DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);
     WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), documentTypeName);

     // define the chart for the searchable attribute
     WorkflowAttributeDefinition.Builder chartDef = WorkflowAttributeDefinition.Builder.create("SearchableAttributeWithQuickfinder");
     chartDef.addPropertyDefinition(key, "BL");
     document.addSearchableDefinition(chartDef.build());

     // save the document
     document.setTitle("Routin' with style");
     document.saveDocument("Savin' this document.");

     // prepare to search
     DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);
     Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");

     // execute the search by our chart, we should see one result
     DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
     criteria.setDocumentTypeName(documentTypeName);
     addSearchableAttribute(criteria, key, "BL");
     DocumentSearchResults results = docSearchService.lookupDocuments(user.getPrincipalId(),
             criteria.build());
     assertEquals("Search results should have one document.", 1, results.getSearchResults().size());
     DocumentSearchResult result = results.getSearchResults().get(0);
     String documentId = result.getDocument().getDocumentId();
     assertEquals("Wrong document in search results.", document.getDocumentId(), documentId);

     // search with no searchable attribute criteria, should return our document as well
     criteria = DocumentSearchCriteria.Builder.create();
     criteria.setDocumentTypeName(documentTypeName);
     results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
     assertEquals("Search results should have one document.", 1, results.getSearchResults().size());
     result = results.getSearchResults().get(0);
     assertEquals("Wrong document in search results.", document.getDocumentId(), result.getDocument().getDocumentId());

}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:44,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例4: testRangeDefinitionStringAttributes

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testRangeDefinitionStringAttributes() throws Exception {
    String documentTypeName = "RangeDefinitionTestDocType";
	DocumentType docType = KEWServiceLocator.getDocumentTypeService().findByName(documentTypeName);
    String principalName = "rkirkend";
    String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalName).getPrincipalId();
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(principalId, documentTypeName);

    // adding inclusive-lower-bound searchable attribute
    WorkflowAttributeDefinition.Builder inclusiveLowerXMLDef = WorkflowAttributeDefinition.Builder.create("TextFieldWithInclusiveLower");
    inclusiveLowerXMLDef.addPropertyDefinition("textFieldWithInclusiveLower", "newvalue");
    workflowDocument.addSearchableDefinition(inclusiveLowerXMLDef.build());
    // adding case-sensitive searchable attribute
    WorkflowAttributeDefinition.Builder caseSensitiveXMLDef = WorkflowAttributeDefinition.Builder.create("TextFieldWithCaseSensitivity");
    caseSensitiveXMLDef.addPropertyDefinition("textFieldWithCaseSensitivity", "thevalue");
    workflowDocument.addSearchableDefinition(caseSensitiveXMLDef.build());
    // adding searchable attribute with overridden properties
    WorkflowAttributeDefinition.Builder overridesXMLDef = WorkflowAttributeDefinition.Builder.create("TextFieldWithOverrides");
    overridesXMLDef.addPropertyDefinition("textFieldWithOverrides", "SomeVal");
    workflowDocument.addSearchableDefinition(overridesXMLDef.build());

    workflowDocument.setTitle("Range Def Test");
    workflowDocument.route("routing range def doc.");

    workflowDocument = WorkflowDocumentFactory.loadDocument(principalId, workflowDocument.getDocumentId());

    // Verify that the "TextFieldWithInclusiveLower" attribute behaves as expected (lower-bound-inclusive and (by default) case-insensitive).
    // both upper and lower bounds set to inclusive in attr definition
    assertSearchBehavesAsExpected(docType, principalId, "textFieldWithInclusiveLower",
            new String[] { "newvalue", ""        , ""        , "NEWVALUD", "newValuf", "newValuj", "newvaluf"},
            new String[] { ""        , "newvalue", "Newvaluf", "NEWVALUF", "newValud", "NEWVALUK", ""        },
            new int[]    { 1         , 1         , 1         , 1         , -1        , 0         , 0         });

    // Verify that the "TextFieldWithCaseSensitivity" attribute behaves as expected (bound-inclusive and case-sensitive).
    assertSearchBehavesAsExpected(docType, principalId, "textFieldWithCaseSensitivity",
    		new String[] { "thevalue", ""        , ""        , "THEVALUD", "thevalud", "Thevalud", "THEVALUF"},
    		new String[] { ""        , "thevalue", "Thevalue", "THEVALUF", "THEVALUF", "Thevaluf", ""        },
    		new int[]    { 1         , 1         , 0         , 0         , -1        , 0         , 1         });

    // Verify that the "TextFieldWithOverrides" attribute behaves as expected
    assertSearchBehavesAsExpected(docType, principalId, "textFieldWithOverrides",
    		new String[] { "> someval", "> SomeVal", "<= SOMEVAL", "<= SomeVal", "SOMEVAK>..SomeVam", "SomeVam>..SOMEVAK", "SOMEVAM>..SomeVak", "> somevak", "<= SomeVak" },
          //new String[] { ""         , ""         ,    "SOMEVAL",    "SomeVal", "SomeVam"          ,           "SOMEVAK",           "SomeVak", ""         ,    "SomeVak"},
    		new int[]    { 0          , 0          , 1           , 1           , 1                  , -1                 , -1                 , 1          , 0        });
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:45,代码来源:StandardGenericXMLSearchableAttributeRangesTest.java

示例5: testRouteDocumentWithSearchableAttribute

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testRouteDocumentWithSearchableAttribute() throws Exception {
    String documentTypeName = "SearchDocType";
    String key = "givenname";
    DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), documentTypeName);
    WorkflowAttributeDefinition.Builder givennameXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttribute");

    workflowDocument.setApplicationContent("<test></test>");

    givennameXMLDef.addPropertyDefinition(key, "jack");
    workflowDocument.addSearchableDefinition(givennameXMLDef.build());

    workflowDocument.setTitle("Routing style");
    workflowDocument.route("routing this document.");

    DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");
    DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "jack");
    DocumentSearchResults results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());

    criteria = null;
    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "fred");
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should be empty.", 0, results.getSearchResults().size());

    criteria = null;
    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, "fakeproperty", "doesntexist");
    try {
        docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
        fail("Search results should be throwing a validation exception for use of non-existant searchable attribute");
    } catch (RuntimeException wsee) {
        assertTrue(wsee.getMessage().contains("LookupException"));
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:45,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例6: testDocumentSearchAttributeWildcarding

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testDocumentSearchAttributeWildcarding() throws Exception {
    DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);

    String documentTypeName = "SearchDocType";
    String key = "givenname";
    DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(
            documentTypeName);
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"),
            documentTypeName);
    WorkflowAttributeDefinition.Builder givennameXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttribute");

    workflowDocument.setApplicationContent("<test></test>");

    givennameXMLDef.addPropertyDefinition(key, "jack");
    workflowDocument.addSearchableDefinition(givennameXMLDef.build());

    workflowDocument.setTitle("Routing style");
    workflowDocument.route("routing this document.");

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");
    DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "jack");
    DocumentSearchResults results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "ja*");
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "ja");
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should have one document.", 0, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "*ack");
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:49,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例7: testDocumentSearchAttributeWildcardingDisallow

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testDocumentSearchAttributeWildcardingDisallow() throws Exception {
    DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);

    String documentTypeName = "SearchDocTypeStandardSearchDataType";
    DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);
    String userNetworkId = "rkirkend";
    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(userNetworkId), documentTypeName);

    /*
     *   Below we are using the keys and values from the custom searchable attribute classes' static constants but
     *   this is only for convenience as those should always be valid values to test for.
     */
    WorkflowAttributeDefinition.Builder longXMLDef = WorkflowAttributeDefinition.Builder.create("XMLSearchableAttributeStdLong");
    longXMLDef.addPropertyDefinition(TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY, TestXMLSearchableAttributeLong.SEARCH_STORAGE_VALUE.toString());
    workflowDocument.addSearchableDefinition(longXMLDef.build());
    workflowDocument.setTitle("Routing style");
    workflowDocument.route("routing this document.");

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(userNetworkId);

    String validSearchValue = TestXMLSearchableAttributeLong.SEARCH_STORAGE_VALUE.toString();
    DocumentSearchCriteria.Builder criteria = null;
    DocumentSearchResults results = null;
    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY, validSearchValue);
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY,
            "*" + validSearchValue.substring(2));

    if ((new SearchableAttributeLongValue()).allowsWildcards()) {
        results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
        assertEquals("Search results should be empty using wildcard '*' value.", 0, results.getSearchResults().size());
    } else {
        try {
            docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
            fail("Search results should be throwing a validation exception for use of the character '*' without allowing wildcards");
        } catch (WorkflowServiceErrorException wsee) {}
    }

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, TestXMLSearchableAttributeLong.SEARCH_STORAGE_KEY, validSearchValue.substring(
            0, (validSearchValue.length() - 2)));
    results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
    assertEquals("Search results should be empty trying to use assumed ending wildcard.", 0, results.getSearchResults().size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:52,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例8: testRouteDocumentWithXStreamSearchableAttribute

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
 * Tests the XStreamSafeEvaluator against searchable attributes to resolve EN-63 and KULWF-723.
 *
 * This test is pretty much just a copy of testRouteDocumentWithSearchableAttribute using a
 * different document type which defines the same xpath expression, only with embedded
 * XStream "reference" attributes in the XML.
 */
@Test public void testRouteDocumentWithXStreamSearchableAttribute() throws Exception {
    String documentTypeName = "SearchDocType";
    String key = "givenname";
    DocumentType docType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(documentTypeName);

    WorkflowDocument workflowDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "SearchDocTypeXStream");
    WorkflowAttributeDefinition.Builder givennameXMLDef = WorkflowAttributeDefinition.Builder.create("XMLXStreamSearchableAttribute");

    workflowDocument.setApplicationContent("<test></test>");

    givennameXMLDef.addPropertyDefinition("givenname", "jack");
    workflowDocument.addSearchableDefinition(givennameXMLDef.build());

    workflowDocument.setTitle("Routing style");
    workflowDocument.route("routing this document.");

    DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);

    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");
    DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "jack");
    DocumentSearchResults results =  docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should be empty.", 0, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, key, "fred");
    results =  docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());

    assertEquals("Search results should be empty.", 0, results.getSearchResults().size());

    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    addSearchableAttribute(criteria, "fakeproperty", "doesntexist");
    try {
        results =  docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
        fail("Search results should be throwing a validation exception for use of non-existant searchable attribute");
    } catch (RuntimeException wsee) {
        assertTrue(wsee.getMessage().contains("LookupException"));
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例9: testSearchableAttributeWithHiddens

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
 * Tests that the hiding of fields and columns works properly to resolve EN-53.
 *
 * TODO this is currently commented out because we can't test this properly through the unit
 * test since the filtering of the column actually happens in the web-tier.  Shoudl this be
 * the case?  Maybe we need to re-examine when we refactor document search.
 */
@Ignore // can't test this properly through the unit test since the filtering of the column actually happens in the web-tier
@Test public void testSearchableAttributeWithHiddens() throws Exception {
    // for the following document, the chart field should not show up in the result set and the org field
    // should not show up in the criteriaw
    String docType = "AttributeWithHiddensDocType";
    DocumentType documentType = ((DocumentTypeService)KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)).findByName(docType);

    String attributeName = "SearchableAttributeWithHiddens";
    WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), docType);

    // define the chart for the searchable attribute
    WorkflowAttributeDefinition.Builder chartDef = WorkflowAttributeDefinition.Builder.create(attributeName);
    chartDef.addPropertyDefinition("chart", "BL");
    chartDef.addPropertyDefinition("org", "ARSC");
    chartDef.addPropertyDefinition("dollar", "24");
    document.addSearchableDefinition(chartDef.build());

    // save the document
    document.setTitle("Routin' with style");
    document.saveDocument("Savin' this document.");

    // prepare to search
    DocumentSearchService docSearchService = (DocumentSearchService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_SEARCH_SERVICE);
    Person user = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("rkirkend");

    // execute the search by our chart, we should see one result
    DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(docType);
    addSearchableAttribute(criteria, "chart", "BL");
    DocumentSearchResults results = docSearchService.lookupDocuments(user.getPrincipalId(), criteria.build());
    assertEquals("Search results should have one document.", 1, results.getSearchResults().size());
    DocumentSearchResult result = results.getSearchResults().get(0);
    assertEquals("Wrong document in search results.", document.getDocumentId(), result.getDocument().getDocumentId());
    // also check that the chart field is not in the result set and the org field is
    DocumentAttribute documentAttribute = result.getSingleDocumentAttributeByName("chart");
    assertNull("The chart column should not be in the result set!", documentAttribute);
    documentAttribute = result.getSingleDocumentAttributeByName("org");
    assertNotNull("The org column should be in the result set", documentAttribute);
    assertEquals("Wrong org code.", "ARSC", documentAttribute.getValue());
    documentAttribute = result.getSingleDocumentAttributeByName("dollar");
    assertNotNull("The dollar column should be in the result set", documentAttribute);
    assertEquals("Wrong dollar code.", "24", documentAttribute.getValue().toString());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:StandardGenericXMLSearchableAttributeTest.java

示例10: testFiltering_SearchAttribute

import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testFiltering_SearchAttribute() throws Exception {

        String searchAttributeName = "UserEmployeeId";
        String searchAttributeFieldName = "employeeId";
        String documentTypeName = "SecurityDoc_SearchAttributeOnly";
        String initiatorNetworkId = STANDARD_USER_NETWORK_ID;
        WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalId(initiatorNetworkId), documentTypeName);
        WorkflowAttributeDefinition.Builder definition = WorkflowAttributeDefinition.Builder.create(searchAttributeName);
        definition.addPropertyDefinition(searchAttributeFieldName, "user3");
        document.addSearchableDefinition(definition.build());
        document.route("");
        assertFalse("Document should not be in init status after routing", document.isInitiated());

        // verify that initiator cannot see the document
        DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        DocumentSearchResults results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId(initiatorNetworkId), criteria.build());
        assertEquals("Should retrive no records from search", 0, results.getSearchResults().size());
        assertEquals("One row should have been filtered due to security", 1, results.getNumberOfSecurityFilteredResults());

        // verify that user3 can see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId("user3"), criteria.build());
        assertEquals("Should retrive one record from search", 1, results.getSearchResults().size());
        assertEquals("No rows should have been filtered due to security", 0, results.getNumberOfSecurityFilteredResults());

        // verify that user2 cannot see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId("user2"), criteria.build());
        assertEquals("Should retrive no records from search", 0, results.getSearchResults().size());
        assertEquals("One row should have been filtered due to security", 1, results.getNumberOfSecurityFilteredResults());

        // verify that WorkflowAdmin can see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId(WORKFLOW_ADMIN_USER_NETWORK_ID), criteria.build());
        assertEquals("Should retrive one record from search", 1, results.getSearchResults().size());
        assertEquals("No rows should have been filtered due to security", 0, results.getNumberOfSecurityFilteredResults());

        RouteContext.clearCurrentRouteContext();
        document = WorkflowDocumentFactory.loadDocument(getPrincipalId(APPROVER_USER_NETWORK_ID), document.getDocumentId());
        document.clearSearchableContent();
        definition = WorkflowAttributeDefinition.Builder.create(searchAttributeName);
        definition.addPropertyDefinition(searchAttributeFieldName, "user2");
        document.addSearchableDefinition(definition.build());
        document.saveDocumentData();

        // verify that user2 can see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId("user2"), criteria.build());
        assertEquals("Should retrive one record from search", 1, results.getSearchResults().size());
        assertEquals("No rows should have been filtered due to security", 0, results.getNumberOfSecurityFilteredResults());

        // verify that user3 cannot see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId("user3"), criteria.build());
        assertEquals("Should retrive no records from search", 0, results.getSearchResults().size());
        assertEquals("One row should have been filtered due to security", 1, results.getNumberOfSecurityFilteredResults());

        // verify that initiator cannot see the document
        criteria = DocumentSearchCriteria.Builder.create();
        criteria.setDocumentId(document.getDocumentId());
        results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(getPrincipalId(initiatorNetworkId), criteria.build());
        assertEquals("Should retrive no records from search", 0, results.getSearchResults().size());
        assertEquals("One row should have been filtered due to security", 1, results.getNumberOfSecurityFilteredResults());
    }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:71,代码来源:DocumentSearchSecurityTest.java


注:本文中的org.kuali.rice.kew.api.WorkflowDocument.addSearchableDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。