コード例 #1
0
ファイル: Entity.java プロジェクト: leasual/greenDAO
  void init2ndPass() {
    init2ndPassNamesWithDefaults();

    for (int i = 0; i < properties.size(); i++) {
      Property property = properties.get(i);
      property.setOrdinal(i);
      property.init2ndPass();
      if (property.isPrimaryKey()) {
        propertiesPk.add(property);
      } else {
        propertiesNonPk.add(property);
      }
    }

    if (propertiesPk.size() == 1) {
      pkProperty = propertiesPk.get(0);
      pkType = schema.mapToJavaTypeNullable(pkProperty.getPropertyType());
    } else {
      pkType = "Void";
    }

    propertiesColumns = new ArrayList<Property>(properties);
    for (ToOne toOne : toOneRelations) {
      toOne.init2ndPass();
      Property[] fkProperties = toOne.getFkProperties();
      for (Property fkProperty : fkProperties) {
        if (!propertiesColumns.contains(fkProperty)) {
          propertiesColumns.add(fkProperty);
        }
      }
    }

    for (ToMany toMany : toManyRelations) {
      toMany.init2ndPass();
      // Source Properties may not be virtual, so we do not need the following code:
      // for (Property sourceProperty : toMany.getSourceProperties()) {
      // if (!propertiesColumns.contains(sourceProperty)) {
      // propertiesColumns.add(sourceProperty);
      // }
      // }
    }

    if (active == null) {
      active = schema.isUseActiveEntitiesByDefault();
    }
    active |= !toOneRelations.isEmpty() || !toManyRelations.isEmpty();

    if (hasKeepSections == null) {
      hasKeepSections = schema.isHasKeepSectionsByDefault();
    }

    init2ndPassIndexNamesWithDefaults();

    for (ContentProvider contentProvider : contentProviders) {
      contentProvider.init2ndPass();
    }
  }
コード例 #2
0
ファイル: Entity.java プロジェクト: leasual/greenDAO
  private void init3rdPassAdditionalImports() {
    if (active && !javaPackage.equals(javaPackageDao)) {
      additionalImportsEntity.add(javaPackageDao + "." + classNameDao);
    }

    for (ToOne toOne : toOneRelations) {
      Entity targetEntity = toOne.getTargetEntity();
      checkAdditionalImportsEntityTargetEntity(targetEntity);
      // For deep loading
      if (!targetEntity.getJavaPackage().equals(javaPackageDao)) {
        additionalImportsDao.add(targetEntity.getJavaPackage() + "." + targetEntity.getClassName());
      }
    }

    for (ToMany toMany : toManyRelations) {
      Entity targetEntity = toMany.getTargetEntity();
      checkAdditionalImportsEntityTargetEntity(targetEntity);
    }
  }
コード例 #3
0
ファイル: Entity.java プロジェクト: leasual/greenDAO
  private void init3rdPassRelations() {
    Set<String> toOneNames = new HashSet<String>();
    for (ToOne toOne : toOneRelations) {
      toOne.init3ndPass();
      if (!toOneNames.add(toOne.getName().toLowerCase())) {
        throw new RuntimeException("Duplicate name for " + toOne);
      }
    }

    Set<String> toManyNames = new HashSet<String>();
    for (ToMany toMany : toManyRelations) {
      toMany.init3ndPass();
      Entity targetEntity = toMany.getTargetEntity();
      for (Property targetProperty : toMany.getTargetProperties()) {
        if (!targetEntity.propertiesColumns.contains(targetProperty)) {
          targetEntity.propertiesColumns.add(targetProperty);
        }
      }
      if (!toManyNames.add(toMany.getName().toLowerCase())) {
        throw new RuntimeException("Duplicate name for " + toMany);
      }
    }
  }
コード例 #4
0
ファイル: Entity.java プロジェクト: leasual/greenDAO
 /**
  * Convenience method for {@link Entity#addToMany(Entity, Property)} with a subsequent call to
  * {@link ToMany#setName(String)}.
  */
 public ToMany addToMany(Entity target, Property targetProperty, String name) {
   ToMany toMany = addToMany(target, targetProperty);
   toMany.setName(name);
   return toMany;
 }