Search in sources :

Example 1 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel 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 2 with TaskFormModel

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

the class AbstractBPMNFormGeneratorService method createFormLayout.

protected void createFormLayout(FormDefinition form) {
    LayoutGenerator layoutGenerator = new LayoutGenerator();
    layoutGenerator.init(new LayoutColumnDefinition[] { new LayoutColumnDefinition(ColSpan.SPAN_12) });
    if (form.getFields().size() > 0) {
        boolean separeateInputsAndOutputs = form.getModel() instanceof TaskFormModel;
        boolean mightAddOtuputsLabel = form.getFields().get(0).getReadOnly();
        if (separeateInputsAndOutputs) {
            if (mightAddOtuputsLabel) {
                layoutGenerator.addComponent(generateHTMLElement(INPUTS), new LayoutSettings());
            } else {
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
        }
        for (FieldDefinition fieldDefinition : form.getFields()) {
            if (separeateInputsAndOutputs && mightAddOtuputsLabel && !fieldDefinition.getReadOnly()) {
                mightAddOtuputsLabel = false;
                layoutGenerator.addComponent(generateHTMLElement(OUTPUTS), new LayoutSettings());
            }
            LayoutComponent fieldComponent = new LayoutComponent(StaticFormLayoutTemplateGenerator.DRAGGABLE_TYPE);
            fieldComponent.addProperty(FormLayoutComponent.FORM_ID, form.getId());
            fieldComponent.addProperty(FormLayoutComponent.FIELD_ID, fieldDefinition.getId());
            layoutGenerator.addComponent(fieldComponent, new LayoutSettings());
        }
    }
    form.setLayoutTemplate(layoutGenerator.build());
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) LayoutSettings(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent)

Example 3 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel 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 4 with TaskFormModel

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

the class FormGenerationWithSynchronizationTest method testRemoveModelProperties.

@Test
public void testRemoveModelProperties() {
    List<ModelProperty> modelProperties = new ArrayList<>();
    modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
    newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
    FormGenerationResult generationResult = service.generateForms(newFormModel, source);
    assertNotNull(generationResult);
    assertNotNull(generationResult.getRootForm());
    FormDefinition formDefinition = generationResult.getRootForm();
    assertEquals(newFormModel, formDefinition.getModel());
    assertEquals(ORIGINAL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
    FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertNull(formDefinition.getFieldByBinding(AGE_PROPERTY));
    assertNull(formDefinition.getFieldByBinding(MARRIED_PROPERTY));
    assertNull(formDefinition.getFieldByBinding(ADDRESS_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(AGE_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(MARRIED_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(ADDRESS_PROPERTY));
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 5 with TaskFormModel

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

the class BPMNFormModelGeneratorImplTest method testGenerateAllForProcessWithoutProcessVariables.

@Test
public void testGenerateAllForProcessWithoutProcessVariables() {
    // generate all = generateProcessFormModel + generateTaskFormModels
    BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithoutVariablesDefinitions, path);
    assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITHOUT_VARIABLES_NAME);
    assertTrue(processFormModel.getProperties().isEmpty());
    List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithoutVariablesDefinitions, path);
    assertTrue(taskFormModels.isEmpty());
}
Also used : BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Aggregations

TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)21 Test (org.junit.Test)15 Matchers.anyString (org.mockito.Matchers.anyString)9 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 Definitions (org.eclipse.bpmn2.Definitions)4 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)4 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)4 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)4 Path (org.uberfire.backend.vfs.Path)4 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)3 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)3 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)3 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)3 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)3 IOException (java.io.IOException)2 List (java.util.List)2 Optional (java.util.Optional)2 Dependent (javax.enterprise.context.Dependent)2