Пример #1
0
  public NSArray<ERIAttributeGroup> groups() {
    NSMutableArray<ERIAttributeGroup> result = new NSMutableArray<ERIAttributeGroup>();
    ERIAttributeGroup current = this;

    result.addObject(current);
    while (current.parent() != null) {
      result.insertObjectAtIndex(current, 0);
      current = current.parent();
    }
    return result;
  }
Пример #2
0
  public NSArray theList() {
    NSMutableArray aSortedArray;
    NSArray anUnsortedArray;
    if (_privateList() == null) {
      EODataSource aDataSource = _localDataSource();
      anUnsortedArray = aDataSource.fetchObjects();
      // 81398 sort contents
      aSortedArray = new NSMutableArray(anUnsortedArray);
      try {
        _WOJExtensionsUtil._sortEOsUsingSingleKey(aSortedArray, _localDestinationDisplayKey());
      } catch (NSComparator.ComparisonException e) {
        throw NSForwardException._runtimeExceptionForThrowable(e);
      }

      if (!_localIsMandatory()) {
        aSortedArray.insertObjectAtIndex(_noneString, 0);
      }
      set_privateList(aSortedArray);
    }
    return _privateList();
  }
Пример #3
0
    /**
     * This is called by super for each join. We do not actually construct the join clause as we get
     * called since for SQL92 JOIN syntax we need to know about all joins before we construct the
     * complete join clause.
     *
     * <p>The objective of this implementation is to insert a new unique {@link
     * JoinClauseDefinition} into the <code>_alreadyJoined</code> array of {@link
     * JoinClauseDefinition} objects.
     *
     * <p>The join clause itself is assembled by <code>joinClauseString()</code>.
     *
     * @param leftName the table name on the left side of the clause
     * @param rightName the table name on the right side of the clause
     * @param semantic the join semantic
     * @return the join clause
     *     <p>kieran based this on logic from PostgresqlExpression
     */
    @SuppressWarnings("unchecked")
    @Override
    public String assembleJoinClause(String leftName, String rightName, int semantic) {
      if (!useAliases()) {
        return super.assembleJoinClause(leftName, rightName, semantic);
      }

      String leftAlias = leftName.substring(0, leftName.indexOf("."));
      String rightAlias = rightName.substring(0, rightName.indexOf("."));

      NSArray<String> k;
      EOEntity rightEntity;
      EOEntity leftEntity;
      String relationshipKey = null;
      EORelationship r;

      if (leftAlias.equals("t0")) {
        leftEntity = entity();
      } else {
        k = aliasesByRelationshipPath().allKeysForObject(leftAlias);
        relationshipKey = k.count() > 0 ? (String) k.lastObject() : "";
        leftEntity = entityForKeyPath(relationshipKey);
      }

      if (rightAlias.equals("t0")) {
        rightEntity = entity();
      } else {
        k = aliasesByRelationshipPath().allKeysForObject(rightAlias);
        relationshipKey = k.count() > 0 ? (String) k.lastObject() : "";
        rightEntity = entityForKeyPath(relationshipKey);
      }
      int dotIndex = relationshipKey.indexOf(".");
      relationshipKey =
          dotIndex == -1
              ? relationshipKey
              : relationshipKey.substring(relationshipKey.lastIndexOf(".") + 1);
      r = rightEntity.anyRelationshipNamed(relationshipKey);
      // fix from Michael Müller for the case Foo.fooBars.bar has a
      // Bar.foo relationship (instead of Bar.foos)
      if (r == null || r.destinationEntity() != leftEntity) {
        r = leftEntity.anyRelationshipNamed(relationshipKey);
      }
      // timc 2006-02-26 IMPORTANT or quotes are ignored and mixed case
      // field names won't work
      String rightTable;
      String leftTable;
      if (CONFIG.ENABLE_IDENTIFIER_QUOTING) {
        rightTable = rightEntity.valueForSQLExpression(this);
        leftTable = leftEntity.valueForSQLExpression(this);
      } else {
        rightTable = rightEntity.externalName();
        leftTable = leftEntity.externalName();
      }

      // We need the numeric table by removing the leading 't' or 'T' from the table alias
      int leftTableID = Integer.parseInt(leftAlias.substring(1));

      // Compute left and right table references
      String leftTableNameAndAlias = leftTable + " " + leftAlias;
      String rightTableNameAndAlias = rightTable + " " + rightAlias;

      // COmpute joinOperation
      String joinOperation = null;
      switch (semantic) {
        case EORelationship.LeftOuterJoin:
          // LEFT OUTER JOIN and LEFT JOIN are equivalent in MySQL
          joinOperation = " LEFT JOIN ";
          break;
        case EORelationship.RightOuterJoin:
          // RIGHT OUTER JOIN and RIGHT JOIN are equivalent in MySQL
          joinOperation = " RIGHT JOIN ";
          break;
        case EORelationship.FullOuterJoin:
          throw new IllegalArgumentException(
              "Unfortunately MySQL does not support FULL OUTER JOIN that is specified for "
                  + leftName
                  + " joining "
                  + rightName
                  + "!");
          // jc.op = " FULL OUTER JOIN ";
          // break;
        case EORelationship.InnerJoin:
          // INNER JOIN and JOIN are equivalent in MySQL
          joinOperation = " JOIN ";
          break;
      }

      // Compute joinCondition
      NSArray<EOJoin> joins = r.joins();
      int joinsCount = joins.count();
      NSMutableArray<String> joinStrings = new NSMutableArray<String>(joinsCount);
      for (int i = 0; i < joinsCount; i++) {
        EOJoin currentJoin = joins.objectAtIndex(i);
        String left;
        String right;
        if (CONFIG.ENABLE_IDENTIFIER_QUOTING) {
          left =
              leftAlias
                  + "."
                  + sqlStringForSchemaObjectName(currentJoin.sourceAttribute().columnName());
          right =
              rightAlias
                  + "."
                  + sqlStringForSchemaObjectName(currentJoin.destinationAttribute().columnName());
        } else {
          left = leftAlias + "." + currentJoin.sourceAttribute().columnName();
          right = rightAlias + "." + currentJoin.destinationAttribute().columnName();
        }
        joinStrings.addObject(left + " = " + right);
      }
      String joinCondition = " ON " + joinStrings.componentsJoinedByString(" AND ");

      JoinClauseDefinition jc =
          new JoinClauseDefinition(
              leftTableNameAndAlias,
              joinOperation,
              rightTableNameAndAlias,
              joinCondition,
              leftTableID);
      if (!_alreadyJoined.containsObject(jc)) {
        _alreadyJoined.insertObjectAtIndex(jc, 0);
      }
      return null;
    }
Пример #4
0
 /**
  * Inserts a route at the beginning of the route list.
  *
  * @param route the route to insert
  */
 public void insertRoute(ERXRoute route) {
   verifyRoute(route);
   _routes.insertObjectAtIndex(route, 0);
 }