// Lets start rolling
// retVal.setUpdatable(valueTag.isUpdatable());
// TODO: Are we supporting hierarchaly generated files
// similar to PrimaryKeys ?
JavaMethod[] methods = javaClass.getMethods(true);
JavaMethod method;
for (int i = 0; i < methods.length; i++) {
method = methods[i];
if (log.isTraceEnabled()) {
// log.trace(method.getName() + " = " + method);
log.trace(method.getName() + " seeing if this is a value-object-field");
}
// Obtain extra method flags
int metaFlags = ejbUtils.getMethodMetadata(javaClass, method);
if (EjbUtils.hasFlag(metaFlags, EjbUtils.METADATA_METHOD_PRIMARY_KEY_FIELD) ||
EjbUtils.hasFlag(metaFlags, EjbUtils.METADATA_METHOD_PERSISTENCE_FIELD) ||
EjbUtils.hasFlag(metaFlags, EjbUtils.METADATA_METHOD_RELATION_FIELD)) {
if (log.isDebugEnabled()) {
log.debug(method.getName() +
" is candidate for checking. It's a persistence field, relation field or primary key field");
}
// Por aqui o resto das valida��es e l�gica
boolean isValueObjectField = isSelectedValueObjectField(valueTag.getMatch(), method);
// Primary key field must ALLWAYS be included ! (or then they must be checked if ....)
isValueObjectField = isValueObjectField ||
EjbUtils.hasFlag(metaFlags, EjbUtils.METADATA_METHOD_PRIMARY_KEY_FIELD);
if (isValueObjectField) {
EjbValueObjectFieldTag vTag = findMatchedTag(valueTag.getMatch(), method);
BeanProperty prop = javaClass.getBeanProperty(method.getPropertyName(), true);
if (log.isDebugEnabled()) {
log.debug(method.getName() + " is a value-object-field: matches or is a pk-field.");
}
// XXX: Todo, if we have a relation found by the RelationManager, then we must have
// it's treatment as such, or should be ignored
// Maybe just check if is a EjbUtils.METADATA_METHOD_RELATION_FIELD
Relation relation = getRelationManager().getRelationFor(method, javaClass);
if ((relation != null) ||
((vTag != null) && ((vTag.getAggregate() != null) || (vTag.getCompose() != null)))) {
// This is a value-object relation
// vTag must be non-null, because we need values from it
if ((vTag != null) && ((vTag.getAggregate() != null) ^ (vTag.getCompose() != null))) {
JavaClass relationEjb = null;
Type collectionType = null;
if (relation != null) {
if (!method.equals(relation.getLeftMethod())) {
log.debug(
"Current method doesn't match relations' left method. Reversing relation");
relation = relation.reverse();
if (log.isDebugEnabled()) {
log.debug("Reversed relation is relation=" + relation);
}
}
if (log.isDebugEnabled()) {
log.debug("Using relation information. relation=" + relation);
log.debug("1# Left bean=" +
((relation.getLeftBean() != null)
? relation.getLeftBean().getFullyQualifiedName() : null));
log.debug("1# Rigth bean=" +
((relation.getRightBean() != null)
? relation.getRightBean().getFullyQualifiedName() : null));
}
String relationEjbName = relation.getRightEJBName();
relationEjb = getBeanResolver().findEjbByName(relationEjbName);
collectionType = relation.getLeftMethod().getReturns();
} else {
log.debug("We don't have relation information for this method");
Type returnType = method.getReturns();
Type relationType = null;
if (returnType.isA(COLLECTION_TYPE) || returnType.isA(SET_TYPE)) {
String members = vTag.getMembers();