boolean redefined = false;
if ("table".equals(key)) {
redefined = table != null;
table = getTable(value);
if (table == null) {
throw new JDOFatalUserException(I18N.msg("E_unknown_table", value));
}
} else if (ATTR_SOURCE.equals(key)) {
redefined = sourceStr != null;
sourceStr = value;
} else if (ATTR_TARGET.equals(key)) {
redefined = targetStr != null;
targetStr = value;
} else if (ATTR_ORDER_BY.equals(key)) {
redefined = relationship.getOrderBy() != null;
relationship.setOrderBy(value);
} else if (ATTR_INDEX.equals(key)) {
redefined = indexStr != null;
indexStr = value;
} else if (ATTR_FILTER.equals(key)) {
// Filtered collection query
redefined = filterStr != null;
filterStr = value;
} else if (ATTR_PARAMETERS.equals(key)) {
// Filtered collection query parameters
redefined = parametersStr != null;
parametersStr = value;
} else if (ATTR_VARIABLES.equals(key)) {
// Filtered collection query variables
redefined = variablesStr != null;
variablesStr = value;
} else if (ATTR_ORDERING.equals(key)) {
// JDO-style ordering
redefined = relationship.getOrdering() != null;
relationship.setOrdering(value);
} else if (ATTR_IMPORTS.equals(key)) {
redefined = importsStr != null;
importsStr = value;
}
if (redefined) {
throw new JDOFatalUserException(I18N.msg("E_collection_redefinition", key, field.getName(), jdoClass.getName()));
}
}
} // for each "extension" element
if (sourceStr == null && filterStr == null) {
if (useDefaultMapping) {
sourceStr = "source_" + ownerClass.getName();
} else {
// You have to specify either a source or a filter or both.
throw new JDOFatalUserException(I18N.msg("E_collection_no_source", field.getName(), jdoClass.getName()));
}
}
if (table == null) {
// The table wasn't explicitly specified. We can safely
// assume that if a collection is specified without an explicit
// table, then the table is the collection element type's table.
ClassMapping mapping = getClassMapping(elementClass);
if ((table = mapping.getTable()) == null) {
// Not much we can do about this. I don't think it will ever
// happen, but just in case...
throw new JDOFatalUserException(I18N.msg("E_collection_no_table", field.getName(), jdoClass.getName()));
}
logger.fine("No table specified for collection field \"" +
field.getName() +
"\"...assuming element type table: " +
table.getName());
}
if (relationship.getOrderBy() != null &&
relationship.getOrdering() != null) {
// Don't even bother trying to interpret precedence
throw new JDOFatalUserException(I18N.msg("E_collection_order_by_and_ordering"));
}
if (relationship.getOrdering() != null && filterStr == null) {
throw new JDOFatalUserException(I18N.msg("E_collection_ordering_without_filter", field.getName(), jdoClass.getName()));
}
if (sourceStr != null) {
source.setColumn(table.getColumnByName(sourceStr));
}