Search in sources :

Example 16 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class BPMFinderServiceImpl method scannProcessesForType.

protected void scannProcessesForType(final Path path, final String extension, final GenerationConfig generationConfig) {
    List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
    nioPaths.add(Paths.convert(path));
    Collection<FileUtils.ScanResult> processes = fileUtils.scan(ioService, nioPaths, extension, true);
    processes.stream().map(scanResult -> parse(scanResult)).filter(definitions -> definitions != null && generationConfig.getPredicate().test(definitions)).forEach(definitions -> {
        BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions.get(), path);
        List<TaskFormModel> taskModels = bpmnFormModelGenerator.generateTaskFormModels(definitions.get(), path);
        generationConfig.getConsumer().accept(new JBPMProcessModel(processFormModel, taskModels));
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) URI(org.eclipse.emf.common.util.URI) BPMFinderService(org.kie.workbench.common.forms.jbpm.service.shared.BPMFinderService) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) Service(org.jboss.errai.bus.server.annotations.Service) Named(javax.inject.Named) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl) FileUtils(org.kie.workbench.common.services.datamodeller.util.FileUtils) Process(org.eclipse.bpmn2.Process) Logger(org.slf4j.Logger) DroolsPackage(org.jboss.drools.DroolsPackage) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Predicate(java.util.function.Predicate) Collection(java.util.Collection) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Consumer(java.util.function.Consumer) List(java.util.List) Dependent(javax.enterprise.context.Dependent) PostConstruct(javax.annotation.PostConstruct) Bpmn2ResourceFactoryImpl(org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl) Resource(org.eclipse.emf.ecore.resource.Resource) IOService(org.uberfire.io.IOService) Optional(java.util.Optional) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) Bpmn2Package(org.eclipse.bpmn2.Bpmn2Package) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)

Example 17 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class DMNEditBusinessKnowledgeModelToolboxAction method onMouseClick.

@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
    // Notice the toolbox factory ensure this action is only being included
    // for BusinessKnowledgeModel definitions, next cast is safe.
    final Node<View<? extends BusinessKnowledgeModel>, Edge> bkmNode = (Node<View<? extends BusinessKnowledgeModel>, Edge>) AbstractToolboxAction.getElement(canvasHandler, uuid).asNode();
    final BusinessKnowledgeModel bkm = bkmNode.getContent().getDefinition();
    editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, bkm.getEncapsulatedLogic(), Optional.of(bkm)));
    return this;
}
Also used : BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel) Node(org.kie.workbench.common.stunner.core.graph.Node) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 18 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxAction method onMouseClick.

@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
    // Notice the toolbox factory ensure this action is only being included
    // for Decision definitions, next cast is safe.
    final Node<View<? extends Decision>, Edge> decisionNode = (Node<View<? extends Decision>, Edge>) AbstractToolboxAction.getElement(canvasHandler, uuid).asNode();
    final Decision decision = decisionNode.getContent().getDefinition();
    editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, decision, Optional.of(decision)));
    return this;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision)

Example 19 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.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 20 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyBaseElementProperties.

protected void applyBaseElementProperties(BaseElement baseElement, Map<String, String> properties) {
    if (properties.get("documentation") != null && !"".equals(properties.get("documentation"))) {
        if (baseElement instanceof Definitions) {
            this.processDocs = properties.get("documentation");
        } else {
            baseElement.getDocumentation().add(createDocumentation(wrapInCDATABlock(properties.get("documentation"))));
        }
    }
    if (baseElement.getId() == null || baseElement.getId().length() < 1) {
        baseElement.setId(properties.get("resourceId"));
    }
    if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bgcolor:" + properties.get("bgcolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("bgcolor:" + properties.get("bgcolor"));
        }
    }
    if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
        baseElement.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bordercolor:" + properties.get("bordercolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("bordercolor:" + properties.get("bordercolor"));
        }
    }
    if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
        baseElement.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
        if (!(_elementColors.containsKey(baseElement.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("fontcolor:" + properties.get("fontcolor"));
            _elementColors.put(baseElement.getId(), colorsList);
        } else {
            _elementColors.get(baseElement.getId()).add("fontcolor:" + properties.get("fontcolor"));
        }
    }
}
Also used : EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) Definitions(org.eclipse.bpmn2.Definitions) ArrayList(java.util.ArrayList) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData)

Aggregations

Definitions (org.eclipse.bpmn2.Definitions)25 Definitions (org.kie.dmn.model.v1_1.Definitions)22 Test (org.junit.Test)20 Process (org.eclipse.bpmn2.Process)13 IOException (java.io.IOException)9 InputStreamReader (java.io.InputStreamReader)9 DMNMarshaller (org.kie.dmn.api.marshalling.v1_1.DMNMarshaller)8 Graph (org.kie.workbench.common.stunner.core.graph.Graph)8 InputStream (java.io.InputStream)7 DMNModel (org.kie.dmn.api.core.DMNModel)7 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)7 Path (org.uberfire.backend.vfs.Path)7 List (java.util.List)6 RootElement (org.eclipse.bpmn2.RootElement)6 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)6 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)5 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)5 Matchers.anyString (org.mockito.Matchers.anyString)5