Search in sources :

Example 6 with BusinessProcessFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.

the class BusinessProcessFormModelHandlerTest method init.

@Before
public void init() throws ClassNotFoundException {
    super.init();
    model = new BusinessProcessFormModel(PROCESS_ID, PROCESS_ID, propertyList);
    handler = new BusinessProcessFormModelHandler(moduleService, moduleClassLoaderHelper, new TestFieldManager(), finderService);
    handler.init(model, path);
}
Also used : BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) Before(org.junit.Before)

Example 7 with BusinessProcessFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel 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);
        }).filter(modelProperty -> modelProperty != null).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) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Parser(org.jsoup.parser.Parser) Inject(javax.inject.Inject) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInput(org.eclipse.bpmn2.DataInput) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) MultiInstanceLoopCharacteristics(org.eclipse.bpmn2.MultiInstanceLoopCharacteristics) 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) BaseElement(org.eclipse.bpmn2.BaseElement) 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) Optional(java.util.Optional) Collections(java.util.Collections) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) UserTask(org.eclipse.bpmn2.UserTask) 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 8 with BusinessProcessFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImpl method generateProcessForm.

@Override
public void generateProcessForm(Diagram diagram) {
    try {
        LOGGER.finest("Generating form for process ");
        final Definitions definitions = toDefinitions(diagram);
        final Path path = diagram.getMetadata().getPath();
        final BusinessProcessFormModel formModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
        createFormForModel(formModel, Paths.convert(path));
    } catch (Exception ex) {
        LOGGER.severe("Error generating process form");
        throw new RuntimeException(ex);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) IOException(java.io.IOException)

Example 9 with BusinessProcessFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImpl method generateAllForms.

@Override
public void generateAllForms(Diagram diagram) {
    try {
        LOGGER.finest("Generating all forms");
        final Path path = diagram.getMetadata().getPath();
        final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
        ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
        final Definitions definitions = toDefinitions(diagram);
        final BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions, path);
        createFormForModel(processFormModel, nioPath);
        List<TaskFormModel> taskFormModels = bpmnFormModelGenerator.generateTaskFormModels(definitions, path);
        for (TaskFormModel taskFormModel : taskFormModels) {
            createFormForModel(taskFormModel, nioPath);
        }
    } catch (Exception ex) {
        LOGGER.severe("Error generating all diagram forms");
        throw new RuntimeException(ex);
    } finally {
        ioService.endBatch();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Example 10 with BusinessProcessFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.

the class BPMNAnalyzer method read.

public BPMNProcess read(InputStream inputStream) {
    Definitions definitions = BPMN2Utils.getDefinitions(inputStream);
    Optional<Process> processOptional = findProcess(definitions);
    if (!processOptional.isPresent()) {
        throw new RuntimeException("Cannot find Process on definitions");
    }
    Process process = processOptional.get();
    BusinessProcessFormModel formModel = new BusinessProcessFormModel(process.getId(), process.getName(), new ArrayList<>());
    BPMNProcess bpmmProcess = new BPMNProcess(formModel);
    readContainerUserTasks(process, bpmmProcess::addTaskFormModel);
    return bpmmProcess;
}
Also used : Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)

Aggregations

BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)16 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)9 ArrayList (java.util.ArrayList)6 Definitions (org.eclipse.bpmn2.Definitions)5 Test (org.junit.Test)5 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)4 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)4 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)4 Path (org.uberfire.backend.vfs.Path)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Process (org.eclipse.bpmn2.Process)3 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)3 IOException (java.io.IOException)2 Optional (java.util.Optional)2 Dependent (javax.enterprise.context.Dependent)2 Inject (javax.inject.Inject)2 JBPMProcessModel (org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel)2 BPMNFormModelGenerator (org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator)2 KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)2