Package com.alvazan.orm.api.base

Examples of com.alvazan.orm.api.base.MetaLayer


 
    @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
    public Object bind(RootParamNode rootParamNode, String name, Class clazz, java.lang.reflect.Type type, Annotation[] annotations) {
        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);

        Object theId = metaLayer.convertIdFromString(clazz, idStr);
       
        //Read the entity in so that this entity is used instead...
      Object o = em.find(clazz, theId);
      if(o == null)
        throw new RowNotFoundException("Row with rowkey="+theId+" was not found, but your page posted this id to lookup the row of class type="+clazz.getSimpleName());
View Full Code Here


    }

  @Override
    public Object bindBean(RootParamNode rootParamNode, String name, Object bean) {
      NoSqlEntityManager mgr = NoSql.em();
      MetaLayer meta = mgr.getMeta();
      if(meta.isManagedEntity(bean.getClass())) {
            return NoSqlModel.edit(rootParamNode, name, bean, null);
        }
        return null;
    }
View Full Code Here

 
    @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
    public Object bind(RootParamNode rootParamNode, String name, Class clazz, java.lang.reflect.Type type, Annotation[] annotations) {
        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);

        Object theId = metaLayer.convertIdFromString(clazz, idStr);
       
        //Read the entity in so that this entity is used instead...
      Object o = em.find(clazz, theId);
     
      return NoSqlModel.edit(rootParamNode, name, o, annotations);
View Full Code Here

    }

  @Override
    public Object bindBean(RootParamNode rootParamNode, String name, Object bean) {
      NoSqlEntityManager mgr = NoSql.em();
      MetaLayer meta = mgr.getMeta();
      if(meta.isManagedEntity(bean.getClass())) {
            return NoSqlModel.edit(rootParamNode, name, bean, null);
        }
        return null;
    }
View Full Code Here

        }
    }

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

  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
    public Object bind(RootParamNode rootParamNode, String name, Class clazz, java.lang.reflect.Type type, Annotation[] annotations) {
        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);

        Object theId = metaLayer.convertIdFromString(clazz, idStr);
       
        //Read the entity in so that this entity is used instead...
      Object o = em.find(clazz, theId);
      if(o == null)
        throw new RowNotFoundException("Row with rowkey="+theId+" was not found, but your page posted this id to lookup the row of class type="+clazz.getSimpleName());
View Full Code Here

    }

  @Override
    public Object bindBean(RootParamNode rootParamNode, String name, Object bean) {
      NoSqlEntityManager mgr = NoSql.em();
      MetaLayer meta = mgr.getMeta();
      if(meta.isManagedEntity(bean.getClass())) {
            return NoSqlModel.edit(rootParamNode, name, bean, null);
        }
        return null;
    }
View Full Code Here

 
    @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
    public Object bind(RootParamNode rootParamNode, String name, Class clazz, java.lang.reflect.Type type, Annotation[] annotations) {
        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);

        Object theId = metaLayer.convertIdFromString(clazz, idStr);
       
        //Read the entity in so that this entity is used instead...
      Object o = em.find(clazz, theId);
      if(o == null)
        throw new RowNotFoundException("Row with rowkey="+theId+" was not found, but your page posted this id to lookup the row of class type="+clazz.getSimpleName());
View Full Code Here

    }

  @Override
    public Object bindBean(RootParamNode rootParamNode, String name, Object bean) {
      NoSqlEntityManager mgr = NoSql.em();
      MetaLayer meta = mgr.getMeta();
      if(meta.isManagedEntity(bean.getClass())) {
            return NoSqlModel.edit(rootParamNode, name, bean, null);
        }
        return null;
    }
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Override
    public Object bind(RootParamNode rootParamNode, String name, Class clazz, java.lang.reflect.Type type, Annotation[] annotations) {
        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);

        Object theId = metaLayer.convertIdFromString(clazz, idStr);
       
        //Read the entity in so that this entity is used instead...
      Object o = em.find(clazz, theId);
      if(o == null)
        throw new RowNotFoundException("Row with rowkey="+theId+" was not found, but your page posted this id to lookup the row of class type="+clazz.getSimpleName());
View Full Code Here

TOP

Related Classes of com.alvazan.orm.api.base.MetaLayer

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.