ParamNode.restoreRemovedChildren( removedNodesList );
}
}
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;
else if(multiple)
return; //we don't do multiple collections yet(like editing in a table)
ParamNode fieldParamNode = paramNode.getChild(field.getName(), true);
String keyName = meta.getKeyFieldName(relation);
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);
set(field, o, to);