/**
  * @param SessionInterface $session
  * @param ObjectDataInterface $objectData
  */
 public function __construct(SessionInterface $session, ObjectDataInterface $objectData)
 {
     $objectFactory = $session->getObjectFactory();
     $properties = $objectData->getProperties();
     // handle properties
     if (!empty($properties)) {
         $queryProperties = $objectFactory->convertQueryProperties($properties);
         foreach ($queryProperties as $queryProperty) {
             if ($queryProperty->getId() !== null) {
                 $this->propertiesById[$queryProperty->getId()] = $queryProperty;
             }
             if ($queryProperty->getQueryName() !== null) {
                 $this->propertiesByQueryName[$queryProperty->getQueryName()] = $queryProperty;
             }
         }
     }
     // handle allowable actions
     $allowableActions = $objectData->getAllowableActions();
     if ($allowableActions !== null) {
         $this->allowableActions = $allowableActions;
     }
     // handle relationships
     $relationshipsObjectData = $objectData->getRelationships();
     foreach ($relationshipsObjectData as $relationshipObjectData) {
         $relationship = $objectFactory->convertObject($relationshipObjectData, $session->getDefaultContext());
         if ($relationship instanceof RelationshipInterface) {
             $this->relationships[] = $relationship;
         }
     }
     // handle renditions
     $renditionsData = $objectData->getRenditions();
     foreach ($renditionsData as $renditionData) {
         $rendition = $objectFactory->convertRendition($objectData->getId(), $renditionData);
         if ($rendition instanceof RenditionInterface) {
             $this->renditions[] = $rendition;
         }
     }
 }
 /**
  * Handle initialization for objectData
  *
  * @param ObjectDataInterface $objectData
  */
 private function initializeObjectData(ObjectDataInterface $objectData)
 {
     // handle properties
     if ($objectData->getProperties() !== null) {
         $this->initializeObjectDataProperties($objectData->getProperties());
     }
     // handle allowable actions
     if ($objectData->getAllowableActions() !== null) {
         $this->allowableActions = $objectData->getAllowableActions();
         $this->extensions[(string) ExtensionLevel::cast(ExtensionLevel::ALLOWABLE_ACTIONS)] = $objectData->getAllowableActions()->getExtensions();
     }
     // handle renditions
     foreach ($objectData->getRenditions() as $rendition) {
         $this->renditions[] = $this->getObjectFactory()->convertRendition($this->getId(), $rendition);
     }
     // handle ACL
     if ($objectData->getAcl() !== null) {
         $this->acl = $objectData->getAcl();
         $this->extensions[(string) ExtensionLevel::cast(ExtensionLevel::ACL)] = $objectData->getAcl()->getExtensions();
     }
     // handle policies
     if ($objectData->getPolicyIds() !== null) {
         $this->initializeObjectDataPolicies($objectData->getPolicyIds());
     }
     // handle relationships
     foreach ($objectData->getRelationships() as $relationshipData) {
         $relationship = $this->getObjectFactory()->convertObject($relationshipData, $this->getCreationContext());
         if ($relationship instanceof RelationshipInterface) {
             $this->relationships[] = $relationship;
         }
     }
     $this->extensions[(string) ExtensionLevel::OBJECT] = $objectData->getExtensions();
 }
 /**
  * Try to determined what object type the given objectData belongs to and return that type.
  *
  * @param ObjectDataInterface $objectData
  * @return ObjectTypeInterface|null The object type or <code>null</code> if type could not be determined
  */
 public function getTypeFromObjectData(ObjectDataInterface $objectData)
 {
     if ($objectData->getProperties() === null || count($objectData->getProperties()->getProperties()) === 0) {
         return null;
     }
     $typeProperty = $objectData->getProperties()->getProperties()[PropertyIds::OBJECT_TYPE_ID];
     if (!$typeProperty instanceof PropertyId) {
         return null;
     }
     return $this->session->getTypeDefinition($typeProperty->getFirstValue());
 }