use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class WorkItemDefinitionProjectInstaller method install.
@SuppressWarnings("all")
public void install(final Collection<WorkItemDefinition> items, final Metadata metadata) {
final Module module = moduleService.resolveModule(metadata.getRoot());
final Path pomXMLPath = module.getPomXMLPath();
final POM projectPOM = pomService.load(pomXMLPath);
if (projectPOM != null) {
final Dependencies projectDependencies = projectPOM.getDependencies();
final Set<Dependency> widDependencies = items.stream().flatMap(wid -> wid.getDependencies().stream()).filter(d -> !projectDependencies.contains(d)).collect(Collectors.toSet());
projectDependencies.addAll(widDependencies);
pomService.save(pomXMLPath, projectPOM, metadataService.getMetadata(pomXMLPath), INSALL_MESSAGE, false);
}
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class CustomTaskShapeViewHandler method handle.
@Override
public void handle(final CustomTask bean, final SVGShapeView<?> view) {
// Obtain the work item's icon data url.
final WorkItemDefinition wid = workItemDefinitionRegistry.get().get(bean.getName());
final String iconData;
if (null != wid && null != wid.getIconDefinition() && null != wid.getIconDefinition().getIconData()) {
iconData = wid.getIconDefinition().getIconData();
} else {
iconData = WorkItemDefinitionClientUtils.getDefaultIconData();
}
// Obtain the image element from the svg shape view.
final SVGPrimitive svgPrimitive = SVGViewUtils.getPrimitive(view, WID_ICON_ID).get();
// Load the icon data.
final Picture icon = (Picture) svgPrimitive.get();
if (hasDataChanged(iconData, icon.getURL())) {
forceLoad(icon, iconData, () -> scaleViewIcon(view, icon));
}
if (Objects.equals(bean.getDimensionsSet().getHeight().getValue(), 0d) && Objects.equals(bean.getDimensionsSet().getWidth().getValue(), 0d)) {
bean.getDimensionsSet().getHeight().setValue(view.getPrimitive().get().getAttributes().getHeight());
bean.getDimensionsSet().getWidth().setValue(view.getPrimitive().get().getAttributes().getWidth());
}
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class BPMNPaletteDefinitionBuilderTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(definitionUtils.getDefinitionManager()).thenReturn(definitionManager);
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.registry()).thenReturn(adapterRegistry);
when(adapterRegistry.getDefinitionAdapter(any(Class.class))).thenReturn(widAdapter);
when(widAdapter.getId(eq(customTask))).thenReturn(DefinitionId.build(WID_NAME));
when(widAdapter.getCategory(eq(customTask))).thenReturn(WID_CAT);
when(widAdapter.getTitle(eq(customTask))).thenReturn(WID_DISPLAY_NAME);
when(widAdapter.getDescription(eq(customTask))).thenReturn(WID_DESC);
ExpandedPaletteDefinitionBuilder paletteDefinitionBuilder = spy(new ExpandedPaletteDefinitionBuilder(definitionUtils, profileManager, definitionsRegistry, translationService));
doAnswer(invocationOnMock -> {
Consumer<DefaultPaletteDefinition> definitionConsumer = (Consumer<DefaultPaletteDefinition>) invocationOnMock.getArguments()[1];
definitionConsumer.accept(PALETTE_DEFINITION);
return null;
}).when(paletteDefinitionBuilder).build(eq(canvasHandler), any(Consumer.class));
Function<WorkItemDefinition, CustomTask> serviceTaskBuilder = wid -> WID.equals(wid) ? customTask : null;
tested = new BPMNPaletteDefinitionBuilder(definitionManager, paletteDefinitionBuilder, translationService, () -> workItemDefinitionRegistry, serviceTaskBuilder, definitionUtils, new BPMNCategoryDefinitionProvider());
tested.init();
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class CustomTaskShapeDef method getGlyph.
public Glyph getGlyph(final Class<? extends CustomTask> type, final String defId) {
final String name = defId.substring(defId.lastIndexOf(".") + 1);
String itemIconData = WorkItemDefinitionClientUtils.getDefaultIconData();
if (!CustomTask.class.getSimpleName().equals(name)) {
WorkItemDefinition workItemDefinition = workItemDefinitionRegistry.get().get(name);
if (workItemDefinition != null) {
itemIconData = workItemDefinition.getIconDefinition().getIconData();
}
}
return iconDataGlyphGenerator.apply(itemIconData);
}
use of org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition in project kie-wb-common by kiegroup.
the class ServiceTaskNodeBuilder method doBuild.
@Override
protected Node<View<BPMNDefinition>, Edge> doBuild(final BuilderContext context) {
final Node<View<BPMNDefinition>, Edge> node = super.doBuild(context);
final ServiceTask serviceTask = (ServiceTask) node.getContent().getDefinition();
// Oryx handles the taskName property, use it for populating the service task.
final String taskName = serviceTask.getExecutionSet().getTaskName().getValue();
final WorkItemDefinition workItemDefinition = workItemDefinitionRegistry.get().get(taskName);
ServiceTaskFactory.ServiceTaskBuilder.setProperties(workItemDefinition, serviceTask);
return node;
}
Aggregations