Ejemplo n.º 1
0
 /**
  * Write an entity type and associated attributes.
  * 
  * @param ResourceType $resourceType                            Resource type
  * @param array        $associationTypesInResourceTypeNamespace Collection of 
  * association types for the given resource types
  * array(string, AssociationType)
  * 
  * @return nothing
  */
 private function _writeEntityType(ResourceType $resourceType, $associationTypesInResourceTypeNamespace)
 {
     $this->_iOdataWriter->startElement(ODataConstants::ENTITY_TYPE);
     $this->_iOdataWriter->writeAttribute(ODataConstants::NAME, $resourceType->getName());
     if ($resourceType->isAbstract()) {
         $this->_iOdataWriter->writeAttribute(ODataConstants::ABSTRACT1, "true");
     }
     if ($resourceType->isMediaLinkEntry() && (!$resourceType->hasBaseType() || $resourceType->hasBaseType() && $resourceType->getBaseType()->isMediaLinkEntry())) {
         $this->_iOdataWriter->writeAttributeNs(ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, ODataConstants::DATAWEB_ACCESS_HASSTREAM_ATTRIBUTE, null, "true");
     }
     if ($resourceType->hasBaseType()) {
         $this->_iOdataWriter->writeAttribute(ODataConstants::BASE_TYPE, $resourceType->getBaseType()->getFullName());
     } else {
         $this->_iOdataWriter->startElement(ODataConstants::KEY);
         foreach ($resourceType->getKeyProperties() as $resourceProperty) {
             $this->_iOdataWriter->startElement(ODataConstants::PROPERTY_REF);
             $this->_iOdataWriter->writeAttribute(ODataConstants::NAME, $resourceProperty->getName());
             $this->_iOdataWriter->endElement();
         }
         $this->_iOdataWriter->endElement();
     }
     $this->_writeProperties($resourceType, $associationTypesInResourceTypeNamespace);
     $this->_writeNamedStreams($resourceType);
     $this->_iOdataWriter->endElement();
 }