Search in sources :

Example 86 with Definitions

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Optional(java.util.Optional) Process(org.eclipse.bpmn2.Process)

Example 87 with Definitions

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();
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) FormalExpression(org.eclipse.bpmn2.FormalExpression) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) LoggerFactory(org.slf4j.LoggerFactory) FieldReadOnlyEntry(org.kie.workbench.common.forms.model.impl.meta.entries.FieldReadOnlyEntry) StringUtils(org.apache.commons.lang3.StringUtils) Parser(org.jsoup.parser.Parser) Inject(javax.inject.Inject) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) FieldTypeEntry(org.kie.workbench.common.forms.model.impl.meta.entries.FieldTypeEntry) DataInput(org.eclipse.bpmn2.DataInput) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) DataOutput(org.eclipse.bpmn2.DataOutput) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) BPMNVariableUtils(org.kie.workbench.common.forms.jbpm.service.bpmn.util.BPMNVariableUtils) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) Collectors(java.util.stream.Collectors) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) List(java.util.List) Dependent(javax.enterprise.context.Dependent) Assignment(org.eclipse.bpmn2.Assignment) ModelPropertiesGenerator(org.kie.workbench.common.forms.service.backend.util.ModelPropertiesGenerator) Optional(java.util.Optional) FormModelPropertiesUtil(org.kie.workbench.common.forms.model.util.formModel.FormModelPropertiesUtil) Collections(java.util.Collections) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) UserTask(org.eclipse.bpmn2.UserTask) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) Process(org.eclipse.bpmn2.Process)

Example 88 with Definitions

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;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) HashMap(java.util.HashMap) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JBPMBpmn2ResourceFactoryImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl) IOException(java.io.IOException)

Example 89 with Definitions

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;
}
Also used : Definitions(org.eclipse.bpmn2.Definitions) DefinitionsPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.DefinitionsPropertyWriter) ProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter)

Example 90 with 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();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Aggregations

Process (org.eclipse.bpmn2.Process)40 RootElement (org.eclipse.bpmn2.RootElement)35 ArrayList (java.util.ArrayList)27 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)26 SubProcess (org.eclipse.bpmn2.SubProcess)26 Definitions (org.eclipse.bpmn2.Definitions)25 Definitions (org.kie.dmn.model.v1_1.Definitions)22 List (java.util.List)21 Test (org.junit.Test)20 FlowElement (org.eclipse.bpmn2.FlowElement)18 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)16 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)15 Entry (java.util.Map.Entry)14 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)13 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)13 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)13 EventDefinition (org.eclipse.bpmn2.EventDefinition)13 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)13 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)13 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)12