Examples of EORelationship


Examples of com.webobjects.eoaccess.EORelationship

     * @param context current context
     * @return display name for the destination entity
     */
    public String displayNameForDestinationEntity(D2WContext context) {
        String displayName = null;
        EORelationship relationship = (EORelationship)context.valueForKey("smartRelationship");
        if (relationship != null) {
            EOEntity entity = (EOEntity)context.valueForKey("entity");
            if (entity != null) {
                context.takeValueForKey(relationship.destinationEntity(), "entity");
                displayName = (String)context.valueForKey("displayNameForEntity");
            } else {
                log.warn("Current context: " + context + " doesn't have an entity, very strange, defaulting to destination entity name.");
                displayName = relationship.destinationEntity().name();
            }
        }
        return displayName;
    }   
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

    // check if there are any node ids specified, if yes then go to those nodes directly
    ValueMap map = new ValueMap(entity, qualifier);
   
    if (map.getAttributes().size() == 1) {
      EOAttribute att = map.getMostFrequentAttribute();
      EORelationship rel = EOUtilities.getRelationshipForSourceAttribute(entity, att);
      Collection<?> values = map.getValuesForAttribute(att);
      boolean containsNulls = values.contains(null);
     
      if (! containsNulls) {
        if (entity.primaryKeyAttributes().size() == 1 && att.equals(EOUtilities.primaryKeyAttribute(entity))) {
          // it's primary key
          Results<T> filter = (Results<T>) primaryKeyReference(db, (Collection<? extends Number>) values);
         
          return new EvaluatingFilter<T>(filter, entity, qualifier);
        }
        if (rel != null
            && ! RelationshipStore.shouldBeStoredAsRelationship(rel.entity())
            && ! RelationshipStore.shouldBeStoredAsRelationship(rel.destinationEntity()) ) {
          // it's using foreign key
          Results<T> filter = (Results<T>) foreignKeyReference(db, rel, (Collection<? extends Number>) values);
         
          return new EvaluatingFilter<T>(filter, entity, qualifier);
        }
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

          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

Examples of com.webobjects.eoaccess.EORelationship

    Retriever<? extends PropertyContainer, V> lastRetriever;
   
    // iterate over splits except for the last one
    for (int i=0; i<splits.length-1; i++) { 
      String key = splits[i];
      EORelationship rel = current.relationshipNamed(key);
      RelationshipRetriever<? extends PropertyContainer, ? extends PropertyContainer> r = RelationshipRetriever.create(rel);
     
      interimRetrievers.add(r);
     
      current = rel.destinationEntity();
    }
   
    // now handle last one (which could be attribute or relationship)
    {
      String key = splits[splits.length - 1];
      EORelationship rel = current.relationshipNamed(key);
     
      if (rel != null) {
        lastRetriever = (Retriever<? extends PropertyContainer, V>) RelationshipRetriever.create(rel);       
      } else {
        EOAttribute att = current.attributeNamed(key);
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

          + 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 {
            // Search for and return the snapshot
            return dbc.snapshotForSourceGlobalID(gid, relationshipName, ec.fetchTimestamp());
          }
        });

    // Null means that a relationship snapshot array was not found in EODBCtx or EODB.
    if (toManySnapshot != null) {
      // --- (3) return result
      return Integer.valueOf(toManySnapshot.count());
    }

    // Default case
    // --- (4) Case where relationship has not been faulted, and no snapshot array exists
    EOQualifier q = EODatabaseDataSource._qualifierForRelationshipKey(relationshipName, object);
    // --- (4) return result
    return objectCountWithQualifier(ec, relationship.destinationEntity().name(), q);
  }
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

      EOKeyValueQualifier kvq = (EOKeyValueQualifier) q;
      String key = kvq.key();
      String [] segments = key.split("\\.");
     
      if (segments.length == 2) {
        EORelationship r = e.relationshipNamed(segments[0]);
       
        if (r != null && false == r.isToMany() && false == r.isFlattened()) {
          List<EOKeyValueQualifier> list = result.get(r);
         
          if (list == null) {
            list = new ArrayList<EOKeyValueQualifier>();
            result.put(r, list);
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

  protected abstract void setForeignKeyValue(EORelationship rel, Number val);
 
  @Override
  public Object get(EOAttribute att) {
    if (isForeignKey(att)) {
      EORelationship rel = foreignKeys.get(att.name());
     
      return getForeignKeyValue(rel);
    } else {
      return getAttribute(pc, att);
    }
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

  }

  @Override
  public void put(EOAttribute att, Object value) {
    if (isForeignKey(att)) {
      EORelationship rel = foreignKeys.get(att.name());
     
      setForeignKeyValue(rel, (Number) value);
    } else {
      setAttribute(pc, att, value);
    }
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

        String restrictedChoiceKey=(String)d2wContext().valueForKey("restrictedChoiceKey");
        if( restrictedChoiceKey!=null &&  restrictedChoiceKey.length()>0 )
            return valueForKeyPath(restrictedChoiceKey);
        String fetchSpecName=(String)d2wContext().valueForKey("restrictingFetchSpecification");
        if(fetchSpecName != null) {
            EORelationship relationship = ERXUtilities.relationshipWithObjectAndKeyPath(object(),
                                                                                        (String)d2wContext().valueForKey("propertyKey"));
            return EOUtilities.objectsWithFetchSpecificationAndBindings(object().editingContext(), relationship.destinationEntity().name(),fetchSpecName,null);
        }
        return null;
    }
View Full Code Here

Examples of com.webobjects.eoaccess.EORelationship

        return _detailDataSource;
    }

    public EORelationship entityRelationship() {
        EOEntity e = EOModelGroup.defaultGroup().entityNamed(object().entityName());
        EORelationship result=e.relationshipNamed(key());
        if (result==null)
            throw new RuntimeException("Could not find relationship for entity "+object().entityName()+" - "+key());
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.