Search in sources :

Example 1 with ElementMetadata

use of javax.jdo.metadata.ElementMetadata in project motech by motech.

the class EntityMetadataBuilderImpl method fixDuplicateColumnDefinitions.

private void fixDuplicateColumnDefinitions(MemberMetadata mmd) {
    JoinMetadata jmd = mmd.getJoinMetadata();
    ElementMetadata emd = mmd.getElementMetadata();
    if (jmd != null && ArrayUtils.isNotEmpty(jmd.getColumns()) && StringUtils.isNotEmpty(jmd.getColumn())) {
        jmd.setColumn(null);
    }
    if (emd != null && ArrayUtils.isNotEmpty(emd.getColumns()) && StringUtils.isNotEmpty(emd.getColumn())) {
        emd.setColumn(null);
    }
}
Also used : ElementMetadata(javax.jdo.metadata.ElementMetadata) JoinMetadata(javax.jdo.metadata.JoinMetadata)

Example 2 with ElementMetadata

use of javax.jdo.metadata.ElementMetadata in project motech by motech.

the class EntityMetadataBuilderImpl method processHistoryTrashRelationship.

private void processHistoryTrashRelationship(ClassMetadata cmd, FieldMetadata fmd, RelationshipHolder holder) {
    if (holder.isOneToOne() || holder.isManyToOne()) {
        fmd.setColumn(holder.getFieldName() + ID_SUFFIX);
    } else {
        fmd.setTable(cmd.getTable() + '_' + holder.getFieldName());
        CollectionMetadata collMd = fmd.newCollectionMetadata();
        collMd.setElementType(Long.class.getName());
        JoinMetadata joinMd = fmd.newJoinMetadata();
        ColumnMetadata joinColumnMd = joinMd.newColumnMetadata();
        joinColumnMd.setName(cmd.getName() + ID_SUFFIX);
        ElementMetadata elementMd = fmd.newElementMetadata();
        elementMd.setColumn(holder.getFieldName() + ID_SUFFIX);
    }
}
Also used : CollectionMetadata(javax.jdo.metadata.CollectionMetadata) ColumnMetadata(javax.jdo.metadata.ColumnMetadata) ElementMetadata(javax.jdo.metadata.ElementMetadata) JoinMetadata(javax.jdo.metadata.JoinMetadata)

Example 3 with ElementMetadata

use of javax.jdo.metadata.ElementMetadata in project motech by motech.

the class EntityMetadataBuilderImpl method setElementMetadata.

private void setElementMetadata(FieldMetadata fmd, Element element, RelationshipHolder holder, EntityDto entity) {
    if (element == null || StringUtils.isEmpty(element.column())) {
        ElementMetadata emd = fmd.newElementMetadata();
        emd.setColumn((ClassName.getSimpleName(holder.getRelatedClass()) + ID_SUFFIX).toUpperCase());
        ForeignKeyMetadata fkmd = emd.newForeignKeyMetadata();
        fkmd.setName(KeyNames.foreignKeyName(ClassName.getSimpleName(holder.getRelatedClass()), entity.getId(), holder.getRelatedField(), EntityType.STANDARD));
    }
}
Also used : ForeignKeyMetadata(javax.jdo.metadata.ForeignKeyMetadata) ElementMetadata(javax.jdo.metadata.ElementMetadata)

Aggregations

ElementMetadata (javax.jdo.metadata.ElementMetadata)3 JoinMetadata (javax.jdo.metadata.JoinMetadata)2 CollectionMetadata (javax.jdo.metadata.CollectionMetadata)1 ColumnMetadata (javax.jdo.metadata.ColumnMetadata)1 ForeignKeyMetadata (javax.jdo.metadata.ForeignKeyMetadata)1