Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EORelationship


   
    Collections.addAll(splits, DOT_PATTERN.split(keypath));
   
    for (int i=0; i<splits.size(); i++) {
      String key = splits.get(i);
      EORelationship rel = currentEntity.relationshipNamed(key);
     
      if (rel != null) {       
        if (rel.isFlattened()) {
          String [] newDefinition = DOT_PATTERN.split(rel.definition());
         
          // perform replacement
          splits.remove(i);
         
          for (int j=0; j<newDefinition.length; j++) {
            splits.add(i+j, newDefinition[j]);
          }
         
          // possibly we have replaced flat relationship with another flat one,
          // let's have a look at it again then
          i--;
        }
        currentEntity = rel.destinationEntity();
      }
    }
    for (int i=0; i<splits.size(); i++) {
      if (i > 0) {
        b.append('.');
View Full Code Here


         * @param eoentity to be check
         */
        public void checkForeignKeys(EOEntity eoentity) {
            NSArray primaryKeys = eoentity.primaryKeyAttributes();
            for(Enumeration relationships = eoentity.relationships().objectEnumerator(); relationships.hasMoreElements(); ) {
                EORelationship relationship = (EORelationship)relationships.nextElement();
                if(!relationship.isToMany()) {
                    if(relationship.isMandatory()) {
                        for(Enumeration attributes = relationship.sourceAttributes().objectEnumerator(); attributes.hasMoreElements(); ) {
                            EOAttribute attribute = (EOAttribute)attributes.nextElement();
                            if(attribute.allowsNull()) {
                                handleMandatoryRelationshipError(eoentity, relationship, attribute);
                            }
                        }
                    } else {
                        for(Enumeration attributes = relationship.sourceAttributes().objectEnumerator(); attributes.hasMoreElements(); ) {
                            EOAttribute attribute = (EOAttribute)attributes.nextElement();
                            if(!attribute.allowsNull() && !primaryKeys.containsObject(attribute)) {
                                handleOptionalRelationshipError(eoentity, relationship, attribute);
                            }
                        }
View Full Code Here

    EOEntity currentEntity = entity;
    String [] splits = key.split("\\.");
    Collection<EORelationship> rels = new ArrayList<EORelationship>();
   
    for (int i=0; i<splits.length - 1; i++) {
      EORelationship rel = currentEntity.relationshipNamed(splits[i]);
     
      rels.add(rel);
      currentEntity = rel.destinationEntity();
    }
   
    // now process the last bit
    String last = splits[splits.length-1];
   
    if (entity.attributeNamed(last) != null) {
      // it's a plain attribute value comparison
      return new Comparison(rels, entity.attributeNamed(last), operator, value);
    } else {
      // it's a relationship value comparison, let's represent it as attribute comparison
      EORelationship lastRel = entity.relationshipNamed(last);
      EOAttribute srcAtt = asOne(lastRel.sourceAttributes());
      EOAttribute dstAtt = asOne(lastRel.destinationAttributes());
     
      rels.add(lastRel);
      if (value != null) {
        value = ((NSKeyValueCoding) value).valueForKey(dstAtt.name());
      }
View Full Code Here

  public NSArray referenceEOs() {
    if (_referenceEOs == null) {
      String relationshipName = (String) d2wContext().valueForKey("referenceRelationshipForBackgroupColor");
      if (relationshipName != null) {
        EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName());
        EORelationship relationship = entity.relationshipNamed(relationshipName);
        _referenceEOs = EOUtilities.objectsForEntityNamed(EOSharedEditingContext.defaultSharedEditingContext(), relationship.destinationEntity().name());
        _referenceEOs = ERXArrayUtilities.sortedArraySortedWithKey(_referenceEOs, "ordering", EOSortOrdering.CompareAscending);
      }
    }
    return _referenceEOs;
  }
View Full Code Here

        }

        private ConfigurationEntry configureKeyPath(ConfigurationEntry config, String keyPath, EOEntity source) {
            String key = ERXStringUtilities.firstPropertyKeyInKeyPath(keyPath);
            String rest = ERXStringUtilities.keyPathWithoutFirstProperty(keyPath);
            EORelationship rel = source._relationshipForPath(key);
            if (rel != null) {
                if (rel.isFlattened()) {
                    ConfigurationEntry c = configureKeyPath(config, rel.definition() + (rest != null ? "." + rest : ""), source);
                    return c;
                }
                EOEntity destinationEntity = rel.destinationEntity();

                ConfigurationEntry destinationConfiguration;
                if (rest != null) {
                    destinationConfiguration = configureEntity(destinationEntity.name(), new NSArray(rest));
                } else {
                    destinationConfiguration = configureEntity(destinationEntity.name(), new NSArray());
                }
                String inverseName = rel.anyInverseRelationship().name();
                destinationConfiguration.notificationKeys.addObject(inverseName);
            } else {
                config.keys.addObject(key);
            }
            return config;
View Full Code Here

    EOAttribute attribute = entity._attributeForPath(key);
    if (attribute != null) {
      type = ERXKey.Type.Attribute;
    }
    else {
      EORelationship relationship = entity._relationshipForPath(key);
      if (relationship != null) {
        if (relationship.isToMany()) {
          type = ERXKey.Type.ToManyRelationship;
        }
        else {
          type = ERXKey.Type.ToOneRelationship;
        }
View Full Code Here

                                if (!_warned.containsObject(entityName)) {
                                    log.error("We currently don't support unsaved related objects for this entity: " + entityName);
                                    _warned.addObject(entityName);
                                }
                            } else {
                                EORelationship rel = source.anyRelationshipNamed(key);
                                EOKeyGlobalID sourceGlobalID = (EOKeyGlobalID) ec.globalIDForObject(eo);
                                // AK: I wish I could, but when a relationship
                                // is
                                // not a class prop, there's nothing we can do.
                                // value =
                                // ec.arrayFaultWithSourceGlobalID(sourceGlobalID,
                                // rel.name(), ec);
                                EOFetchSpecification fs = new EOFetchSpecification(rel.destinationEntity().name(), null, null);
                                NSMutableArray<EOQualifier> qualifiers = new NSMutableArray(rel.joins().count());
                                NSDictionary pk = source.primaryKeyForGlobalID(sourceGlobalID);
                                for (Iterator iterator = rel.joins().iterator(); iterator.hasNext();) {
                                    EOJoin join = (EOJoin) iterator.next();
                                    Object pkValue = pk.objectForKey(join.sourceAttribute().name());
                                    EOKeyValueQualifier qualifier = new EOKeyValueQualifier(join.destinationAttribute().name(), EOQualifier.QualifierOperatorEqual, pkValue);
                                    qualifiers.addObject(qualifier);
                                }
View Full Code Here

            EOAttribute attribute = null;
            if (ERXValueUtilities.booleanValue(d2wContext.valueForKey("isAttribute"))) {
                attribute = d2wContext.attribute();
            } else {
                EORelationship relationship = d2wContext.relationship();
                if (relationship != null && !(value instanceof EOEnterpriseObject)) {
                    String keyWhenRelationship = (String)d2wContext.valueForKey("keyWhenRelationship");
                    if (keyWhenRelationship != null) {
                        EOEntity destinationEntity = relationship.destinationEntity();
                        attribute = destinationEntity.attributeNamed(keyWhenRelationship);
                    }
                }
            }
View Full Code Here

     */
    public Object keyWhenRelationship(D2WContext context) {
        EOEntity joinEntity=context.entity();
        NSArray relationships=joinRelationshipsForJoinEntity(joinEntity);
       
        EORelationship destinationRelationship=null;
        String originEntityName=(String)context.valueForKeyPath("object.entityName");
        for (Enumeration e=relationships.objectEnumerator(); e.hasMoreElements();) {
            EORelationship r=(EORelationship)e.nextElement();
            if (!originEntityName.equals(r.destinationEntity().name())) {
                destinationRelationship=r;
                break;
            }
        }
        return (destinationRelationship!=null ? (destinationRelationship.name()+".") : "") + "userPresentableDescription";
View Full Code Here

        } else if (entity.relationships().count() == 2) {
            joinRelationships = entity.relationships();
        } else {
            NSMutableArray relationshipCache = new NSMutableArray();
            for (Enumeration e = entity.relationships().objectEnumerator(); e.hasMoreElements();) {
                EORelationship relationship = (EORelationship)e.nextElement();
                if (relationship.userInfo() != null
                    && ERXValueUtilities.booleanValue(relationship.userInfo().objectForKey(SortedJoinRelationshipUserInfoKey))) {
                    relationshipCache.addObject(relationship);
                }
            }
            if (relationshipCache.count() != 2)
                throw new RuntimeException("Did not find two relationships with user info entries: " +
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.