Package com.adaptrex.core.ext

Examples of com.adaptrex.core.ext.ModelInstance


    try {
      ObjectContext objectContext = getObjectContext();
      Class<?> clazz = extConfig.getEntityClass();
      Object entity = objectContext.newObject(clazz);
      this.updateEntity(objectContext, clazz, entity, data);
      return new ModelInstance(extConfig, entity);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here


    Class<?> clazz = extConfig.getEntityClass();
    Object entity = id != null
        ? this.getEntity(objectContext, clazz, id)
        : this.getEntity(objectContext, clazz, key, value);
    this.updateEntity(objectContext, clazz, entity, data);
    return new ModelInstance(extConfig, entity);
  }
View Full Code Here

    ObjectContext objectContext = getObjectContext();
    Class<?> clazz = extConfig.getEntityClass();
    Object entity = id != null
        ? this.getEntity(objectContext, clazz, id)
        : this.getEntity(objectContext, clazz, key, value);
    ModelInstance model = new ModelInstance(extConfig, entity);
    objectContext.deleteObjects(entity);
    objectContext.commitChanges();
    return model;
  }
View Full Code Here

       */
      TypedQuery<?> typedQuery = em.createQuery(query);
      if (this.getLimit() != null) typedQuery.setMaxResults(this.getLimit());
      if (this.getStart() != null) typedQuery.setFirstResult(this.getStart());
      for (Object entity : typedQuery.getResultList()) {
        data.add(new ModelInstance(extConfig, entity).getData());
      }

     
      /*
       * Create a CriteriaQuery used to get the total count of records in the resultset
View Full Code Here

    }   
   
    if (this.getLimit() != null) query.setMaxResults(this.getLimit());
    if (this.getStart() != null) query.setFirstResult(this.getStart().intValue());
    for (Object entity : query.getResultList()) {
      data.add(new ModelInstance(extConfig, entity).getData());
    }
   
    /*
     * Get the initial list before applying limits
     */
 
View Full Code Here

  @Override
  public ModelInstance getModelInstance(ExtConfig extConfig, Object id) {
    EntityManager em = getEntityManager();
    try {
      Object entity = this.getEntity(em, extConfig.getEntityClass(), id);
      return new ModelInstance(extConfig, entity);
    } catch (Exception e) {} finally {
      closeEM(em);
    }
    return null;
  }
View Full Code Here

  @Override
  public ModelInstance getModelInstance(ExtConfig extConfig, String key, Object value) {
    EntityManager em = getEntityManager();
    try {
      Object entity = this.getEntity(em, extConfig.getEntityClass(), key, value);
      return new ModelInstance(extConfig, entity);
    } catch (Exception e) {} finally {
      closeEM(em);
    }
    return null;
  }
View Full Code Here

    EntityTransaction tx = em.getTransaction();
    try {
      tx.begin();
      Class<?> clazz = extConfig.getEntityClass();
      Object entity = id != null ? this.getEntity(em, clazz, id) : this.getEntity(em, clazz, key, value);
      ModelInstance model = new ModelInstance(extConfig, entity);
      this.evictAssociated(em, entity);
      em.remove(em.merge(entity));
      tx.commit();
      return model;
    } catch (Exception e) {
View Full Code Here

 

  @Override
  public ModelInstance getModelInstance(ExtConfig extConfig, Object id) throws Exception {
    Object entity = this.getEntity(extConfig.getEntityClass(), id);
    return new ModelInstance(extConfig, entity);
  }
View Full Code Here

  }

  @Override
  public ModelInstance getModelInstance(ExtConfig extConfig, String key, Object value) throws Exception {
    Object entity = this.getEntity(extConfig.getEntityClass(), key, value);
    return new ModelInstance(extConfig, entity);
  }
View Full Code Here

TOP

Related Classes of com.adaptrex.core.ext.ModelInstance

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.