Пример #1
0
 public void deleteAllEveryScreenRelationships() {
   Enumeration<org.pachyderm.foundation.eof.PDBScreen> objects =
       everyScreen().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteEveryScreenRelationship(objects.nextElement());
   }
 }
Пример #2
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;
  }
 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());
   }
 }
Пример #6
0
 public void deleteAllAdvertsRelationships() {
   Enumeration objects = adverts().immutableClone().objectEnumerator();
   while (objects.hasMoreElements()) {
     deleteAdvertsRelationship((edu.umich.marketplace.eof.Advert) objects.nextElement());
   }
 }