Search in sources :

Example 76 with FormDefinition

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

the class TestFormGenerator method getAddressForm.

public static FormDefinition getAddressForm() {
    FormDefinition form = new FormDefinition();
    form.setName("Address");
    form.setId("Address");
    TextBoxFieldDefinition name = new TextBoxFieldDefinition();
    name.setId(ADDRESS_STREET);
    name.setName(ADDRESS_STREET);
    name.setLabel("Street Name");
    name.setPlaceHolder("Street Name");
    name.setBinding(ADDRESS_STREET);
    name.setStandaloneClassName(String.class.getName());
    TextBoxFieldDefinition num = new TextBoxFieldDefinition();
    num.setId(ADDRESS_NUM);
    num.setName(ADDRESS_NUM);
    num.setLabel("#");
    num.setPlaceHolder("#");
    num.setBinding(ADDRESS_NUM);
    num.setStandaloneClassName(Integer.class.getName());
    form.getFields().add(name);
    form.getFields().add(num);
    form.setModel(generateModelFor(form));
    return form;
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 77 with FormDefinition

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

the class TestFormGenerator method getEmployeeForm.

public static FormDefinition getEmployeeForm() {
    FormDefinition form = new FormDefinition();
    form.setName("Employee");
    form.setId("Employee");
    TextBoxFieldDefinition name = new TextBoxFieldDefinition();
    name.setId(EMPLOYEE_NAME);
    name.setName(EMPLOYEE_NAME);
    name.setLabel("Name");
    name.setPlaceHolder("Name");
    name.setBinding(EMPLOYEE_NAME);
    name.setStandaloneClassName(String.class.getName());
    TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
    lastName.setId(EMPLOYEE_SURNAME);
    lastName.setName(EMPLOYEE_SURNAME);
    lastName.setLabel("Surname");
    lastName.setPlaceHolder("SurName");
    lastName.setBinding(EMPLOYEE_SURNAME);
    lastName.setStandaloneClassName(String.class.getName());
    DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
    birthday.setId(EMPLOYEE_BIRTHDAY);
    birthday.setName(EMPLOYEE_BIRTHDAY);
    birthday.setLabel("Birthday");
    birthday.setBinding(EMPLOYEE_BIRTHDAY);
    birthday.setStandaloneClassName(Date.class.getName());
    TextBoxFieldDefinition age = new TextBoxFieldDefinition();
    age.setId(EMPLOYEE_AGE);
    age.setName(EMPLOYEE_AGE);
    age.setLabel("Age");
    age.setPlaceHolder("Age");
    age.setBinding(EMPLOYEE_AGE_BINDING);
    age.setStandaloneClassName(Integer.class.getName());
    CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
    married.setId(EMPLOYEE_MARRIED);
    married.setName(EMPLOYEE_MARRIED);
    married.setLabel("Married");
    married.setBinding(EMPLOYEE_MARRIED);
    married.setStandaloneClassName(Boolean.class.getName());
    SubFormFieldDefinition address = new SubFormFieldDefinition();
    address.setId(EMPLOYEE_ADDRESS);
    address.setName(EMPLOYEE_ADDRESS);
    address.setLabel("Address");
    address.setBinding(EMPLOYEE_ADDRESS);
    address.setNestedForm("Address");
    address.setStandaloneClassName(Address.class.getName());
    form.getFields().add(name);
    form.getFields().add(lastName);
    form.getFields().add(birthday);
    form.getFields().add(age);
    form.getFields().add(married);
    form.getFields().add(address);
    form.setModel(generateModelFor(form));
    return form;
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) Address(org.kie.workbench.common.forms.dynamic.test.model.Address) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Date(java.util.Date)

Example 78 with FormDefinition

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

the class MultipleSubFormFieldValueProcessor method toFlatValue.

@Override
public List<Map<String, Object>> toFlatValue(MultipleSubFormFieldDefinition field, List rawValues, BackendFormRenderingContext context) {
    final FormDefinition creationForm = context.getRenderingContext().getAvailableForms().get(field.getCreationForm());
    final FormDefinition editionForm = context.getRenderingContext().getAvailableForms().get(field.getEditionForm());
    final List<Map<String, Object>> nestedRawValues = new ArrayList<>();
    if (rawValues != null) {
        rawValues.forEach(nestedValue -> {
            Map<String, Object> nestedRawValue = new HashMap<>();
            nestedRawValues.add(nestedRawValue);
            prepareNestedRawValues(nestedRawValue, creationForm, nestedValue);
            prepareNestedRawValues(nestedRawValue, editionForm, nestedValue);
        });
    }
    List<Map<String, Object>> nestedFormValues = new ArrayList<>();
    nestedRawValues.forEach(rawValue -> {
        Map<String, Object> formValue = processor.readFormValues(creationForm, rawValue, context);
        formValue.putAll(processor.readFormValues(editionForm, rawValue, context));
        formValue.put(MapModelRenderingContext.FORM_ENGINE_OBJECT_IDX, nestedFormValues.size());
        formValue.put(MapModelRenderingContext.FORM_ENGINE_EDITED_OBJECT, Boolean.FALSE);
        nestedFormValues.add(formValue);
    });
    return nestedFormValues;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Map(java.util.Map) HashMap(java.util.HashMap)

Example 79 with FormDefinition

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

the class SubFormFieldValueProcessor method toFlatValue.

@Override
public Map<String, Object> toFlatValue(SubFormFieldDefinition field, Object rawValue, BackendFormRenderingContext context) {
    FormDefinition nestedForm = context.getRenderingContext().getAvailableForms().get(field.getNestedForm());
    Map<String, Object> nestedRawValues = new HashMap<>();
    prepareNestedRawValues(nestedRawValues, nestedForm, rawValue);
    return processor.readFormValues(nestedForm, nestedRawValues, context);
}
Also used : HashMap(java.util.HashMap) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 80 with FormDefinition

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

the class SubFormFieldValueProcessor method toRawValue.

@Override
public Object toRawValue(SubFormFieldDefinition field, Map<String, Object> flatValue, Object originalValue, BackendFormRenderingContext context) {
    FormDefinition nestedForm = context.getRenderingContext().getAvailableForms().get(field.getNestedForm());
    Map<String, Object> nestedValues = processor.writeFormValues(nestedForm, flatValue, new HashMap<>(), context);
    return writeObjectValues(originalValue, nestedValues, field, context);
}
Also used : FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Aggregations

FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)89 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)30 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)16 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)14 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)14 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)13 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)12 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)12 AbstractFormGenerationTest (org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)10 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)10 List (java.util.List)9 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)8 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)8 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)8 Person (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person)7 FormModel (org.kie.workbench.common.forms.model.FormModel)7 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)7 Date (java.util.Date)6