Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EORelationship


    if (aKey != null) {
      String anEntityName = entityName();
      EOEntity anEntity = EOModelGroup.defaultGroup().entityNamed(
          anEntityName);
      EORelationship aRelationship = anEntity.relationshipNamed(aKey);

      if (aRelationship != null) {
        EOEditingContext anEditingContext = editingContext();
        EOGlobalID aGlobalID = anEditingContext.globalIDForObject(this);
        String aModelName = anEntity.model().name();
        EODatabaseContext aDatabaseContext = EOUtilities
            .databaseContextForModelNamed(anEditingContext,
                aModelName);
        aDatabaseContext.lock();
        NSDictionary aRow = aDatabaseContext
            .snapshotForGlobalID(aGlobalID);
        aDatabaseContext.unlock();
        EOQualifier aQualifier = aRelationship
            .qualifierWithSourceRow(aRow);

        return aQualifier;
      }
    }
View Full Code Here


        String entityName = (String) _WOJExtensionsUtil.valueForBindingOrNull("sourceEntityName", this);
        EOModelGroup modelGroup = EOModelGroup.defaultGroup();
        EOEntity entity = modelGroup.entityNamed(entityName);
        EOAttribute selectedAttribute = null;
        if (relationshipKey() != null && entity.relationshipNamed(relationshipKey()) != null) {
            EORelationship relationship = entity.relationshipNamed(relationshipKey());
            EOEntity destinationEntity = relationship.destinationEntity();
            selectedAttribute = destinationEntity.attributeNamed(key);
        } else {
            selectedAttribute = entity.attributeNamed(key);
        }
        return selectedAttribute.className();
View Full Code Here

            //BOOGIE
            EOAttribute a=entity.attributeNamed(lastKey);
            NSDictionary userInfo=null;
            if (a!=null) userInfo=a.userInfo();
            else {
                EORelationship r=entity.relationshipNamed(lastKey);
                if (r!=null) userInfo=r.userInfo();
            }
            //
           // NSDictionary userInfo=(NSDictionary)(property!=null ? property.valueForKey("userInfo") : null);
            result= (String)(userInfo!=null ? userInfo.valueForKey("unit") : null);
        }
View Full Code Here

                if(defaultValue != null)
                    setDefaultAttributeValue(attr, defaultValue);
            }

            for( Enumeration e = entity.relationships().objectEnumerator(); e.hasMoreElements();) {
                EORelationship rel = (EORelationship)e.nextElement();
                String defaultValue = null;

                if(rel.userInfo() != null)
                    defaultValue = (String)rel.userInfo().objectForKey(defaultKey);

                if(defaultValue == null && entityInfo != null) {
                    defaultValue = (String)entityInfo.objectForKey(rel.name());
                }
                if(defaultValue != null)
                    setDefaultRelationshipValue(rel, defaultValue);
            }
        }
View Full Code Here

    }

    @Override
    public String inverseForRelationshipKey(String relationshipKey) {
        String result = null;
        EORelationship relationship = entity().relationshipNamed(relationshipKey);
        if(relationship != null && relationship.userInfo() != null) {
            result = (String) relationship.userInfo().objectForKey("ERXInverseRelationshipName");
        }
        if(result == null) {
            result = super.inverseForRelationshipKey(relationshipKey);
        }
        return result;
View Full Code Here

            NSArray joinRelationships = ERDSortedManyToManyAssignment.joinRelationshipsForJoinEntity(entity());

            String originEntityName=object().entityName();
            //General case
            for (Enumeration e=joinRelationships.objectEnumerator(); e.hasMoreElements();) {
                EORelationship r=(EORelationship)e.nextElement();
                if (!originEntityName.equals(r.destinationEntity().name())) {
                    _destinationRelationship=r;
                    break;
                }
            }
            // In the case we have a self join relationship we have to be more clever
            if(_destinationRelationship==null){
                EOEntity originEntity = EOModelGroup.defaultGroup().entityNamed(originEntityName);
                EORelationship originRelationship = originEntity.relationshipNamed(relationshipKey());
                EORelationship inverseOriginRelationship = originRelationship.inverseRelationship();
                for (Enumeration e=joinRelationships.objectEnumerator(); e.hasMoreElements();) {
                    EORelationship r=(EORelationship)e.nextElement();
                    if (r!=inverseOriginRelationship) {
                        _destinationRelationship=r;
                        break;
                    }
                }
View Full Code Here

  private EREntityStore joinedStore(NSArray<EOAttribute> attributesToFetch, EOFetchSpecification fetchSpecification, EOEntity entity) {
    EREntityStore store = _stores.objectForKey(entity);
    for (EOAttribute attrib : attributesToFetch) {
      if (attrib.isFlattened()) {
        EOAttribute _attrib = entity._attributeForPath(attrib.definition());
        EORelationship _rel = entity._relationshipForPath(attrib.relationshipPath());
        store = join(_rel, store, _stores.objectForKey(_attrib.entity()));
      }
    }
    // We need to check the qualifier for _hiddenRelationships and include them if referenced
//    for (EORelationship rel : (NSArray<EORelationship>) entity._hiddenRelationships()) {
View Full Code Here

        }
        _hasNext = null;
        NSMutableDictionary<String, Object> row = new NSMutableDictionary<String, Object>(src);
        EOEntity entity = relationship.entity();
        for (EOAttribute attrib : (NSArray<EOAttribute>) entity.attributesToFetch()) {
          EORelationship rel = entity._relationshipForPath(attrib.relationshipPath());
          if (attrib.isFlattened() && relationship.equals(rel)) {
            String dstKey = entity._attributeForPath(attrib.definition()).columnName();
            Object value = dst.objectForKey(dstKey);
            row.setObjectForKey(value != null ? value : NSKeyValueCoding.NullValue, attrib.definition());
          }
View Full Code Here

        String qualifierKey = keyValueQualifier.key();
        String relationshipName = qualifierKey;
        if (relationshipName.contains(".")) {
          relationshipName = ERXStringUtilities.firstPropertyKeyInKeyPath(relationshipName);
        }
        EORelationship mergeRelationship = entity.relationshipNamed(relationshipName);
        if (mergeRelationship != null) {
          mergeRelationships.add(mergeRelationship);
          qualifier = ERXQ.replaceQualifierWithQualifier(qualifier, keyValueQualifier,
              ERXQ.has(qualifierKey, new NSArray(keyValueQualifier.value())));
        } else if (qualifierKey.equals(entity.primaryKeyAttributeNames().get(0))
            && keyValueQualifier.selector().name().equals("doesContain") && !(keyValueQualifier.value() instanceof NSArray)) {
          // fix wrong schemaBasedQualifier
          qualifier= ERXQ.replaceQualifierWithQualifier(qualifier, keyValueQualifier,
              ERXQ.is(qualifierKey, keyValueQualifier.value()));
        }
      }
    }

    // int count = 0;
    NSMutableArray<NSMutableDictionary<String, Object>> fetchedRows = new NSMutableArray<NSMutableDictionary<String, Object>>();
    Iterator<NSMutableDictionary<String, Object>> i = iterator();
    while (i.hasNext()) {
      NSMutableDictionary<String, Object> rawRow = i.next();
      NSMutableDictionary<String, Object> row = rowFromStoredValues(rawRow, entity);
      for (EORelationship mergeRelationship : mergeRelationships) {
        NSArray<NSMutableDictionary<String, Object>> found = null;
        if (mergeRelationship.isFlattened() && mergeRelationship.isToMany()) {
          found = fetchRelatedManyToManyRows(entity, row, mergeRelationship, context);
        } else {
          found = fetchRelatedRows(entity, row, mergeRelationship, context);
        }
        if (found != null && !found.isEmpty()) {
          row.setObjectForKey(found, mergeRelationship.name());
        }
      }
      if (qualifier == null || qualifier.evaluateWithObject(row)) {
        for (EORelationship mergeRelationship : mergeRelationships) {
          row.removeObjectForKey(mergeRelationship.name());
        }
        fetchedRows.addObject(row);
        // count++;
      }
      // if (fetchLimit > 0 && count == fetchLimit) {
View Full Code Here

  protected NSArray<NSMutableDictionary<String, Object>> fetchRelatedManyToManyRows(EOEntity entity,
      NSDictionary<String, Object> row, EORelationship relationship, ERMemoryAdaptorContext context) {
    String relationshipPath = relationship.relationshipPath();
    String toJoinKey = ERXStringUtilities.firstPropertyKeyInKeyPath(relationshipPath);
    String toDestKey = ERXStringUtilities.keyPathWithoutFirstProperty(relationshipPath);
    EORelationship toJoinRelationship = entity.anyRelationshipNamed(toJoinKey);
    EOEntity joinEntity = toJoinRelationship.destinationEntity();
    EREntityStore joinStore = context._entityStoreForEntity(joinEntity);
    String sourceAttribute = toJoinRelationship.sourceAttributes().get(0).name();
    String destinationAttribute = toJoinRelationship.destinationAttributes().get(0).name();

    ERXFetchSpecification fs = new ERXFetchSpecification(joinEntity.name(), ERXQ.equals(destinationAttribute,
        row.valueForKey(sourceAttribute)), null);
    NSArray<NSMutableDictionary<String, Object>> fetchedObjects = joinStore.fetch(joinEntity.attributesToFetch(),
        fs, false, joinEntity, context);

    if (fetchedObjects.isEmpty()) {
      return NSArray.EmptyArray;
    }

    EORelationship destRelationship = joinEntity.anyRelationshipNamed(toDestKey);
    sourceAttribute = destRelationship.sourceAttributes().get(0).name();
    destinationAttribute = destRelationship.destinationAttributes().get(0).name();
    NSArray<Object> destValues = (NSArray<Object>) fetchedObjects.valueForKey(sourceAttribute);
    EOEntity destEntity = relationship.destinationEntity();

    fs = new ERXFetchSpecification(destEntity.name(), ERXQ.in(destinationAttribute, destValues), null);
    EREntityStore destinationStore = context._entityStoreForEntity(destEntity);
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EORelationship

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.