Search in sources :

Example 1 with WorkItemDefinition

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.

the class WorkItemDefinitionServiceImplTest method testSearch.

@Test
public void testSearch() {
    Collection<WorkItemDefinition> items = tested.search(path);
    assertNotNull(items);
    assertEquals(1, items.size());
    WorkItemDefinition item = items.iterator().next();
    assertNotNull(item);
    assertEquals("Email", item.getName());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Test(org.junit.Test)

Example 2 with WorkItemDefinition

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.

the class WorkItemDefinitionServiceImplTest method testGet.

@Test
public void testGet() {
    Collection<WorkItemDefinition> items = tested.get(path);
    assertNotNull(items);
    assertEquals(1, items.size());
    WorkItemDefinition item = items.iterator().next();
    assertNotNull(item);
    assertEquals("Email", item.getName());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Test(org.junit.Test)

Example 3 with WorkItemDefinition

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition 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 4 with WorkItemDefinition

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.

the class WorkItemDefinitionParserTest method testEmptyWorkItemDefinition.

@Test
public void testEmptyWorkItemDefinition() {
    WorkItemDefinition wid = WorkItemDefinitionParser.emptyWid();
    assertNotNull(wid.getIconDefinition());
    assertTrue(wid.getIconDefinition().getUri().isEmpty());
    assertTrue(wid.getUri().isEmpty());
    assertTrue(wid.getName().isEmpty());
    assertTrue(wid.getCategory().isEmpty());
    assertTrue(wid.getDescription().isEmpty());
    assertTrue(wid.getDocumentation().isEmpty());
    assertTrue(wid.getDisplayName().isEmpty());
    assertTrue(wid.getResults().isEmpty());
    assertTrue(wid.getDefaultHandler().isEmpty());
    assertNotNull(wid.getDependencies());
    assertTrue(wid.getParameters().isEmpty());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Test(org.junit.Test)

Example 5 with WorkItemDefinition

use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.

the class WorkItemDefinitionParserTest method testFTPWorkItemDefinition.

@Test
public void testFTPWorkItemDefinition() throws Exception {
    when(dataUriProvider.apply(eq("ftp.gif"))).thenReturn(ICON_DATA);
    String raw = loadStream(WID_FTP);
    Collection<WorkItemDefinition> workItemDefinitions = WorkItemDefinitionParser.parse(raw, w -> "uri", dataUriProvider);
    assertNotNull(workItemDefinitions);
    assertEquals(1, workItemDefinitions.size());
    WorkItemDefinition workItemDefinition = workItemDefinitions.iterator().next();
    assertNotNull(workItemDefinition);
    assertEquals("FTP", workItemDefinition.getName());
    assertEquals("File System", workItemDefinition.getCategory());
    assertEquals("Sending files using FTP", workItemDefinition.getDescription());
    assertEquals("FTP", workItemDefinition.getDisplayName());
    assertEquals("", workItemDefinition.getDocumentation());
    assertEquals("org.jbpm.process.workitem.ftp.FTPUploadWorkItemHandler", workItemDefinition.getDefaultHandler());
    assertEquals(ICON_DATA, workItemDefinition.getIconDefinition().getIconData());
    assertEquals("|Body:String,FilePath:String,Password:String,User:String|", workItemDefinition.getParameters());
    assertEquals("||", workItemDefinition.getResults());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Test(org.junit.Test)

Aggregations

WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)33 Test (org.junit.Test)18 IconDefinition (org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)5 Collection (java.util.Collection)4 Dependencies (org.guvnor.common.services.project.model.Dependencies)4 WorkItemDefinitionRegistry (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry)4 Map (java.util.Map)3 Consumer (java.util.function.Consumer)3 Function (java.util.function.Function)3 Inject (javax.inject.Inject)3 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)3 Lane (org.kie.workbench.common.stunner.bpmn.definition.Lane)3 NoneTask (org.kie.workbench.common.stunner.bpmn.definition.NoneTask)3 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Predicate (java.util.function.Predicate)2