use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class BPMFinderServiceImpl method getModelForProcess.
@Override
public JBPMProcessModel getModelForProcess(final String processId, final Path path) {
GenerationConfig<Optional<JBPMProcessModel>> operations = new GenerationConfig<>(Optional.empty());
operations.setPredicate(definitions -> {
if (definitions.isPresent()) {
if (!operations.getValue().isPresent()) {
Optional<Process> optional = Optional.of(bpmnFormModelGenerator.getProcess(definitions.get()));
return optional.isPresent() && optional.get().getId().equals(processId);
}
}
return false;
});
operations.setConsumer(processModel -> operations.setValue(Optional.ofNullable(processModel)));
Path rootPath = moduleService.resolveModule(path).getRootPath();
scannProcessesForType(rootPath, "bpmn2", operations);
if (!operations.getValue().isPresent()) {
scannProcessesForType(rootPath, "bpmn", operations);
}
return operations.getValue().orElse(null);
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImpl method generateTaskFormModels.
@Override
public List<TaskFormModel> generateTaskFormModels(Definitions source, Path path) {
Process process = getProcess(source);
final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));
if (process != null) {
ProcessTaskFormsGenerationResult result = readUserTaskFormVariables(process);
return result.getAllTaskFormVariables().stream().filter(taskFormVariables -> {
if (!taskFormVariables.isValid()) {
logger.warn(generateErrorMessage(taskFormVariables));
return false;
}
return true;
}).map(taskFormVariables -> taskFormVariables.toFormModel(variable -> createModelProperty(variable, projectClassLoader))).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class BaseDiagramMarshaller method parseDefinitions.
private Definitions parseDefinitions(final InputStream inputStream) throws IOException {
try {
DroolsPackageImpl.init();
BpsimPackageImpl.init();
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new JBPMBpmn2ResourceFactoryImpl());
resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
resourceSet.getPackageRegistry().put("http://www.jboss.org/drools", DroolsPackage.eINSTANCE);
final JBPMBpmn2ResourceImpl resource = (JBPMBpmn2ResourceImpl) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
resource.setEncoding("UTF-8");
final Map<String, Object> options = new HashMap<String, Object>();
options.put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
options.put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
resource.load(inputStream, options);
final DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
return root.getDefinitions();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
inputStream.close();
}
}
return null;
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class DefinitionsConverter method toDefinitions.
public Definitions toDefinitions() {
Definitions definitions = bpmn2.createDefinitions();
DefinitionsPropertyWriter p = propertyWriterFactory.of(definitions);
ProcessPropertyWriter pp = processConverter.convertProcess();
p.setProcess(pp.getProcess());
p.setDiagram(pp.getBpmnDiagram());
p.setRelationship(pp.getRelationship());
p.addAllRootElements(pp.getRootElements());
p.addAllRootElements(pp.getItemDefinitions());
return definitions;
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImpl method generateSelectedFormsForTasks.
private void generateSelectedFormsForTasks(Diagram diagram, String... taskIds) {
try {
final String idsRaw = Arrays.stream(taskIds).collect(Collectors.joining(","));
LOGGER.finest("Generating form for tasks " + idsRaw);
final Path path = diagram.getMetadata().getPath();
org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
final Definitions definitions = toDefinitions(diagram);
for (String taskId : taskIds) {
final TaskFormModel formModel = bpmnFormModelGenerator.generateTaskFormModel(definitions, taskId, path);
createFormForModel(formModel, nioPath);
}
} catch (Exception ex) {
LOGGER.severe("Error generating task forms");
throw new RuntimeException(ex);
} finally {
ioService.endBatch();
}
}
Aggregations