public Operation addOperation(String id, String name) { Operation operation = new Operation(id, name); operations.put(id, operation); return operation; }
public void visitAssociation(Association association, StringBuilder xmlDump) { xmlDump.append(" <association id=\"" + association.getId() + "\" "); xmlDump.append(" sourceRef=\"" + association.getSourceRef() + "\" "); xmlDump.append(" targetRef=\"" + association.getTargetRef() + "\" "); xmlDump.append("/>" + EOL); }
private static Object findNodeOrDataStoreByUniqueId(Definitions definitions, NodeContainer nodeContainer, final String nodeRef, String errorMsg) { if( definitions != null ) { List<DataStore> dataStores = definitions.getDataStores(); if( dataStores != null ) { for( DataStore dataStore : dataStores ) { if( nodeRef.equals(dataStore.getId()) ) { return dataStore; } } } } return findNodeByIdOrUniqueIdInMetadata(nodeContainer, nodeRef, errorMsg); }
throws SAXException { parser.startElementBuilder(localName, attrs); DataStore store = new DataStore(); store.setId(attrs.getValue("id")); store.setName(attrs.getValue("name")); final String itemSubjectRef = attrs.getValue("itemSubjectRef"); store.setItemSubjectRef(itemSubjectRef); Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions"); ItemDefinition itemDefinition = itemDefinitions.get(localItemSubjectRef); if (itemDefinition != null) { dataType = new ObjectDataType(itemDefinition.getStructureRef(), parser.getClassLoader()); store.setType(dataType); List<DataStore> dataStores = parent.getDataStores(); if (dataStores == null) { dataStores = new ArrayList<DataStore>(); parent.setDataStores(dataStores);
Operation operation = null; for (Interface i: interfaces) { operation = i.getOperation(operationRef); if (operation != null) { break; workItemNode.getWork().setParameter("Interface", operation.getInterface().getName()); workItemNode.getWork().setParameter("Operation", operation.getName()); workItemNode.getWork().setParameter("ParameterType", operation.getMessage().getType()); workItemNode.getWork().setParameter("interfaceImplementationRef", operation.getInterface().getImplementationRef()); workItemNode.getWork().setParameter("operationImplementationRef", operation.getImplementationRef()); workItemNode.getWork().setParameter("implementation", implementation);
@Test public void testDataStore() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-DataStore.bpmn2"); ksession = createKnowledgeSession(kbase); ProcessInstance processInstance = ksession.startProcess("Evaluation"); Definitions def = (Definitions) processInstance.getProcess() .getMetaData().get("Definitions"); assertNotNull(def.getDataStores()); assertTrue(def.getDataStores().size() == 1); DataStore dataStore = def.getDataStores().get(0); assertEquals("employee", dataStore.getId()); assertEquals("employeeStore", dataStore.getName()); assertEquals(String.class.getCanonicalName(), ((ObjectDataType) dataStore.getType()).getClassName()); }
private void visitDataStore(DataStore dataStore, StringBuilder xmlDump) { String itemSubjectRef = dataStore.getItemSubjectRef(); String itemDefId = itemSubjectRef.substring(itemSubjectRef.indexOf(':') + 1); xmlDump.append(" <itemDefinition id=\"" + itemDefId + "\" "); if (dataStore.getType() != null && !"java.lang.Object".equals(dataStore.getType().getStringType())) { xmlDump.append("structureRef=\"" + XmlDumper.replaceIllegalChars(dataStore.getType().getStringType()) + "\" "); } xmlDump.append("/>" + EOL); xmlDump.append(" <dataStore name=\"" + XmlDumper.replaceIllegalChars(dataStore.getName()) + "\""); xmlDump.append(" id=\"" + XmlDumper.replaceIllegalChars(dataStore.getId()) + "\""); xmlDump.append(" itemSubjectRef=\"" + XmlDumper.replaceIllegalChars(dataStore.getItemSubjectRef()) + "\""); xmlDump.append("/>" + EOL); }
buildData.setMetaData("Messages", messages); Message message = new Message(id); message.setType(itemDefinition.getStructureRef()); message.setName(name); messages.put(id, message); return message;
protected void visitErrors(Definitions definitions, StringBuilder xmlDump) { if( definitions == null ) { return; } List<Error> errors = definitions.getErrors(); if( errors == null || errors.isEmpty() ) { return; } for( org.jbpm.bpmn2.core.Error error : errors ) { String id = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(error.getId()); String code = error.getErrorCode(); xmlDump.append(" <error id=\"" + id + "\"" ); if (error.getErrorCode() != null) { code = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(code); xmlDump.append(" errorCode=\"" + code + "\"" ); } String structureRef = error.getStructureRef(); if( structureRef != null ) { structureRef = XmlBPMNProcessDumper.replaceIllegalCharsAttribute(structureRef); xmlDump.append(" structureRef=\"" + structureRef + "\""); } xmlDump.append("/>" + EOL ); } }
@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 errorCode = attrs.getValue("errorCode"); String structureRef = attrs.getValue("structureRef"); Definitions definitions = (Definitions) parser.getParent(); List<Error> errors = definitions.getErrors(); if (errors == null) { errors = new ArrayList<Error>(); definitions.setErrors(errors); ((ProcessBuildData) parser.getData()).setMetaData("Errors", errors); } Error e = new Error(id, errorCode, structureRef); errors.add(e); return e; }
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 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"); String implRef = attrs.getValue("implementationRef"); Interface i = (Interface) parser.getParent(); Operation operation = i.addOperation(id, name); if (implRef != null) { operation.setImplementationRef(implRef); } return operation; }
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder(localName, attrs); return new Definitions(); }
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"); 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 Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { final Element element = parser.endElementBuilder(); Lane lane = (Lane) parser.getCurrent(); org.w3c.dom.Node xmlNode = element.getFirstChild(); while (xmlNode != null) { String nodeName = xmlNode.getNodeName(); if ("flowNodeRef".equals(nodeName)) { String flowElementRef = xmlNode.getTextContent(); lane.addFlowElement(flowElementRef); } xmlNode = xmlNode.getNextSibling(); } return lane; }
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder(localName, attrs); final String type = attrs.getValue("importType"); final String location = attrs.getValue("location"); final String namespace = attrs.getValue("namespace"); ProcessBuildData buildData = (ProcessBuildData) parser.getData(); if (type != null && location != null && namespace != null) { List<Bpmn2Import> typedImports = (List<Bpmn2Import>) buildData.getMetaData("Bpmn2Imports"); if (typedImports == null) { typedImports = new ArrayList< Bpmn2Import>(); buildData.setMetaData("Bpmn2Imports", typedImports); } typedImports.add(new Bpmn2Import(type, location, namespace)); } return null; }
@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 escalationCode = attrs.getValue("escalationCode"); ProcessBuildData buildData = (ProcessBuildData) parser.getData(); Map<String, Escalation> escalations = (Map<String, Escalation>) buildData.getMetaData(ProcessHandler.ESCALATIONS); if (escalations == null) { escalations = new HashMap<String, Escalation>(); buildData.setMetaData(ProcessHandler.ESCALATIONS, escalations); } Escalation e = new Escalation(id, escalationCode); escalations.put(id, e); return e; }
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { final Element element = parser.endElementBuilder(); Definitions definitions = (Definitions) parser.getCurrent(); String namespace = element.getAttribute("targetNamespace"); List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses(); Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions"); List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces"); for (Process process : processes) { RuleFlowProcess ruleFlowProcess = (RuleFlowProcess)process; ruleFlowProcess.setMetaData("TargetNamespace", namespace); postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader()); postProcessInterfaces(ruleFlowProcess, interfaces); } definitions.setTargetNamespace(namespace); return definitions; }
operation = i.getOperation(operationRef); if (operation != null) { break; workItemNode.getWork().setParameter("Interface", operation.getInterface().getName()); workItemNode.getWork().setParameter("Operation", operation.getName()); workItemNode.getWork().setParameter("ParameterType", operation.getMessage().getType()); workItemNode.getWork().setParameter("interfaceImplementationRef", operation.getInterface().getImplementationRef()); workItemNode.getWork().setParameter("operationImplementationRef", operation.getImplementationRef()); workItemNode.getWork().setParameter("implementation", implementation);