Package com.adaptrex.core.ext

Examples of com.adaptrex.core.ext.FieldDefinition


     
      /*
       * Identify id field
       */
      if (orm.isIdField(clazz, fieldName)) {
        this.fields.add(new FieldDefinition(field, config));
        this.idProperty = fieldName;
        continue;
      }
     
     
      /*
       * Create the field names for association id fields
       */
      String extFieldName = field.getName();
      if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName)) {
        extFieldName = Inflector.getInstance().singularize(fieldName) + "Ids";
      } else if (orm.isManyToOne(clazz, fieldName)) {
        extFieldName = fieldName + "Id";
      }
     
     
      /*
       * Is this field included or excluded?
       */
      if (isRoot) {
        if (includes.size() > 0
            && (!includes.contains("*") && !includes.contains(extFieldName))) {
          continue;
        }
        if (excludes.contains("*") || excludes.contains(extFieldName)) {
          continue;
        }

      } else {
        if (includes.size() > 0) {
          if (entityClassIncludes.isEmpty()
              || (!entityClassIncludes.contains("*") && !entityClassIncludes.contains(extFieldName))) {
            continue;
          }
        }

        if (excludes.size() > 0) {
          if (entityClassExcludes.contains("*") || entityClassExcludes.contains(extFieldName)) {
            continue;
          }
        }
      }
     
     
      /*
       * If we have a one to many association, add a field to hold an array
       * of ID's for that association
       */
      if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName) || orm.isManyToOne(clazz, fieldName)) {
        this.fields.add(new FieldDefinition(extFieldName, "auto"));
      } else {
        this.fields.add(new FieldDefinition(field, config));
      }
    }
  }
View Full Code Here


  public JPACollectionType(PluralAttribute<?,?,?> collection, SecureEntity secureEntity) {
    super(collection.getName(), collection.getJavaType(), collection.getElementType().getJavaType(), secureEntity);
   
    String relName = StringUtilities.singularize(collection.getName());
    this.idsFieldDefinition =
        new FieldDefinition(
            relName + StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
            ExtTypeFormatter.AUTO
          );
   
    String capName = StringUtilities.capitalize(getName());
View Full Code Here

 
  public JPAAssociationType(SingularAttribute<?,?> association, SecureEntity secureEntity) {
    super(association.getName(), association.getJavaType(), secureEntity);
    String associationName = association.getName();
    this.idFieldDefinition =
        new FieldDefinition(
            associationName + StringUtils.capitalize(AdaptrexEntityType.ENTITY_ID_NAME),
            ExtTypeFormatter.AUTO);
   
    String capName = StringUtilities.capitalize(getName());
   
View Full Code Here

          StringUtilities.uncapitalize(relEntityName)
        );
      this.name = relName;
      this.itemType = dataMap.getObjEntity(relEntityName).getJavaClass();
      this.idsFieldDefinition =
          new FieldDefinition(
              StringUtilities.uncapitalize(relEntityName) +
                StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
              ExtTypeFormatter.AUTO
            );
     
      /*
       * Get the methods to grab the join table and target table
       */
      try {
        joinGetter = declaringClass.getMethod(
            "get" + StringUtilities.pluralize(joinTable.getSimpleName()));
        targetGetter = joinTable.getMethod("get" + this.itemType.getSimpleName());
       
        primarySetter = joinTable.getMethod("set" + declaringClass.getSimpleName(), declaringClass);
        targetSetter = joinTable.getMethod("set" + this.itemType.getSimpleName(), this.itemType);
      } catch (Exception e) {}
     
     
     
     
    }
   
   
    /*
     * Flattened association
     */
    else {
      String relName = StringUtilities.singularize(relationship.getName());
      this.idsFieldDefinition =
          new FieldDefinition(
              relName + StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
              ExtTypeFormatter.AUTO
            );
     
      String capName = StringUtilities.capitalize(getName());
View Full Code Here

  private Method setter;
 
  public CayenneAssociationType(ObjEntity objEntity, ObjRelationship relationship, Class<?> associationType, SecureEntity secureEntity) {
    super(relationship.getName(), associationType, secureEntity);
    this.idFieldDefinition =
        new FieldDefinition(
            relationship.getName() + StringUtils.capitalize(AdaptrexEntityType.ENTITY_ID_NAME),
            ExtTypeFormatter.STRING
          );
   
    String capName = StringUtilities.capitalize(getName());
View Full Code Here

     
      /*
       * Identify id field
       */
      if (orm.isIdField(clazz, fieldName)) {
        this.fields.add(new FieldDefinition(field, config));
        this.idProperty = fieldName;
        continue;
      }
     
     
      /*
       * Create the field names for association id fields
       */
      String extFieldName = field.getName();
      if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName)) {
        extFieldName = Inflector.getInstance().singularize(fieldName) + "Ids";
      } else if (orm.isManyToOne(clazz, fieldName)) {
        extFieldName = fieldName + "Id";
      }
     
     
      /*
       * Is this field included or excluded?
       */
      if (isRoot) {
        if (includes.size() > 0
            && (!includes.contains("*") && !includes.contains(extFieldName))) {
          continue;
        }
        if (excludes.contains("*") || excludes.contains(extFieldName)) {
          continue;
        }

      } else {
        if (includes.size() > 0) {
          if (entityClassIncludes.isEmpty()
              || (!entityClassIncludes.contains("*") && !entityClassIncludes.contains(extFieldName))) {
            continue;
          }
        }

        if (excludes.size() > 0) {
          if (entityClassExcludes.contains("*") || entityClassExcludes.contains(extFieldName)) {
            continue;
          }
        }
      }
     
     
      /*
       * If we have a one to many association, add a field to hold an array
       * of ID's for that association
       */
      if (orm.isOneToMany(clazz, fieldName) || orm.isManyToMany(clazz, fieldName) || orm.isManyToOne(clazz, fieldName)) {
        this.fields.add(new FieldDefinition(extFieldName, "auto"));
      } else {
        this.fields.add(new FieldDefinition(field, config));
      }
    }
  }
View Full Code Here

    if (secureEntity != null) {
      this.secureField = secureEntity.getField(name);
    }
   
    this.fieldDefinition =
        new FieldDefinition(name, ExtTypeFormatter.getType(fieldType));
   
    log.info("Initializing: " + name + " (" +
        this.fieldType.getSimpleName() + ")"
        );
  }
View Full Code Here

  private Method setter;
 
  public CayenneAssociationType(ObjEntity objEntity, ObjRelationship relationship, Class<?> associationType, SecureEntity secureEntity) {
    super(relationship.getName(), associationType, secureEntity);
    this.idFieldDefinition =
        new FieldDefinition(
            relationship.getName() + StringUtils.capitalize(AdaptrexEntityType.ENTITY_ID_NAME),
            ExtTypeFormatter.STRING
          );
   
    String capName = StringUtilities.capitalize(getName());
View Full Code Here

          StringUtilities.uncapitalize(relEntityName)
        );
      this.name = relName;
      this.itemType = dataMap.getObjEntity(relEntityName).getJavaClass();
      this.idsFieldDefinition =
          new FieldDefinition(
              StringUtilities.uncapitalize(relEntityName) +
                StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
              ExtTypeFormatter.AUTO
            );
     
      /*
       * Get the methods to grab the join table and target table
       */
      try {
        joinGetter = declaringClass.getMethod(
            "get" + StringUtilities.pluralize(joinTable.getSimpleName()));
        targetGetter = joinTable.getMethod("get" + this.itemType.getSimpleName());
       
        primarySetter = joinTable.getMethod("set" + declaringClass.getSimpleName(), declaringClass);
        targetSetter = joinTable.getMethod("set" + this.itemType.getSimpleName(), this.itemType);
      } catch (Exception e) {}
     
     
     
     
    }
   
   
    /*
     * Flattened association
     */
    else {
      String relName = StringUtilities.singularize(relationship.getName());
      this.idsFieldDefinition =
          new FieldDefinition(
              relName + StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
              ExtTypeFormatter.AUTO
            );
     
      String capName = StringUtilities.capitalize(getName());
View Full Code Here

  public JPACollectionType(PluralAttribute<?,?,?> collection, SecureEntity secureEntity) {
    super(collection.getName(), collection.getJavaType(), collection.getElementType().getJavaType(), secureEntity);
   
    String relName = StringUtilities.singularize(collection.getName());
    this.idsFieldDefinition =
        new FieldDefinition(
            relName + StringUtils.capitalize(AdaptrexEntityType.COLLECTION_IDS_NAME),
            ExtTypeFormatter.AUTO
          );
   
    String capName = StringUtilities.capitalize(getName());
View Full Code Here

TOP

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

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.