Package org.beangle.model.entity.types

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


    EntityType type = Model.getEntityType(entityName);
    return populate(type.newInstance(), type.getEntityName(), EntityUtils.getCommandName(entityName));
  }

  public static Object populate(String entityName, String name) {
    EntityType type = Model.getEntityType(entityName);
    return populate(type.newInstance(), type.getEntityName(), name);
  }
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

  public static String getEntityName(Object obj) {
    return context.getEntityName(obj);
  }

  public static EntityType getEntityType(Class<?> clazz) {
    EntityType type = context.getEntityType(clazz);
    if (null == type) {
      type = new EntityType(clazz);
    }
    return type;
  }
View Full Code Here

      return populate(type.newInstance(), type.getName(), params);
    }
  }

  public Object populate(Class<?> entityClass, Map<String, Object> params) {
    EntityType entityType = Model.getEntityType(entityClass);
    return populate(entityType.newInstance(), entityType.getEntityName(), params);
  }
View Full Code Here

  private void loggerTypeInfo() {
    List<String> names = CollectUtils.newArrayList(entityTypes.keySet());
    Collections.sort(names);
    for (final String entityName : names) {
      EntityType entityType = (EntityType) entityTypes.get(entityName);
      logger.debug("entity:{}-->{}", entityType.getEntityName(), entityType.getEntityClass().getName());
      logger.debug("propertyType size:{}", Integer.valueOf(entityType.getPropertyTypes().size()));
    }
    names.clear();
    names.addAll(collectionTypes.keySet());
    Collections.sort(names);
    for (final String collectionName : names) {
View Full Code Here

      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

   *
   * @param entityName
   * @return
   */
  private EntityType buildEntityType(SessionFactory sessionFactory, String entityName) {
    EntityType entityType = (EntityType) entityTypes.get(entityName);
    if (null == entityType) {
      ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
      if (null == cm) {
        logger.error("Cannot find ClassMetadata for {}", entityName);
        return null;
      }
      entityType = new EntityType();
      entityType.setEntityName(cm.getEntityName());
      entityType.setIdPropertyName(cm.getIdentifierPropertyName());
      entityType.setEntityClass(cm.getMappedClass(EntityMode.POJO));
      entityTypes.put(cm.getEntityName(), entityType);

      Map<String, Type> propertyTypes = entityType.getPropertyTypes();
      String[] ps = cm.getPropertyNames();
      for (int i = 0; i < ps.length; i++) {
        org.hibernate.type.Type type = cm.getPropertyType(ps[i]);
        if (type.isEntityType()) {
          propertyTypes.put(ps[i], buildEntityType(sessionFactory, type.getName()));
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

      String role) {
    CollectionMetadata cm = sessionFactory.getCollectionMetadata(role);
    // FIXME buildCollectionType
    if (null == cm) { return null; }
    org.hibernate.type.Type type = cm.getElementType();
    EntityType elementType = null;
    if (type.isEntityType()) {
      elementType = (EntityType) entityTypes.get(type.getName());
      if (null == elementType) {
        elementType = buildEntityType(sessionFactory, type.getName());
      }
    } else {
      elementType = new EntityType(type.getReturnedClass());
    }

    CollectionType collectionType = new CollectionType();
    collectionType.setElementType(elementType);
    collectionType.setArray(cm.isArray());
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.