logger.log(BasicLevel.WARN, sc.getSourceDescShort()
+ ": unknown type for element of collection for field ("
+ sf.name + ").");
return;
}
SpeedoClass scf = scp.smi.getSpeedoClass(t.getName());
if (scf != null) {
// This is en Entity class.
sf.relationType = SpeedoField.ONE_REFERENCE;
if (sf.type != null) { // defined at association definition time
if (! sf.type.equals(t.getName())) {
logger.log(BasicLevel.WARN, sc.getSourceDescShort()
+ ": type for field ("
+ sf.name + ") is different from the one defined in association - association type ignored.");
}
}
sf.type = Type.getDescriptor(t);
return;
}
if (isValidType(Type.getDescriptor(t), FIELDTYPES) || t.isEnum()) {
// This a basic valid type or an enum type. Nothing to do.
sf.type = Type.getDescriptor(t);
return;
}
// Verifies if it is a Collection or a Serializable type.
if (Set.class.isAssignableFrom(t)
|| List.class.isAssignableFrom(t)
|| Collection.class.isAssignableFrom(t)) {
// This is a valid type: a Set, List or Collection of Entity class.
sf.jdoTuple = new SpeedoCollection();
sf.jdoTuple.moField = sf;
if (t == gt) {
// No generic type defined.
if (sf.type == null) {
nbErrors++;
logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
+ ": unknown type for element of Set/List/Collection for field ("
+ sf.name + ").");
return;
}
((SpeedoCollection) sf.jdoTuple).elementType = sf.type;
sf.type = Type.getDescriptor(t);
return;
}
// The Java generic type is completely defined.
sf.relationType = SpeedoField.MANY_REFERENCE;
SpeedoClass escf = scp.smi.getSpeedoClass(((Class)((ParameterizedType) gt).getActualTypeArguments()[0]).getName());
if (escf == null) {
nbErrors++;
logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
+ ": element of collection should belong to an Entity class (found "
+ Type.getDescriptor((Class)((ParameterizedType) gt).getActualTypeArguments()[0])
+ ") for field (" + sf.name + ").");
return;
}
if (! sf.type.equals(escf.name)) {
logger.log(BasicLevel.WARN, sc.getSourceDescShort()
+ ": type for element of collection field ("
+ sf.name + ") is different from the one defined in association - association type ignored.");
}
((SpeedoCollection) sf.jdoTuple).elementType = ((Class)((ParameterizedType) gt).getActualTypeArguments()[0]).getName();
sf.type = Type.getDescriptor(t);
return;
}
if (Map.class.isAssignableFrom(t)) {
// This is a Map valid type.
sf.jdoTuple = new SpeedoMap();
sf.jdoTuple.moField = sf;
if (t == gt) {
logger.log(BasicLevel.WARN, sc.getSourceDescShort()
+ ": unknown type for element of Map for field ("
+ sf.name + ").");
return;
}
// The Java generic type is completely defined.
sf.relationType = SpeedoField.MANY_REFERENCE;
SpeedoClass escf = scp.smi.getSpeedoClass(((Class)((ParameterizedType) gt).getActualTypeArguments()[1]).getName());
if (escf == null) {
nbErrors++;
logger.log(BasicLevel.ERROR, sc.getSourceDescShort()
+ ": element of Map should belong to an Entity class (found "
+ Type.getDescriptor((Class)((ParameterizedType) gt).getActualTypeArguments()[1])