Search in sources :

Example 31 with Definitions

use of org.eclipse.bpmn2.Definitions 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 32 with Definitions

use of org.eclipse.bpmn2.Definitions 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 33 with Definitions

use of org.eclipse.bpmn2.Definitions 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)

Example 34 with Definitions

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

the class Bpmn2JsonUnmarshaller method revisitSignalRef.

/**
 * Updates the signal ref on catch and throw event definitions (including boundary)
 * @param def Definitions
 */
public void revisitSignalRef(Definitions def) {
    revisitSignalIds(def);
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            setSignalRefForCatchEvents((Process) root, def);
            setSignalRefForThrowEvents((Process) root, def);
            setSignalRefForBoundaryEvents((Process) root, def);
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 35 with Definitions

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

the class Bpmn2JsonUnmarshaller method updateIDs.

public void updateIDs(Definitions def) {
    // data object id update
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            if (process.getId() != null) {
                String processId = process.getId().trim();
                processId = processId.replaceAll("\\s", "");
                process.setId(processId);
            }
            List<FlowElement> flowElements = process.getFlowElements();
            for (FlowElement fe : flowElements) {
                if (fe instanceof DataObject) {
                    DataObject da = (DataObject) fe;
                    if (da.getName() != null) {
                        String daId = da.getName().trim();
                        daId = daId.replaceAll("\\W", "");
                        da.setId(daId);
                    }
                }
            }
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) DataObject(org.eclipse.bpmn2.DataObject) FlowElement(org.eclipse.bpmn2.FlowElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

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