use of org.jbpm.kie.services.impl.model.ProcessAssetDesc in project jbpm by kiegroup.
the class KModuleDeploymentService method processResources.
/**
* Goes through all files in a deployment, and processes them so that they are then ready
* for use after deployment.
*
* @param module The {@link InternalKieModule}, necessary to get form content
* @param files The {@link List} of file (names) to process.
* @param kieContainer The {@link KieContainer}, necesary in order to load classes
* @param deploymentUnit The {@link DeploymentUnit}, necessary to get the deployment id
* @param deployedUnit The {@link DeployedUnit}, which contains the results of actions here
*/
protected void processResources(InternalKieModule module, Collection<String> files, KieContainer kieContainer, DeploymentUnit unit, DeployedUnitImpl deployedUnit, ReleaseId releaseId, Map<String, ProcessDescriptor> processes) {
for (String fileName : files) {
if (fileName.matches(".+bpmn[2]?$")) {
ProcessAssetDesc process;
try {
String processString = new String(module.getBytes(fileName), "UTF-8");
String processId = getProcessId(processString);
ProcessDescriptor processDesriptor = processes.get(processId);
if (processDesriptor != null) {
process = processDesriptor.getProcess();
if (process == null) {
throw new IllegalArgumentException("Unable to read process " + fileName);
}
process.setEncodedProcessSource(Base64.encodeBase64String(processString.getBytes()));
process.setDeploymentId(unit.getIdentifier());
deployedUnit.addAssetLocation(process.getId(), process);
bpmn2Service.addProcessDefinition(unit.getIdentifier(), processId, processDesriptor, kieContainer);
}
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding while processing process " + fileName);
}
} else if (fileName.matches(".+ftl$") || fileName.matches(".+form$") || fileName.matches(".+frm$")) {
try {
String formContent = new String(module.getBytes(fileName), "UTF-8");
if (fileName.indexOf("/") != -1)
fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
formManagerService.registerForm(unit.getIdentifier(), fileName, formContent);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException("Unsupported encoding while processing form " + fileName);
}
} else if (fileName.matches(".+class$")) {
// Classes 1: classes from deployment added
String className = fileName.replaceAll("/", ".");
className = className.substring(0, fileName.length() - ".class".length());
Class deploymentClass = null;
try {
deploymentClass = kieContainer.getClassLoader().loadClass(className);
} catch (ClassNotFoundException cnfe) {
throw new IllegalArgumentException("Class " + className + " not found in the project");
} catch (NoClassDefFoundError e) {
throw new IllegalArgumentException("Class " + className + " not found in the project");
}
addClassToDeployedUnit(deploymentClass, deployedUnit);
}
}
}
use of org.jbpm.kie.services.impl.model.ProcessAssetDesc in project jbpm by kiegroup.
the class InMemoryFormProvider method render.
@Override
public String render(String name, ProcessDefinition process, Map<String, Object> renderContext) {
ProcessAssetDesc asset = null;
if (!(process instanceof ProcessAssetDesc)) {
return null;
}
String templateString = formManagerService.getFormByKey(process.getDeploymentId(), process.getId());
if (templateString == null) {
templateString = formManagerService.getFormByKey(process.getDeploymentId(), process.getId() + getFormSuffix());
}
if (templateString == null || templateString.isEmpty()) {
return null;
} else {
return render(name, new ByteArrayInputStream(templateString.getBytes()), renderContext);
}
}
use of org.jbpm.kie.services.impl.model.ProcessAssetDesc in project jbpm by kiegroup.
the class BPMN2DataServiceImpl method fillProcessDefinition.
private ProcessAssetDesc fillProcessDefinition(ProcessDescriptor helper, KieContainer kieContainer) {
ProcessAssetDesc definition = helper.getProcess();
definition.setAssociatedEntities(helper.getTaskAssignments());
definition.setProcessVariables(helper.getInputs());
definition.setServiceTasks(helper.getServiceTasks());
definition.setSignals(helper.getSignals());
definition.setGlobals(helper.getGlobals());
definition.setReferencedRules(helper.getReferencedRules());
if (kieContainer != null && helper.hasUnresolvedReusableSubProcessNames()) {
helper.resolveReusableSubProcessNames(kieContainer.getKieBase().getProcesses());
}
definition.setReusableSubProcesses(helper.getReusableSubProcesses());
return definition;
}
Aggregations