Search in sources :

Example 1 with FieldMetadata

use of org.motechproject.mds.domain.FieldMetadata in project motech by motech.

the class FieldTestHelper method field.

public static Field field(String name, Class<?> typeClass, boolean required, boolean exposedViaRest, boolean autoGenerated) {
    Field field = field(name, name + " Display", typeClass);
    field.setRequired(required);
    field.setExposedViaRest(exposedViaRest);
    field.addMetadata(new FieldMetadata(field, Constants.Util.AUTO_GENERATED, String.valueOf(autoGenerated)));
    return field;
}
Also used : Field(org.motechproject.mds.domain.Field) FieldMetadata(org.motechproject.mds.domain.FieldMetadata)

Example 2 with FieldMetadata

use of org.motechproject.mds.domain.FieldMetadata in project motech by motech.

the class FieldHelper method addOrUpdateMetadataForCombobox.

public static void addOrUpdateMetadataForCombobox(Field field) {
    if (field.getType().isCombobox()) {
        FieldMetadata metadata = field.getMetadata(ENUM_CLASS_NAME);
        if (metadata == null) {
            metadata = new FieldMetadata(field, ENUM_CLASS_NAME);
            metadata.setValue(MemberUtil.getDefaultEnumName(field.getEntity().getClassName(), field.getName()));
            field.addMetadata(metadata);
        } else {
            field.setMetadataValue(ENUM_CLASS_NAME, MemberUtil.getDefaultEnumName(field.getEntity().getClassName(), field.getName()));
        }
    }
}
Also used : FieldMetadata(org.motechproject.mds.domain.FieldMetadata)

Example 3 with FieldMetadata

use of org.motechproject.mds.domain.FieldMetadata in project motech by motech.

the class FieldHelper method setMetadataForOneToManyRelationship.

private static void setMetadataForOneToManyRelationship(Field field) {
    setMetadataForOneToOneRelationship(field);
    if (field != null) {
        FieldMetadata metadata = new FieldMetadata(field, RELATIONSHIP_COLLECTION_TYPE);
        field.addMetadata(metadata);
    }
}
Also used : FieldMetadata(org.motechproject.mds.domain.FieldMetadata)

Example 4 with FieldMetadata

use of org.motechproject.mds.domain.FieldMetadata in project motech by motech.

the class FieldHelper method setMetadataForManyToManyRelationship.

public static void setMetadataForManyToManyRelationship(Field field, boolean isOwningSide) {
    setMetadataForOneToManyRelationship(field);
    if (field != null) {
        FieldMetadata metadata = new FieldMetadata(field, RELATED_FIELD);
        field.addMetadata(metadata);
        if (isOwningSide) {
            metadata = new FieldMetadata(field, OWNING_SIDE);
            metadata.setValue("true");
            field.addMetadata(metadata);
        }
    }
}
Also used : FieldMetadata(org.motechproject.mds.domain.FieldMetadata)

Example 5 with FieldMetadata

use of org.motechproject.mds.domain.FieldMetadata in project motech by motech.

the class FieldHelper method setMetadataForOneToOneRelationship.

private static void setMetadataForOneToOneRelationship(Field field) {
    if (field != null) {
        FieldMetadata metadata = new FieldMetadata(field, RELATED_CLASS);
        field.addMetadata(metadata);
    }
}
Also used : FieldMetadata(org.motechproject.mds.domain.FieldMetadata)

Aggregations

FieldMetadata (org.motechproject.mds.domain.FieldMetadata)10 Field (org.motechproject.mds.domain.Field)4 Type (org.motechproject.mds.domain.Type)3 FieldSetting (org.motechproject.mds.domain.FieldSetting)2 TypeSetting (org.motechproject.mds.domain.TypeSetting)2 HashSet (java.util.HashSet)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 EntityDraft (org.motechproject.mds.domain.EntityDraft)1 FieldValidation (org.motechproject.mds.domain.FieldValidation)1 Lookup (org.motechproject.mds.domain.Lookup)1 TypeValidation (org.motechproject.mds.domain.TypeValidation)1 DraftData (org.motechproject.mds.dto.DraftData)1 EntityDto (org.motechproject.mds.dto.EntityDto)1 FieldBasicDto (org.motechproject.mds.dto.FieldBasicDto)1 FieldDto (org.motechproject.mds.dto.FieldDto)1 FieldValidationDto (org.motechproject.mds.dto.FieldValidationDto)1 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)1 MetadataDto (org.motechproject.mds.dto.MetadataDto)1 SettingDto (org.motechproject.mds.dto.SettingDto)1