Package org.beangle.model.entity

Examples of org.beangle.model.entity.Type


    Object propObj = target;
    Object property = null;

    int index = 0;
    String[] attrs = StringUtils.split(attr, ".");
    Type type = Model.getType(entityName);
    while (index < attrs.length) {
      try {
        property = PropertyUtils.getProperty(propObj, attrs[index]);
        Type propertyType = type.getPropertyType(attrs[index]);
        // 初始化
        if (null == propertyType) {
          logger.error("Cannot find property type [{}] of {}", attrs[index], propObj.getClass());
          throw new RuntimeException("Cannot find property type " + attrs[index] + " of "
              + propObj.getClass().getName());
        }
        if (null == property) {
          property = propertyType.newInstance();
          PropertyUtils.setProperty(propObj, attrs[index], property);
        }
        index++;
        propObj = property;
        type = propertyType;
View Full Code Here


  public Object populate(Object target, Map<String, Object> params) {
    return populate(target, Model.getEntityName(target), params);
  }

  public Object populate(String entityName, Map<String, Object> params) {
    Type type = Model.getType(entityName);
    if (null == type) {
      throw new RuntimeException(entityName + " was not configured!");
    } else {
      return populate(type.newInstance(), type.getName(), params);
    }
  }
View Full Code Here

  private ComponentType buildComponentType(SessionFactory sessionFactory, String entityName,
      String propertyName) {
    EntityType entityType = (EntityType) entityTypes.get(entityName);
    if (null != entityType) {
      Type propertyType = (Type) entityType.getPropertyTypes().get(propertyName);
      if (null != propertyType) { return (ComponentType) propertyType; }
    }

    ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
    org.hibernate.type.ComponentType hcType = (org.hibernate.type.ComponentType) cm
View Full Code Here

   *
   * @param params
   * @param entity
   */
  public Object populate(Object entity, String entityName, Map<String, Object> params) {
    Type type = Model.getType(entityName);
    for (final Map.Entry<String, Object> paramEntry : params.entrySet()) {
      String attr = paramEntry.getKey();
      Object value = paramEntry.getValue();
      if (value instanceof String) {
        if (StringUtils.isEmpty((String) value)) {
          value = null;
        } else if (TRIM_STR) {
          value = ((String) value).trim();
        }
      }
      // 主键
      if (null != type && type.isEntityType() && attr.equals(((EntityType) type).getIdPropertyName())) {
        if (ValidEntityKeyPredicate.INSTANCE.evaluate(value)) {
          setValue(attr, value, entity);
        } else {
          try {
            PropertyUtils.setProperty(entity, attr, null);
View Full Code Here

  public String[] getEntityNames(Class<?> clazz) {
    return new String[0];
  }

  public Type getType(String name) {
    Type type = getEntityType(name);
    if (null == type) {
      try {
        return new IdentifierType(Class.forName(name));
      } catch (ClassNotFoundException e) {
        logger.error("system doesn't contains entity {}", name);
View Full Code Here

  /**
   * Get the type of a particular (named) property
   */
  public Type getPropertyType(String propertyName) {
    Type type = (Type) propertyTypes.get(propertyName);
    if (null == type) {
      Method getMethod = MethodUtils.getAccessibleMethod(componentClass,
          "get" + StringUtils.capitalize(propertyName), (Class[]) null);
      if (null != getMethod) { return new IdentifierType(getMethod.getReturnType()); }
    }
View Full Code Here

  /**
   * Get the type of a particular (named) property
   */
  public Type getPropertyType(String property) {
    Type type = (Type) propertyTypes.get(property);
    if (null == type) {
      Class<?> propertyType = ReflectHelper.getProperty(entityClass, property);
      if (null != propertyType) {
        if (Entity.class.isAssignableFrom(propertyType)) {
          type = new EntityType(propertyType);
View Full Code Here

  private ComponentType buildComponentType(SessionFactory sessionFactory, String entityName,
      String propertyName) {
    EntityType entityType = (EntityType) entityTypes.get(entityName);
    if (null != entityType) {
      Type propertyType = (Type) entityType.getPropertyTypes().get(propertyName);
      if (null != propertyType) { return (ComponentType) propertyType; }
    }

    ClassMetadata cm = sessionFactory.getClassMetadata(entityName);
    org.hibernate.type.ComponentType hcType = (org.hibernate.type.ComponentType) cm
View Full Code Here

  public String[] getEntityNames(Class<?> clazz) {
    return new String[0];
  }

  public Type getType(String name) {
    Type type = getEntityType(name);
    if (null == type) {
      try {
        return new IdentifierType(Class.forName(name));
      } catch (ClassNotFoundException e) {
        logger.error("system doesn't contains entity {}", name);
View Full Code Here

    Object propObj = target;
    Object property = null;

    int index = 0;
    String[] attrs = StringUtils.split(attr, ".");
    Type type = Model.getType(entityName);
    while (index < attrs.length) {
      try {
        property = PropertyUtils.getProperty(propObj, attrs[index]);
        Type propertyType = type.getPropertyType(attrs[index]);
        // 初始化
        if (null == propertyType) {
          logger.error("Cannot find property type [{}] of {}", attrs[index], propObj
              .getClass());
          throw new RuntimeException("Cannot find property type " + attrs[index] + " of "
              + propObj.getClass().getName());
        }
        if (null == property) {
          property = propertyType.newInstance();
          PropertyUtils.setProperty(propObj, attrs[index], property);
        }
        index++;
        propObj = property;
        type = propertyType;
View Full Code Here

TOP

Related Classes of org.beangle.model.entity.Type

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.