Package com.webobjects.eocontrol

Examples of com.webobjects.eocontrol.EOFetchSpecification


   
    // Since it is likely the fetch spec will be used in a different
    // background thread during report generation, we need to ensure we have a schema-based
    // qualifier instead of a memory-based qualifier that might have references to EOs
    // in an RR-locked editing context
    EOFetchSpecification fs = null;
    EOEditingContext ec = ERXEC.newEditingContext();
    ec.lock();
    try {
      fs = schemaBasedFetchSpecification(fetchSpecification);
    } catch (Exception e) {
View Full Code Here


                                                                      String entityName,
                                                                      EOQualifier eoqualifier,
                                                                      NSArray<EOSortOrdering> sortOrderings,
                                                                      NSArray<String> additionalKeys) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);
        EOFetchSpecification fs = new EOFetchSpecification(entityName, eoqualifier, sortOrderings);
        fs.setFetchesRawRows(true);
        NSMutableArray<String> keys = new NSMutableArray<String>(entity.primaryKeyAttributeNames());
        if (additionalKeys != null) {
            keys.addObjectsFromArray(additionalKeys);
        }
        fs.setRawRowKeyPaths(keys);
        return fs;
    }
View Full Code Here

     */
    public static NSArray primaryKeysMatchingQualifier(EOEditingContext ec,
                                                       String entityName,
                                                       EOQualifier eoqualifier,
                                                       NSArray<EOSortOrdering> sortOrderings) {
        EOFetchSpecification fs = ERXEOControlUtilities.primaryKeyFetchSpecificationForEntity(ec,
                                                                                              entityName,
                                                                                              eoqualifier,
                                                                                              sortOrderings,
                                                                                              null);
        return ec.objectsWithFetchSpecification(fs);
View Full Code Here

          }
          eos = new NSArray<EOEnterpriseObject>(eo);
        }
        else {
          EOQualifier qualfier = EOQualifier.qualifierToMatchAllValues(values);
          EOFetchSpecification fs = new EOFetchSpecification(entityName, qualfier, null);
          // Might as well get fresh stuff
          fs.setRefreshesRefetchedObjects(refreshRefetchedObjects);
          if (prefetchingKeyPaths != null) {
            fs.setPrefetchingRelationshipKeyPaths(prefetchingKeyPaths);
          }
          eos = ec.objectsWithFetchSpecification(fs);
        }
        if (eos.count() > 1) {
          throw new MoreThanOneException("Found multiple objects for the entity '" + entity.name() + "' with primary key value: " + primaryKeyValue);
View Full Code Here

     
      if (rawRowsForCustomQueries) {
        result = EOUtilities.rawRowsForSQL(ec, model.name(), sql, null);
      }
      else {
        EOFetchSpecification fs = new EOFetchSpecification(spec.entityName(), null, null);
        fs.setHints(new NSDictionary(sql, EODatabaseContext.CustomQueryExpressionHintKey));
        result = ec.objectsWithFetchSpecification(fs);
      }
    }
    return result;
  }
View Full Code Here

     * @return primary keys in the given range
     */
    public static NSArray<NSDictionary<String, Object>> primaryKeyValuesInRange(EOEditingContext ec, EOFetchSpecification spec, int start, int end) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
        NSArray<String> pkNames = entity.primaryKeyAttributeNames();
        EOFetchSpecification clonedFetchSpec = (EOFetchSpecification)spec.clone();
        clonedFetchSpec.setFetchesRawRows(true);
        clonedFetchSpec.setRawRowKeyPaths(pkNames);
        if (clonedFetchSpec instanceof ERXFetchSpecification) {
            // remove any range setting as we will explicitly set start and end limit
            ((ERXFetchSpecification)clonedFetchSpec).setFetchRange(null);
        }
        EOSQLExpression sql = ERXEOAccessUtilities.sqlExpressionForFetchSpecification(ec, clonedFetchSpec, start, end);
        NSDictionary<String, EOSQLExpression> hints = new NSDictionary<String, EOSQLExpression>(sql, EODatabaseContext.CustomQueryExpressionHintKey);
        clonedFetchSpec.setHints(hints);
        return ec.objectsWithFetchSpecification(clonedFetchSpec);
    }
View Full Code Here

    private static Object __aggregateFunctionWithQualifierAndAggregateAttribute(EODatabaseContext databaseContext, EOEditingContext ec, String entityName, EOQualifier qualifier, EOAttribute aggregateAttribute) {
        EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, entityName);

        EOSQLExpressionFactory sqlFactory = databaseContext.adaptorContext().adaptor().expressionFactory();
        EOQualifier schemaBasedQualifier = entity.schemaBasedQualifier(qualifier);
        EOFetchSpecification fetchSpec = new EOFetchSpecification(entity.name(), schemaBasedQualifier, null);
        fetchSpec.setFetchesRawRows(true);

        if (sqlFactory == null) {
          /* if there is no expression factory we have no choice but to fetch */
          NSArray<?> array = ec.objectsWithFetchSpecification(fetchSpec);
          if (aggregateAttribute == EOEnterpriseObjectClazz.objectCountAttribute()) {
View Full Code Here

                                                        String entityName,
                                                        String attributeName,
                                                        String function,
                                                        String fetchSpecificationName,
                                                        NSDictionary bindings) {
       EOFetchSpecification fs = fetchSpecificationNamedWithBindings(entityName,
                                                                     fetchSpecificationName,
                                                                     bindings);
        return aggregateFunctionWithQualifier(ec, entityName, attributeName, function, fs.qualifier());
    }
View Full Code Here

            result = (NSArray)objectsByFetchSpecName.objectForKey(fetchSpecName);
        }

        if( result == null ) {
            EOEntity entity = EOUtilities.entityNamed(sharedEditingContext, entityName);
            EOFetchSpecification fetchSpecification = entity.fetchSpecificationNamed(fetchSpecName);

            sharedEditingContext.bindObjectsWithFetchSpecification(fetchSpecification, fetchSpecName);

            objectsByFetchSpecName = (NSDictionary)sharedEditingContext.objectsByEntityNameAndFetchSpecificationName().objectForKey(entityName);
            if( objectsByFetchSpecName != null ) { //shouldn't be
View Full Code Here

     *     bindings replaced.
     */
    public static EOFetchSpecification fetchSpecificationNamedWithBindings(String entityName,
                                                                           String fetchSpecificationName,
                                                                           NSDictionary bindings) {
        EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed(fetchSpecificationName,
                                                                                      entityName);
        return fetchSpec != null && bindings != null ?
            fetchSpec.fetchSpecificationWithQualifierBindings(bindings) : fetchSpec;
    }
View Full Code Here

TOP

Related Classes of com.webobjects.eocontrol.EOFetchSpecification

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.