Search in sources :

Example 66 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormModelSynchronizationUtilImplTest method checkField.

private void checkField(ModelProperty property, Class<? extends FieldDefinition> expectedFieldClass) {
    FieldDefinition field = form.getFieldByBinding(property.getName());
    assertNotNull(field);
    assertEquals(expectedFieldClass, field.getClass());
    assertEquals(property.getTypeInfo(), field.getFieldTypeInfo());
}
Also used : 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) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)

Example 67 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormModelSynchronizationUtilImplTest method checkConflictedFieldDefinition.

public void checkConflictedFieldDefinition(TypeConflict conflict, Class<? extends FieldDefinition> expectedFieldClass) {
    FieldDefinition field = form.getFieldByBinding(conflict.getPropertyName());
    assertNotNull(field);
    assertEquals(conflict.getPropertyName(), field.getBinding());
    assertEquals(conflict.getNow().getClassName(), field.getStandaloneClassName());
    assertEquals(field.getClass(), expectedFieldClass);
}
Also used : 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) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)

Example 68 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormModelSynchronizationUtilImplTest method testRemoveModelProperties.

@Test
public void testRemoveModelProperties() {
    ModelProperty name = formModel.getProperty("name");
    assertNotNull(name);
    formModelSynchronizationResult.getRemovedProperties().add(name);
    ModelProperty surname = formModel.getProperty("surname");
    assertNotNull(surname);
    formModelSynchronizationResult.getRemovedProperties().add(surname);
    ModelProperty birthday = formModel.getProperty("birthday");
    assertNotNull(birthday);
    formModelSynchronizationResult.getRemovedProperties().add(birthday);
    synchronizationUtil.init(form, formModelSynchronizationResult);
    int originalFormFields = form.getFields().size();
    synchronizationUtil.fixRemovedFields();
    assertEquals(originalFormFields, form.getFields().size());
    assertNull(form.getFieldByBinding(name.getName()));
    assertNull(form.getFieldByBinding(surname.getName()));
    assertNull(form.getFieldByBinding(birthday.getName()));
    FieldDefinition field = form.getFieldByName(name.getName());
    assertNotNull(field);
    assertNull(field.getBinding());
    field = form.getFieldByName(surname.getName());
    assertNotNull(field);
    assertNull(field.getBinding());
    field = form.getFieldByName(birthday.getName());
    assertNotNull(field);
    assertNull(field.getBinding());
}
Also used : 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) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) Test(org.junit.Test)

Example 69 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class VFSSelectorFormProvider method getSelectorData.

@Override
public SelectorData getSelectorData(FormRenderingContext context) {
    Map<String, String> values = new TreeMap<>();
    if (context.getModel() instanceof EntityRelationField) {
        FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
        FieldDefinition field = (FieldDefinition) context.getModel();
        List<FormDefinition> forms;
        if (field != null) {
            forms = vfsFormFinderService.findFormsForType(field.getStandaloneClassName(), editorContext.getFormPath());
        } else {
            forms = vfsFormFinderService.findAllForms(editorContext.getFormPath());
        }
        for (FormDefinition form : forms) {
            values.put(form.getId(), form.getName());
        }
    }
    return new SelectorData(values, null);
}
Also used : EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TreeMap(java.util.TreeMap) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData)

Example 70 with FieldDefinition

use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorServiceImpl method constructContent.

@Override
protected FormModelerContent constructContent(Path path, Overview overview) {
    try {
        org.uberfire.java.nio.file.Path kiePath = Paths.convert(path);
        FormDefinition form = findForm(kiePath);
        FormModelerContent formModelConent = new FormModelerContent();
        formModelConent.setDefinition(form);
        formModelConent.setPath(path);
        formModelConent.setOverview(overview);
        FormEditorRenderingContext context = createRenderingContext(form, path);
        formModelConent.setRenderingContext(context);
        if (Optional.ofNullable(form.getModel()).isPresent()) {
            FormModel formModel = form.getModel();
            Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form, path);
            if (modelHandlerOptional.isPresent()) {
                FormModelHandler formModelHandler = modelHandlerOptional.get();
                FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel();
                formModel.getProperties().forEach(property -> {
                    Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName()));
                    if (!fieldOptional.isPresent()) {
                        synchronizationResult.resolveConflict(property.getName());
                    }
                });
                formModelConent.setSynchronizationResult(synchronizationResult);
            }
        }
        resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo));
        return formModelConent;
    } catch (Exception e) {
        log.warn("Error loading form " + path.toURI(), e);
    }
    return null;
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) ResourceOpenedEvent(org.uberfire.workbench.events.ResourceOpenedEvent) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) FormModel(org.kie.workbench.common.forms.model.FormModel) FormModelSynchronizationResult(org.kie.workbench.common.forms.editor.model.FormModelSynchronizationResult) FormModelHandler(org.kie.workbench.common.forms.editor.service.backend.FormModelHandler) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7