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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations