use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class VFSFormFinderServiceImpl method findForms.
private List<FormDefinition> findForms(final Path path, final FormSearchConstraint constraint) {
List<FormDefinition> result = new ArrayList<>();
Module module = moduleService.resolveModule(path);
FileUtils utils = FileUtils.getInstance();
List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
nioPaths.add(Paths.convert(module.getRootPath()));
Collection<FileUtils.ScanResult> forms = utils.scan(ioService, nioPaths, FormResourceTypeDefinition.EXTENSION, true);
for (FileUtils.ScanResult form : forms) {
org.uberfire.java.nio.file.Path formPath = form.getFile();
try {
FormDefinition formDefinition = serializer.deserialize(ioService.readAllString(formPath).trim());
if (constraint == null || constraint.accepts(formDefinition)) {
result.add(formDefinition);
}
} catch (Exception ex) {
logger.warn("Unable to generate FormDefinition for {}", path, ex);
}
}
return result;
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormEditorServiceImplTest method verifyNewForm.
protected String verifyNewForm(InvocationOnMock invocationOnMock) {
FormDefinition form = (FormDefinition) invocationOnMock.getArguments()[0];
assertNotNull(form);
assertNotNull(form.getId());
assertNotNull(form.getModel());
assertEquals(FORM_NAME, form.getName());
assertTrue(form.getFields().isEmpty());
assertNotNull(form.getLayoutTemplate());
return "";
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class DynamicBPMNFormGeneratorImpl method createFormDefinition.
protected Collection<FormDefinition> createFormDefinition(JBPMFormModel model, ClassLoader classLoader) {
FormGenerationResult generationResult = formGeneratorService.generateForms(model, classLoader);
List<FormDefinition> result = new ArrayList<>();
result.add(generationResult.getRootForm());
result.addAll(generationResult.getNestedForms());
return result;
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method checkRootForm.
protected void checkRootForm(JBPMFormModel model, FormGenerationResult result, List<ModelProperty> variableList) {
FormDefinition form = result.getRootForm();
assertEquals(model, form.getModel());
assertFalse(form.getFields().isEmpty());
assertEquals(variableList.size(), form.getFields().size());
variableList.forEach(variable -> {
FieldDefinition field = form.getFieldByBinding(variable.getName());
assertNotNull(field);
assertEquals(variable.getName(), field.getName());
assertEquals(variable.getName(), field.getBinding());
assertEquals(variable.getTypeInfo().getClassName(), field.getStandaloneClassName());
});
assertNotNull(form.getLayoutTemplate());
assertFalse(form.getLayoutTemplate().getRows().isEmpty());
}
use of org.kie.workbench.common.forms.model.FormDefinition 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));
}
Aggregations