use of org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel in project kie-wb-common by kiegroup.
the class DataObjectFinderServiceImpl method getAvailableDataObjects.
@Override
public List<DataObjectFormModel> getAvailableDataObjects(Path path) {
DataModel dataModel = dataModelerService.loadModel(moduleService.resolveModule(path));
List<DataObjectFormModel> formModels = new ArrayList<>();
dataModel.getDataObjects().forEach(dataObject -> {
String modelName = dataObject.getName().substring(0, 1).toLowerCase() + dataObject.getName().substring(1);
formModels.add(new DataObjectFormModel(modelName, dataObject.getClassName()));
});
return formModels;
}
use of org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel in project kie-wb-common by kiegroup.
the class DataObjectFormModelHandler method createFormModel.
public DataObjectFormModel createFormModel(DataObject dataObject, Path path) {
this.path = path;
initClassLoader();
DataObjectFormModel formModel = new DataObjectFormModel(dataObject.getName(), dataObject.getClassName());
formModel.getProperties().clear();
formModel.getProperties().addAll(getDataObjectProperties(dataObject));
return formModel;
}
use of org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel in project kie-wb-common by kiegroup.
the class DataObjectFormModelCreationPresenterTest method setup.
@Before
public void setup() {
path = mock(Path.class);
formModels.add(new DataObjectFormModel("employee", "org.kie.wb.test.Employee"));
formModels.add(new DataObjectFormModel("address", "org.kie.wb.test.Address"));
formModels.add(new DataObjectFormModel("company", "org.kie.wb.test.Company"));
formModels.add(new DataObjectFormModel("department", "org.kie.wb.test.Department"));
dataObjectFormModelCreationService = mock(DataObjectFormModelCreationService.class);
when(dataObjectFormModelCreationService.getAvailableDataObjects(path)).thenReturn(formModels);
dataObjectFormModelCreationServiceCallerMock = new CallerMock<>(dataObjectFormModelCreationService);
view = mock(DataObjectFormModelCreationView.class);
translationService = mock(TranslationService.class);
presenter = new DataObjectFormModelCreationPresenterManager(dataObjectFormModelCreationServiceCallerMock, view, translationService);
}
use of org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorService method createModelFormDefinition.
protected FormDefinition createModelFormDefinition(String modelType, GenerationContext<SOURCE> context) {
FormDefinition form = context.getContextForms().get(modelType);
if (form == null) {
String modelName = modelType.substring(modelType.lastIndexOf(".") + 1);
String formModelName = modelName;
formModelName = formModelName.substring(0, 1).toLowerCase() + formModelName.substring(1);
DataObjectFormModel formModel = new DataObjectFormModel(formModelName, modelType);
form = new FormDefinition(formModel);
context.getContextForms().put(modelType, form);
form.setId(UIDGenerator.generateUID());
form.setName(modelName);
// TODO: extract model properties & generate fields
List<FieldDefinition> fields = extractModelFields(formModel, context);
form.getFields().addAll(fields);
createFormLayout(form);
processFormDefinition(form, context);
}
return form;
}
use of org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method launchNestedFormTestWithGeneratedFormsValidation.
protected void launchNestedFormTestWithGeneratedFormsValidation() {
FormGenerationResult result = launchNestedFormsTest();
assertFalse(result.getNestedForms().isEmpty());
assertEquals(3, result.getNestedForms().size());
result.getNestedForms().forEach(form -> {
assertNotNull(form);
assertFalse(form.getFields().isEmpty());
assertTrue(form.getModel() instanceof DataObjectFormModel);
DataObjectFormModel nestedModel = (DataObjectFormModel) form.getModel();
String className = nestedModel.getType();
if (Expense.class.getName().equals(className)) {
testExpenseForm(form);
} else if (Client.class.getName().equals(className)) {
testClientForm(form);
} else if (Line.class.getName().equals(className)) {
testLineForm(form);
} else {
fail();
}
assertNotNull(form.getLayoutTemplate());
assertEquals(form.getFields().size(), form.getLayoutTemplate().getRows().size());
});
}
Aggregations