public void deleteAllEveryScreenRelationships() {
   Enumeration<org.pachyderm.foundation.eof.PDBScreen> objects =
       everyScreen().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteEveryScreenRelationship(objects.nextElement());
   }
 }
Beispiel #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();
    }
Beispiel #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);
    }
Beispiel #4
0
  /**
   * Overrides the parent implementation to provide a more efficient mechanism for generating
   * primary keys, while generating the primary key support on the fly.
   *
   * @param count the batch size
   * @param entity the entity requesting primary keys
   * @param channel open JDBCChannel
   * @return NSArray of NSDictionary where each dictionary corresponds to a unique primary key value
   */
  public NSArray newPrimaryKeys(int count, EOEntity entity, JDBCChannel channel) {
    if (isPrimaryKeyGenerationNotSupported(entity)) {
      return null;
    }

    EOAttribute attribute = (EOAttribute) entity.primaryKeyAttributes().lastObject();
    String attrName = attribute.name();
    boolean isIntType = "i".equals(attribute.valueType());

    NSMutableArray results = new NSMutableArray(count);
    String sequenceName = sequenceNameForEntity(entity);
    DB2Expression expression = new DB2Expression(entity);

    boolean succeeded = false;
    for (int tries = 0; !succeeded && tries < 2; tries++) {
      while (results.count() < count) {
        try {
          StringBuffer sql = new StringBuffer();
          sql.append("SELECT ");
          sql.append("next value for " + sequenceName + " AS KEY");
          sql.append(" from sysibm.sysdummy1");
          expression.setStatement(sql.toString());
          channel.evaluateExpression(expression);
          try {
            NSDictionary row;
            while ((row = channel.fetchRow()) != null) {
              Enumeration pksEnum = row.allValues().objectEnumerator();
              while (pksEnum.hasMoreElements()) {
                Number pkObj = (Number) pksEnum.nextElement();
                Number pk;
                if (isIntType) {
                  pk = Integer.valueOf(pkObj.intValue());
                } else {
                  pk = Long.valueOf(pkObj.longValue());
                }
                results.addObject(new NSDictionary(pk, attrName));
              }
            }
          } finally {
            channel.cancelFetch();
          }
          succeeded = true;
        } catch (JDBCAdaptorException ex) {
          throw ex;
        }
      }
    }

    if (results.count() != count) {
      throw new IllegalStateException(
          "Unable to generate primary keys from the sequence for " + entity + ".");
    }

    return results;
  }
Beispiel #5
0
 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;
 }
Beispiel #6
0
  // 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);
  }
Beispiel #7
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);
 }
Beispiel #8
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));
    }
Beispiel #9
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());
   }
 }
Beispiel #13
0
 public void deleteAllAdvertsRelationships() {
   Enumeration objects = adverts().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteAdvertsRelationship((edu.umich.marketplace.eof.Advert) objects.nextElement());
   }
 }