Search in sources :

Example 31 with TypeInfoImpl

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

the class FieldManagerTest method testGetFieldByTypeInfo.

@Test
public void testGetFieldByTypeInfo() {
    for (Class clazz : basicTypesSupported) {
        TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
        checkFieldExists(typeInfo);
    }
    for (Class clazz : basicMultipleTypesSupported) {
        TypeInfo typeInfo = new TypeInfoImpl(TypeKind.BASE, clazz.getName(), true);
        checkFieldExists(typeInfo);
    }
    // check nested form
    checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), false));
    // check multiple subform
    checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), true));
}
Also used : TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TypeInfo(org.kie.workbench.common.forms.model.TypeInfo) Test(org.junit.Test)

Example 32 with TypeInfoImpl

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

the class ModelPropertiesGenerator method createModelProperty.

public static ModelProperty createModelProperty(String name, String className, boolean isMultiple, ClassLoader classLoader) {
    if (FormModelPropertiesUtil.isBaseType(className)) {
        // Dealing with basic type properties (String, Integer...)
        return new ModelPropertyImpl(name, new TypeInfoImpl(className, isMultiple));
    } else {
        // Dealing with complex types.
        if (FormModelPropertiesUtil.isListType(className)) {
            // If className is a List let's create a model for Object...
            return createModelProperty(name, Object.class.getName(), true);
        }
        try {
            Class clazz = classLoader.loadClass(className);
            TypeKind typeKind = clazz.isEnum() ? TypeKind.ENUM : TypeKind.OBJECT;
            return new ModelPropertyImpl(name, new TypeInfoImpl(typeKind, className, isMultiple));
        } catch (ClassNotFoundException e) {
            logger.warn("Unable to create property '" + name + "' for class '" + className + "':", e);
        }
    }
    return null;
}
Also used : TypeKind(org.kie.workbench.common.forms.model.TypeKind) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl)

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