本文整理汇总了Java中org.kuali.rice.kew.api.WorkflowDocument.adHocToGroup方法的典型用法代码示例。如果您正苦于以下问题:Java WorkflowDocument.adHocToGroup方法的具体用法?Java WorkflowDocument.adHocToGroup怎么用?Java WorkflowDocument.adHocToGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.kew.api.WorkflowDocument
的用法示例。
在下文中一共展示了WorkflowDocument.adHocToGroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAdHocWithRequestLabel_ToGroup
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void testAdHocWithRequestLabel_ToGroup() throws Exception {
WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("user1"), ADHOC_DOC);
String label = "MY GROUP LABEL";
Group workflowAdmin = KEWServiceLocator.getIdentityHelperService().getGroupByName("KR-WKFLW", "WorkflowAdmin");
doc.adHocToGroup(ActionRequestType.APPROVE, null, "", workflowAdmin.getId(), "", true, label);
List<ActionRequestValue> actionRequests = KEWServiceLocator.getActionRequestService().findPendingRootRequestsByDocId(doc.getDocumentId());
assertEquals("Should have 1 request.", 1, actionRequests.size());
ActionRequestValue actionRequest = actionRequests.get(0);
assertEquals("Should be an approve request", ActionRequestType.APPROVE.getCode(), actionRequest.getActionRequested());
assertEquals("Invalid request label", label, actionRequest.getRequestLabel());
assertEquals("Request should be initialized", ActionRequestStatus.INITIALIZED.getCode(), actionRequest.getStatus());
// now route the document, it should activate the request and create action items
doc.route("");
Collection<ActionItem> actionItems = KEWServiceLocator.getActionListService().getActionListForSingleDocument(doc.getDocumentId());
assertTrue("Should have more than 1 action item.", actionItems.size() > 1);
for (ActionItem actionItem : actionItems) {
assertEquals("ActionItem should be constructed from request.", actionRequest.getActionRequestId(), actionItem.getActionRequestId());
assertEquals("ActionItem should have same label", label, actionItem.getRequestLabel());
}
}
示例2: testParallelAdHocRouting
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void testParallelAdHocRouting() throws Exception {
WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), ADHOC_DOC);
docId = doc.getDocumentId();
doc.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false);
doc = getDocument("dewey");
assertFalse("User andlee should not have an approve request yet. Document not yet routed.", doc.isApprovalRequested());
doc.adHocToGroup(ActionRequestType.APPROVE, "AdHoc", "annotation2", getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "WorkflowAdmin"), "respDesc2", true);
doc = getDocument("quickstart");
assertFalse("User should not have approve request yet. Document not yet routed.", doc.isApprovalRequested());
doc = getDocument("rkirkend");
doc.route("");
// there should be two adhoc requests
List<ActionRequest> actionRequests = doc.getRootActionRequests();
for (ActionRequest actionRequest : actionRequests) {
assertTrue("Request should be an adhoc request.", actionRequest.isAdHocRequest());
}
//all users should now have active approvals
WorkflowDocument deweyDoc = getDocument("dewey");
assertTrue("Dewey should have an approve request", deweyDoc.isApprovalRequested());
doc = getDocument("ewestfal");// test that more than 1 member got
// requests
assertTrue("WorkflowAdmin should have an approve request", doc.isApprovalRequested());
deweyDoc.approve("");
doc.approve("");
doc = getDocument("user1");//this dude has a rule in ActionsConfig.xml
doc.approve("");
assertTrue("The document should be final", doc.isFinal());
}
示例3: testUpdateActionItemsForNestedGroupChange
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* When workgroup membership changes all action items to that workgroup need to reflect
* the new membership even in the case of nested workgroups.
*
* @throws Exception
*/
@Test public void testUpdateActionItemsForNestedGroupChange() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("user1"), "ActionItemDocumentType");
document.setTitle("");
Group workgroup1 = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName("KR-WKFLW",
"AIWG-Admin");
document.adHocToGroup(ActionRequestType.APPROVE, "",workgroup1.getId(), "", true);
document.route("");
Principal ewestfal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName("ewestfal");
assertEquals("User should have 1 action item", 1, KEWServiceLocator.getActionListService().findByPrincipalId(ewestfal.getPrincipalId()).size());
assertEquals("Workgroup should have 6 members.", 6, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
KimApiServiceLocator.getGroupService().removePrincipalFromGroup(ewestfal.getPrincipalId(), workgroup1.getId());
assertEquals("Workgroup should have 5 members.", 5,
KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
assertEquals("User should have 0 action item", 0, KEWServiceLocator.getActionListService().findByPrincipalId(ewestfal.getPrincipalId()).size());
KimApiServiceLocator.getGroupService().addPrincipalToGroup(ewestfal.getPrincipalId(), workgroup1.getId());
assertEquals("Workgroup should have 6 members.", 6, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
assertEquals("User should have 1 action item", 1, KEWServiceLocator.getActionListService().findByPrincipalId(ewestfal.getPrincipalId()).size());
// test the save group
Group workgroup1Impl = this.getGroup(workgroup1.getId());
Principal dewey = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName("dewey");
KimApiServiceLocator.getGroupService().addPrincipalToGroup(dewey.getPrincipalId(), workgroup1Impl.getId());
//GroupMember groupMember = GroupMember.Builder.create(workgroup1Impl.getId(), dewey.getPrincipalId(), KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE).build();
//GroupBo workgroup1Bo = GroupBo.from(workgroup1Impl);
//workgroup1Bo.getMembersOfGroup().add(GroupMemberBo.from(groupMember));
//workgroup1Impl.getMembersOfGroup().add(groupMember);
//KimImplServiceLocator.getGroupInternalService().saveWorkgroup(workgroup1Bo);
assertEquals("Workgroup should have 7 members.", 7, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
assertEquals("User should have 1 action item", 1, KEWServiceLocator.getActionListService().findByPrincipalId(dewey.getPrincipalId()).size());
// test nested
Principal user1 = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName("user1");
document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("jhopf"), "ActionItemDocumentType");
document.setTitle("");
workgroup1 = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName("KR-WKFLW", "AIWG-Nested1");
document.adHocToGroup(ActionRequestType.APPROVE, "",workgroup1.getId(), "", true);
document.route("");
assertEquals("User should have 1 action item", 1, KEWServiceLocator.getActionListService().findByPrincipalId(user1.getPrincipalId()).size());
assertEquals("Workgroup should have 6 members.", 6, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
//get the subgroup so we can remove the member.
Group workgroupSub = KimApiServiceLocator.getGroupService().getGroupByNamespaceCodeAndName("KR-WKFLW",
"AIWG-Nested2");
KimApiServiceLocator.getGroupService().removePrincipalFromGroup(user1.getPrincipalId(), workgroupSub.getId());
assertEquals("Workgroup should have 5 members.", 5, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
assertEquals("User should have 0 action item", 0, KEWServiceLocator.getActionListService().findByPrincipalId(user1.getPrincipalId()).size());
KimApiServiceLocator.getGroupService().addPrincipalToGroup(user1.getPrincipalId(), workgroupSub.getId());
assertEquals("Workgroup should have 6 members.", 6, KimApiServiceLocator.getGroupService().getMemberPrincipalIds(workgroup1.getId()).size());
assertEquals("User should have 1 action item", 1, KEWServiceLocator.getActionListService().findByPrincipalId(user1.getPrincipalId()).size());
}
示例4: testRevokeByUserAndGroup
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Tests revoking by user and workgroup.
*/
@Test public void testRevokeByUserAndGroup() throws Exception {
// ad hoc the document to dewey (twice) and the workgroup WorkflowAdmin
WorkflowDocument doc =WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), ADH0C_DOC);
docId = doc.getDocumentId();
String principalId = getPrincipalIdForName("dewey");
doc.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "annotationDewey1", principalId, "respDesc1", false);
doc.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "annotationDewey2", principalId, "respDesc1", false);
String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "WorkflowAdmin");
doc.adHocToGroup(ActionRequestType.APPROVE, "AdHoc", "Annotation WorkflowAdmin", groupId, "respDesc2", true);
TestUtilities.assertNumberOfPendingRequests(docId, 3);
TestUtilities.assertUserHasPendingRequest(docId, "dewey");
TestUtilities.assertUserHasPendingRequest(docId, "quickstart");
// route the document, this should activate the ad hoc requests
doc.route("");
assertTrue(doc.isEnroute());
TestUtilities.assertAtNodeNew(doc, "AdHoc");
TestUtilities.assertNumberOfPendingRequests(docId, 3);
String testGroupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup");
// try revoking by a user and workgroup without adhoc requests, it should effectively be a no-op
AdHocRevoke revoke = AdHocRevoke.createRevokeFromPrincipal(getPrincipalIdForName("ewestfal"));
doc.revokeAdHocRequests(revoke, "This should be a no-op");
revoke = AdHocRevoke.createRevokeFromGroup(testGroupId);
doc.revokeAdHocRequests(revoke, "This should be a no-op");
doc = getDocument("rkirkend");
TestUtilities.assertNumberOfPendingRequests(docId, 3);
TestUtilities.assertUserHasPendingRequest(docId, "dewey");
TestUtilities.assertUserHasPendingRequest(docId, "quickstart");
// now revoke each request in turn, after the second one is invoked the document should transition to it's next route level
// and route to user1
revoke = AdHocRevoke.createRevokeFromPrincipal(getPrincipalIdForName("dewey"));
doc.revokeAdHocRequests(revoke, "revokeUser");
TestUtilities.assertNumberOfPendingRequests(docId, 1);
doc = getDocument("dewey");
assertFalse("dewey should no longer have an approve request.", doc.isApprovalRequested());
revoke = AdHocRevoke.createRevokeFromGroup(groupId);
doc.revokeAdHocRequests(revoke, "revokeWorkgroup");
// the doc should now transition to the next node
doc = getDocument("user1");
TestUtilities.assertAtNodeNew(doc, "One");
assertTrue("user1 should have an approve request.", doc.isApprovalRequested());
doc.approve("");
// doc should now be final
assertTrue("doc should be final", doc.isFinal());
}
示例5: testRevokeByNodeName
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Tests revoking by node name.
*/
@Test public void testRevokeByNodeName() throws Exception {
// ad hoc requests at the AdHoc node and then revoke the entire node
WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), ADH0C_DOC);
docId = doc.getDocumentId();
doc.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "annotationDewey1", getPrincipalIdForName("dewey"), "respDesc1", false);
String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "WorkflowAdmin");
doc.adHocToGroup(ActionRequestType.APPROVE, "AdHoc", "Annotation WorkflowAdmin", groupId, "respDesc2", true);
TestUtilities.assertNumberOfPendingRequests(docId, 2);
// now revoke the node
doc.revokeAdHocRequests(AdHocRevoke.createRevokeAtNode("AdHoc"), "");
TestUtilities.assertNumberOfPendingRequests(docId, 0);
// send an Acknowledge to the AdHoc node prior to routing
doc.adHocToPrincipal(ActionRequestType.ACKNOWLEDGE, "AdHoc", "annotationEwestfal1", getPrincipalIdForName("ewestfal"), "respDesc1", false);
// route the document
doc = getDocument("rkirkend");
doc.route("");
TestUtilities.assertAtNodeNew(doc, "One");
// ewestfal should have an acknowledge request
doc = getDocument("ewestfal");
assertTrue(doc.isAcknowledgeRequested());
// approve the document, it should go PROCESSED
doc = getDocument("user1");
assertTrue(doc.isApprovalRequested());
doc.approve("");
assertTrue(doc.isProcessed());
// revoke at the "One" node where there are no requests, it should be a no-op (the document should stay processed)
doc.revokeAdHocRequests(AdHocRevoke.createRevokeAtNode("One"), "");
doc = getDocument("ewestfal");
assertTrue(doc.isProcessed());
// now revoke the ACKNOWLEDGE to ewestfal by revoking at the "AdHoc" node, the document should go FINAL
doc.revokeAdHocRequests(AdHocRevoke.createRevokeAtNode("AdHoc"), "");
doc = getDocument("ewestfal");
assertTrue(doc.isFinal());
}
示例6: testRevokePriorToRouting
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Tests the behavior revocation of ad hoc requests prior to the routing of the document.
*
* @throws Exception
*/
@Test public void testRevokePriorToRouting() throws Exception {
// ad hoc the document to dewey and the workgroup WorkflowAdmin
WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), ADH0C_DOC);
docId = doc.getDocumentId();
doc.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "annotation1", getPrincipalIdForName("dewey"), "respDesc1", false);
doc = getDocument("dewey");
assertFalse("User andlee should not have an approve request yet. Document not yet routed.", doc.isApprovalRequested());
String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "WorkflowAdmin");
doc.adHocToGroup(ActionRequestType.APPROVE, "AdHoc", "annotation2", groupId , "respDesc2", true);
doc = getDocument("quickstart");
assertFalse("User should not have approve request yet. Document not yet routed.", doc.isApprovalRequested());
// the document should be initiated at this point
assertTrue("Document should still be intitiated.", doc.isInitiated());
// check and revoke the actual ActionRequestVOs
// reaquire the document as the initiator
doc = getDocument("rkirkend");
List<ActionRequest> actionRequestVOs = KewApiServiceLocator.getWorkflowDocumentService().getRootActionRequests(doc.getDocumentId());
assertEquals("There should be 2 ad hoc requests.", 2, actionRequestVOs.size());
for (ActionRequest requestVO : actionRequestVOs) {
assertTrue("Should be an ad hoc request.", requestVO.isAdHocRequest());
// revoke by id
doc.revokeAdHocRequestById(requestVO.getId().toString(), "");
}
// now the document should have no pending action requests on it
List actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(docId);
assertEquals("There should be no pending requests.", 0, actionRequests.size());
// check that the "ActionTakens" have been properly recorded
Collection<ActionTakenValue> actionTakens = KEWServiceLocator.getActionTakenService().findByDocumentId(docId);
// count how many are AdhocRevoked
int numAdhocRevoked = 0;
for (ActionTakenValue actionTaken : actionTakens) {
if (actionTaken.getActionTaken().equals(KewApiConstants.ACTION_TAKEN_ADHOC_REVOKED_CD)) {
numAdhocRevoked++;
}
}
assertEquals("There should be 2 'AdHocRevoked' action takens", 2, numAdhocRevoked);
// now check that the document is still intiated
doc = getDocument("rkirkend");
assertTrue("Document should still be intitiated.", doc.isInitiated());
}
示例7: testIsLastApprover
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testIsLastApprover() throws Exception {
// test the is last approver in route level against our sequential document type
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), SeqSetup.DOCUMENT_TYPE_NAME);
document.saveDocumentData();
WorkflowDocumentActionsService wdas = KewApiServiceLocator.getWorkflowDocumentActionsService();
// the initial "route level" should have no requests initially so it should return false
assertFalse("Should not be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("ewestfal"), SeqSetup.ADHOC_NODE));
// app specific route a request to a workgroup at the initial node (TestWorkgroup)
String groupId = getGroupIdForName(KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, "TestWorkgroup");
document.adHocToGroup(ActionRequestType.APPROVE, "AdHoc", "", groupId, "", false);
assertTrue("Should be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("ewestfal"), SeqSetup.ADHOC_NODE));
// app specific route a request to a member of the workgroup (jitrue)
document.adHocToPrincipal(ActionRequestType.APPROVE, "AdHoc", "", getPrincipalIdForName("jitrue"), "", false);
// member of the workgroup with the user request should be last approver
assertTrue("Should be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("jitrue"), SeqSetup.ADHOC_NODE));
// other members of the workgroup will not be last approvers because they don't satisfy the individuals request (ewestfal)
assertFalse("Should not be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("ewestfal"), SeqSetup.ADHOC_NODE));
// route the document, should stay at the adhoc node until those requests have been completed
document.route("");
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("jitrue"), document.getDocumentId());
assertEquals("Document should be at adhoc node.", SeqSetup.ADHOC_NODE, document.getNodeNames().iterator().next());
assertTrue("Approve should be requested.", document.isApprovalRequested());
document.approve("");
// document should now be at the WorkflowDocument node with a request to bmcgough and rkirkend
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("bmcgough"), document.getDocumentId());
assertTrue("Approve should be requested.", document.isApprovalRequested());
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
assertTrue("Approve should be requested.", document.isApprovalRequested());
// since there are two requests, neither should be last approver
assertFalse("Should not be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("bmcgough"), SeqSetup.WORKFLOW_DOCUMENT_NODE));
assertFalse("Should not be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("rkirkend"), SeqSetup.WORKFLOW_DOCUMENT_NODE));
document.approve("");
// request to rirkend has been satisfied, now request to bmcgough is only request remaining at level so he should be last approver
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("bmcgough"), document.getDocumentId());
assertTrue("Approve should be requested.", document.isApprovalRequested());
assertTrue("Should be last approver.", wdas.isLastApproverAtNode(document.getDocumentId(), getPrincipalIdForName("bmcgough"), SeqSetup.WORKFLOW_DOCUMENT_NODE));
document.approve("");
}