protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; composite.setLayout(gridLayout); Work work = (Work) getValue(); Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText("Name: "); Text nameText = new Text(composite, SWT.NONE); nameText.setEditable(false); GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; nameText.setLayoutData(gridData); String name = work.getName(); nameText.setText(name == null ? "" : name); Set<ParameterDefinition> parameters = workDefinition.getParameters(); for (ParameterDefinition param : parameters) { Label label = new Label(composite, SWT.NONE); label.setText(param.getName() + ": "); Text text = new Text(composite, SWT.NONE); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; text.setLayoutData(gridData); texts.put(param.getName(), text); Object value = work.getParameter(param.getName()); text.setText(value == null ? "" : value.toString()); } return composite; }
protected void handleNode( final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException { super.handleNode(node, element, uri, localName, parser); WorkItemNode workItemNode = (WorkItemNode) node; String name = getTaskName(element); Work work = new WorkImpl(); work.setName(name); workItemNode.setWork(work); org.w3c.dom.Node xmlNode = element.getFirstChild(); while (xmlNode != null) { String nodeName = xmlNode.getNodeName(); if ("ioSpecification".equals(nodeName)) { readIoSpecification(xmlNode, dataInputs, dataOutputs); } else if ("dataInputAssociation".equals(nodeName)) { readDataInputAssociation(xmlNode, workItemNode, dataInputs); } else if ("dataOutputAssociation".equals(nodeName)) { readDataOutputAssociation(xmlNode, workItemNode, dataOutputs); } xmlNode = xmlNode.getNextSibling(); } handleScript(workItemNode, element, "onEntry"); handleScript(workItemNode, element, "onExit"); }
@SuppressWarnings("unused") private static KnowledgePackage getProcessWorkItems() { RuleFlowProcess process = new RuleFlowProcess(); process.setId("org.drools.test.TestProcess"); process.setName("TestProcess"); process.setPackageName("org.drools.test"); StartNode start = new StartNode(); start.setId(1); start.setName("Start"); process.addNode(start); ActionNode actionNode = new ActionNode(); actionNode.setId(2); actionNode.setName("Action"); DroolsConsequenceAction action = new DroolsConsequenceAction(); action.setDialect("java"); action.setConsequence("System.out.println(\"Executed action\");"); actionNode.setAction(action); process.addNode(actionNode); new ConnectionImpl( start, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE); WorkItemNode workItemNode = new WorkItemNode(); workItemNode.setId(3); workItemNode.setName("WorkItem1"); Work work = new WorkImpl(); work.setName("MyWork"); workItemNode.setWork(work); process.addNode(workItemNode); new ConnectionImpl( actionNode, Node.CONNECTION_DEFAULT_TYPE, workItemNode, Node.CONNECTION_DEFAULT_TYPE); WorkItemNode workItemNode2 = new WorkItemNode(); workItemNode2.setId(4); workItemNode2.setName("WorkItem2"); work = new WorkImpl(); work.setName("MyWork"); workItemNode2.setWork(work); process.addNode(workItemNode2); new ConnectionImpl( workItemNode, Node.CONNECTION_DEFAULT_TYPE, workItemNode2, Node.CONNECTION_DEFAULT_TYPE); WorkItemNode workItemNode3 = new WorkItemNode(); workItemNode3.setId(5); workItemNode3.setName("WorkItem3"); work = new WorkImpl(); work.setName("MyWork"); workItemNode3.setWork(work); process.addNode(workItemNode3); new ConnectionImpl( workItemNode2, Node.CONNECTION_DEFAULT_TYPE, workItemNode3, Node.CONNECTION_DEFAULT_TYPE); EndNode end = new EndNode(); end.setId(6); end.setName("End"); process.addNode(end); new ConnectionImpl( workItemNode3, Node.CONNECTION_DEFAULT_TYPE, end, Node.CONNECTION_DEFAULT_TYPE); KnowledgeBuilderImpl packageBuilder = new KnowledgeBuilderImpl(); ProcessBuilderImpl processBuilder = new ProcessBuilderImpl(packageBuilder); processBuilder.buildProcess(process, null); return packageBuilder.getPackage(); }
public Work getWork() { if (work == null) { work = new WorkImpl(); Work sourceWork = getDefinition().getWork(); work.setName(sourceWork.getName()); for (ParameterDefinition pd : sourceWork.getParameterDefinitions()) { work.addParameterDefinition(new ParameterDefinitionImpl(pd.getName(), pd.getType())); } for (Entry<String, Object> entry : sourceWork.getParameters().entrySet()) { work.setParameter(entry.getKey(), entry.getValue()); } work.setParameter("NodeName", getName()); work.setParameter( PeopleAssignmentHelper.BUSINESSADMINISTRATOR_ID, TableItem.getPlannerRoles(this)); } return work; }
protected Work updateValue(Work value) { Work work = new WorkImpl(); work.setName(value.getName()); for (Map.Entry<String, Text> entry : texts.entrySet()) { String text = entry.getValue().getText(); work.setParameter(entry.getKey(), "".equals(text) ? null : text); } work.setParameterDefinitions(value.getParameterDefinitions()); return work; }
private RuleFlowProcess getWorkItemProcess(String processId, String workName) { RuleFlowProcess process = new RuleFlowProcess(); process.setId(processId); List<Variable> variables = new ArrayList<Variable>(); Variable variable = new Variable(); variable.setName("UserName"); variable.setType(new StringDataType()); variables.add(variable); variable = new Variable(); variable.setName("Person"); variable.setType(new ObjectDataType(Person.class.getName())); variables.add(variable); variable = new Variable(); variable.setName("MyObject"); variable.setType(new ObjectDataType()); variables.add(variable); variable = new Variable(); variable.setName("Number"); variable.setType(new IntegerDataType()); variables.add(variable); process.getVariableScope().setVariables(variables); StartNode startNode = new StartNode(); startNode.setName("Start"); startNode.setId(1); WorkItemNode workItemNode = new WorkItemNode(); workItemNode.setName("workItemNode"); workItemNode.setId(2); workItemNode.addInMapping("Comment", "Person.name"); workItemNode.addInMapping("Attachment", "MyObject"); workItemNode.addOutMapping("Result", "MyObject"); workItemNode.addOutMapping("Result.length()", "Number"); Work work = new WorkImpl(); work.setName(workName); Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>(); ParameterDefinition parameterDefinition = new ParameterDefinitionImpl("ActorId", new StringDataType()); parameterDefinitions.add(parameterDefinition); parameterDefinition = new ParameterDefinitionImpl("Content", new StringDataType()); parameterDefinitions.add(parameterDefinition); parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType()); parameterDefinitions.add(parameterDefinition); work.setParameterDefinitions(parameterDefinitions); work.setParameter("ActorId", "#{UserName}"); work.setParameter("Content", "#{Person.name}"); workItemNode.setWork(work); EndNode endNode = new EndNode(); endNode.setName("End"); endNode.setId(3); connect(startNode, workItemNode); connect(workItemNode, endNode); process.addNode(startNode); process.addNode(workItemNode); process.addNode(endNode); return process; }