Beispiel #1
0
 public static NSArray<edu.umich.marketplace.eof.Category> fetchSubCategories(
     EOEditingContext editingContext, edu.umich.marketplace.eof.Category parentBinding) {
   EOFetchSpecification fetchSpec =
       EOFetchSpecification.fetchSpecificationNamed("subCategories", "Category");
   NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>();
   bindings.takeValueForKey(parentBinding, "parent");
   fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings);
   return (NSArray<edu.umich.marketplace.eof.Category>)
       editingContext.objectsWithFetchSpecification(fetchSpec);
 }
 public static NSArray<org.pachyderm.foundation.eof.PDBPresentation>
     fetchPresentationNamesAndIdentities(EOEditingContext editingContext, String authorBinding) {
   EOFetchSpecification fetchSpec =
       EOFetchSpecification.fetchSpecificationNamed(
           "presentationNamesAndIdentities", _PDBPresentation.ENTITY_NAME);
   NSMutableDictionary<String, Object> bindings = new NSMutableDictionary<String, Object>();
   bindings.takeValueForKey(authorBinding, "author");
   fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings);
   return (NSArray<org.pachyderm.foundation.eof.PDBPresentation>)
       editingContext.objectsWithFetchSpecification(fetchSpec);
 }
Beispiel #3
0
 // [PJYF Nov 5 2004]
 // This is major Hack to generate a diffenrent bind dictionary for update and insert form the
 // one for select and delete
 public String sqlStringForForInsertOrUpdateValue(Object value, String keyPath) {
   EOAttribute attribute = this.entity()._attributeForPath(keyPath);
   if (value != NSKeyValueCoding.NullValue
       && (useBindVariables() && this.shouldUseBindVariableForAttribute(attribute)
           || this.mustUseBindVariableForAttribute(attribute))) {
     NSMutableDictionary bindVariableDictionary =
         this.bindVariableDictionaryForAttribute(attribute, value);
     this.addBindVariableDictionary(bindVariableDictionary);
     return (String) bindVariableDictionary.objectForKey(BindVariablePlaceHolderKey);
   } else {
     return this.formatValueForAttribute(value, attribute);
   }
 }
Beispiel #4
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 #5
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();
    }