/**
  *
  * @param array callOptions an array of parameters sent to the results storage configuration
  * @param mixed $resultServer
  * @param string uri or resource
  */
 public function __construct($resultServer, $additionalStorages = array())
 {
     $this->implementations = array();
     if (is_object($resultServer) and get_class($resultServer) == 'core_kernel_classes_Resource') {
         $this->resultServer = $resultServer;
     } else {
         if (common_Utils::isUri($resultServer)) {
             $this->resultServer = new core_kernel_classes_Resource($resultServer);
         }
     }
     // the static storages
     if ($this->resultServer->getUri() != TAO_VOID_RESULT_SERVER) {
         $resultServerModels = $this->resultServer->getPropertyValues(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_PROP));
         if (!isset($resultServerModels) or count($resultServerModels) == 0) {
             throw new common_Exception("The result server is not correctly configured (Resource definition)");
         }
         foreach ($resultServerModels as $resultServerModelUri) {
             $resultServerModel = new core_kernel_classes_Resource($resultServerModelUri);
             $this->addImplementation($resultServerModel->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP))->literal);
         }
     }
     if (!is_null($additionalStorages)) {
         // the dynamic storages
         foreach ($additionalStorages as $additionalStorage) {
             $this->addImplementation($additionalStorage["implementation"], $additionalStorage["parameters"]);
         }
     }
     common_Logger::i("Result Server Initialized using defintion:" . $this->resultServer->getUri());
     // sets the details required depending on the type of storage
 }
 /**
  * Short description of method remove
  *
  * @access public
  * @author Jehan Bihin, <*****@*****.**>
  * @param  string roleUri
  * @param  string accessUri
  * @return mixed
  */
 public function remove($roleUri, $accessUri)
 {
     $uri = explode('#', $accessUri);
     list($type, $ext, $mod, $act) = explode('_', $uri[1]);
     $role = new core_kernel_classes_Class($roleUri);
     $actionAccessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
     $module = new core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
     $controllerClassName = funcAcl_helpers_Map::getControllerFromUri($module->getUri());
     // access via controller?
     $controllerAccess = funcAcl_helpers_Cache::getControllerAccess($controllerClassName);
     if (in_array($roleUri, $controllerAccess['module'])) {
         // remove access to controller
         funcAcl_models_classes_ModuleAccessService::singleton()->remove($roleUri, $module->getUri());
         // add access to all other actions
         foreach (funcAcl_helpers_Model::getActions($module) as $action) {
             if ($action->getUri() != $accessUri) {
                 $this->add($roleUri, $action->getUri());
                 $this->getEventManager()->trigger(new AccessRightAddedEvent($roleUri, $action->getUri()));
             }
         }
     } elseif (isset($controllerAccess['actions'][$act]) && in_array($roleUri, $controllerAccess['actions'][$act])) {
         // remove action only
         $role->removePropertyValues($actionAccessProperty, array('pattern' => $accessUri));
         $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
         funcAcl_helpers_Cache::flushControllerAccess($controllerClassName);
     }
 }
 public function testCompile()
 {
     //test with items
     $config = array('previous' => true);
     $items = array($this->item->getUri());
     $this->testModel->save($this->test, array('itemUris' => $items, 'config' => $config));
     $waitingReport = new \common_report_Report(\common_report_Report::TYPE_SUCCESS);
     $serviceCall = $this->getMockBuilder('tao_models_classes_service_ServiceCall')->disableOriginalConstructor()->setMethods(array('serializeToString'))->getMock();
     $serviceCall->expects($this->once())->method('serializeToString')->willReturn('greatString');
     $waitingReport->setData($serviceCall);
     $testCompiler = $this->getMockBuilder('oat\\taoTestLinear\\model\\TestCompiler')->setConstructorArgs(array($this->test, $this->storage))->setMethods(array('subCompile', 'spawnPrivateDirectory'))->getMock();
     $testCompiler->expects($this->once())->method('subCompile')->willReturn($waitingReport);
     //will spawn a new directory and store the content file
     $directoryMock = $this->getMockBuilder('tao_models_classes_service_StorageDirectory')->disableOriginalConstructor()->setMethods(array('getPath'))->getMock();
     if (!file_exists(sys_get_temp_dir() . '/sample/compile/')) {
         mkdir(sys_get_temp_dir() . '/sample/compile/', 0777, true);
     }
     $directoryMock->expects($this->once())->method('getPath')->willReturn(sys_get_temp_dir() . '/sample/compile/');
     $testCompiler->expects($this->once())->method('spawnPrivateDirectory')->willReturn($directoryMock);
     $report = $testCompiler->compile();
     $this->assertEquals(__('Test Compilation'), $report->getMessage(), __('Compilation should work'));
     $this->assertFileExists(sys_get_temp_dir() . '/sample/compile/data.json', __('Compilation file not created'));
     $compile = '{"items":{"http:\\/\\/myFancyDomain.com\\/myGreatResourceUriForItem":"greatString"},"previous":true}';
     $this->assertEquals($compile, file_get_contents(sys_get_temp_dir() . '/sample/compile/data.json', __('File content error')));
 }
 /**
  * Initialise the form for the given importHandlers
  *
  * @param tao_models_classes_import_ImportHandler $importHandler
  * @param array $availableHandlers
  * @param core_kernel_classes_Resource $class
  * @internal param array $importHandlers
  * @internal param tao_helpers_form_Form $subForm
  */
 public function __construct($importHandler, $availableHandlers, $class)
 {
     $this->importHandlers = $availableHandlers;
     if (!is_null($importHandler)) {
         $this->subForm = $importHandler->getForm();
     }
     parent::__construct(array('importHandler' => get_class($importHandler), 'classUri' => $class->getUri(), 'id' => $class->getUri()));
 }
Beispiel #5
0
 public static function getWidgetDefinition(\core_kernel_classes_Resource $widget)
 {
     $widgets = self::getWidgetDefinitions();
     if (isset($widgets[$widget->getUri()])) {
         return $widgets[$widget->getUri()];
     } else {
         common_Logger::w('Widget "' . $widget->getUri() . '" not found');
         return null;
     }
 }
 /**
  * @requiresRight id WRITE
  */
 public function index()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     $revisions = RepositoryProxy::getRevisions($resource->getUri());
     $returnRevision = array();
     foreach ($revisions as $revision) {
         $returnRevision[] = array('id' => $revision->getVersion(), 'modified' => \tao_helpers_Date::displayeDate($revision->getDateCreated()), 'author' => UserHelper::renderHtmlUser($revision->getAuthorId()), 'message' => _dh($revision->getMessage()));
     }
     $this->setData('resourceLabel', _dh($resource->getLabel()));
     $this->setData('id', $resource->getUri());
     $this->setData('revisions', $returnRevision);
     $this->setView('History/index.tpl');
 }
Beispiel #7
0
 /**
  * Short description of method createSPX
  *
  * @access public
  * @author firstname and lastname of author, <*****@*****.**>
  * @param  Resource $subject
  * @param  Property $predicate
  * @return core_kernel_rules_Term
  */
 public static function createSPX(core_kernel_classes_Resource $subject, core_kernel_classes_Property $predicate)
 {
     $returnValue = null;
     $termSPXClass = new core_kernel_classes_Class(CLASS_TERM_SUJET_PREDICATE_X, __METHOD__);
     $label = 'Def Term SPX Label : ' . $subject->getLabel() . ' - ' . $predicate->getLabel();
     $comment = 'Def Term SPX Label : ' . $subject->getUri() . ' ' . $predicate->getUri();
     $SPXResource = core_kernel_classes_ResourceFactory::create($termSPXClass, $label, $comment);
     $returnValue = new core_kernel_rules_Term($SPXResource->getUri());
     $subjectProperty = new core_kernel_classes_Property(PROPERTY_TERM_SPX_SUBJET, __METHOD__);
     $predicateProperty = new core_kernel_classes_Property(PROPERTY_TERM_SPX_PREDICATE, __METHOD__);
     $returnValue->setPropertyValue($subjectProperty, $subject->getUri());
     $returnValue->setPropertyValue($predicateProperty, $predicate->getUri());
     return $returnValue;
 }
 /**
  * (non-PHPdoc)
  * @see \oat\generis\model\data\PermissionInterface::onResourceCreated()
  */
 public function onResourceCreated(\core_kernel_classes_Resource $resource)
 {
     $dbAccess = new DataBaseAccess();
     // verify resource is created
     $permissions = $dbAccess->getResourcePermissions($resource->getUri());
     if (empty($permissions)) {
         // treat resources as classes without parent classes
         $class = new \core_kernel_classes_Class($resource);
         foreach (array_merge($resource->getTypes(), $class->getParentClasses()) as $parent) {
             foreach (AdminService::getUsersPermissions($parent->getUri()) as $userUri => $rights) {
                 $dbAccess->addPermissions($userUri, $resource->getUri(), $rights);
             }
         }
     }
 }
 /**
  * Short description of method buildStatusImageURI
  *
  * @access public
  * @author Somsack Sipasseuth, <*****@*****.**>
  * @param  Resource status
  * @return string
  */
 public static function buildStatusImageURI(core_kernel_classes_Resource $status)
 {
     $returnValue = (string) '';
     $baseURI = 'img/status_';
     $statusName = '';
     switch ($status->getUri()) {
         case INSTANCE_PROCESSSTATUS_PAUSED:
             $statusName = 'paused';
             break;
         case INSTANCE_PROCESSSTATUS_RESUMED:
             $statusName = 'resumed';
             break;
         case INSTANCE_PROCESSSTATUS_FINISHED:
             $statusName = 'finished';
             break;
         case INSTANCE_PROCESSSTATUS_STARTED:
             $statusName = 'started';
             break;
         case INSTANCE_PROCESSSTATUS_CLOSED:
             $statusName = 'closed';
             break;
         case INSTANCE_PROCESSSTATUS_STOPPED:
             $statusName = 'stopped';
             break;
     }
     $returnValue = $baseURI . $statusName . '.png';
     return (string) $returnValue;
 }
Beispiel #10
0
 /**
  * Search results
  * The search is paginated and initiated by the datatable component.
  */
 public function search()
 {
     $params = $this->getRequestParameter('params');
     $query = $params['query'];
     $class = new core_kernel_classes_Class($params['rootNode']);
     $rows = $this->hasRequestParameter('rows') ? (int) $this->getRequestParameter('rows') : null;
     $page = $this->hasRequestParameter('page') ? (int) $this->getRequestParameter('page') : 1;
     $startRow = is_null($rows) ? 0 : $rows * ($page - 1);
     try {
         $results = SearchService::getSearchImplementation()->query($query, $class, $startRow, $rows);
         $totalPages = is_null($rows) ? 1 : ceil($results->getTotalCount() / $rows);
         $response = new StdClass();
         if (count($results) > 0) {
             foreach ($results as $uri) {
                 $instance = new core_kernel_classes_Resource($uri);
                 $instanceProperties = array('id' => $instance->getUri(), RDFS_LABEL => $instance->getLabel());
                 $response->data[] = $instanceProperties;
             }
         }
         $response->success = true;
         $response->page = empty($response->data) ? 0 : $page;
         $response->total = $totalPages;
         $response->records = count($results);
         $this->returnJson($response, 200);
     } catch (SyntaxException $e) {
         $this->returnJson(array('success' => false, 'msg' => $e->getUserMessage()));
     }
 }
Beispiel #11
0
 /**
  * Action dedicated to change the settings of the user (language, ...)
  */
 public function properties()
 {
     $myFormContainer = new tao_actions_form_UserSettings($this->getUserSettings());
     $myForm = $myFormContainer->getForm();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $currentUser = $this->userService->getCurrentUser();
             $userSettings = array(PROPERTY_USER_UILG => $myForm->getValue('ui_lang'), PROPERTY_USER_DEFLG => $myForm->getValue('data_lang'), PROPERTY_USER_TIMEZONE => $myForm->getValue('timezone'));
             $uiLang = new core_kernel_classes_Resource($myForm->getValue('ui_lang'));
             $dataLang = new core_kernel_classes_Resource($myForm->getValue('data_lang'));
             $userSettings[PROPERTY_USER_UILG] = $uiLang->getUri();
             $userSettings[PROPERTY_USER_DEFLG] = $dataLang->getUri();
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($currentUser);
             if ($binder->bind($userSettings)) {
                 \common_session_SessionManager::getSession()->refresh();
                 $uiLangCode = tao_models_classes_LanguageService::singleton()->getCode($uiLang);
                 $extension = common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
                 tao_helpers_I18n::init($extension, $uiLangCode);
                 $this->setData('message', __('Settings updated'));
                 $this->setData('reload', true);
             }
         }
     }
     $userLabel = $this->userService->getCurrentUser()->getLabel();
     $this->setData('formTitle', sprintf(__("My settings (%s)"), __($userLabel)));
     $this->setData('myForm', $myForm->render());
     //$this->setView('form.tpl');
     $this->setView('form/settings_user.tpl');
 }
 /**
  * Manage permissions
  */
 protected function adminPermissions()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     $accessRights = AdminService::getUsersPermissions($resource->getUri());
     $userList = $this->getUserList();
     $roleList = $this->getRoleList();
     $this->setData('privileges', PermissionProvider::getRightLabels());
     $userData = array();
     foreach (array_keys($accessRights) as $uri) {
         if (isset($userList[$uri])) {
             $userData[$uri] = array('label' => $userList[$uri], 'isRole' => false);
             unset($userList[$uri]);
         } elseif (isset($roleList[$uri])) {
             $userData[$uri] = array('label' => $roleList[$uri], 'isRole' => true);
             unset($roleList[$uri]);
         } else {
             \common_Logger::d('unknown user ' . $uri);
         }
     }
     $this->setData('users', $userList);
     $this->setData('roles', $roleList);
     $this->setData('userPrivileges', $accessRights);
     $this->setData('userData', $userData);
     $this->setData('uri', $resource->getUri());
     $this->setData('label', _dh($resource->getLabel()));
     $this->setView('AdminAccessController/index.tpl');
 }
 /**
  *
  * @param unknown $userId
  * @param core_kernel_classes_Resource $assembly
  * @return taoDelivery_models_classes_execution_KVDeliveryExecution
  */
 public static function spawn(common_persistence_KeyValuePersistence $persistence, $userId, core_kernel_classes_Resource $assembly)
 {
     $identifier = self::DELIVERY_EXECUTION_PREFIX . common_Utils::getNewUri();
     $de = new self($persistence, $identifier, array(RDFS_LABEL => $assembly->getLabel(), PROPERTY_DELVIERYEXECUTION_DELIVERY => $assembly->getUri(), PROPERTY_DELVIERYEXECUTION_SUBJECT => $userId, PROPERTY_DELVIERYEXECUTION_START => time(), PROPERTY_DELVIERYEXECUTION_STATUS => INSTANCE_DELIVERYEXEC_ACTIVE));
     $de->save();
     return $de;
 }
 /**
  * Short description of method remove
  *
  * @access public
  * @author Jehan Bihin, <*****@*****.**>
  * @param  string $roleUri
  * @param  string $accessUri
  * @return mixed
  */
 public function remove($roleUri, $accessUri)
 {
     $module = new core_kernel_classes_Resource($accessUri);
     $role = new core_kernel_classes_Class($roleUri);
     $accessProperty = new core_kernel_classes_Property(funcAcl_models_classes_AccessService::PROPERTY_ACL_GRANTACCESS);
     // Retrieve the module ID.
     $uri = explode('#', $module->getUri());
     list($type, $extId, $modId) = explode('_', $uri[1]);
     // access via extension?
     $extAccess = funcAcl_helpers_Cache::getExtensionAccess($extId);
     if (in_array($roleUri, $extAccess)) {
         // remove access to extension
         $extUri = $this->makeEMAUri($extId);
         funcAcl_models_classes_ExtensionAccessService::singleton()->remove($roleUri, $extUri);
         // add access to all other controllers
         foreach (funcAcl_helpers_Model::getModules($extId) as $eModule) {
             if (!$module->equals($eModule)) {
                 $this->add($roleUri, $eModule->getUri());
                 $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $eModule->getUri()));
                 //$role->setPropertyValue($accessProperty, $eModule->getUri());
             }
         }
         //funcAcl_helpers_Cache::flushExtensionAccess($extId);
     }
     // Remove the access to the module for this role.
     $role->removePropertyValue($accessProperty, $module->getUri());
     $this->getEventManager()->trigger(new AccessRightRemovedEvent($roleUri, $accessUri));
     funcAcl_helpers_Cache::cacheModule($module);
     // Remove the access to the actions corresponding to the module for this role.
     foreach (funcAcl_helpers_Model::getActions($module) as $actionResource) {
         funcAcl_models_classes_ActionAccessService::singleton()->remove($role->getUri(), $actionResource->getUri());
     }
     funcAcl_helpers_Cache::cacheModule($module);
 }
 public function getResourceDescription(core_kernel_classes_Resource $resource, $fromDefinition = true)
 {
     $returnValue = new stdClass();
     $properties = array();
     if ($fromDefinition) {
         $types = $resource->getTypes();
         foreach ($types as $type) {
             foreach ($type->getProperties(true) as $property) {
                 //$this->$$property->getUri() = array($property->getLabel(),$this->getPropertyValues());
                 $properties[$property->getUri()] = $property;
             }
         }
         //var_dump($properties);
         $properties = array_unique($properties);
         $propertiesValues = $resource->getPropertiesValues($properties);
         if (count($propertiesValues) == 0) {
             throw new common_exception_NoContent();
         }
         $propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($propertiesValues);
     } else {
         $triples = $resource->getRdfTriples();
         if (count($triples) == 0) {
             throw new common_exception_NoContent();
         }
         foreach ($triples as $triple) {
             $properties[$triple->predicate][] = common_Utils::isUri($triple->object) ? new core_kernel_classes_Resource($triple->object) : new core_kernel_classes_Literal($triple->object);
         }
         $propertiesValuesStdClasses = $this->propertiesValuestoStdClasses($properties);
     }
     $returnValue->uri = $resource->getUri();
     $returnValue->properties = $propertiesValuesStdClasses;
     return $returnValue;
 }
Beispiel #16
0
 /**
  * Builds a service call parameter from it's serialized form
  *
  * @param core_kernel_classes_Resource $resource
  * @return tao_models_classes_service_Parameter
  */
 public static function fromResource(core_kernel_classes_Resource $resource)
 {
     $values = $resource->getPropertiesValues(array(PROPERTY_ACTUALPARAMETER_FORMALPARAMETER, PROPERTY_ACTUALPARAMETER_CONSTANTVALUE, PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE));
     if (count($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]) != 1) {
         throw new common_exception_InconsistentData('Actual variable ' . $resource->getUri() . ' missing formal parameter');
     }
     if (count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) + count($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]) != 1) {
         throw new common_exception_InconsistentData('Actual variable ' . $resource->getUri() . ' invalid, ' . count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) . ' constant values and ' . count($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]) . ' process variables');
     }
     if (count($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]) > 0) {
         $param = new tao_models_classes_service_ConstantParameter(current($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]), current($values[PROPERTY_ACTUALPARAMETER_CONSTANTVALUE]));
     } else {
         $param = new tao_models_classes_service_VariableParameter(current($values[PROPERTY_ACTUALPARAMETER_FORMALPARAMETER]), current($values[PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE]));
     }
     return $param;
 }
Beispiel #17
0
 /**
  * Short description of method exec
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  Resource resource
  * @param  string command
  * @return string
  */
 public static function exec(core_kernel_classes_Resource $resource, $command)
 {
     $returnValue = (string) '';
     $username = "";
     $password = "";
     $repository = null;
     try {
         if (empty($command)) {
             throw new Exception(__CLASS__ . ' -> ' . __FUNCTION__ . '() : $command_ must be specified');
         }
         //get context variables
         if ($resource instanceof core_kernel_versioning_File) {
             $repository = $resource->getRepository();
         } else {
             if ($resource instanceof core_kernel_versioning_Repository) {
                 $repository = $resource;
             } else {
                 throw new Exception('The first parameter (resource) should be a File or a Repository');
             }
         }
         if (is_null($repository)) {
             throw new Exception('Unable to find the repository to work with for the reference resource (' . $resource->getUri() . ')');
         }
         $username = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_LOGIN));
         $password = $repository->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PASSWORD));
         $returnValue = shell_exec('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
         //                var_dump('svn --username ' . $username . ' --password ' . $password . ' ' . $command);
         //                var_dump($returnValue);
     } catch (Exception $e) {
         die('Error code `svn_error_command` in ' . $e->getMessage());
     }
     return (string) $returnValue;
 }
 /**
  * Short description of method createOperation
  *
  * @access public
  * @author firstname and lastname of author, <*****@*****.**>
  * @param  Term term1
  * @param  Term term2
  * @param  Resource operator
  * @return core_kernel_rules_Operation
  */
 public static function createOperation(core_kernel_rules_Term $term1, core_kernel_rules_Term $term2, core_kernel_classes_Resource $operator)
 {
     $returnValue = null;
     $operationClass = new core_kernel_classes_Class(CLASS_OPERATION, __METHOD__);
     $label = 'Def Operation Label ' . $term1->getLabel() . ' ' . $operator->getLabel() . ' ' . $term2->getLabel();
     $comment = 'Def Operation Comment ' . $term1->getUri() . ' ' . $operator->getUri() . ' ' . $term2->getUri();
     $operatorProperty = new core_kernel_classes_Property(PROPERTY_OPERATION_OPERATOR, __METHOD__);
     $firstOperand = new core_kernel_classes_Property(PROPERTY_OPERATION_FIRST_OP, __METHOD__);
     $secondOperand = new core_kernel_classes_Property(PROPERTY_OPERATION_SECND_OP, __METHOD__);
     $termOperationInstance = core_kernel_classes_ResourceFactory::create($operationClass, $label, $comment);
     $returnValue = new core_kernel_rules_Operation($termOperationInstance->getUri());
     $returnValue->debug = __METHOD__;
     $returnValue->setPropertyValue($operatorProperty, $operator->getUri());
     $returnValue->setPropertyValue($firstOperand, $term1->getUri());
     $returnValue->setPropertyValue($secondOperand, $term2->getUri());
     return $returnValue;
 }
 /**
  * @requiresRight id WRITE
  */
 public function commitResource()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     // prevent escaping on input
     $message = isset($_POST['message']) ? $_POST['message'] : '';
     $revision = $this->getRevisionService()->commit($resource->getUri(), $message);
     $this->returnJson(array('success' => true, 'id' => $revision->getVersion(), 'modified' => \tao_helpers_Date::displayeDate($revision->getDateCreated()), 'author' => UserHelper::renderHtmlUser($revision->getAuthorId()), 'message' => $revision->getMessage(), 'commitMessage' => __('%s has been committed', $resource->getLabel())));
 }
 /**
  * Creates a new simple delivery
  * 
  * @param core_kernel_classes_Class $deliveryClass
  * @param core_kernel_classes_Resource $test
  * @param string $label
  * @return common_report_Report
  */
 public function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label)
 {
     common_Logger::i('Creating ' . $label . ' with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel());
     $contentClass = new core_kernel_classes_Class(CLASS_SIMPLE_DELIVERYCONTENT);
     $content = $contentClass->createInstanceWithProperties(array(PROPERTY_DELIVERYCONTENT_TEST => $test->getUri()));
     $report = TemplateAssemblyService::singleton()->createAssemblyByContent($deliveryClass, $content, array(RDFS_LABEL => $label));
     $content->delete();
     return $report;
 }
 protected function logoutUser()
 {
     if (!is_null($this->currentUser)) {
         $loginProperty = new core_kernel_classes_Property(PROPERTY_USER_LOGIN);
         $this->out("logout " . $this->currentUser->getOnePropertyValue($loginProperty) . ' "' . $this->currentUser->getUri() . '"', true);
         $this->userService->logout();
         $this->currentUser = null;
     }
 }
 /**
  *
  * @param common_persistence_KeyValuePersistence $persistence
  * @param unknown $userId
  * @param core_kernel_classes_Resource $assembly
  * @return DeliveryExecution
  */
 public static function spawn(common_persistence_KeyValuePersistence $persistence, $userId, core_kernel_classes_Resource $assembly)
 {
     $identifier = self::DELIVERY_EXECUTION_PREFIX . common_Utils::getNewUri();
     $params = array(RDFS_LABEL => $assembly->getLabel(), PROPERTY_DELVIERYEXECUTION_DELIVERY => $assembly->getUri(), PROPERTY_DELVIERYEXECUTION_SUBJECT => $userId, PROPERTY_DELVIERYEXECUTION_START => microtime(), PROPERTY_DELVIERYEXECUTION_STATUS => InterfaceDeliveryExecution::STATE_ACTIVE);
     $kvDe = new static($persistence, $identifier, $params);
     $kvDe->save();
     $de = new DeliveryExecution($kvDe);
     return $de;
 }
 public function getTokenizer()
 {
     $tokenizerUri = $this->getUniquePropertyValue(new \core_kernel_classes_Property("http://www.tao.lu/Ontologies/TAO.rdf#IndexTokenizer"));
     $tokenizer = new \core_kernel_classes_Resource($tokenizerUri);
     $implClass = (string) $tokenizer->getUniquePropertyValue(new \core_kernel_classes_Property("http://www.tao.lu/Ontologies/TAO.rdf#TokenizerClass"));
     if (!class_exists($implClass)) {
         throw new \common_exception_Error('Tokenizer class "' . $implClass . '" not found for ' . $tokenizer->getUri());
     }
     return new $implClass();
 }
 protected static function getParamName(core_kernel_classes_Resource $paramDefinition)
 {
     try {
         $paramKey = common_cache_FileCache::singleton()->get(self::CACHE_PREFIX_PARAM_NAME . urlencode($paramDefinition->getUri()));
     } catch (common_cache_NotFoundException $e) {
         $paramKey = common_Utils::fullTrim($paramDefinition->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_FORMALPARAMETER_NAME)));
         common_cache_FileCache::singleton()->put($paramKey, self::CACHE_PREFIX_PARAM_NAME . urlencode($paramDefinition->getUri()));
     }
     return $paramKey;
 }
 /**
  * (non-PHPdoc)
  * 
  * @see taoTests_models_classes_TestModel::getAuthoring()
  */
 public function getAuthoring(core_kernel_classes_Resource $content)
 {
     common_Logger::i('Generating form for delivery content ' . $content->getUri());
     $widget = new Renderer($this->extension->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
     $form = new taoSimpleDelivery_actions_form_ContentForm($this->getClass(), $content);
     $widget->setData('formContent', $form->getForm()->render());
     $widget->setData('saveUrl', _url('save', 'Authoring', 'taoSimpleDelivery'));
     $widget->setData('formId', $form->getForm()->getName());
     return $widget->render();
 }
 /**
  * (non-PHPdoc)
  * @see taoDelivery_models_classes_execution_Service::getUserExecutions()
  */
 public function getUserExecutions(core_kernel_classes_Resource $compiled, $userUri)
 {
     $executionClass = new core_kernel_classes_Class(CLASS_DELVIERYEXECUTION);
     $instances = $executionClass->searchInstances(array(PROPERTY_DELVIERYEXECUTION_SUBJECT => $userUri, PROPERTY_DELVIERYEXECUTION_DELIVERY => $compiled->getUri()), array('like' => false));
     $deliveryExecutions = array();
     foreach ($instances as $resource) {
         $deliveryExecutions[] = new taoDelivery_models_classes_execution_OntologyDeliveryExecution($resource->getUri());
     }
     return $deliveryExecutions;
 }
 /**
  * (non-PHPdoc)
  * @see \oat\generis\model\data\PermissionInterface::onResourceCreated()
  */
 public function onResourceCreated(\core_kernel_classes_Resource $resource)
 {
     $dbAccess = new DataBaseAccess();
     // test if class
     $class = new \core_kernel_classes_Class($resource);
     foreach (array_merge($resource->getTypes(), $class->getParentClasses()) as $parent) {
         foreach (AdminService::getUsersPermissions($parent->getUri()) as $userUri => $rights) {
             $dbAccess->addPermissions($userUri, $resource->getUri(), $rights);
         }
     }
 }
 /**
  * Short description of method getResourceToTableId
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Resource resource
  * @return string
  */
 public static function getResourceToTableId(\core_kernel_classes_Resource $resource)
 {
     $returnValue = (string) '';
     $dbWrapper = \core_kernel_classes_DbWrapper::singleton();
     $query = 'SELECT "id" FROM "resource_to_table" WHERE "uri"=?';
     $result = $dbWrapper->query($query, array($resource->getUri()));
     if ($row = $result->fetch()) {
         $returnValue = $row['id'];
     }
     return (string) $returnValue;
 }
 private function getRdfTriples(\core_kernel_classes_Resource $resource, $usingRestrictionOn = "object")
 {
     $returnValue = null;
     $dbWrapper = \core_kernel_classes_DbWrapper::singleton();
     $namespaces = \common_ext_NamespaceManager::singleton()->getAllNamespaces();
     $namespace = $namespaces[substr($resource->getUri(), 0, strpos($resource->getUri(), '#') + 1)];
     $query = 'SELECT * FROM "statements" WHERE "' . $usingRestrictionOn . '" = ? order by modelid ';
     $result = $dbWrapper->query($query, array($resource->getUri()));
     $returnValue = new \core_kernel_classes_ContainerCollection(new \common_Object(__METHOD__));
     while ($statement = $result->fetch()) {
         $triple = new \core_kernel_classes_Triple();
         $triple->modelid = $statement["modelid"];
         $triple->subject = $statement["subject"];
         $triple->predicate = $statement["predicate"];
         $triple->object = $statement["object"];
         $triple->id = $statement["id"];
         $triple->lg = $statement["l_language"];
         $returnValue->add($triple);
     }
     return $returnValue;
 }
 /**
  * Manage permissions
  * @requiresRight id GRANT
  */
 public function adminPermissions()
 {
     $resource = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
     $accessRights = AdminService::getUsersPermissions($resource->getUri());
     $this->setData('privileges', PermissionProvider::getRightLabels());
     $users = array();
     $roles = array();
     foreach ($accessRights as $uri => $privileges) {
         $identity = new \core_kernel_classes_Resource($uri);
         if ($identity->isInstanceOf(\tao_models_classes_RoleService::singleton()->getRoleClass())) {
             $roles[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges);
         } else {
             $users[$uri] = array('label' => $identity->getLabel(), 'privileges' => $privileges);
         }
     }
     $this->setData('users', $users);
     $this->setData('roles', $roles);
     $this->setData('isClass', $resource->isClass());
     $this->setData('uri', $resource->getUri());
     $this->setData('label', _dh($resource->getLabel()));
     $this->setView('AdminAccessController/index.tpl');
 }