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();
}
}
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());
}
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));
});
}
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));
}
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());
}
Aggregations