use of javax.jdo.metadata.ColumnMetadata 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.ColumnMetadata in project motech by motech.
the class EntityMetadataBuilderImpl method addColumnMetadata.
private void addColumnMetadata(FieldMetadata fmd, FieldDto field, Value valueAnnotation) {
SettingDto maxLengthSetting = field.getSetting(Constants.Settings.STRING_MAX_LENGTH);
ColumnMetadata colMd = fmd.newColumnMetadata();
// text(clob) fields don't have length
if (maxLengthSetting != null && !isClob(field)) {
colMd.setLength(Integer.parseInt(maxLengthSetting.getValueAsString()));
}
// if TextArea then change length
if (field.getSetting(Constants.Settings.STRING_TEXT_AREA) != null && "true".equalsIgnoreCase(field.getSetting(Constants.Settings.STRING_TEXT_AREA).getValueAsString())) {
fmd.setIndexed(false);
colMd.setSQLType("CLOB");
}
if (field.getMetadata(DATABASE_COLUMN_NAME) != null) {
colMd.setName(field.getMetadata(DATABASE_COLUMN_NAME).getValue());
}
if (valueAnnotation != null) {
copyParametersFromValueAnnotation(fmd, valueAnnotation);
}
}
use of javax.jdo.metadata.ColumnMetadata in project motech by motech.
the class EntityMetadataBuilderImpl method copyParametersFromValueAnnotation.
private void copyParametersFromValueAnnotation(FieldMetadata fmd, Value valueAnnotation) {
ValueMetadata valueMetadata = fmd.newValueMetadata();
for (Column column : valueAnnotation.columns()) {
ColumnMetadata colMd = valueMetadata.newColumnMetadata();
colMd.setName(column.name());
colMd.setLength(column.length());
colMd.setAllowsNull(Boolean.parseBoolean(column.allowsNull()));
colMd.setDefaultValue(column.defaultValue());
colMd.setInsertValue(column.insertValue());
colMd.setJDBCType(column.jdbcType());
colMd.setSQLType(column.sqlType());
}
}
Aggregations