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);
}
}
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);
}
}
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));
}
}
Aggregations