Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOJoin


                                // 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);
                                }
                                fs.setQualifier(qualifiers.count() == 1 ? qualifiers.lastObject() : new EOAndQualifier(qualifiers));
                                value = ec.objectsWithFetchSpecification(fs);
                            }
View Full Code Here


        jc.table2 = rightTable + " " + rightAlias;
        NSArray<EOJoin> joins = r.joins();
        int joinsCount = joins.count();
        NSMutableArray<String> joinStrings = new NSMutableArray<String>(joinsCount);
        for( int i = 0; i < joinsCount; i++ ) {
            EOJoin currentJoin = joins.objectAtIndex(i);
            String left;
            String right;
            if(enableIdentifierQuoting()) {
                left = leftAlias +"."+ sqlStringForSchemaObjectName(currentJoin.sourceAttribute().columnName());
                right =  rightAlias +"."+ sqlStringForSchemaObjectName(currentJoin.destinationAttribute().columnName());
            } else {
                left = leftAlias +"."+currentJoin.sourceAttribute().columnName();
                right = rightAlias +"."+currentJoin.destinationAttribute().columnName();
            }
            joinStrings.addObject( left + " = " + right);
        }
        jc.joinCondition = " ON " + joinStrings.componentsJoinedByString( " AND " );
        if( !_alreadyJoined.containsObject( jc ) ) {
View Full Code Here

            EORelationship relationship = new EORelationship();
            relationship.setName(targetName+(isToMany ? "s" : ""));
            selectedEntity.addRelationship(relationship);

           
            EOJoin join = new EOJoin(selectedPK, foreignAttribute);
            relationship.addJoin(join);
            relationship.setToMany(isToMany);
            relationship.setJoinSemantic(EORelationship.InnerJoin);
           
            if(addBack) {
                relationship = new EORelationship();
                join = new EOJoin(foreignAttribute,selectedPK);
                relationship.setName(selectedName);
                targetEntity.addRelationship(relationship);
                relationship.addJoin(join);
                relationship.setToMany(false);
                relationship.setJoinSemantic(EORelationship.InnerJoin);
View Full Code Here

                foreignAttribute = addAttributeNamed(selectedEntity, targetName+"id", selectedPK.prototype());
            }
            relationship.setName(targetName+(isToMany ? "s" : ""));
            selectedEntity.addRelationship(relationship);

            EOJoin join = new EOJoin(foreignAttribute,selectedPK);
            relationship.addJoin(join);
            relationship.setToMany(isToMany);
            relationship.setJoinSemantic(EORelationship.InnerJoin);
        }
View Full Code Here

     * @param relationship relationship on entity to return source attribute for
     * @return source attribute for the relationship
     */
    public static EOAttribute sourceAttributeForRelationship(EORelationship relationship)
    {
        EOJoin join = relationship.joins().objectAtIndex(0);
        return join.sourceAttribute();
    }
View Full Code Here

    if(sourceEntity.isAbstractEntity())
      log.warn("If you programatically add relationships to an abstract entity, make sure you also add it to child entities");
    EOEntity destinationEntity = EOModelGroup.defaultGroup().entityNamed(destinationEntityName);
    EOAttribute sourceAttribute = sourceEntity.attributeNamed(sourceAttributeName);
    EOAttribute destinationAttribute = destinationEntity.attributeNamed(destinationAttributeName);
    EOJoin join = new EOJoin(sourceAttribute, destinationAttribute);
    EORelationship relationship = new EORelationship();

    relationship.setName(relationshipName);
    sourceEntity.addRelationship(relationship);
    relationship.addJoin(join);
View Full Code Here

        itemFKAttribute.setPrecision(itemPrimaryKey.precision());
        itemFKAttribute.setScale(itemPrimaryKey.scale());
        itemFKAttribute.setAllowsNull(false);
        joinEntity.addAttribute(itemFKAttribute);

        EOJoin join = new EOJoin(itemFKAttribute, itemPrimaryKey);
        joinToItemRelationship.addJoin(join);
      }

      EORelationship joinToTagRelationship = new EORelationship();
      joinToTagRelationship.setName(tagEntity.name());
      joinToTagRelationship.setIsMandatory(true);
      joinToTagRelationship.setToMany(false);
      joinToTagRelationship.setJoinSemantic(EORelationship.InnerJoin);
      joinEntity.addRelationship(joinToTagRelationship);
      for (EOAttribute tagPrimaryKey : tagEntity.primaryKeyAttributes()) {
        EOAttribute tagFKAttribute = new EOAttribute();
        tagFKAttribute.setExternalType(tagPrimaryKey.externalType());
        tagFKAttribute.setValueType(tagPrimaryKey.valueType());
        tagFKAttribute.setName("tag_" + tagPrimaryKey.name());
        tagFKAttribute.setColumnName("tag_" + tagPrimaryKey.columnName());
        tagFKAttribute.setClassName(tagPrimaryKey.className());
        tagFKAttribute.setWidth(tagPrimaryKey.width());
        tagFKAttribute.setPrecision(tagPrimaryKey.precision());
        tagFKAttribute.setScale(tagPrimaryKey.scale());
        tagFKAttribute.setAllowsNull(false);
        joinEntity.addAttribute(tagFKAttribute);

        joinToTagRelationship.addJoin(new EOJoin(tagFKAttribute, tagPrimaryKey));
      }

      joinEntity.setPrimaryKeyAttributes(joinEntity.attributes());
      joinEntity.setAttributesUsedForLocking(joinEntity.attributes());
      entity.model().addEntity(joinEntity);

      EORelationship itemToJoinRelationship = new EORelationship();
      itemToJoinRelationship.setEntity(joinToItemRelationship.destinationEntity());
      itemToJoinRelationship.setName("_eofInv_" + joinToItemRelationship.entity().name() + "_" + joinToItemRelationship.name());
      NSArray<EOJoin> joinToItemRelationshipJoins = joinToItemRelationship.joins();
      for (int joinNum = joinToItemRelationshipJoins.count() - 1; joinNum >= 0; joinNum--) {
        EOJoin join = joinToItemRelationshipJoins.objectAtIndex(joinNum);
        EOJoin inverseJoin = new EOJoin(join.destinationAttribute(), join.sourceAttribute());
        itemToJoinRelationship.addJoin(inverseJoin);
      }
      itemToJoinRelationship.setDeleteRule(1); // cascade
      itemToJoinRelationship.setJoinSemantic(EORelationship.InnerJoin);
      itemToJoinRelationship.setToMany(true);
View Full Code Here

     */
    public void addPreferenceRelationshipToActorEntity(String entityName, String attributeNameToJoin) {
        EOEntity actor = EOModelGroup.defaultGroup().entityNamed(entityName);
        EOEntity preference = EOModelGroup.defaultGroup().entityNamed("ERCPreference");

        EOJoin preferencesJoin = new EOJoin(actor.attributeNamed(attributeNameToJoin), preference.attributeNamed("userID"));
        EORelationship preferencesRelationship = new EORelationship();

        preferencesRelationship.setName("preferences");
        actor.addRelationship(preferencesRelationship);
        preferencesRelationship.addJoin(preferencesJoin);
        preferencesRelationship.setToMany(true);
        preferencesRelationship.setJoinSemantic(EORelationship.InnerJoin);
        preferencesRelationship.setDeleteRule(EOEntityClassDescription.DeleteRuleCascade);
       
        EOJoin userJoin = new EOJoin(preference.attributeNamed("userID"), actor.attributeNamed(attributeNameToJoin) );
        EORelationship userRelationship = new EORelationship();
        userRelationship.setName("user");
        preference.addRelationship(userRelationship);
        userRelationship.addJoin(userJoin);
        userRelationship.setToMany(false);
View Full Code Here

                String definitionKeyPath=targetRelationship.definition();                       
                NSArray<String> definitionKeys=NSArray.componentsSeparatedByString(definitionKeyPath,".");
                EOEntity lastStopEntity=targetRelationship.entity();
                EORelationship firstHopRelationship= lastStopEntity.relationshipNamed(definitionKeys.objectAtIndex(0));
                EOEntity endOfFirstHopEntity= firstHopRelationship.destinationEntity();
                EOJoin join= firstHopRelationship.joins().objectAtIndex(0); // assumes 1 join
                EOAttribute sourceAttribute=join.sourceAttribute();
                EOAttribute targetAttribute=join.destinationAttribute();
                EORelationship secondHopRelationship=endOfFirstHopEntity.relationshipNamed(definitionKeys.objectAtIndex(1));
                join= secondHopRelationship.joins().objectAtIndex(0); // assumes 1 join
                EOAttribute secondHopSourceAttribute=join.sourceAttribute();

                NSMutableArray<String> lastStopPKeyPath = toManyKeys.mutableClone();
                lastStopPKeyPath.removeLastObject();
                lastStopPKeyPath.addObject(firstHopRelationship.name());
                lastStopPKeyPath.addObject(targetAttribute.name());
View Full Code Here

              // (AR) could not find relationship from source object into "exists" clause, use primary key then instead
                EOAttribute pk = srcEntity.primaryKeyAttributes().lastObject();
                srcEntityForeignKey = expression.sqlStringForAttribute(pk);
            }
           
            EOJoin parentChildJoin = ERXArrayUtilities.firstObject(relationship.joins());
            String destEntityForeignKey = "." + expression.sqlStringForSchemaObjectName(parentChildJoin.destinationAttribute().columnName());
           
            EOQualifier qual = EOQualifierSQLGeneration.Support._schemaBasedQualifierWithRootEntity(subqualifier, destEntity);
            EOFetchSpecification fetchSpecification = new EOFetchSpecification(destEntity.name(), qual, null, false, true, null);

            EODatabaseContext context = EODatabaseContext.registeredDatabaseContextForModel(destEntity.model(), EOObjectStoreCoordinator.defaultCoordinator());
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOJoin

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.