use of org.kie.workbench.common.stunner.bpmn.workitem.CustomTask in project kie-wb-common by kiegroup.
the class RestCustomTaskTest method testUnmarshallTopLevelTaskOneIncomeFilledProperties.
@Test
@Override
public void testUnmarshallTopLevelTaskOneIncomeFilledProperties() {
final String TASK_NAME_JAVA = "Rest task02 name ~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./";
final String TASK_DOCUMENTATION_JAVA = "Rest task02 doc\n ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./";
final String TASK_ON_ENTRY_ACTION_JAVA = "System.out.println(\"On Entry Action from Rest Task.\");";
final String TASK_ON_EXIT_ACTION_JAVA = "System.out.println(\"On Exit Action from Rest Task.\");";
final String TASK_NAME_JAVASCRIPT = "Rest task05 name ~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./";
final String TASK_DOCUMENTATION_JAVASCRIPT = "Rest task05 doc\n ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./";
final String TASK_ON_ENTRY_ACTION_JAVASCRIPT = "console.log(\"On Entry Action from Rest Task.\");";
final String TASK_ON_EXIT_ACTION_JAVASCRIPT = "console.log(\"On Exit Action from Rest Task.\");";
final String TASK_NAME_MVEL = "Rest task08 name ~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./";
final String TASK_DOCUMENTATION_MVEL = "Rest task08 doc\n ~!@#$%^&*()_+`1234567890-={}|[]\\:\";'<>?,./";
final String TASK_ON_ENTRY_ACTION_MVEL = "System.out.println(\"On Entry Action from Rest Task.\");";
final String TASK_ON_EXIT_ACTION_MVEL = "System.out.println(\"On Exit Action from Rest Task.\");";
final String TASK_DATA_INPUT_OUTPUT = "|ConnectTimeout:String,ContentData:String,Method:String,Password:String,ReadTimeout:String,Url:String,Username:String,input:String||Result:java.lang.Object,output:String|[din]processGlobalVar->input,[dout]output->processGlobalVar";
assertDiagram(getDiagram(), AMOUNT_OF_NODES_IN_DIAGRAM);
CustomTask filledTopLevelTaskJava = getTaskNodeById(getDiagram(), FILLED_ONE_INCOME_TOP_LEVEL_TASK_JAVA_ID, ONE_INCOME_EDGE, HAS_OUTCOME_EDGE);
assertGeneralSet(filledTopLevelTaskJava.getGeneral(), TASK_NAME_JAVA, TASK_DOCUMENTATION_JAVA);
assertServiceTaskExecutionSet(filledTopLevelTaskJava.getExecutionSet(), TASK_ON_ENTRY_ACTION_JAVA, TASK_SCRIPT_JAVA_LANGUAGE, TASK_ON_EXIT_ACTION_JAVA, TASK_SCRIPT_JAVA_LANGUAGE, IS_ASYNC, AD_HOC_AUTOSTART, SLA_DUE_DATE);
assertDataIOSet(filledTopLevelTaskJava.getDataIOSet(), TASK_DATA_INPUT_OUTPUT);
CustomTask filledTopLevelTaskJavascript = getTaskNodeById(getDiagram(), FILLED_ONE_INCOME_TOP_LEVEL_TASK_JAVASCRIPT_ID, ONE_INCOME_EDGE, HAS_OUTCOME_EDGE);
assertGeneralSet(filledTopLevelTaskJavascript.getGeneral(), TASK_NAME_JAVASCRIPT, TASK_DOCUMENTATION_JAVASCRIPT);
assertServiceTaskExecutionSet(filledTopLevelTaskJavascript.getExecutionSet(), TASK_ON_ENTRY_ACTION_JAVASCRIPT, TASK_SCRIPT_JAVASCRIPT_LANGUAGE, TASK_ON_EXIT_ACTION_JAVASCRIPT, TASK_SCRIPT_JAVASCRIPT_LANGUAGE, IS_ASYNC, AD_HOC_AUTOSTART, SLA_DUE_DATE);
assertDataIOSet(filledTopLevelTaskJavascript.getDataIOSet(), TASK_DATA_INPUT_OUTPUT);
CustomTask filledTopLevelTaskMvel = getTaskNodeById(getDiagram(), FILLED_ONE_INCOME_TOP_LEVEL_TASK_MVEL_ID, ONE_INCOME_EDGE, HAS_OUTCOME_EDGE);
assertGeneralSet(filledTopLevelTaskMvel.getGeneral(), TASK_NAME_MVEL, TASK_DOCUMENTATION_MVEL);
assertServiceTaskExecutionSet(filledTopLevelTaskMvel.getExecutionSet(), TASK_ON_ENTRY_ACTION_MVEL, TASK_SCRIPT_MVEL_LANGUAGE, TASK_ON_EXIT_ACTION_MVEL, TASK_SCRIPT_MVEL_LANGUAGE, IS_ASYNC, AD_HOC_AUTOSTART, SLA_DUE_DATE);
assertDataIOSet(filledTopLevelTaskMvel.getDataIOSet(), TASK_DATA_INPUT_OUTPUT);
}
use of org.kie.workbench.common.stunner.bpmn.workitem.CustomTask in project kie-wb-common by kiegroup.
the class BPMNPaletteDefinitionBuilder method createPaletteCustomTasksCategory.
private void createPaletteCustomTasksCategory(final DefaultPaletteDefinition paletteDefinition, final Consumer<DefaultPaletteDefinition> callback) {
final ExpandedPaletteDefinitionBuilder.ItemMessageProvider categoryMessageProvider = paletteDefinitionBuilder.getCategoryMessageProvider();
final Function<String, Glyph> categoryGlyphProvider = paletteDefinitionBuilder.getCategoryGlyphProvider();
final Collection<WorkItemDefinition> workItemDefinitions = workItemDefinitionRegistry.get().items();
if (!workItemDefinitions.isEmpty()) {
final String customTasksTitle = categoryMessageProvider.getTitle(BPMNCategories.CUSTOM_TASKS);
final String customTasksDesc = categoryMessageProvider.getDescription(BPMNCategories.CUSTOM_TASKS);
final DefaultPaletteCategory workItemsCategory = new CategoryBuilder().setItemId(BPMNCategories.CUSTOM_TASKS).setTitle(customTasksTitle).setDescription(customTasksDesc).setTooltip(customTasksTitle).setGlyph(categoryGlyphProvider.apply(BPMNCategories.CUSTOM_TASKS)).build();
int i = 0;
for (final WorkItemDefinition workItemDefinition : workItemDefinitions) {
final CustomTask customTask = customTaskBuilder.apply(workItemDefinition);
final DefinitionAdapter<Object> adapter = definitionManager.adapters().registry().getDefinitionAdapter(customTask.getClass());
final String category = adapter.getCategory(customTask);
DefaultPaletteGroup subcategoryGroup = null;
final Optional<DefaultPaletteItem> subcategoryGroupOp = workItemsCategory.getItems().stream().filter(item -> category.equals(item.getId())).findFirst();
if (!subcategoryGroupOp.isPresent()) {
subcategoryGroup = new GroupBuilder().setItemId(category).setTitle(category).setDescription(category).build();
workItemsCategory.getItems().add(subcategoryGroup);
} else {
subcategoryGroup = (DefaultPaletteGroup) subcategoryGroupOp.get();
}
final String defId = adapter.getId(customTask).value();
final String title = adapter.getTitle(customTask);
final String description = adapter.getDescription(customTask);
final DefaultPaletteItem item = new ItemBuilder().setItemId(defId).setDefinitionId(defId).setTitle(title).setDescription(description).build();
subcategoryGroup.getItems().add(item);
// Link the first work item definition found to the work item's palette category.
if (0 == i) {
workItemsCategory.setDefinitionId(defId);
}
i++;
}
paletteDefinition.getItems().add(workItemsCategory);
}
callback.accept(paletteDefinition);
}
use of org.kie.workbench.common.stunner.bpmn.workitem.CustomTask in project kie-wb-common by kiegroup.
the class VariableUtilsTest method mockServiceTask.
private CustomTask mockServiceTask(String name, String assignmentsInfoValue) {
CustomTask result = mock(CustomTask.class);
TaskGeneralSet generalSet = mockTaskGeneralSet(name);
when(result.getGeneral()).thenReturn(generalSet);
AssignmentsInfo assignmentsInfo = mockAssignmentsInfo(assignmentsInfoValue);
DataIOSet dataIOSet = mockIOSet(assignmentsInfo);
when(result.getDataIOSet()).thenReturn(dataIOSet);
return result;
}
use of org.kie.workbench.common.stunner.bpmn.workitem.CustomTask in project kie-wb-common by kiegroup.
the class CustomTaskShapeViewHandlerTest method init.
@Before
@SuppressWarnings("unchecked")
public void init() {
task = new CustomTask();
task.setName(WID_ID);
task.setDimensionsSet(new RectangleDimensionsSet());
width = spy(new Width(0d));
height = spy(new Height(0d));
task.getDimensionsSet().setWidth(width);
task.getDimensionsSet().setHeight(height);
when(registry.items()).thenReturn(Collections.singleton(DEF));
when(registry.get(eq(WID_ID))).thenReturn(DEF);
when(view.getChildren()).thenReturn(Collections.singletonList(iconSVGPrimiite));
when(iconSVGPrimiite.getId()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
when(iconSVGPrimiite.get()).thenReturn(icon);
when(iconSVGPrimiite.getPrimitiveId()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
when(icon.getID()).thenReturn(CustomTaskShapeViewHandler.WID_ICON_ID);
when(icon.getImageProxy()).thenReturn(imageProxy);
when(view.getPrimitive()).thenReturn(iconSVGPrimiite);
when(icon.getAttributes()).thenReturn(svgAttr);
when(svgAttr.getHeight()).thenReturn(HEIGHT);
when(svgAttr.getWidth()).thenReturn(WIDTH);
this.tested = new CustomTaskShapeViewHandler(() -> registry);
}
use of org.kie.workbench.common.stunner.bpmn.workitem.CustomTask in project kie-wb-common by kiegroup.
the class TaskConverter method customTask.
private PropertyWriter customTask(Node<View<CustomTask>, ?> n) {
org.eclipse.bpmn2.Task task = bpmn2.createTask();
task.setId(n.getUUID());
CustomTask definition = n.getContent().getDefinition();
ServiceTaskPropertyWriter p = propertyWriterFactory.of(task);
p.setServiceTaskName(definition.getName());
TaskGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
p.setAssignmentsInfo(definition.getDataIOSet().getAssignmentsinfo());
CustomTaskExecutionSet executionSet = definition.getExecutionSet();
p.setTaskName(executionSet.getTaskName().getValue());
p.setAsync(executionSet.getIsAsync().getValue());
p.setOnEntryAction(executionSet.getOnEntryAction());
p.setOnExitAction(executionSet.getOnExitAction());
p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue());
p.setSlaDueDate(executionSet.getSlaDueDate().getValue());
p.setSimulationSet(definition.getSimulationSet());
p.setMetaData(definition.getAdvancedData().getMetaDataAttributes());
p.setAbsoluteBounds(n);
return p;
}
Aggregations