use of org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask in project kie-wb-common by kiegroup.
the class TaskConverter method businessRuleTask.
private PropertyWriter businessRuleTask(Node<View<BusinessRuleTask>, ?> n) {
org.eclipse.bpmn2.BusinessRuleTask task = bpmn2.createBusinessRuleTask();
task.setId(n.getUUID());
BusinessRuleTask definition = n.getContent().getDefinition();
BusinessRuleTaskPropertyWriter p = propertyWriterFactory.of(task);
TaskGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
BusinessRuleTaskExecutionSet executionSet = definition.getExecutionSet();
p.setAsync(executionSet.getIsAsync().getValue());
p.setOnEntryAction(executionSet.getOnEntryAction());
p.setOnExitAction(executionSet.getOnExitAction());
p.setRuleFlowGroup(executionSet.getRuleFlowGroup());
p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue());
p.setAssignmentsInfo(definition.getDataIOSet().getAssignmentsinfo());
p.setSimulationSet(definition.getSimulationSet());
p.setBounds(n.getContent().getBounds());
return p;
}
use of org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask in project kie-wb-common by kiegroup.
the class TaskConverter method businessRuleTask.
private BpmnNode businessRuleTask(org.eclipse.bpmn2.BusinessRuleTask task) {
Node<View<BusinessRuleTask>, Edge> node = factoryManager.newNode(task.getId(), BusinessRuleTask.class);
BusinessRuleTask definition = node.getContent().getDefinition();
BusinessRuleTaskPropertyReader p = propertyReaderFactory.of(task);
definition.setGeneral(new TaskGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
definition.setDataIOSet(new DataIOSet(p.getAssignmentsInfo()));
definition.setExecutionSet(new BusinessRuleTaskExecutionSet(new RuleFlowGroup(p.getRuleFlowGroup()), new OnEntryAction(p.getOnEntryAction()), new OnExitAction(p.getOnExitAction()), new IsAsync(p.isAsync()), new AdHocAutostart(p.isAdHocAutoStart())));
definition.setSimulationSet(p.getSimulationSet());
node.getContent().setBounds(p.getBounds());
definition.setDimensionsSet(p.getRectangleDimensionsSet());
definition.setBackgroundSet(p.getBackgroundSet());
definition.setFontSet(p.getFontSet());
return BpmnNode.of(node);
}
use of org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask in project kie-wb-common by kiegroup.
the class BPMNProcessVariableDeleteHandler method isVariableBoundToNode.
private boolean isVariableBoundToNode(Node node, String propertyId) {
Object content = node.getContent();
if (content instanceof Definition) {
Object nodeDefinition = ((Definition) content).getDefinition();
Collection<String> variablesName = new ArrayList();
if (nodeDefinition instanceof UserTask) {
UserTask userTask = (UserTask) nodeDefinition;
final String userTaskAssignmentsinfo = userTask.getExecutionSet().getAssignmentsinfo().getValue();
variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
}
if ((nodeDefinition instanceof BusinessRuleTask)) {
BusinessRuleTask businessRuleTaskTask = (BusinessRuleTask) nodeDefinition;
final String businessRuleTaskAssignmentsinfo = businessRuleTaskTask.getDataIOSet().getAssignmentsinfo().getValue();
variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
}
return variablesName.stream().filter(id -> propertyId.equals(id)).findAny().isPresent();
}
return false;
}
use of org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallBusinessRuleTaskAssignments.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallBusinessRuleTaskAssignments() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BUSINESSRULETASKASSIGNMENTS);
assertDiagram(diagram, 4);
assertEquals("BusinessRuleTaskAssignments", diagram.getMetadata().getTitle());
Node<? extends Definition, ?> businessRuleNode = diagram.getGraph().getNode("_45C2C340-D1D0-4D63-8419-EF38F9E73507");
BusinessRuleTask businessRuleTask = (BusinessRuleTask) businessRuleNode.getContent().getDefinition();
assertEquals(businessRuleTask.getTaskType().getValue(), TaskTypes.BUSINESS_RULE);
DataIOSet dataIOSet = businessRuleTask.getDataIOSet();
AssignmentsInfo assignmentsinfo = dataIOSet.getAssignmentsinfo();
assertEquals(assignmentsinfo.getValue(), "|input1:String,input2:String||output1:String,output2:String|[din]pv1->input1,[din]pv2->input2,[dout]output1->pv2,[dout]output2->pv2");
}
use of org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallBusinessRuleTask.
@Test
public void testUnmarshallBusinessRuleTask() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BUSINESSRULETASKRULEFLOWGROUP);
BusinessRuleTask businessRuleTask = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof BusinessRuleTask) {
businessRuleTask = (BusinessRuleTask) oDefinition;
break;
}
}
}
assertNotNull(businessRuleTask);
assertNotNull(businessRuleTask.getExecutionSet());
assertNotNull(businessRuleTask.getExecutionSet().getRuleFlowGroup());
assertNotNull(businessRuleTask.getGeneral());
assertNotNull(businessRuleTask.getGeneral().getName());
assertEquals(businessRuleTask.getTaskType().getValue(), TaskTypes.BUSINESS_RULE);
assertEquals("my business rule task", businessRuleTask.getGeneral().getName().getValue());
assertEquals("my-ruleflow-group", businessRuleTask.getExecutionSet().getRuleFlowGroup().getValue());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("System.out.println(\"Hello\");", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals("System.out.println(\"Bye\");", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
}
Aggregations