Package org.beangle.model.entity.types

Examples of org.beangle.model.entity.types.EntityType


      return type;
    }
  }

  public String getEntityName(Object obj) {
    EntityType type = getEntityType(obj.getClass());
    if (null != type) {
      return type.getEntityName();
    } else {
      return null;
    }
  }
View Full Code Here


    }
  }

  public EntityType getEntityType(Class<?> entityClass) {
    String className = entityClass.getName();
    EntityType type = entityTypes.get(className);
    if (null != type) { return type; }

    type = classEntityTypes.get(className);
    if (null == type) {
      List<EntityType> matched = CollectUtils.newArrayList();
      for (EntityType entityType : entityTypes.values()) {
        if (className.equals(entityType.getEntityName())
            || className.equals(entityType.getEntityClass().getName())) {
          matched.add(entityType);
        }
      }
      if (matched.size() > 1) { throw new RuntimeException("multi-entityName for class:" + className); }
      if (matched.isEmpty()) {
        EntityType tmp = new EntityType(entityClass);
        classEntityTypes.put(className, tmp);
        return tmp;
      } else {
        classEntityTypes.put(className, matched.get(0));
        type = (EntityType) matched.get(0);
View Full Code Here

    }
    return type;
  }

  public EntityType getEntityType(String entityName) {
    EntityType type = entityTypes.get(entityName);
    if (null != type) { return type; }
    type = classEntityTypes.get(entityName);
    // last try by it's interface
    if (null == type) {
      try {
        // FIXME
        Class<?> entityClass = Class.forName(entityName);
        if (Entity.class.isAssignableFrom(entityClass)) {
          type = new EntityType(entityClass);
        } else {
          logger.warn("{} 's is not entity", entityClass);
        }
      } catch (ClassNotFoundException e) {
        logger.error("system doesn't contains entity {}", entityName);
View Full Code Here

   */
  public static List<Condition> extractConditions(Class<?> clazz, String prefix, String exclusiveAttrNames) {
    Object entity = null;
    try {
      if (clazz.isInterface()) {
        EntityType entityType = Model.getEntityType(clazz.getName());
        clazz = entityType.getEntityClass();
      }
      entity = clazz.newInstance();
    } catch (Exception e) {
      throw new RuntimeException("[RequestUtil.extractConditions]: error in in initialize " + clazz);
    }
View Full Code Here

    return entity;
  }

  @SuppressWarnings("unchecked")
  protected <T> T populateEntity(Class<T> entityClass, String shortName) {
    EntityType type = null;
    if (entityClass.isInterface()) {
      type = Model.getEntityType(entityClass.getName());
    } else {
      type = Model.getEntityType(entityClass);
    }
    return (T) populateEntity(type.getEntityName(), shortName);
  }
View Full Code Here

  protected Entity<?> getEntity(String entityName, String name) {
    Long entityId = getEntityId(name);
    Entity<?> entity = null;
    try {
      EntityType type = Model.getEntityType(entityName);
      if (null == entityId) {
        entity = (Entity<?>) populate(type.newInstance(), type.getEntityName(), name);
      } else {
        entity = getModel(entityName, entityId);
      }
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
View Full Code Here

    return entity;
  }

  @SuppressWarnings("unchecked")
  protected <T> T getEntity(Class<T> entityClass, String shortName) {
    EntityType type = null;
    if (entityClass.isInterface()) {
      type = Model.getEntityType(entityClass.getName());
    } else {
      type = Model.getEntityType(entityClass);
    }
    return (T) getEntity(type.getEntityName(), shortName);
  }
View Full Code Here

        clazz = Class.forName(field.getValueType());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
      }
      EntityType myType=Model.getEntityType(clazz);
      OqlBuilder<T> builder=OqlBuilder.from(myType.getEntityName(), "restrictField");
     
      String[] ids=StringUtils.split(text,",");
      PropertyDescriptor pd=BeanUtils.getPropertyDescriptor(clazz, field.getKeyName());
      Class<?> propertyType=pd.getReadMethod().getReturnType();
      List<Object> realIds=CollectUtils.newArrayList(ids.length);
View Full Code Here

TOP

Related Classes of org.beangle.model.entity.types.EntityType

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.