public function setServiceDefinition() { $serviceCallUri = tao_helpers_Uri::decode($this->getRequestParameter('callOfServiceUri')); $serviceDefinitionUri = tao_helpers_Uri::decode($this->getRequestParameter(tao_helpers_Uri::encode(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION))); if (empty($serviceCallUri)) { throw new tao_models_classes_MissingRequestParameterException('callOfServiceUri'); } if (empty($serviceDefinitionUri)) { throw new tao_models_classes_MissingRequestParameterException(tao_helpers_Uri::encode(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION)); } $serviceCall = new core_kernel_classes_Resource($serviceCallUri); $serviceDefinition = new core_kernel_classes_Resource($serviceDefinitionUri); $service = tao_models_classes_InteractiveServiceService::singleton(); $service->setCallOfServiceDefinition($serviceCall, $serviceDefinition); $service->setDefaultParameters($serviceCall); echo json_encode(array('saved' => 'true')); }
/** * constructor: initialize the service and the default data * @return Groups */ public function __construct() { parent::__construct(); //the service is initialized by default $this->service = tao_models_classes_InteractiveServiceService::singleton(); }
/** * Short description of method addService * * @access protected * @author Joel Bout, <*****@*****.**> * @param Resource activity * @return core_kernel_classes_Resource */ protected function addService(core_kernel_classes_Resource $activity, $serviceDefinition) { $returnValue = null; //an interactive service of an activity is a call of service: $callOfServiceClass = new core_kernel_classes_Class(CLASS_CALLOFSERVICES); //create new resource for the property value of the current call of service PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN or PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT $returnValue = $callOfServiceClass->createInstance($activity->getLabel() . "_service"); if (empty($returnValue)) { throw new Exception("the interactive service cannot be created for the activity {$activity->getUri()}"); } //associate the new instance to the activity instance $activity->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $returnValue->getUri()); tao_models_classes_InteractiveServiceService::singleton()->setCallOfServiceDefinition($returnValue, $serviceDefinition); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_WIDTH), 100); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_HEIGHT), 100); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_TOP), 0); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_LEFT), 0); $defaultParams = tao_models_classes_InteractiveServiceService::singleton()->setDefaultParameters($returnValue); return $returnValue; }