本文整理汇总了Java中org.kuali.rice.kew.api.WorkflowDocument.blanketApprove方法的典型用法代码示例。如果您正苦于以下问题:Java WorkflowDocument.blanketApprove方法的具体用法?Java WorkflowDocument.blanketApprove怎么用?Java WorkflowDocument.blanketApprove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.kew.api.WorkflowDocument
的用法示例。
在下文中一共展示了WorkflowDocument.blanketApprove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetFlattenedNodeInstances
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testGetFlattenedNodeInstances() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "SeqDocType");
document.saveDocument("");
DocumentRouteHeaderValue serverDocument = KEWServiceLocator.getRouteHeaderService().getRouteHeader(document.getDocumentId());
List routeNodeInstances = routeNodeService.getFlattenedNodeInstances(serverDocument, true);
assertEquals(1, routeNodeInstances.size());
assertEquals("AdHoc", ((RouteNodeInstance)routeNodeInstances.get(0)).getName());
document.blanketApprove("");
assertTrue(document.isProcessed());
serverDocument = KEWServiceLocator.getRouteHeaderService().getRouteHeader(document.getDocumentId());
routeNodeInstances = routeNodeService.getFlattenedNodeInstances(serverDocument, true);
assertEquals(4, routeNodeInstances.size());
assertEquals("AdHoc", ((RouteNodeInstance)routeNodeInstances.get(0)).getName());
assertEquals("WorkflowDocument", ((RouteNodeInstance)routeNodeInstances.get(1)).getName());
assertEquals("Acknowledge1", ((RouteNodeInstance)routeNodeInstances.get(2)).getName());
assertEquals("Acknowledge2", ((RouteNodeInstance)routeNodeInstances.get(3)).getName());
}
示例2: testMoveDocumentParallel
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testMoveDocumentParallel() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), ParallelSetup.DOCUMENT_TYPE_NAME);
document.blanketApprove("", new String[] { ParallelSetup.WORKFLOW_DOCUMENT_2_B2_NODE, ParallelSetup.WORKFLOW_DOCUMENT_3_B1_NODE, ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE });
Set nodeNames = TestUtilities.createNodeInstanceNameSet(KEWServiceLocator.getRouteNodeService().getActiveNodeInstances(document.getDocumentId()));
assertEquals("There should be 3 active nodes.", 3, nodeNames.size());
assertTrue("Should be at WorkflowDocument3-B1", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_3_B1_NODE));
assertTrue("Should be at WorkflowDocument2-B2", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_2_B2_NODE));
assertTrue("Should be at WorkflowDocument4-B3", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE));
// try to move the document from WorkflowDocument3-B1 to WorkflowDocument2-B1
document.move(MovePoint.create(ParallelSetup.WORKFLOW_DOCUMENT_3_B1_NODE, -1), "");
nodeNames = TestUtilities.createNodeInstanceNameSet(KEWServiceLocator.getRouteNodeService().getActiveNodeInstances(document.getDocumentId()));
assertEquals("There should be 3 active nodes.", 3, nodeNames.size());
assertTrue("Should be at WorkflowDocument2-B1", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE));
assertTrue("Should be at WorkflowDocument2-B2", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_2_B2_NODE));
assertTrue("Should be at WorkflowDocument4-B3", nodeNames.contains(ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE));
}
示例3: testBlanketApproveParallel
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testBlanketApproveParallel() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ParallelSetup.DOCUMENT_TYPE_NAME);
document.blanketApprove("");
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), document.getDocumentId());
assertTrue("Document should be processed.", document.isProcessed());
Collection nodeInstances = getRouteNodeService().getActiveNodeInstances(document.getDocumentId());
// once the document has gone processed there are no active nodes
assertEquals("Wrong number of active nodes.", 0, nodeInstances.size());
nodeInstances = getRouteNodeService().getTerminalNodeInstances(document.getDocumentId());
assertEquals("Wrong number of terminal nodes.", 1, nodeInstances.size());
RouteNodeInstance ackNodeInstance = (RouteNodeInstance)nodeInstances.iterator().next();
assertEquals("At wrong node.", SequentialSetup.ACKNOWLEDGE_2_NODE, ackNodeInstance.getRouteNode().getRouteNodeName());
assertTrue("Node should be complete.", ackNodeInstance.isComplete());
List actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getDocumentId());
assertEquals("Wrong number of pending action requests.", 10, actionRequests.size());
}
示例4: blanketApprove
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Override
public void blanketApprove(WorkflowDocument workflowDocument, String annotation, List<AdHocRouteRecipient> adHocRecipients) throws WorkflowException {
if (LOG.isDebugEnabled()) {
LOG.debug("blanket approving document(" + workflowDocument.getDocumentId() + ",'" + annotation + "')");
}
handleAdHocRouteRequests(workflowDocument, annotation, filterAdHocRecipients(adHocRecipients, new String[] { KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ }));
workflowDocument.blanketApprove(annotation);
}
示例5: testOrphanedAcknowledgeFromBlanketApprovalFix
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* This tests verifies that bug KULWF-507 has been fixed:
*
* https://test.kuali.org/jira/browse/KULWF-507
*
* To fix this, we implemented the system so that multiple action items are generated rather then just
* one which gets reassigned across multiple requests as needed.
*
* This test verifies that after the blanket approval, there should no longer be an orphaned Acknowledge
* request. The workgroup used here is the TestWorkgroup and "user1" is ewestfal with "user2" as rkirkend.
*
* The routing is configured in the BAOrphanedRequestDocumentType.
*/
@Test public void testOrphanedAcknowledgeFromBlanketApprovalFix() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "BAOrphanedRequestDocumentType");
document.blanketApprove("");
assertTrue("Document should be processed.", document.isProcessed());
// after the document has blanket approved there should be 2 action items since the blanket approver
// is in the final workgroup. These action items should be the acknowledges generated to both
// rkirkend and user1
int numActionItems = actionListService.findByDocumentId(document.getDocumentId()).size();
assertEquals("Incorrect number of action items.", 2, numActionItems);
String user1PrincipalId = getPrincipalIdForName("user1");
String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
// check that user1 has 1 action item
Collection actionItems = actionListService.findByWorkflowUserDocumentId(user1PrincipalId, document.getDocumentId());
assertEquals("user1 should have one action item.", 1, actionItems.size());
// check that rkirkend still has 1, the is where the bug would have manifested itself before, rkirkend would have had
// no action item (hence the orphaned request)
actionItems = actionListService.findByWorkflowUserDocumentId(rkirkendPrincipalId, document.getDocumentId());
assertEquals("rkirkend should have one action item.", 1, actionItems.size());
// lets go ahead and take it to final for funsies
document = WorkflowDocumentFactory.loadDocument(rkirkendPrincipalId, document.getDocumentId());
assertTrue("Should have ack request.", document.isAcknowledgeRequested());
document.acknowledge("");
assertTrue("Should still be PROCESSED.", document.isProcessed());
document = WorkflowDocumentFactory.loadDocument(user1PrincipalId, document.getDocumentId());
assertTrue("Should have ack request.", document.isAcknowledgeRequested());
document.acknowledge("");
assertTrue("Should now be FINAL.", document.isFinal());
}
示例6: testOnlyPersonWhoTookActionReceivesOutboxItem_BlanketApprove
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test
public void testOnlyPersonWhoTookActionReceivesOutboxItem_BlanketApprove() throws Exception {
final String rkirkendPrincipalId = getPrincipalIdForName("rkirkend");
final String user1PrincipalId = getPrincipalIdForName("user1");
List<String> recipients = new ArrayList<String>();
recipients.add(rkirkendPrincipalId);
recipients.add(user1PrincipalId);
TestRuleAttribute.setRecipientPrincipalIds("TestRole", "qualRole", recipients);
turnOnOutboxForUser(rkirkendPrincipalId);
turnOnOutboxForUser(user1PrincipalId);
WorkflowDocument document = WorkflowDocumentFactory.createDocument(rkirkendPrincipalId, "TestDocumentType");
document.blanketApprove("");
// verify only user who took action has the outbox item
assertEquals("Wrong number of outbox items found for rkirkend", 0, KEWServiceLocator.getActionListService().getOutbox(rkirkendPrincipalId, new ActionListFilter()).size());
assertEquals("Wrong number of outbox items found for user1", 0, KEWServiceLocator.getActionListService().getOutbox(user1PrincipalId, new ActionListFilter()).size());
document = WorkflowDocumentFactory.createDocument(rkirkendPrincipalId, "TestDocumentType");
document.saveDocument("");
// verify test is sane and users have action items
assertEquals("Wrong number of action items found for rkirkend", 1, KEWServiceLocator.getActionListService().getActionList(rkirkendPrincipalId, new ActionListFilter()).size());
// verify that outboxes of two users are clear
assertEquals("Wrong number of outbox items found for rkirkend", 0, KEWServiceLocator.getActionListService().getOutbox(rkirkendPrincipalId, new ActionListFilter()).size());
assertEquals("Wrong number of outbox items found for user1", 0, KEWServiceLocator.getActionListService().getOutbox(user1PrincipalId, new ActionListFilter()).size());
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
document.blanketApprove("");
// verify only user who took action has the outbox item
assertEquals("Wrong number of outbox items found for rkirkend", 1, KEWServiceLocator.getActionListService().getOutbox(rkirkendPrincipalId, new ActionListFilter()).size());
assertEquals("Wrong number of outbox items found for user1", 0, KEWServiceLocator.getActionListService().getOutbox(user1PrincipalId, new ActionListFilter()).size());
}
示例7: testBlanketApproverNotInBlanketApproverWorkgroup
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* When a user is not in the blanket approver workgroup an exception should be thrown and
* it should have a good message.
*
* @throws Exception
*/
@Test public void testBlanketApproverNotInBlanketApproverWorkgroup() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_USER1), SequentialSetup.DOCUMENT_TYPE_NAME);
try {
document.blanketApprove("");
fail("InvalidActionTakenException should have been thrown");
} catch (InvalidActionTakenException iate) {
assertEquals("Exception on message is incorrent", "User is not authorized to BlanketApprove document", iate.getMessage());
}
}
示例8: testBlanketApproverNotInitiator
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* When a user is in the blanket approve workgroup but the user is not the initiator an exception
* should be thrown.
*/
@Test public void testBlanketApproverNotInitiator() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_USER1), SequentialSetup.DOCUMENT_TYPE_NAME);
WorkflowDocument newDocument = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), document.getDocumentId());
try {
newDocument.blanketApprove("");
fail("Exception should have been thrown when non-initiator user attempts blanket approve on default blanket approve policy document");
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: testChainedBlanketApproval
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* Test the blanket approval of a document chained by the post processor
*
* @throws Exception
*/
@Ignore
@Test
public void testChainedBlanketApproval() throws Exception {
// Generate child document
WorkflowDocument childDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ChainedChildSetup.DOCUMENT_TYPE_NAME);
WorkflowAttributeDefinition.Builder childDocAttribute = WorkflowAttributeDefinition.Builder.create(ChainedParentSetup.CHILD_DOC_ATTRIBUTE);
PropertyDefinition docIdProperty = PropertyDefinition.create(
ChainedParentSetup.DOC_ID_PROPERTY, childDocument.getDocumentId());
childDocAttribute.addPropertyDefinition(docIdProperty);
// Generate a parent document, apply child attribute
WorkflowDocument parentDocument = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ChainedParentSetup.DOCUMENT_TYPE_NAME);
//parentDocument.addAttributeDefinition(childDocAttribute.build());
//parentDocument.saveDocumentData();
// Issue with attribute definition save
String fullContent = parentDocument.getDocumentContent().getFullContent();
String newContent = "<documentContent><attributeContent><documentId>" + childDocument.getDocumentId() + "</documentId></attributeContent></documentContent>";
DocumentContentUpdate.Builder documentContentUpdateBuilder = DocumentContentUpdate.Builder.create();
documentContentUpdateBuilder.setAttributeContent(newContent);
parentDocument.updateDocumentContent(documentContentUpdateBuilder.build());
parentDocument.saveDocumentData();
parentDocument.blanketApprove("");
parentDocument = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), parentDocument.getDocumentId());
assertTrue("Parent Document should be processed.", parentDocument.isProcessed());
childDocument = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), childDocument.getDocumentId());
assertTrue("Child Document should be processed.", childDocument.isProcessed());
}
示例10: testBlanketApproveIntoBranch
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testBlanketApproveIntoBranch() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ParallelSetup.DOCUMENT_TYPE_NAME);
document.blanketApprove("", ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
List actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getDocumentId());
assertEquals("Wrong number of pending action requests.", 5, actionRequests.size());
// document should now be at the node we blanket approved to and the join node
Collection activeNodes = getRouteNodeService().getActiveNodeInstances(document.getDocumentId());
assertEquals("Wrong number of active nodes.", 3, activeNodes.size());
boolean isAtWD2B1 = false;
boolean isAtJoin = false;
boolean isAtWD3B2 = false;
boolean isAtWD4B3 = false;
for (Iterator iterator = activeNodes.iterator(); iterator.hasNext();) {
RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator.next();
isAtWD2B1 = isAtWD2B1 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
isAtWD3B2 = isAtWD3B2 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE);
isAtWD4B3 = isAtWD4B3 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE);
isAtJoin = isAtJoin || nodeInstance.getName().equals(ParallelSetup.JOIN_NODE);
}
assertTrue("Should be at blanket approved node.", isAtWD2B1);
assertTrue("Should be at blanket approved node WD3B2.", isAtWD3B2);
assertTrue("Should be at blanket approved node WD4B3.", isAtWD4B3);
assertFalse("Should be at join node.", isAtJoin);
document.blanketApprove("");
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), document.getDocumentId());
assertTrue("Document should be processed.", document.isProcessed());
actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getDocumentId());
assertEquals("Wrong number of pending action requests.", 10, actionRequests.size());
}
示例11: testBlanketApproveToMultipleNodes
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testBlanketApproveToMultipleNodes() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ParallelSetup.DOCUMENT_TYPE_NAME);
document.blanketApprove("", new String[] { ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE, ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE });
List actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getDocumentId());
assertEquals("Wrong number of pending action requests.", 5, actionRequests.size());
// document should now be at both nodes we blanket approved to and the join node
Collection activeNodes = getRouteNodeService().getActiveNodeInstances(document.getDocumentId());
assertEquals("Wrong number of active nodes.", 3, activeNodes.size());
boolean isAtWD2B1 = false;
boolean isAtWD3B2 = false;
boolean isAtJoin = false;
boolean isAtWD4B3 = false;
for (Iterator iterator = activeNodes.iterator(); iterator.hasNext();) {
RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator.next();
isAtWD2B1 = isAtWD2B1 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_2_B1_NODE);
isAtWD3B2 = isAtWD3B2 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_3_B2_NODE);
isAtWD4B3 = isAtWD4B3 || nodeInstance.getName().equals(ParallelSetup.WORKFLOW_DOCUMENT_4_B3_NODE);
isAtJoin = isAtJoin || nodeInstance.getName().equals(ParallelSetup.JOIN_NODE);
}
assertTrue("Should be at blanket approved node WD2B1.", isAtWD2B1);
assertTrue("Should be at blanket approved node WD3B2.", isAtWD3B2);
assertTrue("Should be at blanket approved node WD4B3. https://jira.kuali.org/browse/KULRICE-8481 - "
+ "BlanketApproveTest.testBlanketApproveToMultipleNodes fails in CI with Should be at blanket approved node WD4B3.", isAtWD4B3);
assertFalse("Should not be at join node.", isAtJoin);
document.blanketApprove("");
document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), document.getDocumentId());
assertTrue("Document should be processed.", document.isProcessed());
actionRequests = KEWServiceLocator.getActionRequestService().findPendingByDoc(document.getDocumentId());
assertEquals("Wrong number of pending action requests.", 10, actionRequests.size());
}
示例12: testBlanketApproveToAcknowledge
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testBlanketApproveToAcknowledge() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName(TEST_USER_EWESTFAL), ParallelSetup.DOCUMENT_TYPE_NAME);
document.blanketApprove("", ParallelSetup.ACKNOWLEDGE_1_NODE);
assertTrue("Document should be processed.", document.isProcessed());
// document should now be terminal
Collection activeNodes = getRouteNodeService().getActiveNodeInstances(document.getDocumentId());
assertEquals("Wrong number of active nodes.", 0, activeNodes.size());
Collection terminalNodes = getRouteNodeService().getTerminalNodeInstances(document.getDocumentId());
assertEquals("Wrong number of terminal nodes.", 1, terminalNodes.size());
RouteNodeInstance nodeInstance = (RouteNodeInstance)terminalNodes.iterator().next();
assertEquals("Document at wrong node.", ParallelSetup.ACKNOWLEDGE_2_NODE, nodeInstance.getName());
assertTrue("Final node not complete.", nodeInstance.isComplete());
}
示例13: testBlanketApproverSubmitted
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
/**
* test for issue KFSMI-2979 This method verifies that
* workflowInfo.getRoutedByPrincipalIdByDocumentId returns the blanket approver for a document that
* was put onroute by that person (the blanket approver)
*/
@Test
public void testBlanketApproverSubmitted() throws WorkflowException {
Person blanketApprover = KimApiServiceLocator.getPersonService().getPersonByPrincipalName("ewestfal");
WorkflowDocument document = WorkflowDocumentFactory.createDocument(blanketApprover.getPrincipalId(),
"BlanketApproveParallelTest");
document.blanketApprove("");
String routedByPrincipalId = KewApiServiceLocator.getWorkflowDocumentService().getRoutedByPrincipalIdByDocumentId(
document.getDocumentId());
assertEquals("the blanket approver should be the routed by", blanketApprover.getPrincipalId(),
routedByPrincipalId);
}
示例14: routeRuleWithDelegate
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Override
public String routeRuleWithDelegate(String documentId, RuleBaseValues parentRule, RuleBaseValues delegateRule, PrincipalContract principal, String annotation, boolean blanketApprove) throws Exception {
if (parentRule == null) {
throw new IllegalArgumentException("Cannot route a delegate without a parent rule.");
}
if (parentRule.getDelegateRule().booleanValue()) {
throw new IllegalArgumentException("Parent rule cannot be a delegate.");
}
if (parentRule.getPreviousRuleId() == null && delegateRule.getPreviousRuleId() == null) {
throw new IllegalArgumentException("Previous rule version required.");
}
// if the parent rule is new, unsaved, then save it
// boolean isRoutingParent = parentRule.getId() == null;
// if (isRoutingParent) {
// // it's very important that we do not save delegations here (that's what the false parameter is for)
// // this is because, if we save the delegations, the existing delegations on our parent rule will become
// // saved as "non current" before the rule is approved!!!
// save2(parentRule, null, false);
// //save2(parentRule, null, true);
// }
// XXX: added when the RuleValidation stuff was added, basically we just need to get the RuleDelegation
// that points to our delegate rule, this rule code is scary...
RuleDelegationBo ruleDelegation = getRuleDelegation(parentRule, delegateRule);
save2(delegateRule, ruleDelegation, true);
// if the parent rule is new, unsaved, then save it
// It's important to save the parent rule after the delegate rule is saved, that way we can ensure that any new rule
// delegations have a valid, saved, delegation rule to point to (otherwise we end up with a null constraint violation)
boolean isRoutingParent = parentRule.getId() == null;
if (isRoutingParent) {
// it's very important that we do not save delegations here (that's what the false parameter is for)
// this is because, if we save the delegations, the existing delegations on our parent rule will become
// saved as "non current" before the rule is approved!!!
save2(parentRule, null, false);
//save2(parentRule, null, true);
}
WorkflowDocument workflowDocument = null;
if (documentId != null) {
workflowDocument = WorkflowDocumentFactory.loadDocument(principal.getPrincipalId(), documentId);
} else {
List<RuleBaseValues> rules = new ArrayList<RuleBaseValues>();
rules.add(delegateRule);
rules.add(parentRule);
workflowDocument = WorkflowDocumentFactory.createDocument(principal.getPrincipalId(), getRuleDocumentTypeName(
rules));
}
workflowDocument.setTitle(generateTitle(parentRule, delegateRule));
delegateRule.setDocumentId(workflowDocument.getDocumentId());
workflowDocument.addAttributeDefinition(RuleRoutingDefinition.createAttributeDefinition(parentRule.getDocTypeName()));
getRuleDAO().save(delegateRule);
if (isRoutingParent) {
parentRule.setDocumentId(workflowDocument.getDocumentId());
getRuleDAO().save(parentRule);
}
if (blanketApprove) {
workflowDocument.blanketApprove(annotation);
} else {
workflowDocument.route(annotation);
}
return workflowDocument.getDocumentId();
}
示例15: testSearchNodeGraphSequentailBackward
import org.kuali.rice.kew.api.WorkflowDocument; //导入方法依赖的package包/类
@Test public void testSearchNodeGraphSequentailBackward() throws Exception {
WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("ewestfal"), "SeqDocType");
document.blanketApprove("", "WorkflowDocument");
List activeNodeInstances = routeNodeService.getActiveNodeInstances(document.getDocumentId());
NodeGraphSearchCriteria criteria = new NodeGraphSearchCriteria(NodeGraphSearchCriteria.SEARCH_DIRECTION_BACKWARD, activeNodeInstances, "AdHoc");
NodeGraphSearchResult result = routeNodeService.searchNodeGraph(criteria);
assertEquals("Path should have two nodes.", 2, result.getPath().size());
RouteNodeInstance resultNodeInstance = result.getResultNodeInstance();
assertNotNull("Should have a resulting node instance.", resultNodeInstance);
assertEquals("Result node should be the adhoc node.", "AdHoc", resultNodeInstance.getName());
// take it to the end
document.blanketApprove("");
assertTrue("Document should be processed.", document.isProcessed());
List terminalNodeInstances = routeNodeService.getTerminalNodeInstances(document.getDocumentId());
criteria = new NodeGraphSearchCriteria(NodeGraphSearchCriteria.SEARCH_DIRECTION_BACKWARD, terminalNodeInstances, "AdHoc");
result = routeNodeService.searchNodeGraph(criteria);
assertEquals("Path should have 4 nodes.", 4, result.getPath().size());
resultNodeInstance = result.getResultNodeInstance();
assertNotNull("Should have a resulting node instance.", resultNodeInstance);
assertEquals("Result node should be the adhoc node.", "AdHoc", resultNodeInstance.getName());
// now try searching from the Ack1 node for the WorkflowDocument node
RouteNodeInstance ack1NodeInstance = null;
for (Iterator iterator = result.getPath().iterator(); iterator.hasNext(); ) {
RouteNodeInstance nodeInstance = (RouteNodeInstance) iterator.next();
if (nodeInstance.getName().equals("Acknowledge1")) {
ack1NodeInstance = nodeInstance;
break;
}
}
assertNotNull("Could not locate the Acknowledge1 node in the path.", ack1NodeInstance);
List<RouteNodeInstance> startNodes = new ArrayList<RouteNodeInstance>();
startNodes.add(ack1NodeInstance);
criteria = new NodeGraphSearchCriteria(NodeGraphSearchCriteria.SEARCH_DIRECTION_BACKWARD, startNodes, "WorkflowDocument");
result = routeNodeService.searchNodeGraph(criteria);
// since we started at 'Acknowledge1' there should just be 'Acknowledge1' and 'WorkflowDocument' in the path
assertEquals("Path should have 2 nodes.", 2, result.getPath().size());
resultNodeInstance = result.getResultNodeInstance();
assertNotNull("Should have a resulting node instance.", resultNodeInstance);
assertEquals("Result node should be the workflow document node.", "WorkflowDocument", resultNodeInstance.getName());
}