Search in sources :

Example 1 with EntityType

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

the class EntityMetadataBuilderImpl method fixEnhancerIssuesInMetadata.

@Override
public void fixEnhancerIssuesInMetadata(JDOMetadata jdoMetadata, SchemaHolder schemaHolder) {
    for (PackageMetadata pmd : jdoMetadata.getPackages()) {
        for (ClassMetadata cmd : pmd.getClasses()) {
            String className = String.format("%s.%s", pmd.getName(), cmd.getName());
            EntityType entityType = EntityType.forClassName(className);
            if (entityType == EntityType.STANDARD) {
                EntityDto entity = schemaHolder.getEntityByClassName(className);
                if (null != entity) {
                    for (MemberMetadata mmd : cmd.getMembers()) {
                        CollectionMetadata collMd = mmd.getCollectionMetadata();
                        FieldDto field = schemaHolder.getFieldByName(entity, mmd.getName());
                        if (null != collMd) {
                            fixCollectionMetadata(collMd, field);
                        }
                        if (null != field && field.getType().isRelationship()) {
                            fixRelationMetadata(pmd, entity, field);
                        }
                        // Defining column name for join and element results in setting it both as XML attribute and child element
                        fixDuplicateColumnDefinitions(mmd);
                    }
                }
            }
        }
    }
}
Also used : ClassMetadata(javax.jdo.metadata.ClassMetadata) EntityType(org.motechproject.mds.domain.EntityType) EntityDto(org.motechproject.mds.dto.EntityDto) CollectionMetadata(javax.jdo.metadata.CollectionMetadata) PackageMetadata(javax.jdo.metadata.PackageMetadata) MemberMetadata(javax.jdo.metadata.MemberMetadata) FieldDto(org.motechproject.mds.dto.FieldDto)

Aggregations

ClassMetadata (javax.jdo.metadata.ClassMetadata)1 CollectionMetadata (javax.jdo.metadata.CollectionMetadata)1 MemberMetadata (javax.jdo.metadata.MemberMetadata)1 PackageMetadata (javax.jdo.metadata.PackageMetadata)1 EntityType (org.motechproject.mds.domain.EntityType)1 EntityDto (org.motechproject.mds.dto.EntityDto)1 FieldDto (org.motechproject.mds.dto.FieldDto)1