Search in sources :

Example 1 with IconDefinition

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

the class CustomTaskShapeViewHandlerTest method testHandleIconDataNull.

@Test
@SuppressWarnings("unchecked")
public void testHandleIconDataNull() {
    final WorkItemDefinition wid = mock(WorkItemDefinition.class);
    final IconDefinition iconDef = mock(IconDefinition.class);
    when(iconDef.getIconData()).thenReturn(null);
    when(wid.getIconDefinition()).thenReturn(iconDef);
    when(registry.get(eq(WID_ID))).thenReturn(wid);
    checkIconLoad(WorkItemDefinitionClientUtils.getDefaultIconData());
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition) Test(org.junit.Test)

Example 2 with IconDefinition

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

the class WorkItemDefinitionParser method emptyWid.

public static WorkItemDefinition emptyWid() {
    WorkItemDefinition wid = new WorkItemDefinition();
    wid.setIconDefinition(new IconDefinition());
    wid.getIconDefinition().setUri("");
    wid.setUri("");
    wid.setName("");
    wid.setCategory("");
    wid.setDescription("");
    wid.setDocumentation("");
    wid.setDisplayName("");
    wid.setResults("");
    wid.setDefaultHandler("");
    wid.setDependencies(new Dependencies(Collections.emptyList()));
    wid.setParameters("");
    return wid;
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Dependencies(org.guvnor.common.services.project.model.Dependencies) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)

Example 3 with IconDefinition

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

the class WorkItemDefinitionParser method parse.

public static WorkItemDefinition parse(final WorkDefinitionImpl workDefinition, final Function<WorkDefinitionImpl, String> uriProvider, final Function<String, String> dataUriProvider) {
    final WorkItemDefinition workItem = new WorkItemDefinition();
    // Attributes..
    workItem.setUri(uriProvider.apply(workDefinition));
    workItem.setName(workDefinition.getName());
    workItem.setCategory(workDefinition.getCategory());
    workItem.setDocumentation(workDefinition.getDocumentation());
    workItem.setDescription(workDefinition.getDescription());
    workItem.setDefaultHandler(workDefinition.getDefaultHandler());
    workItem.setDisplayName(workDefinition.getDisplayName());
    // Icon.
    final IconDefinition iconDefinition = new IconDefinition();
    final String iconEncoded = workDefinition.getIconEncoded();
    final String icon = workDefinition.getIcon();
    String iconData = null;
    if (null != iconEncoded && iconEncoded.trim().length() > 0) {
        iconData = iconEncoded;
    } else if (null != icon && icon.trim().length() > 0) {
        final String iconUrl = workDefinition.getPath() + "/" + icon;
        iconData = dataUriProvider.apply(iconUrl);
    }
    iconDefinition.setUri(icon);
    iconDefinition.setIconData(iconData);
    workItem.setIconDefinition(iconDefinition);
    // Parameters.
    workItem.setParameters(parseParameters(workDefinition.getParameters()));
    // Results.
    workItem.setResults(parseParameters(workDefinition.getResults()));
    // Dependencies.
    final String[] dependencies = workDefinition.getMavenDependencies();
    final List<Dependency> dependencyList = null == dependencies ? Collections.emptyList() : Stream.of(dependencies).map(WorkItemDefinitionParser::parseDependency).filter(Objects::nonNull).collect(Collectors.toList());
    workItem.setDependencies(new Dependencies(dependencyList));
    return workItem;
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Objects(java.util.Objects) Dependency(org.guvnor.common.services.project.model.Dependency) Dependencies(org.guvnor.common.services.project.model.Dependencies) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)

Example 4 with IconDefinition

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

the class WorkItemDefinitionClientParser method emptyWid.

public static WorkItemDefinition emptyWid() {
    WorkItemDefinition wid = new WorkItemDefinition();
    wid.setIconDefinition(new IconDefinition());
    wid.getIconDefinition().setUri("");
    wid.getIconDefinition().setIconData(getDefaultIconData());
    wid.setUri("");
    wid.setName("");
    wid.setCategory("");
    wid.setDescription("");
    wid.setDocumentation("");
    wid.setDisplayName("");
    wid.setResults("");
    wid.setDefaultHandler("");
    wid.setDependencies(new Dependencies(Collections.emptyList()));
    wid.setParameters("");
    return wid;
}
Also used : WorkItemDefinition(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition) Dependencies(org.guvnor.common.services.project.model.Dependencies) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)

Example 5 with IconDefinition

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

the class WorkItemDefinitionRemoteDeployService method createIconAsset.

private static Optional<Asset> createIconAsset(final WorkItemDefinition item) {
    final IconDefinition icon = item.getIconDefinition();
    if (null != icon && null != icon.getUri()) {
        final String path = parsePath(item.getUri());
        final String iconUri = icon.getUri();
        final Asset iconAsset;
        try {
            iconAsset = new AssetBuilder().setFileName(parseFileName(iconUri)).binaryFromURI(path + "/" + iconUri).build();
            return Optional.of(iconAsset);
        } catch (IOException e) {
            LOG.error("Error reading work item definition asset from URL [" + item.getUri() + "]", e);
        }
    }
    return Optional.empty();
}
Also used : AssetBuilder(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.AssetBuilder) Asset(org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset) IOException(java.io.IOException) IconDefinition(org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)

Aggregations

IconDefinition (org.kie.workbench.common.stunner.bpmn.workitem.IconDefinition)5 WorkItemDefinition (org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinition)4 Dependencies (org.guvnor.common.services.project.model.Dependencies)3 IOException (java.io.IOException)1 Objects (java.util.Objects)1 Dependency (org.guvnor.common.services.project.model.Dependency)1 Test (org.junit.Test)1 Asset (org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.Asset)1 AssetBuilder (org.kie.workbench.common.stunner.core.backend.service.BackendFileSystemManager.AssetBuilder)1