* @package taoDelivery */ class ContainerRuntime extends LegacyRuntime { use OntologyAwareTrait; const PROPERTY_RUNTIME = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDeliveryRuntime'; const PROPERTY_CONTAINER = 'http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDeliveryContainer'; const CACHE_PREFIX = 'container:'; public function getDeliveryContainer($deliveryId) { $containerJson = $this->getCache()->get(self::CACHE_PREFIX . $deliveryId); if (is_null($containerJson)) { $delivery = $this->getResource($deliveryId); $containerJson = (string)$delivery->getOnePropertyValue($this->getProperty(self::PROPERTY_CONTAINER)); $this->getCache()->set(self::CACHE_PREFIX . $deliveryId, $containerJson); } if (!empty($containerJson)) { $registry = $this->getServiceLocator()->get(DeliveryContainerRegistry::class); $this->propagate($registry); $container = $registry->fromJson($containerJson); return $container; } else { return parent::getDeliveryContainer($deliveryId); } } /** * (non-PHPdoc) * @see \oat\taoDelivery\model\RuntimeService::getRuntime() */ public function getRuntime($deliveryId) { $delivery = $this->getResource($deliveryId); $runtimeResource = $delivery->getOnePropertyValue($this->getProperty(self::PROPERTY_RUNTIME)); if ($runtimeResource === null) { throw new \common_exception_NoContent('Unable to load runtime associated for delivery ' . $deliveryId . ' Delivery probably deleted.'); } return ($runtimeResource instanceof \core_kernel_classes_Resource) ? tao_models_classes_service_ServiceCall::fromResource($runtimeResource) : tao_models_classes_service_ServiceCall::fromString((string)$runtimeResource); } private function getCache(): CacheInterface { return $this->getServiceLocator()->get(SimpleCache::SERVICE_ID); } }