Search in sources :

Example 31 with CustomTask

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);
}
Also used : CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Test(org.junit.Test)

Example 32 with CustomTask

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);
}
Also used : DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) DefaultPaletteItem(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteItem) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) ItemBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.ItemBuilder) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Map(java.util.Map) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) CategoryDefinitionProvider(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionProviders.CategoryDefinitionProvider) DefaultPaletteGroup(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteGroup) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) Predicate(java.util.function.Predicate) Collection(java.util.Collection) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Lists(org.kie.soup.commons.util.Lists) MorphDefinition(org.kie.workbench.common.stunner.core.definition.morph.MorphDefinition) Objects(java.util.Objects) DefaultPaletteDefinitionProviders.isType(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionProviders.isType) BPMN(org.kie.workbench.common.stunner.bpmn.qualifiers.BPMN) List(java.util.List) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) CategoryBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.CategoryBuilder) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) DefaultPaletteCategory(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteCategory) GroupBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.GroupBuilder) Maps(org.kie.soup.commons.util.Maps) Function(java.util.function.Function) Supplier(java.util.function.Supplier) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Inject(javax.inject.Inject) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) StunnerTranslationService(org.kie.workbench.common.stunner.core.i18n.StunnerTranslationService) PaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.PaletteDefinitionBuilder) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) MorphAdapter(org.kie.workbench.common.stunner.core.definition.adapter.MorphAdapter) DefaultPaletteDefinitionProviders(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionProviders) CustomTaskFactory(org.kie.workbench.common.stunner.bpmn.workitem.CustomTaskFactory) Association(org.kie.workbench.common.stunner.bpmn.definition.Association) BaseSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseSubprocess) Consumer(java.util.function.Consumer) BPMNCategories(org.kie.workbench.common.stunner.bpmn.definition.BPMNCategories) Dependent(javax.enterprise.context.Dependent) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) Comparator(java.util.Comparator) Collections(java.util.Collections) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) GroupBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.GroupBuilder) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) DefaultPaletteCategory(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteCategory) DefaultPaletteItem(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteItem) DefaultPaletteGroup(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteGroup) ItemBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.ItemBuilder) CategoryBuilder(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionBuilders.CategoryBuilder) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask)

Example 33 with CustomTask

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;
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) TaskGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask)

Example 34 with CustomTask

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);
}
Also used : Height(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Height) RectangleDimensionsSet(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.RectangleDimensionsSet) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Width(org.kie.workbench.common.stunner.bpmn.definition.property.dimensions.Width) Before(org.junit.Before)

Example 35 with CustomTask

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;
}
Also used : GenericServiceTaskPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.GenericServiceTaskPropertyWriter) ServiceTaskPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ServiceTaskPropertyWriter) CustomTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.workitem.CustomTaskExecutionSet) TaskGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet) Task(org.eclipse.bpmn2.Task) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask)

Aggregations

CustomTask (org.kie.workbench.common.stunner.bpmn.workitem.CustomTask)66 Test (org.junit.Test)58 Ignore (org.junit.Ignore)18 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Before (org.junit.Before)4 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)3 TaskGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 Collections (java.util.Collections)2 Consumer (java.util.function.Consumer)2 Function (java.util.function.Function)2 GenericServiceTaskPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.GenericServiceTaskPropertyReader)2 ServiceTaskPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ServiceTaskPropertyReader)2 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)2 NoneTask (org.kie.workbench.common.stunner.bpmn.definition.NoneTask)2 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)2 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)2 CustomTaskExecutionSet (org.kie.workbench.common.stunner.bpmn.workitem.CustomTaskExecutionSet)2 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)2 WorkItemDefinitionRegistry (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry)2