Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOQualifier


   * Overridden to support extra qualifiers.
   * @return the qualifier constructed
   */
  @Override
  public EOQualifier qualifierFromQueryValues() {
    EOQualifier q1 = super.qualifierFromQueryValues();
    EOQualifier q2 = null;
    if(_extraQualifiers.allValues().count() > 1) {
      q2 = new EOAndQualifier(_extraQualifiers.allValues());
    } else if(_extraQualifiers.allValues().count() > 0) {
      q2 = _extraQualifiers.allValues().lastObject();
    }
View Full Code Here


   * @return filtered objects
   */
  public NSArray<T> filteredObjects() {
    // FIXME AK: need to cache here
    NSArray<T> result;
    EOQualifier q=qualifier();
    if (q!=null) {
      result=EOQualifier.filteredArrayWithQualifier(allObjects(),q);
    } else {
      result=allObjects();
    }
View Full Code Here

            if (null == qualifier || null == expression) {
                return null;
            }

            ERXExistsQualifier existsQualifier = (ERXExistsQualifier)qualifier;
            EOQualifier subqualifier = existsQualifier.subqualifier();
            String baseKeyPath = existsQualifier.baseKeyPath();

            EOEntity baseEntity = expression.entity();
            EORelationship relationship = null;

            // Walk the key path to the last entity.
            if (baseKeyPath != null) {
                for (String path : NSArray.componentsSeparatedByString(baseKeyPath, ".")) {
                    if (null == relationship) {
                        relationship = baseEntity.anyRelationshipNamed(path);
                    } else {
                        relationship = relationship.destinationEntity().anyRelationshipNamed(path);
                    }
                }
            }

            EOEntity srcEntity = relationship != null ? relationship.entity() : baseEntity;
            EOEntity destEntity = relationship != null ? relationship.destinationEntity() : baseEntity;

            // We need to do a bunch of hand-waiving to get the right table aliases for the table used in the exists
            // subquery and for the join clause back to the source table.
            String sourceTableAlias = "t0"; // The alias for the the source table of the baseKeyPath from the main query.
            String destTableAlias; // The alias for the table used in the subquery.
            if (!srcEntity.equals(baseEntity)) { // The exists clause is applied to the different table.
                sqlStringForAttributeNamedInExpression(baseKeyPath, expression);
                destTableAlias = (String)expression.aliasesByRelationshipPath().valueForKey(baseKeyPath);
                if (null == destTableAlias) {
                    destTableAlias = EXISTS_ALIAS + (expression.aliasesByRelationshipPath().count()); // The first entry = "t0".
                    expression.aliasesByRelationshipPath().takeValueForKey(destTableAlias, baseKeyPath);
                }
            } else { // The exists clause is applied to the base table.
                destTableAlias = EXISTS_ALIAS + expression.aliasesByRelationshipPath().count(); // Probably "t1"
            }

            String srcEntityForeignKey = null;
            NSArray<EOAttribute> sourceAttributes = relationship.sourceAttributes();
            if (sourceAttributes != null && sourceAttributes.count() > 0) {
                EOAttribute fk = sourceAttributes.lastObject();
                srcEntityForeignKey = expression.sqlStringForAttribute(fk);
            } else {
              // (AR) could not find relationship from source object into "exists" clause, use primary key then instead
                EOAttribute pk = srcEntity.primaryKeyAttributes().lastObject();
                srcEntityForeignKey = expression.sqlStringForAttribute(pk);
            }
           
            EOJoin parentChildJoin = ERXArrayUtilities.firstObject(relationship.joins());
            String destEntityForeignKey = "." + expression.sqlStringForSchemaObjectName(parentChildJoin.destinationAttribute().columnName());
           
            EOQualifier qual = EOQualifierSQLGeneration.Support._schemaBasedQualifierWithRootEntity(subqualifier, destEntity);
            EOFetchSpecification fetchSpecification = new EOFetchSpecification(destEntity.name(), qual, null, false, true, null);

            EODatabaseContext context = EODatabaseContext.registeredDatabaseContextForModel(destEntity.model(), EOObjectStoreCoordinator.defaultCoordinator());
            EOSQLExpressionFactory factory = context.database().adaptor().expressionFactory();
View Full Code Here

   */
  protected EOFetchSpecification fetchSpecification() {
    EODatabaseDataSource ds = (EODatabaseDataSource) dataSource();
    EOFetchSpecification spec = (EOFetchSpecification) ds.fetchSpecificationForFetch().clone();
    spec.setSortOrderings(ERXArrayUtilities.arrayByAddingObjectsFromArrayWithoutDuplicates(sortOrderings(), spec.sortOrderings()));
    EOQualifier dgQualifier = qualifier();
    EOQualifier qualifier = spec.qualifier();
    if (dgQualifier != null) {
      if (qualifier != null) {
        qualifier = new ERXAndQualifier(dgQualifier, qualifier);
      } else {
        qualifier = dgQualifier;
View Full Code Here

  }

  public NSArray<D> objects(EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch) {
    NSArray<D> results;
    if (fetch) {
      EOQualifier fullQualifier;
      EOQualifier inverseQualifier = qualifierForObjects();

      if (qualifier == null) {
        fullQualifier = inverseQualifier;
      } else {
        NSMutableArray<EOQualifier> qualifiers = new NSMutableArray<EOQualifier>();
View Full Code Here

      return result;
    }

    @Override
    public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier qualifier, EOEntity entity) {
      EOQualifier result = super.schemaBasedQualifierWithRootEntity(qualifier, entity);
      return result;
    }
View Full Code Here

      return result;
    }

    @Override
    public EOQualifier qualifierMigratedFromEntityRelationshipPath(EOQualifier qualifier, EOEntity entity, String s) {
      EOQualifier result = super.qualifierMigratedFromEntityRelationshipPath(qualifier, entity, s);
      return result;
    }
View Full Code Here

   * @return decoded object from the archive
   */
  public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver) {
    String entityName = (String) unarchiver.decodeObjectForKey("masterClassDescription");
    String detailKey = (String) unarchiver.decodeObjectForKey("detailKey");
    EOQualifier auxiliaryQualifier = (EOQualifier) unarchiver.decodeObjectForKey("auxiliaryQualifier");
    ERXDetailDataSource dataSource = new ERXDetailDataSource(EOClassDescription.classDescriptionForEntityName(entityName), detailKey);
    dataSource.setAuxiliaryQualifier(auxiliaryQualifier);
    dataSource.qualifyWithRelationshipKey(detailKey, null);
    return dataSource;
  }
View Full Code Here

            return super.sqlStringForSQLExpression(eoqualifier, e);
        }

        @Override
        public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier eoqualifier, EOEntity eoentity) {
            EOQualifier result = null;
            EOKeyValueQualifier qualifier = (EOKeyValueQualifier)eoqualifier;
            String key = qualifier.key();
            if(key.indexOf('.') < 0) {
                // ak: this code is only for binding values in display groups and
                // to support the twolevelrelationship and the ERD2WQuery*Relationship, it probably should go away...
View Full Code Here

                  result.addObject(eo);
                }
              }
            }
            if (fetch) {
              EOQualifier qualifier = entity.qualifierForPrimaryKey(entity.primaryKeyForGlobalID(g));
              qualifiers.addObject(qualifier);
            }
          }
          if (qualifiers.count() > 0) {
            EOQualifier qualifier = qualifiers.count() > 1 ? new EOOrQualifier(qualifiers) : qualifiers.lastObject();
            EOFetchSpecification fetchSpec = new EOFetchSpecification(entityName, qualifier, null);
            fetchSpec.setRefreshesRefetchedObjects(refreshesRefetchedObjects);
            NSArray<EOEnterpriseObject> details = ec.objectsWithFetchSpecification(fetchSpec);
            result.addObjectsFromArray(details);
          }
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOQualifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.