Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOEntity


                    String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                    Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                    lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
                }
                if (lastEO!=null) {
                    EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                    String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                    result=entity.relationshipNamed(lastKey);
                }
            }
            if (result==null) {
                // working around D2W bug
                result=c.relationship();
View Full Code Here


    private transient EOEntity _dummyEntity;
    /** Utility to create a fake entity that can be used for tasks such as error/confirm. */
    // CHECKME ak We may have to insert the entity into the default model group
    protected EOEntity dummyEntity() {
        if (_dummyEntity==null) {
            _dummyEntity=new EOEntity();
            _dummyEntity.setName("*all*");
        }
        return _dummyEntity;
    }
View Full Code Here

     * we are now also able to set the destination entity in other rules.
     * @param c current D2W context
     * @return the destination entity.
     */
    public Object destinationEntity(D2WContext c) {
        EOEntity destinationEntity = (EOEntity)c.valueForKeyPath("smartRelationship.destinationEntity");
        return destinationEntity;
    }
View Full Code Here

      // with that is that for abstract entities, this would fetch the objects one-by-one
      // to determine what the correct EOGlobalID is for each subentity. Instead, I've
      // changed this to created a global ID for each row (which supports being a guess)
      // and then fetch the objects with the global IDs.
      NSArray primKeys = ERXEOControlUtilities.primaryKeyValuesInRange(ec, spec, start, end);
      EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, spec.entityName());
      NSMutableArray<EOGlobalID> gids = new NSMutableArray<EOGlobalID>();
      for (Object obj : primKeys) {
        NSDictionary pkDict = (NSDictionary) obj;
        EOGlobalID gid = entity.globalIDForRow(pkDict);
        gids.addObject(gid);
      }
      NSMutableArray objects = ERXEOGlobalIDUtilities.fetchObjectsWithGlobalIDs(ec, gids, spec.refreshesRefetchedObjects());

      if (spec.prefetchingRelationshipKeyPaths() != null && spec.prefetchingRelationshipKeyPaths().count() > 0) {
View Full Code Here

     * @param end the last row number
     *
     * @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
View Full Code Here

     * @param qualifier to find the matching objects
     * @param attributeName name of attribute in same entity to consider in order to determine uniqueness
     * @return number of matching objects
     */
    public static Integer objectCountUniqueWithQualifierAndAttribute(EOEditingContext ec, String entityName, EOQualifier qualifier, String attributeName) {
        EOEntity entity = EOUtilities.entityNamed(ec, entityName);
        EOAttribute attribute = entity.attributeNamed(attributeName);
        EOAttribute aggregateAttribute = EOEnterpriseObjectClazz.objectCountUniqueAttribute(attribute);
        return (Integer)_aggregateFunctionWithQualifierAndAggregateAttribute(ec, entityName, qualifier, aggregateAttribute);
    }
View Full Code Here

                String partialKeyPath=KeyValuePath.keyPathWithoutLastProperty(propertyKey);
                Object rawLastEO=object.valueForKeyPath(partialKeyPath);
                lastEO=rawLastEO instanceof EOEnterpriseObject ? (EOEnterpriseObject)rawLastEO : null;
            }
            if (lastEO!=null) {
                EOEntity entity=EOModelGroup.defaultGroup().entityNamed(lastEO.entityName());
                String lastKey=KeyValuePath.lastPropertyKeyInKeyPath(propertyKey);
                result=entity.attributeNamed(lastKey);
            }
        }
        if (result==null) {
            // default to the basic attribute if the above didnt' work
            if (propertyKey!=null) result=c.attribute();
View Full Code Here

          + "' is not a toMany relationship! Expected an NSArray, but got a "
          + object.storedValueForKey(relationshipName).getClass().getName(), e);
    }
   
    final EOEditingContext ec = object.editingContext();
    EOEntity entity = ERXEOAccessUtilities.entityForEo(object);
    EORelationship relationship = entity.relationshipNamed(relationshipName);

    // Fail in the event that the relationship fault is not a toMany
    if (!relationship.isToMany()) {
      // Happens if toOne key used and the to-one is a fault
      throw new IllegalArgumentException("The attribute named '" + relationshipName
          + "' in the entity named '" + object.entityName() +"' is not a toMany relationship!");
    }

    // --- (3) Case of a fault and a snapshot exists to provide a count
    final EOGlobalID gid = ec.globalIDForObject(object);
    String modelName = entity.model().name();
    final EODatabaseContext dbc = EOUtilities.databaseContextForModelNamed(ec, modelName);

    NSArray toManySnapshot = ERXEOAccessUtilities.executeDatabaseContextOperation(dbc, 2,
        new DatabaseContextOperation<NSArray>() {
          public NSArray execute(EODatabaseContext databaseContext) throws Exception {
View Full Code Here

        Enumeration entitiesEnumerator = entityNames.objectEnumerator();
        while (entitiesEnumerator.hasMoreElements()) {
            String entityName = (String)entitiesEnumerator.nextElement();
            if (! ERCNSnapshot.shouldSynchronizeEntity(entityName))   continue;

            EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
            EODatabaseContext dbContext = ERCNNotificationCoordinator.databaseContextForEntityNamed(entityName, ec);
            EODatabase database = dbContext.database();
            NSArray snapshots = (NSArray)ercnSnapshot.shapshotsForUpdateGroupedByEntity().objectForKey(entityName);
            Enumeration snapshotsEnumerator = snapshots.objectEnumerator();
            while (snapshotsEnumerator.hasMoreElements()) {
                NSDictionary snapshot = (NSDictionary)snapshotsEnumerator.nextElement();
                if (NSLog.debug.isEnabled())
                    NSLog.debug.appendln(ERCNNotificationCoordinator.LOG_HEADER + "Snapshot: " + snapshot);
                if (snapshot != null) {
                    EOGlobalID globalID = entity.globalIDForRow(snapshot);
                    dbContext.lock();
                    database.forgetSnapshotForGlobalID(globalID);
                    database.recordSnapshotForGlobalID(snapshot, globalID);
                    dbContext.unlock();
                }
View Full Code Here

      public void processRelationships(EODatabase database, NSArray gids, NSDictionary snapshots, Object context, SynchronizerSettings settings) {
        Enumeration gidsEnum = gids.objectEnumerator();
        while (gidsEnum.hasMoreElements()) {
          EOKeyGlobalID gid = (EOKeyGlobalID) gidsEnum.nextElement();
          processGID(database, gid, context, settings);
          EOEntity entity = database.entityNamed(gid.entityName());
          NSDictionary snapshot = (NSDictionary) snapshots.objectForKey(gid);
          Enumeration relationshipsEnum = entity.relationships().objectEnumerator();
          while (relationshipsEnum.hasMoreElements()) {
            EORelationship relationship = (EORelationship) relationshipsEnum.nextElement();
            if (!relationship.isToMany()) {
              EORelationship inverseRelationship = relationship.inverseRelationship();
              if (inverseRelationship != null && inverseRelationship.isToMany()) {
                EOEntity destEntity = inverseRelationship.entity();
                NSDictionary destPK = relationship._foreignKeyForSourceRow(snapshot);
                EOGlobalID destGID = destEntity.globalIDForRow(destPK);
                if (destGID != null) {
                  processRelationship(database, gid, relationship, destGID, inverseRelationship, context, settings);
                }
              }
            }
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOEntity

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.