Search in sources :

Example 1 with DataObjectFormModel

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;
}
Also used : DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) ArrayList(java.util.ArrayList) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Example 2 with DataObjectFormModel

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;
}
Also used : DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Example 3 with DataObjectFormModel

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) DataObjectFormModelCreationService(org.kie.workbench.common.forms.data.modeller.service.DataObjectFormModelCreationService) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel) Before(org.junit.Before)

Example 4 with DataObjectFormModel

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;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Example 5 with DataObjectFormModel

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());
    });
}
Also used : Line(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) Expense(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Aggregations

DataObjectFormModel (org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)7 Expense (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense)2 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)2 ArrayList (java.util.ArrayList)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Before (org.junit.Before)1 DataObjectFormModelCreationService (org.kie.workbench.common.forms.data.modeller.service.DataObjectFormModelCreationService)1 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)1 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)1 Line (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line)1 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)1 FormModel (org.kie.workbench.common.forms.model.FormModel)1 DataModel (org.kie.workbench.common.services.datamodeller.core.DataModel)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Path (org.uberfire.backend.vfs.Path)1