private byte[] getProcessImageAsBytes(String containerId, String processId) { ProcessDefinition procDef = dataService.getProcessesByDeploymentIdProcessId(containerId, processId); if( procDef == null ) { throw new IllegalArgumentException("No process found for " + processId + " within container " + containerId); } String location = ""; if (procDef.getPackageName() != null && !procDef.getPackageName().trim().isEmpty()) { location = procDef.getPackageName().replaceAll("\\.", "/") + "/"; } // get SVG String byte[] imageSVG = imageReferenceMap.get(containerId).getImageContent(location, processId); if( imageSVG == null ) { logger.warn("Could not find SVG image file for process '" + processId + "' within container " + containerId); return null; } return imageSVG; }
public byte[] getImageContent(String location, String name) { org.kie.api.definition.process.Process process = kieContainer.getKieBase(kieBaseName).getProcess(name); if (process != null) { String sourcePath = process.getResource().getSourcePath(); if (sourcePath != null) { String processDirectory = ""; if (sourcePath.indexOf("/") != -1) { processDirectory = sourcePath.substring(0, sourcePath.lastIndexOf("/") + 1); } byte[] data = seek(processDirectory, name, kieModule); if (data != null) { return data; } // set process directory as location in case the main search mechanism did not find the image location = processDirectory; } } byte[] data = seek(location, name, kieModule); if (data == null && kieModule.getKieDependencies() != null) { for (InternalKieModule depKieModule : kieModule.getKieDependencies().values()) { data = seek(location, name, depKieModule); if (data != null) { break; } } } return data; }
@SuppressWarnings("unchecked") @Override public void createContainer(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) { if (!initialized) { return; } List<Message> messages = (List<Message>) parameters.get(KieServerConstants.KIE_SERVER_PARAM_MESSAGES); try { DeployedUnit deployedUnit = deploymentService.getDeployedUnit(id); if(deployedUnit != null) { String kieBaseName = ((KModuleDeploymentUnit)deployedUnit.getDeploymentUnit()).getKbaseName(); KieContainer kieContainer = kieContainerInstance.getKieContainer(); imageReferences.putIfAbsent(id, new ImageReference(kieContainer, kieBaseName)); formRendererBase.indexDeploymentForms(id); } } catch (Exception e) { messages.add(new Message(Severity.WARN, "Unable to create image reference for container " + id +" by extension " + this + " due to " + e.getMessage())); logger.warn("Unable to create image reference for container {} due to {}", id, e.getMessage(), e); } }