src/POData/Writers/Metadata/MetadataAssociationTypeSet.php
/**
     * Gets and validate the ResourceAssociationSet instance for the 
     * given source resource association end
     * This function first searches the ResourceAssociationSet cache, 
     * if found return it otherwise 
     * get the association set from metadata wrapper, 
     * validate, cache and return it.
     * 
     * @param ResourceSetWrapper $resourceSet        Resource set of the 
     *                                               source association end
     * @param ResourceType       $resourceType       Resource type of the 
     *                                               source association end
     * @param ResourceProperty   $navigationProperty Resource property of the 
     *                                               source association end
     * 
     * @return ResourceAssociationSet|null The association set instance for the 
     *                                     given association set end,
     *                                     NULL if the metadata wrapper 
     *                                     returns NULL 
     *                                     (either IDSMP implementation
     *                                     returns null or 
     *                                     target resource set is invisible)
     *                                  
     * @throws InvalidOperationException If validation of AssociationSet fails
     * @throws ODataException If validation fails at 
     * ProvidersWrapper::getResourceAssociationSet
     */
Gets and validate the ResourceAssociationSet instance for the
given source resource association end
This function first searches the ResourceAssociationSet cache,
if found return it otherwise
get the association set from metadata wrapper,
validate, cache and return it.

@param ResourceSetWrapper $resourceSet        Resource set of the
source association end
@param ResourceType       $resourceType       Resource type of the
source association end
@param ResourceProperty   $navigationProperty Resource property of the
source association end

@return ResourceAssociationSet|null The association set instance for the
given association set end,
NULL if the metadata wrapper
returns NULL
(either IDSMP implementation
returns null or
target resource set is invisible)


Gets and validate the ResourceAssociationSet instance for the given source resource association end This function first searches the ResourceAssociationSet cache if found return it otherwise get the association set from metadata wrapper validate cache and return it . @param ResourceSetWrapper $resourceSet Resource set of the source association end @param ResourceType $resourceType Resource type of the source association end @param ResourceProperty $navigationProperty Resource property of the source association end @return ResourceAssociationSet|null The association set instance for the given association set end NULL if the metadata wrapper returns NULL ( either IDSMP implementation returns null or target resource set is invisible )
private function _getResourceAssociationSet(ResourceSetWrapper $resourceSet, ResourceType $resourceType, ResourceProperty $navigationProperty)
    {
        $associationSetLookupKey = $resourceSet->getName() . '_' . $resourceType->getFullName() . '_' . $navigationProperty->getName();
        if (array_key_exists($associationSetLookupKey, $this->_resourceAssociationSets)) {
            return $this->_resourceAssociationSets[$associationSetLookupKey];
        }
        $resourceAssociationSet = $this->providersWrapper->getResourceAssociationSet($resourceSet, $resourceType, $navigationProperty);
        if (is_null($resourceAssociationSet)) {
            return null;
        }
        $relatedEnd = $resourceAssociationSet->getRelatedResourceAssociationSetEnd(
            $resourceSet->getResourceSet(), 
            $resourceType, $navigationProperty
        );
        if (!is_null($relatedEnd->getResourceProperty())) {
            $relatedResourceSetWrapper = $this->providersWrapper->validateResourceSetAndGetWrapper($relatedEnd->getResourceSet());
            $reverseResourceAssociationSet = $this->providersWrapper->getResourceAssociationSet($relatedResourceSetWrapper, $relatedEnd->getResourceType(), $relatedEnd->getResourceProperty());
            if (is_null($reverseResourceAssociationSet) || (!is_null($reverseResourceAssociationSet) && $resourceAssociationSet->getName() != $reverseResourceAssociationSet->getName())) {
                throw new InvalidOperationException(Messages::metadataAssociationTypeSetBidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd());
            }
        }
        $reverseAssociationSetLookupKey = null;
        if (!is_null($relatedEnd->getResourceProperty())) {
            $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName() . '_' . $relatedEnd->getResourceProperty()->getResourceType()->getFullName() . '_' . $relatedEnd->getResourceProperty()->getName();
        } else {
            $reverseAssociationSetLookupKey = $relatedEnd->getResourceSet()->getName() . '_Null_' . $resourceType->getFullName() . '_' . $navigationProperty->getName();
        }
        if (array_key_exists($reverseAssociationSetLookupKey, $this->_resourceAssociationSets)) {
            throw new InvalidOperationException(Messages::metadataAssociationTypeSetMultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets($this->_resourceAssociationSets[$reverseAssociationSetLookupKey]->getName(), $resourceAssociationSet->getName(), $relatedEnd->getResourceSet()->getName()));
        }
        $this->_resourceAssociationSets[$associationSetLookupKey] = $resourceAssociationSet;
        $this->_resourceAssociationSets[$reverseAssociationSetLookupKey] = $resourceAssociationSet;
        return $resourceAssociationSet;
    }
private function _getResourceAssociationSet ( ResourceSetWrapper $ resourceSet , ResourceType $ resourceType , ResourceProperty $ navigationProperty ) { $ associationSetLookupKey = $ resourceSet -> getName ( ) . '_' . $ resourceType -> getFullName ( ) . '_' . $ navigationProperty -> getName ( ) ; if ( array_key_exists ( $ associationSetLookupKey , $ this -> _resourceAssociationSets ) ) { return $ this -> _resourceAssociationSets [ $ associationSetLookupKey ] ; } $ resourceAssociationSet = $ this -> providersWrapper -> getResourceAssociationSet ( $ resourceSet , $ resourceType , $ navigationProperty ) ; if ( is_null ( $ resourceAssociationSet ) ) { return null ; } $ relatedEnd = $ resourceAssociationSet -> getRelatedResourceAssociationSetEnd ( $ resourceSet -> getResourceSet ( ) , $ resourceType , $ navigationProperty ) ; if ( ! is_null ( $ relatedEnd -> getResourceProperty ( ) ) ) { $ relatedResourceSetWrapper = $ this -> providersWrapper -> validateResourceSetAndGetWrapper ( $ relatedEnd -> getResourceSet ( ) ) ; $ reverseResourceAssociationSet = $ this -> providersWrapper -> getResourceAssociationSet ( $ relatedResourceSetWrapper , $ relatedEnd -> getResourceType ( ) , $ relatedEnd -> getResourceProperty ( ) ) ; if ( is_null ( $ reverseResourceAssociationSet ) || ( ! is_null ( $ reverseResourceAssociationSet ) && $ resourceAssociationSet -> getName ( ) != $ reverseResourceAssociationSet -> getName ( ) ) ) { throw new InvalidOperationException ( Messages :: metadataAssociationTypeSetBidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd ( ) ) ; } } $ reverseAssociationSetLookupKey = null ; if ( ! is_null ( $ relatedEnd -> getResourceProperty ( ) ) ) { $ reverseAssociationSetLookupKey = $ relatedEnd -> getResourceSet ( ) -> getName ( ) . '_' . $ relatedEnd -> getResourceProperty ( ) -> getResourceType ( ) -> getFullName ( ) . '_' . $ relatedEnd -> getResourceProperty ( ) -> getName ( ) ; } else { $ reverseAssociationSetLookupKey = $ relatedEnd -> getResourceSet ( ) -> getName ( ) . '_Null_' . $ resourceType -> getFullName ( ) . '_' . $ navigationProperty -> getName ( ) ; } if ( array_key_exists ( $ reverseAssociationSetLookupKey , $ this -> _resourceAssociationSets ) ) { throw new InvalidOperationException ( Messages :: metadataAssociationTypeSetMultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets ( $ this -> _resourceAssociationSets [ $ reverseAssociationSetLookupKey ] -> getName ( ) , $ resourceAssociationSet -> getName ( ) , $ relatedEnd -> getResourceSet ( ) -> getName ( ) ) ) ; } $ this -> _resourceAssociationSets [ $ associationSetLookupKey ] = $ resourceAssociationSet ; $ this -> _resourceAssociationSets [ $ reverseAssociationSetLookupKey ] = $ resourceAssociationSet ; return $ resourceAssociationSet ; }
Gets and validate the ResourceAssociationSet instance for the
 given source resource association end
 This function first searches the ResourceAssociationSet cache,
 if found return it otherwise
 get the association set from metadata wrapper,
 validate, cache and return it.
Gets and validate the ResourceAssociationSet instance for the given source resource association end This function first searches the ResourceAssociationSet cache if found return it otherwise get the association set from metadata wrapper validate cache and return it .
//Either the related ResourceSet is invisible or IDSMP implementation returns null /**
         * @var ResourceAssociationSetEnd
         */ //For bidirectional relationship IDSMP::getResourceAssociationSet should //return same association set when called from either end //No need to check whether the following call returns NULL,  //because the above call  //providersWrapper::getResourceAssociationSet //causes the metadata wrapper to check the visibility of //related resource set and cache the corresponding wrapper. //If found invisible it would have return NULL,  //which we are any way handling above.