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