Search in sources :

Example 26 with TypeInfoImpl

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

the class SimpleFieldTypesBackendFormRenderingContextManagerTest method getRootForm.

@Override
protected FormDefinition getRootForm() {
    FormDefinition form = new FormDefinition();
    FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName(STRING_FIELD);
    field.setBinding(STRING_FIELD);
    form.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Integer.class.getName()));
    field.setName(INTEGER_FIELD);
    field.setBinding(INTEGER_FIELD);
    form.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
    field.setName(DATE_FIELD);
    field.setBinding(DATE_FIELD);
    form.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Boolean.class.getName()));
    field.setName(BOOLEAN_FIELD);
    field.setBinding(BOOLEAN_FIELD);
    form.getFields().add(field);
    field = fieldManager.getDefinitionByFieldType(new MultipleInputFieldType());
    field.setName(MULTIPLE_INPUT_FIELD);
    field.setBinding(MULTIPLE_INPUT_FIELD);
    form.getFields().add(field);
    field = fieldManager.getDefinitionByFieldType(new MultipleSelectorFieldType());
    field.setName(MULTIPLE_SELECTOR_FIELD);
    field.setBinding(MULTIPLE_SELECTOR_FIELD);
    form.getFields().add(field);
    return form;
}
Also used : MultipleInputFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.lists.input.MultipleInputFieldType) MultipleSelectorFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.lists.selector.MultipleSelectorFieldType) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Date(java.util.Date)

Example 27 with TypeInfoImpl

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

the class MultipleSubformBackendFormRenderingContextManagerTest method getRootForm.

@Override
protected FormDefinition getRootForm() {
    FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
    form.setId("form");
    FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), true));
    field.setName("persons");
    field.setBinding("persons");
    MultipleSubFormFieldDefinition multpleSubForm = (MultipleSubFormFieldDefinition) field;
    multpleSubForm.setCreationForm("person-creation");
    multpleSubForm.setEditionForm("person-edition");
    form.getFields().add(field);
    return form;
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)

Example 28 with TypeInfoImpl

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

the class ProcessableModelBackendFormRenderingContextManagerTest method getFormDefinition.

private FormDefinition getFormDefinition(final String id, final boolean appendNested) {
    final FormDefinition formDefinition = new FormDefinition(new PortableJavaModel(ProcessableModel.class.getName()));
    formDefinition.setId(id);
    appendFieldDefinition(new ModelPropertyImpl(BIG_DECIMAL, new TypeInfoImpl(BigDecimal.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(BIG_INTEGER, new TypeInfoImpl(BigInteger.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(A_FLOAT, new TypeInfoImpl(Float.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(LOCAL_DATE, new TypeInfoImpl(LocalDate.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(LOCAL_DATE_TIME, new TypeInfoImpl(LocalDateTime.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(LOCAL_TIME, new TypeInfoImpl(LocalTime.class.getName())), formDefinition);
    appendFieldDefinition(new ModelPropertyImpl(OFFSET_DATE_TIME, new TypeInfoImpl(OffsetDateTime.class.getName())), formDefinition);
    if (appendNested) {
        appendFieldDefinition(new ModelPropertyImpl(CHILD, new TypeInfoImpl(TypeKind.OBJECT, ProcessableModel.class.getName(), false)), formDefinition);
        ((SubFormFieldDefinition) formDefinition.getFieldByBinding(CHILD)).setNestedForm(NESTED_FORM_ID);
        appendFieldDefinition(new ModelPropertyImpl(CHILDREN, new TypeInfoImpl(TypeKind.OBJECT, ProcessableModel.class.getName(), true)), formDefinition);
        ((MultipleSubFormFieldDefinition) formDefinition.getFieldByBinding(CHILDREN)).setCreationForm(NESTED_FORM_ID);
        ((MultipleSubFormFieldDefinition) formDefinition.getFieldByBinding(CHILDREN)).setEditionForm(NESTED_FORM_ID);
    }
    return formDefinition;
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) OffsetDateTime(java.time.OffsetDateTime) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) BigInteger(java.math.BigInteger) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) ProcessableModel(org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.ProcessableModel)

Example 29 with TypeInfoImpl

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

the class FormEditorHelperTest method initFields.

private void initFields() {
    TextBoxFieldDefinition name = new TextBoxFieldDefinition();
    name.setId("name");
    name.setName("name");
    name.setLabel("Name");
    name.setPlaceHolder("Name");
    name.setBinding("name");
    name.setStandaloneClassName(String.class.getName());
    nameField = name;
    TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
    lastName.setId("lastName");
    lastName.setName("lastName");
    lastName.setLabel("Last Name");
    lastName.setPlaceHolder("Last Name");
    lastName.setBinding("lastName");
    lastName.setStandaloneClassName(String.class.getName());
    lastNameField = lastName;
    DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
    birthday.setId("birthday");
    birthday.setName("birthday");
    birthday.setLabel("Birthday");
    birthday.setBinding("birthday");
    birthday.setStandaloneClassName(Date.class.getName());
    CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
    married.setId("married");
    married.setName("married");
    married.setLabel("Married");
    married.setBinding("married");
    married.setStandaloneClassName(Boolean.class.getName());
    marriedField = married;
    IntegerBoxFieldDefinition age = new IntegerBoxFieldDefinition();
    age.setId("age");
    age.setName("age");
    age.setLabel("Age");
    age.setBinding("age");
    ageField = age;
    DecimalBoxFieldDefinition weight = new DecimalBoxFieldDefinition();
    weight.setId("weight");
    weight.setName("weight");
    weight.setLabel("Weight");
    weight.setBinding("weight");
    weightField = weight;
    employeeFields = new ArrayList<>();
    employeeFields.add(name);
    employeeFields.add(lastName);
    employeeFields.add(birthday);
    employeeFields.add(married);
    employeeFields.add(age);
    employeeFields.add(weight);
    modelProperties = new ArrayList<>();
    employeeFields.forEach(fieldDefinition -> modelProperties.add(new ModelPropertyImpl(fieldDefinition.getBinding(), new TypeInfoImpl(fieldDefinition.getStandaloneClassName()))));
}
Also used : 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) Mockito.anyString(org.mockito.Mockito.anyString) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Date(java.util.Date) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) DecimalBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)

Example 30 with TypeInfoImpl

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

the class FieldManagerTest method testCompatiblefields.

protected void testCompatiblefields(boolean addFieldType) {
    for (Class clazz : basicTypesSupported) {
        TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
        FieldDefinition fieldDefinition = fieldManager.getDefinitionByDataType(typeInfo);
        Assertions.assertThat(fieldDefinition).isNotNull();
        if (addFieldType) {
            fieldDefinition.setStandaloneClassName(typeInfo.getClassName());
        }
        Collection<String> compatibles = fieldManager.getCompatibleFields(fieldDefinition);
        Assertions.assertThat(compatibles).isNotNull().isNotEmpty();
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo)

Aggregations

TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)32 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)19 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)17 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)17 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)15 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)10 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)8 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)8 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)8 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)7 Date (java.util.Date)6 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)6 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)6 TypeInfo (org.kie.workbench.common.forms.model.TypeInfo)6 Person (org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person)4 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)4 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)4 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)4 BasicTypeFieldProvider (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)3