Search in sources :

Example 16 with WorkItemDefinition

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);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) MetadataService(org.guvnor.common.services.shared.metadata.MetadataService) Collection(java.util.Collection) Dependencies(org.guvnor.common.services.project.model.Dependencies) Set(java.util.Set) Collectors(java.util.stream.Collectors) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Inject(javax.inject.Inject) POM(org.guvnor.common.services.project.model.POM) Dependency(org.guvnor.common.services.project.model.Dependency) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) POMService(org.guvnor.common.services.project.service.POMService) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Module(org.guvnor.common.services.project.model.Module) Path(org.uberfire.backend.vfs.Path) Dependencies(org.guvnor.common.services.project.model.Dependencies) Dependency(org.guvnor.common.services.project.model.Dependency) Module(org.guvnor.common.services.project.model.Module) POM(org.guvnor.common.services.project.model.POM)

Example 17 with WorkItemDefinition

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());
    }
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) SVGPrimitive(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitive) Picture(com.ait.lienzo.client.core.shape.Picture)

Example 18 with WorkItemDefinition

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();
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) DefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionId) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) DirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation) DefinitionsCacheRegistry(org.kie.workbench.common.stunner.core.registry.impl.DefinitionsCacheRegistry) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) DomainProfileManager(org.kie.workbench.common.stunner.core.profile.DomainProfileManager) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) DefinitionAdapter(org.kie.workbench.common.stunner.core.definition.adapter.DefinitionAdapter) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) TextAnnotation(org.kie.workbench.common.stunner.bpmn.definition.TextAnnotation) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) NonDirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.NonDirectionalAssociation) AdapterManager(org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager) DefaultPaletteDefinitionProviders.getId(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinitionProviders.getId) Before(org.junit.Before) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) StunnerTranslationService(org.kie.workbench.common.stunner.core.i18n.StunnerTranslationService) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.times(org.mockito.Mockito.times) AdapterRegistry(org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) Assert.assertFalse(org.junit.Assert.assertFalse) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Consumer(java.util.function.Consumer) DefaultPaletteDefinition(org.kie.workbench.common.stunner.core.client.components.palette.DefaultPaletteDefinition) ExpandedPaletteDefinitionBuilder(org.kie.workbench.common.stunner.core.client.components.palette.ExpandedPaletteDefinitionBuilder) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Before(org.junit.Before)

Example 19 with WorkItemDefinition

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

Example 20 with WorkItemDefinition

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;
}
Also used : ServiceTask(org.kie.workbench.common.stunner.bpmn.workitem.ServiceTask) WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

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