@SuppressWarnings("unchecked") public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { parser.endElementBuilder(); RuleFlowProcess process = (RuleFlowProcess) parser.getCurrent(); List<IntermediateLink> throwLinks = (List<IntermediateLink>) process .getMetaData(LINKS); linkIntermediateLinks(process, throwLinks); List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS); linkConnections(process, connections); linkBoundaryEvents(process); // This must be done *after* linkConnections(process, connections) // because it adds hidden connections for compensations List<Association> associations = (List<Association>) process.getMetaData(ASSOCIATIONS); linkAssociations((Definitions) process.getMetaData("Definitions"), process, associations); List<Lane> lanes = (List<Lane>) process.getMetaData(LaneHandler.LANES); assignLanes(process, lanes); postProcessNodes(process, process); return process; }
@SuppressWarnings("unchecked") public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder(localName, attrs); String id = attrs.getValue("id"); String name = attrs.getValue("name"); WorkflowProcess process = (WorkflowProcess) parser.getParent(); List<Lane> lanes = (List<Lane>) ((RuleFlowProcess) process).getMetaData(LaneHandler.LANES); if (lanes == null) { lanes = new ArrayList<Lane>(); ((RuleFlowProcess) process).setMetaData(LaneHandler.LANES, lanes); } Lane lane = new Lane(id); lane.setName(name); lanes.add(lane); return lane; }
protected String getErrorIdForErrorCode(String errorCode, Node node) { org.kie.api.definition.process.NodeContainer parent = node.getNodeContainer(); while( ! (parent instanceof RuleFlowProcess) && parent instanceof Node ) { parent = ((Node) parent).getNodeContainer(); } if( ! (parent instanceof RuleFlowProcess) ) { throw new RuntimeException( "This should never happen: !(parent instanceof RuleFlowProcess): parent is " + parent.getClass().getSimpleName() ); } List<Error> errors = ((Definitions) ((RuleFlowProcess) parent).getMetaData("Definitions")).getErrors(); Error error = null; for( Error listError : errors ) { if( errorCode.equals(listError.getErrorCode()) ) { error = listError; break; } else if ( errorCode.equals(listError.getId()) ) { error = listError; break; } } if (error == null) { throw new IllegalArgumentException("Could not find error with errorCode " + errorCode); } return error.getId(); }
public Map<String, Object> getMetaData() { if (parent instanceof Node) { return ((Node) parent).getMetaData(); } else if (parent instanceof RuleFlowProcess) { return ((RuleFlowProcess) parent).getMetaData(); } else if (parent instanceof Variable) { return ((Variable) parent).getMetaData(); } else if (parent instanceof SequenceFlow) { return ((SequenceFlow) parent).getMetaData(); } else if(parent instanceof Lane) { return ((Lane) parent).getMetaData(); } else { throw new IllegalArgumentException("Unknown parent " + parent); } } public DataType getType() {
@SuppressWarnings("unchecked") public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder(localName, attrs); String id = attrs.getValue("id"); String name = attrs.getValue("name"); logger.debug("Found case role with id {} and name {}", id, name); RuleFlowProcess process = ((RuleFlowProcess) parser.getParent(RuleFlowProcess.class)); String caseRoles = (String) process.getMetaData("customCaseRoles"); if (caseRoles == null) { caseRoles = name; } else { caseRoles += "," + name; } process.setMetaData("customCaseRoles", caseRoles); // save case roles so they can be easily referenced later for human task performer ProcessBuildData buildData = (ProcessBuildData) parser.getData(); Map<String, Role> roles = (Map<String, Role>) buildData.getMetaData("Roles"); if (roles == null) { roles = new HashMap<String, Role>(); buildData.setMetaData("Roles", roles); } Role role = new Role(id, name); roles.put(id, role); return role; }
RuleFlowProcess process = (RuleFlowProcess) nodeContainer; List<IntermediateLink> links = (List<IntermediateLink>) process .getMetaData().get(ProcessHandler.LINKS); if (null == links) { links = new ArrayList<IntermediateLink>();
RuleFlowProcess process = (RuleFlowProcess) nodeContainer; List<IntermediateLink> links = (List<IntermediateLink>) process .getMetaData().get(ProcessHandler.LINKS); if (null == links) { links = new ArrayList<IntermediateLink>();
RuleFlowProcess process = (RuleFlowProcess) nodeContainer; connections = (List<SequenceFlow>) process .getMetaData(ProcessHandler.CONNECTIONS); if (connections == null) { connections = new ArrayList<SequenceFlow>();
if( nodeContainer instanceof Process ) { RuleFlowProcess process = (RuleFlowProcess) nodeContainer; associations = (List<Association>) process.getMetaData(ASSOCIATIONS); if (associations == null) { associations = new ArrayList<Association>();
protected static void addCompensationScope(final RuleFlowProcess process, final Node node, final org.kie.api.definition.process.NodeContainer parentContainer, final String compensationHandlerId) { process.getMetaData().put("Compensation", true);
@Test public void testLoadMinimalCaseWithRoles() throws Exception { KieBase kbase = createKnowledgeBase("CMMN-MinimalCaseWithRoles.cmmn"); assertThat(kbase).isNotNull(); Process process = kbase.getProcess("loan_application"); assertThat(process).isNotNull(); assertThat(process).isInstanceOf(RuleFlowProcess.class); RuleFlowProcess caseProcess = (RuleFlowProcess) process; assertThat(caseProcess.isDynamic()).isTrue(); assertThat(caseProcess.getId()).isEqualTo("loan_application"); assertThat(caseProcess.getName()).isEqualTo("Loan Application"); String roles = (String) caseProcess.getMetaData("customCaseRoles"); assertThat(roles).isNotNull(); assertThat(roles).isEqualTo("owner,participant,manager"); }
@SuppressWarnings("unchecked") public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { parser.endElementBuilder(); ProcessBuildData buildData = (ProcessBuildData) parser.getData(); Map<String, Role> roles = (Map<String, Role>) buildData.getMetaData("Roles"); RuleFlowProcess process = (RuleFlowProcess) parser.getCurrent(); List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS); linkConnections(process, connections); linkBoundaryEvents(process); postProcessNodes(process, process, roles); return process; }
assertThat(caseProcess.getName()).isEqualTo("First case"); String roles = (String) caseProcess.getMetaData("customCaseRoles"); assertThat(roles).isNotNull(); assertThat(roles).isEqualTo("owner,manager");
assertThat(caseProcess.getName()).isEqualTo("Loan Application"); String roles = (String) caseProcess.getMetaData("customCaseRoles"); assertThat(roles).isNotNull(); assertThat(roles).isEqualTo("owner,manager");
assertThat(caseProcess.getName()).isEqualTo("First case"); String roles = (String) caseProcess.getMetaData("customCaseRoles"); assertThat(roles).isNotNull(); assertThat(roles).isEqualTo("owner,manager");
@SuppressWarnings("unchecked") public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { parser.endElementBuilder(); RuleFlowProcess process = (RuleFlowProcess) parser.getCurrent(); List<IntermediateLink> throwLinks = (List<IntermediateLink>) process .getMetaData(LINKS); linkIntermediateLinks(process, throwLinks); List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS); linkConnections(process, connections); linkBoundaryEvents(process); // This must be done *after* linkConnections(process, connections) // because it adds hidden connections for compensations List<Association> associations = (List<Association>) process.getMetaData(ASSOCIATIONS); linkAssociations((Definitions) process.getMetaData("Definitions"), process, associations); List<Lane> lanes = (List<Lane>) process.getMetaData(LaneHandler.LANES); assignLanes(process, lanes); postProcessNodes(process, process); return process; }
@SuppressWarnings("unchecked") public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder(localName, attrs); String id = attrs.getValue("id"); String name = attrs.getValue("name"); WorkflowProcess process = (WorkflowProcess) parser.getParent(); List<Lane> lanes = (List<Lane>) ((RuleFlowProcess) process).getMetaData(LaneHandler.LANES); if (lanes == null) { lanes = new ArrayList<Lane>(); ((RuleFlowProcess) process).setMetaData(LaneHandler.LANES, lanes); } Lane lane = new Lane(id); lane.setName(name); lanes.add(lane); return lane; }
public Map<String, Object> getMetaData() { if (parent instanceof Node) { return ((Node) parent).getMetaData(); } else if (parent instanceof RuleFlowProcess) { return ((RuleFlowProcess) parent).getMetaData(); } else if (parent instanceof Variable) { return ((Variable) parent).getMetaData(); } else if (parent instanceof SequenceFlow) { return ((SequenceFlow) parent).getMetaData(); } else if(parent instanceof Lane) { return ((Lane) parent).getMetaData(); } else { throw new IllegalArgumentException("Unknown parent " + parent); } } public DataType getType() {
@Test public void testLoadMinimalCaseWithRoles() throws Exception { KieBase kbase = createKnowledgeBase("CMMN-MinimalCaseWithRoles.cmmn"); assertThat(kbase).isNotNull(); Process process = kbase.getProcess("loan_application"); assertThat(process).isNotNull(); assertThat(process).isInstanceOf(RuleFlowProcess.class); RuleFlowProcess caseProcess = (RuleFlowProcess) process; assertThat(caseProcess.isDynamic()).isTrue(); assertThat(caseProcess.getId()).isEqualTo("loan_application"); assertThat(caseProcess.getName()).isEqualTo("Loan Application"); String roles = (String) caseProcess.getMetaData("customCaseRoles"); assertThat(roles).isNotNull(); assertThat(roles).isEqualTo("owner,participant,manager"); }
@SuppressWarnings("unchecked") public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { parser.endElementBuilder(); ProcessBuildData buildData = (ProcessBuildData) parser.getData(); Map<String, Role> roles = (Map<String, Role>) buildData.getMetaData("Roles"); RuleFlowProcess process = (RuleFlowProcess) parser.getCurrent(); List<SequenceFlow> connections = (List<SequenceFlow>) process.getMetaData(CONNECTIONS); linkConnections(process, connections); linkBoundaryEvents(process); postProcessNodes(process, process, roles); return process; }