Package play.data.binding

Examples of play.data.binding.ParamNode


        NoSqlEntityManager em = NoSql.em();
        MetaLayer metaLayer = em.getMeta();
        if(!metaLayer.isManagedEntity(clazz))
          return null;
       
        ParamNode paramNode = rootParamNode.getChild(name, true);

        String keyFieldName = metaLayer.getKeyFieldName(clazz);
        ParamNode id = paramNode.getChild(keyFieldName);

        String idStr = NoSqlModel.retrieveValue(id);
        if(idStr == null)
          return NoSqlModel.create(rootParamNode, name, clazz, annotations);
View Full Code Here


    return ids[0];
  }
   
    @SuppressWarnings("rawtypes")
  public static <T> T edit(ParamNode rootParamNode, String name, T o, Annotation[] annotations) {
        ParamNode paramNode = rootParamNode.getChild(name, true);
        // #1195 - Needs to keep track of whick keys we remove so that we can restore it before
        // returning from this method.
        List<ParamNode.RemovedNode> removedNodesList = new ArrayList<ParamNode.RemovedNode>();
        try {
            // Start with relations
            Set<Field> fields = new HashSet<Field>();
            Class clazz = o.getClass();
            while (!clazz.equals(Object.class)) {
                Collections.addAll(fields, clazz.getDeclaredFields());
                clazz = clazz.getSuperclass();
            }
            for (Field field : fields) {
              processField(field, paramNode, removedNodesList, o);
            }
            ParamNode beanNode = rootParamNode.getChild(name, true);
            Binder.bindBean(beanNode, o, annotations);
            return (T) o;
        } catch (Exception e) {
            throw new UnexpectedException(e);
        } finally {
View Full Code Here

        }

        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);
View Full Code Here

        NoSqlEntityManager em = NoSql.em();
        MetaLayer metaLayer = em.getMeta();
        if(!metaLayer.isManagedEntity(clazz))
          return null;
       
        ParamNode paramNode = rootParamNode.getChild(name, true);

        String keyFieldName = metaLayer.getKeyFieldName(clazz);
        ParamNode id = paramNode.getChild(keyFieldName);

        String idStr = NoSqlModel.retrieveValue(id);
        if(idStr == null)
          return NoSqlModel.create(rootParamNode, name, clazz, annotations);
View Full Code Here

            // Try with id but set to null
            Params params = new Params();
            params.put("entity2.cities.id", (String) null);

            Validation.clear();
            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertFalse(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

            // Try to bind with other field
            Validation.clear();
            Params params = new Params();
            params.put("entity2.cities.a", city.name);

            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertTrue(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

            // Try to bind with other field
            Validation.clear();
            Params params = new Params();
            params.put("entity2.cities.id.1", city.getId().toString());

            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertTrue(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

            entity2.save();

            Params params = new Params();

            Validation.clear();
            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertFalse(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

            Params params = new Params();
            params.put("entity2", (String) null);

            Validation.clear();
            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertFalse(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

            params.put("entity2.city.name", "changeNameOfA");

            params.put("entity2.cities.id", city.getId().toString());

            Validation.clear();
            ParamNode rootParamNode = ParamNode.convert(params.all());
            entity2.edit(rootParamNode, "entity2");
            assertFalse(Validation.hasErrors());

            entity2.save();
            entity2.refresh();
View Full Code Here

TOP

Related Classes of play.data.binding.ParamNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.