/**
  * Gets the ResourceAssociationSet instance for the given source 
  * association end.
  * 
  * @param ResourceSet      $resourceSet      Resource set of the source
  *                                           association end
  * @param ResourceType     $resourceType     Resource type of the source
  *                                           association end
  * @param ResourceProperty $resourceProperty Resource property of the source
  *                                           association end
  * 
  * @return ResourceAssociationSet
  */
 public function getResourceAssociationSet(ResourceSet $sourceResourceSet, ResourceType $sourceResourceType, ResourceProperty $targetResourceProperty)
 {
     //e.g.
     //ResourceSet => Representing 'Customers' entity set
     //ResourceType => Representing'Customer' entity type
     //ResourceProperty => Representing 'Orders' property
     //We have created ResourceAssoicationSet while adding
     //ResourceSetReference or ResourceReference
     //and kept in $this->associationSets
     //$metadata->addResourceSetReferenceProperty(
     //             $customersEntityType,
     //             'Orders',
     //             $ordersResourceSet
     //             );
     $targetResourceSet = $targetResourceProperty->getResourceType()->getCustomState();
     if (is_null($targetResourceSet)) {
         throw new InvalidOperationException('Failed to retrieve the custom state from ' . $resourceProperty->getResourceType()->getName());
     }
     //Customer_Orders_Orders, Order_Customer_Customers
     $key = $sourceResourceType->getName() . '_' . $targetResourceProperty->getName() . '_' . $targetResourceSet->getName();
     if (array_key_exists($key, $this->associationSets)) {
         return $this->associationSets[$key];
     }
     return null;
 }
 /**
  * This class method is used to construct a ResourceDescriptor object by providing the XML for that object.
  *
  * @param string $xml - XML String defining ResourceDescriptor
  * @return ResourceDescriptor
  */
 public static function createFromXML($xml)
 {
     $sxi = new \SimpleXMLIterator($xml);
     $temp = new self((string) $sxi->attributes()->name, (string) $sxi->attributes()->wsType, (string) $sxi->attributes()->uriString, (string) $sxi->attributes()->isNew);
     $desc = !empty($sxi->description) ? (string) $sxi->description : null;
     $label = !empty($sxi->label) ? (string) $sxi->label : null;
     $date = !empty($sxi->creationDate) ? (string) $sxi->creationDate : null;
     $temp->setLabel($label);
     $temp->setDescription($desc);
     $temp->setCreationDate($date);
     foreach ($sxi->resourceDescriptor as $nestRd) {
         $temp->children[] = ResourceDescriptor::createFromXML($nestRd->asXML());
     }
     foreach ($sxi->resourceProperty as $prop) {
         $temp->properties[] = ResourceProperty::createFromXML($prop->asXML());
     }
     return $temp;
 }