}
}
private static void processField(Field field, ParamNode paramNode, List<RemovedNode> removedNodesList, Object o) {
NoSqlEntityManager em = NoSql.em();
MetaLayer meta = em.getMeta();
boolean isEntity = false;
Class<?> relation = null;
boolean multiple = false;
//
if (field.isAnnotationPresent(NoSqlOneToOne.class) || field.isAnnotationPresent(NoSqlManyToOne.class)) {
isEntity = true;
relation = field.getType();
} else if (field.isAnnotationPresent(NoSqlOneToMany.class) || field.isAnnotationPresent(NoSqlManyToMany.class)) {
ParameterizedType p = (ParameterizedType) field.getGenericType();
relation = (Class<?>) p.getActualTypeArguments()[0];
if(field.getType().equals(Map.class)) {
relation = (Class<?>) p.getActualTypeArguments()[1];
}
isEntity = true;
multiple = true;
}
if (!isEntity)
return;
ParamNode fieldParamNode = paramNode.getChild(field.getName(), true);
String keyName = meta.getKeyFieldName(relation);
if (multiple && Collection.class.isAssignableFrom(field.getType())) {
// Collection l = new ArrayList();
// if (SortedSet.class.isAssignableFrom(field.getType())) {
// l = new TreeSet();
// } else if (Set.class.isAssignableFrom(field.getType())) {
// l = new HashSet();
// }
log.trace("not implemented");
//NOTE: for now we skip this
return;
}
ParamNode idChild = fieldParamNode.getChild(keyName, true);
String theIdStr = retrieveValue(idChild);
if (theIdStr != null) {
Object theId = meta.convertIdFromString(relation, theIdStr);
Object to = em.find(relation, theId);
if(to != null) {
edit(paramNode, field.getName(), to, field.getAnnotations());
// Remove it to prevent us from finding it again later
paramNode.removeChild( field.getName(), removedNodesList);