예제 #1
0
  void init3rdPass() {
    for (Property property : properties) {
      property.init3ndPass();
    }

    init3rdPassRelations();
    init3rdPassAdditionalImports();
  }
예제 #2
0
  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();
    }
  }
예제 #3
0
 protected void init2ndPassIndexNamesWithDefaults() {
   for (int i = 0; i < indexes.size(); i++) {
     Index index = indexes.get(i);
     if (index.getName() == null) {
       String indexName = "IDX_" + getTableName();
       List<Property> properties = index.getProperties();
       for (int j = 0; j < properties.size(); j++) {
         Property property = properties.get(j);
         indexName += "_" + property.getColumnName();
         if ("DESC".equalsIgnoreCase(index.getPropertiesOrder().get(j))) {
           indexName += "_DESC";
         }
       }
       // TODO can this get too long? how to shorten reliably without depending on the order (i)
       index.setName(indexName);
     }
   }
 }