/** * constructor: initialize the service and the default data * * @access public * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} * @return Delivery */ public function __construct() { parent::__construct(); // the service is initialized by default $this->service = DeliveryTemplateService::singleton(); $this->defaultData(); }
/** * Creates a new assembly from the provided template * and desactivates other assemblies crearted from the same template * * @param core_kernel_classes_Resource $deliveryTemplate * @throws EmptyDeliveryException * @return common_report_Report */ public function createAssemblyFromTemplate(core_kernel_classes_Resource $deliveryTemplate) { $assemblyClass = $this->getRootClass(); $content = DeliveryTemplateService::singleton()->getContent($deliveryTemplate); if (is_null($content)) { throw new EmptyDeliveryException('Delivery ' . $deliveryTemplate->getUri() . ' has no content'); } $props = $deliveryTemplate->getPropertiesValues(array(RDFS_LABEL, TAO_DELIVERY_RESULTSERVER_PROP, TAO_DELIVERY_MAXEXEC_PROP, TAO_DELIVERY_START_PROP, TAO_DELIVERY_END_PROP, TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP)); $props[PROPERTY_COMPILEDDELIVERY_DELIVERY] = array($deliveryTemplate); return $this->createAssemblyByContent($assemblyClass, $content, $props); }
/** * @param core_kernel_classes_Resource $resource * @throws common_exception_Error * @return DeliveryCompiler */ public static function createCompiler(core_kernel_classes_Resource $deliveryContent) { $storage = new TrackedStorage(); $compilerClass = DeliveryTemplateService::singleton()->getImplementationByContent($deliveryContent)->getCompilerClass(); if (!class_exists($compilerClass)) { throw new common_exception_Error('Class ' . $compilerClass . ' not found while instanciating Compiler'); } if (!is_subclass_of($compilerClass, __CLASS__)) { throw new common_exception_Error('Compiler class ' . $compilerClass . ' is not a compiler'); } return new $compilerClass($deliveryContent, $storage); }
/** * * @author Lionel Lecaque, lionel@taotesting.com */ public function testGetAssembliesByTemplate() { $templateService = DeliveryTemplateService::singleton(); $deliveryTemplate = $templateService->createInstance($templateService->getRootClass(), 'unit test delivery template'); $deliveryTemplate->editPropertyValues(new core_kernel_classes_Property(DeliveryTemplate::PROPERTY_CONTENT), $this->content); $report = $this->getAssemblyFromTemplate($deliveryTemplate); $assembly = $report->getData(); $res = TemplateAssemblyService::singleton()->getAssembliesByTemplate($deliveryTemplate, true); $this->assertInstanceOf('core_kernel_classes_Resource', current($res)); $this->assertEquals($assembly->getUri(), current($res)->getUri()); $deliveryTemplate->delete(); $assembly->delete(); }
/** * @expectedException common_exception_NoImplementation */ public function testGetImplementationByContent() { $inexistingClass = new core_kernel_classes_Class('doesnotexist'); DeliveryTemplateService::singleton()->getImplementationByContent($inexistingClass); }