Search in sources :

Example 11 with Process

use of org.eclipse.bpmn2.Process in project kie-wb-common by kiegroup.

the class BPMNFormModelGeneratorImpl method generateTaskFormModel.

@Override
public TaskFormModel generateTaskFormModel(Definitions source, String taskId, Path path) {
    Process process = getProcess(source);
    if (process != null) {
        ProcessTaskFormsGenerationResult generationResult = readUserTaskFormVariables(process);
        Optional<TaskFormVariables> resultTaskFormVariables = Optional.ofNullable(generationResult.getTaskFormVariablesByTaskId(taskId));
        if (resultTaskFormVariables.isPresent()) {
            TaskFormVariables formVariables = resultTaskFormVariables.get();
            if (!formVariables.isValid()) {
                throw new IllegalStateException(generateErrorMessage(formVariables));
            }
            final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));
            return formVariables.toFormModel(variable -> createModelProperty(variable, projectClassLoader));
        }
    }
    return null;
}
Also used : Process(org.eclipse.bpmn2.Process)

Example 12 with Process

use of org.eclipse.bpmn2.Process in project kie-wb-common by kiegroup.

the class BPMNFormModelGeneratorImpl method generateProcessFormModel.

@Override
public BusinessProcessFormModel generateProcessFormModel(Definitions source, Path path) {
    Process process = getProcess(source);
    if (process != null) {
        final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));
        List<ModelProperty> properties = process.getProperties().stream().map(property -> {
            String varName = property.getId();
            String varType = BPMNVariableUtils.getRealTypeForInput(property.getItemSubjectRef().getStructureRef());
            Variable variable = new Variable(varName, varType);
            variable.setInput(true);
            variable.setOutput(true);
            return createModelProperty(variable, projectClassLoader);
        }).sorted((property1, property2) -> property1.getName().compareToIgnoreCase(property2.getName())).collect(Collectors.toList());
        return new BusinessProcessFormModel(process.getId(), process.getName(), properties);
    }
    return null;
}
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) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) Process(org.eclipse.bpmn2.Process) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)

Example 13 with Process

use of org.eclipse.bpmn2.Process in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitAssociationsIoSpec.

public void revisitAssociationsIoSpec(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    List<ItemDefinition> toAddItemDefinitions = new ArrayList<ItemDefinition>();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            setItemDefinitionsForActivitiesIoSpec((Process) root, def, toAddItemDefinitions);
        }
    }
    for (ItemDefinition itemDef : toAddItemDefinitions) {
        def.getRootElements().add(itemDef);
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ArrayList(java.util.ArrayList) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 14 with Process

use of org.eclipse.bpmn2.Process in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyProcessProperties.

protected void applyProcessProperties(Process process, Map<String, String> properties) {
    if (properties.get("processn") != null) {
        process.setName(StringEscapeUtils.escapeXml(properties.get("processn")));
    } else {
        process.setName("");
    }
    if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
        Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
        audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
        process.setAuditing(audit);
    }
    process.setProcessType(ProcessType.getByName(properties.get("processtype")));
    process.setIsClosed(Boolean.parseBoolean(properties.get("isclosed")));
    process.setIsExecutable(Boolean.parseBoolean(properties.get("executable")));
    // get the drools-specific extension packageName attribute to Process if defined
    if (properties.get("package") != null && properties.get("package").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "packageName", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("package"));
        process.getAnyAttribute().add(extensionEntry);
    }
    // add version attrbute to process
    if (properties.get("version") != null && properties.get("version").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "version", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("version"));
        process.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
        Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
        monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
        process.setMonitoring(monitoring);
    }
    // import extension elements
    if (properties.get("imports") != null && properties.get("imports").length() > 0) {
        String[] allImports = properties.get("imports").split(",\\s*");
        for (String importStr : allImports) {
            String[] importParts = importStr.split("\\|\\s*");
            // sample 'com.sample.Myclass|default,location|namespace|wsdl
            if (importParts.length == 2 || importParts.length == 3) {
                if (importParts[1] != null && importParts[1].equals("default")) {
                    ImportType importType = DroolsFactory.eINSTANCE.createImportType();
                    importType.setName(importParts[0]);
                    if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                        ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                        process.getExtensionValues().add(extensionElement);
                    }
                    FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType);
                    process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
                } else {
                    Import imp = Bpmn2Factory.eINSTANCE.createImport();
                    imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
                    imp.setLocation(importParts[0]);
                    imp.setNamespace(importParts[1]);
                    _wsdlImports.add(imp);
                }
            } else {
                // just default (support legacy)
                ImportType importType = DroolsFactory.eINSTANCE.createImportType();
                importType.setName(importStr);
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
    }
    // globals extension elements
    if (properties.get("globals") != null && properties.get("globals").length() > 0) {
        String[] allGlobals = properties.get("globals").split(",\\s*");
        for (String globalStr : allGlobals) {
            // identifier:type
            String[] globalParts = globalStr.split(":\\s*");
            if (globalParts.length == 2) {
                GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType();
                globalType.setIdentifier(globalParts[0]);
                globalType.setType(globalParts[1]);
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            } else if (globalParts.length == 1) {
                GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType();
                globalType.setIdentifier(globalParts[0]);
                globalType.setType("Object");
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
    }
    // simulation properties
    if (properties.get("timeunit") != null && properties.get("timeunit").length() > 0) {
        _simulationScenarioParameters.setBaseTimeUnit(TimeUnit.getByName(properties.get("timeunit")));
    }
    if (properties.get("currency") != null && properties.get("currency").length() > 0) {
        _simulationScenarioParameters.setBaseCurrencyUnit(properties.get("currency"));
    }
}
Also used : ImportType(org.jboss.drools.ImportType) Import(org.eclipse.bpmn2.Import) Internal(org.eclipse.emf.ecore.EStructuralFeature.Internal) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) Auditing(org.eclipse.bpmn2.Auditing) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData) Monitoring(org.eclipse.bpmn2.Monitoring) GlobalType(org.jboss.drools.GlobalType)

Example 15 with Process

use of org.eclipse.bpmn2.Process in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method revisitBoundaryEventsPositions.

protected void revisitBoundaryEventsPositions(Definitions def) {
    for (RootElement root : def.getRootElements()) {
        if (root instanceof Process) {
            Process process = (Process) root;
            List<BoundaryEvent> toRemove = new ArrayList();
            for (FlowElement fe : process.getFlowElements()) {
                if (fe instanceof BoundaryEvent) {
                    BoundaryEvent be = (BoundaryEvent) fe;
                    FlowElementsContainer container = findContainerForBoundaryEvent(process, be);
                    if (container != null && !(container instanceof Process)) {
                        BoundaryEvent beCopy = copyBoundaryEvent(be);
                        container.getFlowElements().add(beCopy);
                        _outgoingFlows.put(beCopy, _outgoingFlows.get(be));
                        toRemove.add(be);
                        _outgoingFlows.remove(be);
                    }
                }
            }
            for (BoundaryEvent be : toRemove) {
                process.getFlowElements().remove(be);
            }
        }
    }
    reconnectFlows();
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Aggregations

Process (org.eclipse.bpmn2.Process)46 SubProcess (org.eclipse.bpmn2.SubProcess)33 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)31 RootElement (org.eclipse.bpmn2.RootElement)31 ArrayList (java.util.ArrayList)24 FlowElement (org.eclipse.bpmn2.FlowElement)19 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)15 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)15 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)14 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)14 List (java.util.List)13 Definitions (org.eclipse.bpmn2.Definitions)13 Entry (java.util.Map.Entry)12 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)12 DataInput (org.eclipse.bpmn2.DataInput)11 DataObject (org.eclipse.bpmn2.DataObject)11 DataOutput (org.eclipse.bpmn2.DataOutput)11 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)11 Artifact (org.eclipse.bpmn2.Artifact)10 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)10