예제 #1
0
 public void deleteAllEveryScreenRelationships() {
   Enumeration<org.pachyderm.foundation.eof.PDBScreen> objects =
       everyScreen().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteEveryScreenRelationship(objects.nextElement());
   }
 }
예제 #2
0
    public NSArray statementsToDropPrimaryKeyConstraintsOnEntityGroups(
        NSArray entityGroups,
        EOSchemaSynchronizationModelChanges changes,
        EOSchemaGenerationOptions options) {
      if (entityGroups == null) return NSArray.EmptyArray;
      if (changes == null) changes = newChanges();

      NSMutableArray expressions = new NSMutableArray();
      for (Enumeration enumerator = entityGroups.objectEnumerator();
          enumerator.hasMoreElements(); ) {
        NSArray entities = (NSArray) enumerator.nextElement();
        EOEntity _last =
            (EOEntity)
                entities.lastObject(); // only need entity to get the table name for the group
        String nameInObjectStore =
            _nameInObjectStoreForEntityGroupWithChangeDictionary(
                entities, changes.changesForTableNamed(_last.externalName()));
        if ((nameInObjectStore != null) && (!"".equals(nameInObjectStore))) {
          expressions.addObject(
              this._expressionForString(
                  "delete from _SYS_RELATIONSHIP where source_table = '"
                      + nameInObjectStore
                      + "' or dest_table = '"
                      + nameInObjectStore
                      + "'"));
        }
      }
      return expressions.immutableClone();
    }
예제 #3
0
    public void prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          addUpdateListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareUpdateExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      _whereClauseString =
          EOQualifierSQLGeneration.Support._sqlStringForSQLExpression(qualifier, this);
      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          assembleUpdateStatementWithRow(
              row, qualifier, tableList, new String(_listString), _whereClauseString);
    }
예제 #4
0
파일: Plots.java 프로젝트: avoy/Tracker
 public SubPlot getSubPlot(String pTitle) {
   SubPlot currSubPlot = null;
   Enumeration enumer = plots.objectEnumerator();
   while (enumer.hasMoreElements()) {
     currSubPlot = (SubPlot) enumer.nextElement();
     if (currSubPlot.title().equals(pTitle)) {
       break;
     }
   }
   return currSubPlot;
 }
예제 #5
0
파일: Plots.java 프로젝트: avoy/Tracker
  // High level all for top dictionary
  public NSMutableDictionary thePlotData() {
    NSMutableDictionary myPlot = new NSMutableDictionary();
    NSMutableArray subPlotDict = new NSMutableArray();

    Enumeration enumer = plots.objectEnumerator();
    while (enumer.hasMoreElements()) {
      SubPlot currSubPlot = (SubPlot) enumer.nextElement();
      subPlotDict.addObject(currSubPlot.toDictionary());
    }
    //    Title = "Defect Trends";
    if (title != null) {
      myPlot.setObjectForKey(title, "Title");
    }
    myPlot.setObjectForKey(subPlotDict, "Plots");
    return (myPlot);
  }
예제 #6
0
 public NSArray statementsToImplementPrimaryKeyConstraintsOnEntityGroups(
     NSArray entityGroups,
     EOSchemaSynchronizationModelChanges changes,
     EOSchemaGenerationOptions options) {
   NSArray primaryKeyExpressions =
       this.primaryKeyConstraintStatementsForEntityGroups(entityGroups);
   NSMutableArray createStatements = new NSMutableArray();
   NSMutableArray otherStatements = new NSMutableArray();
   for (Enumeration enumerator = primaryKeyExpressions.objectEnumerator();
       enumerator.hasMoreElements(); ) {
     EOSQLExpression expression = (EOSQLExpression) enumerator.nextElement();
     String statement = expression.statement();
     if (statement.startsWith("create")) {
       createStatements.addObject(expression);
     } else if (!statement.startsWith("delete from _SYS_RELATIONSHIP")) {
       otherStatements.addObject(expression);
     }
   }
   return createStatements.arrayByAddingObjectsFromArray(otherStatements);
 }
예제 #7
0
    public void prepareInsertExpressionWithRow(NSDictionary row) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          this.addInsertListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareInsertExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          this.assembleInsertStatementWithRow(
              row, tableList, new String(_listString), new String(_valueListString));
    }
예제 #8
0
    public NSArray primaryKeyConstraintStatementsForEntityGroup(NSArray entityGroup) {
      if (entityGroup == null) return NSArray.EmptyArray;

      NSMutableDictionary columnNameDictionary = new NSMutableDictionary();
      NSMutableArray primaryKeyConstraintExpressions = new NSMutableArray();

      for (Enumeration enumerator = entityGroup.objectEnumerator();
          enumerator.hasMoreElements(); ) {
        EOEntity entity = (EOEntity) enumerator.nextElement();
        String tableName = entity.externalName();
        NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
        boolean singlePrimaryKey = primaryKeyAttributes.count() == 1;
        if ((tableName != null) && (!"".equals(tableName)) && (primaryKeyAttributes.count() > 0)) {
          NSArray expressions = super.primaryKeyConstraintStatementsForEntityGroup(entityGroup);
          if ((expressions != null) && (expressions.count() > 0))
            primaryKeyConstraintExpressions.addObjectsFromArray(expressions);
          for (Enumeration attributeEnumerator = primaryKeyAttributes.objectEnumerator();
              attributeEnumerator.hasMoreElements(); ) {
            String columnName = ((EOAttribute) attributeEnumerator.nextElement()).columnName();
            columnNameDictionary.setObjectForKey(
                columnName, entity.externalName() + "." + columnName);
            EOSQLExpression expression =
                this._expressionForString(
                    "create "
                        + (singlePrimaryKey ? "unique" : "")
                        + " index "
                        + entity.externalName()
                        + " "
                        + columnName);
            if (expression != null) primaryKeyConstraintExpressions.addObject(expression);
          }
        }
      }

      for (Enumeration enumerator = entityGroup.objectEnumerator();
          enumerator.hasMoreElements(); ) {
        EOEntity entity = (EOEntity) enumerator.nextElement();
        String tableName = entity.externalName();
        if ((tableName != null) && (!"".equals(tableName))) {
          for (Enumeration relationshipEnumerator = entity.relationships().objectEnumerator();
              relationshipEnumerator.hasMoreElements(); ) {
            EORelationship relationship = (EORelationship) relationshipEnumerator.nextElement();
            if (!relationship.isFlattened()) {
              NSArray destinationAttributes = relationship.destinationAttributes();

              // First exclude all the destination entity primary keys
              for (Enumeration attributeEnumerator =
                      relationship.destinationEntity().primaryKeyAttributes().objectEnumerator();
                  attributeEnumerator.hasMoreElements(); ) {
                EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement();
                columnNameDictionary.setObjectForKey(
                    attribute.columnName(),
                    relationship.destinationEntity().externalName() + "." + attribute.columnName());
              }
              // Then deal with our end of things
              for (Enumeration attributeEnumerator =
                      relationship.sourceAttributes().objectEnumerator();
                  attributeEnumerator.hasMoreElements(); ) {
                EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement();
                if ((!this.isSinglePrimaryKeyAttribute(attribute))
                    && (columnNameDictionary.objectForKey(tableName + "." + attribute.columnName())
                        != null)) {
                  columnNameDictionary.setObjectForKey(
                      attribute.columnName(), tableName + "." + attribute.columnName());
                  EOSQLExpression expression =
                      this._expressionForString(
                          "create index " + tableName + " " + attribute.columnName());
                  if (expression != null) primaryKeyConstraintExpressions.addObject(expression);
                }
              }
              // Then deal with the other side
              if (entity.model() == relationship.destinationEntity().model()) {
                for (Enumeration attributeEnumerator =
                        relationship.destinationAttributes().objectEnumerator();
                    attributeEnumerator.hasMoreElements(); ) {
                  EOAttribute attribute = (EOAttribute) attributeEnumerator.nextElement();
                  String destinationTableName = relationship.destinationEntity().externalName();
                  if ((destinationTableName != null) && (!"".equals(destinationTableName))) {
                    if ((!this.isSinglePrimaryKeyAttribute(attribute))
                        && (columnNameDictionary.objectForKey(
                                destinationTableName + "." + attribute.columnName())
                            != null)) {
                      columnNameDictionary.setObjectForKey(
                          attribute.columnName(),
                          destinationTableName + "." + attribute.columnName());
                      EOSQLExpression expression =
                          this._expressionForString(
                              "create index "
                                  + destinationTableName
                                  + " "
                                  + attribute.columnName());
                      if (expression != null) primaryKeyConstraintExpressions.addObject(expression);
                    }
                    if ((!relationship.isCompound())
                        && (relationship.sourceAttributes().count() == 1)
                        && (relationship.destinationAttributes().count() == 1)) {
                      String semantics;
                      switch (relationship.joinSemantic()) {
                        case EORelationship.FullOuterJoin: // '\001'
                        case EORelationship.LeftOuterJoin: // '\002'
                        case EORelationship.RightOuterJoin: // '\003'
                          semantics = "*";
                          break;

                        default:
                          semantics = "=";
                          break;
                      }
                      String sourceColumn =
                          ((EOAttribute) relationship.sourceAttributes().objectAtIndex(0))
                              .columnName();
                      String destinationColumn =
                          ((EOAttribute) relationship.destinationAttributes().objectAtIndex(0))
                              .columnName();
                      EOSQLExpression expression =
                          this._expressionForString(
                              "delete from _SYS_RELATIONSHIP where relationshipName = '"
                                  + relationship.name()
                                  + "' and source_table = '"
                                  + tableName
                                  + "' ");
                      if (expression != null) primaryKeyConstraintExpressions.addObject(expression);
                      expression =
                          this._expressionForString(
                              "insert into _SYS_RELATIONSHIP (relationshipName, source_table, source_column, dest_table, dest_column, operator, one_to_many) values ('"
                                  + relationship.name()
                                  + "','"
                                  + tableName
                                  + "','"
                                  + sourceColumn
                                  + "','"
                                  + destinationTableName
                                  + "','"
                                  + destinationColumn
                                  + "','"
                                  + semantics
                                  + "',"
                                  + (relationship.isToMany() ? 1 : 0)
                                  + ")");
                      if (expression != null) primaryKeyConstraintExpressions.addObject(expression);
                    }
                  }
                }
              }
            }
          }
        }
      }
      return primaryKeyConstraintExpressions.immutableClone();
    }
 public void deleteAllApplicationsRelationships() {
   Enumeration objects = applications().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteApplicationsRelationship((er.sync.eo.ERSyncClientApp) objects.nextElement());
   }
 }
 public void deleteAllPrincipalsRelationships() {
   Enumeration objects = principals().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deletePrincipalsRelationship((er.sync.eo.ERSyncPrincipal) objects.nextElement());
   }
 }
 public void deleteAllPrivilegesRelationships() {
   Enumeration<er.rbac.eof.ERPrivilege> objects = privileges().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deletePrivilegesRelationship(objects.nextElement());
   }
 }
예제 #12
0
 public void deleteAllAdvertsRelationships() {
   Enumeration objects = adverts().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteAdvertsRelationship((edu.umich.marketplace.eof.Advert) objects.nextElement());
   }
 }