use of org.jbpm.process.core.impl.ProcessImpl in project jbpm by kiegroup.
the class StartProcessHelperTest method testFindLatestProcessByNameDoubleAsVersion.
@Test
public void testFindLatestProcessByNameDoubleAsVersion() {
List<Process> processes = new ArrayList<Process>();
ProcessImpl process = new ProcessImpl();
process.setName("Hello");
process.setId("1");
process.setVersion("0.1");
processes.add(process);
process = new ProcessImpl();
process.setName("Hello");
process.setId("2");
process.setVersion("0.2");
processes.add(process);
String foundProcessId = StartProcessHelper.findLatestProcessByName(processes, "Hello");
assertNotNull(foundProcessId);
assertEquals("2", foundProcessId);
}
use of org.jbpm.process.core.impl.ProcessImpl in project jbpm by kiegroup.
the class TestStatefulKnowledgeSession method getProcessInstance.
public ProcessInstance getProcessInstance(long arg0) {
RuleFlowProcessInstance pi = new RuleFlowProcessInstance();
pi.setId(arg0);
ProcessImpl processImpl = new ProcessImpl();
processImpl.setId("" + arg0);
pi.setProcess(processImpl);
return pi;
}
use of org.jbpm.process.core.impl.ProcessImpl in project jbpm by kiegroup.
the class TestStatefulKnowledgeSession method getProcessInstance.
public ProcessInstance getProcessInstance(long arg0, boolean readOnly) {
RuleFlowProcessInstance pi = new RuleFlowProcessInstance();
pi.setId(arg0);
ProcessImpl processImpl = new ProcessImpl();
processImpl.setId("" + arg0);
pi.setProcess(processImpl);
return pi;
}
use of org.jbpm.process.core.impl.ProcessImpl in project jbpm by kiegroup.
the class StartProcessHelperTest method buildProcessCollection.
private List<Process> buildProcessCollection(String processName, int limit) {
List<Process> processes = new ArrayList<Process>();
ProcessImpl process = null;
for (int i = 1; i <= limit; i++) {
process = new ProcessImpl();
process.setName(processName);
process.setId(i + "");
process.setVersion(i + "");
processes.add(process);
}
return processes;
}
use of org.jbpm.process.core.impl.ProcessImpl in project jbpm by kiegroup.
the class XmlBPMNProcessDumper method visitProcess.
protected void visitProcess(WorkflowProcess process, StringBuilder xmlDump, int metaDataType) {
String targetNamespace = (String) process.getMetaData().get("TargetNamespace");
if (targetNamespace == null) {
targetNamespace = "http://www.jboss.org/drools";
}
xmlDump.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + EOL + "<definitions id=\"Definition\"" + EOL + " targetNamespace=\"" + targetNamespace + "\"" + EOL + " typeLanguage=\"http://www.java.com/javaTypes\"" + EOL + " expressionLanguage=\"http://www.mvel.org/2.0\"" + EOL + " xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\"" + EOL + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + EOL + " xsi:schemaLocation=\"http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd\"" + EOL + " xmlns:g=\"http://www.jboss.org/drools/flow/gpd\"" + EOL + (metaDataType == META_DATA_USING_DI ? " xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\"" + EOL + " xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\"" + EOL + " xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\"" + EOL : "") + " xmlns:tns=\"http://www.jboss.org/drools\">" + EOL + EOL);
// item definitions
this.visitedVariables = new HashSet<String>();
VariableScope variableScope = (VariableScope) ((org.jbpm.process.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
Set<String> dumpedItemDefs = new HashSet<String>();
Map<String, ItemDefinition> itemDefs = (Map<String, ItemDefinition>) process.getMetaData().get("ItemDefinitions");
if (itemDefs != null) {
for (ItemDefinition def : itemDefs.values()) {
xmlDump.append(" <itemDefinition id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(def.getId()) + "\" ");
if (def.getStructureRef() != null && !"java.lang.Object".equals(def.getStructureRef())) {
xmlDump.append("structureRef=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(def.getStructureRef()) + "\" ");
}
xmlDump.append("/>" + EOL);
dumpedItemDefs.add(def.getId().intern());
}
}
visitVariableScope(variableScope, "_", xmlDump, dumpedItemDefs);
visitSubVariableScopes(process.getNodes(), xmlDump, dumpedItemDefs);
visitInterfaces(process.getNodes(), xmlDump);
visitEscalations(process.getNodes(), xmlDump, new ArrayList<String>());
Definitions def = (Definitions) process.getMetaData().get("Definitions");
visitErrors(def, xmlDump);
// data stores
if (def != null && def.getDataStores() != null) {
for (DataStore dataStore : def.getDataStores()) {
visitDataStore(dataStore, xmlDump);
}
}
// the process itself
xmlDump.append(" <process processType=\"Private\" isExecutable=\"true\" ");
if (process.getId() == null || process.getId().trim().length() == 0) {
((ProcessImpl) process).setId("com.sample.bpmn2");
}
xmlDump.append("id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(process.getId()) + "\" ");
if (process.getName() != null) {
xmlDump.append("name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(process.getName()) + "\" ");
}
String packageName = process.getPackageName();
if (packageName != null && !"org.drools.bpmn2".equals(packageName)) {
xmlDump.append("tns:packageName=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(packageName) + "\" ");
}
if (((org.jbpm.workflow.core.WorkflowProcess) process).isDynamic()) {
xmlDump.append("tns:adHoc=\"true\" ");
}
String version = process.getVersion();
if (version != null && !"".equals(version)) {
xmlDump.append("tns:version=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(version) + "\" ");
}
// TODO: package, version
xmlDump.append(">" + EOL + EOL);
visitHeader(process, xmlDump, metaDataType);
List<org.jbpm.workflow.core.Node> processNodes = new ArrayList<org.jbpm.workflow.core.Node>();
for (Node procNode : process.getNodes()) {
processNodes.add((org.jbpm.workflow.core.Node) procNode);
}
visitNodes(processNodes, xmlDump, metaDataType);
visitConnections(process.getNodes(), xmlDump, metaDataType);
// add associations
List<Association> associations = (List<Association>) process.getMetaData().get(ProcessHandler.ASSOCIATIONS);
if (associations != null) {
for (Association association : associations) {
visitAssociation(association, xmlDump);
}
}
xmlDump.append(" </process>" + EOL + EOL);
if (metaDataType == META_DATA_USING_DI) {
xmlDump.append(" <bpmndi:BPMNDiagram>" + EOL + " <bpmndi:BPMNPlane bpmnElement=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(process.getId()) + "\" >" + EOL);
visitNodesDi(process.getNodes(), xmlDump);
visitConnectionsDi(process.getNodes(), xmlDump);
xmlDump.append(" </bpmndi:BPMNPlane>" + EOL + " </bpmndi:BPMNDiagram>" + EOL + EOL);
}
xmlDump.append("</definitions>");
}
Aggregations