public function setUp() { parent::setUp(); TaoPhpUnitTestRunner::initTest(); $class = new core_kernel_classes_Class(CLASS_OAUTH_CONSUMER); $this->credentials = $class->createInstanceWithProperties(array(RDFS_LABEL => 'test_credentials', PROPERTY_OAUTH_KEY => 'testcase_12345', PROPERTY_OAUTH_SECRET => 'secret_12345')); }
/** * tests initialization */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $oauthClass = new core_kernel_classes_Class(CLASS_OAUTH_CONSUMER); $resource = $oauthClass->createInstanceWithProperties(array(PROPERTY_OAUTH_KEY => 'test_key', PROPERTY_OAUTH_SECRET => md5(rand()))); $this->oauthCustomer = new tao_models_classes_oauth_Credentials($resource); }
/** * * @author Lionel Lecaque, lionel@taotesting.com */ private function migrateDeliveryToTemplate() { $deliveryClass = new core_kernel_classes_Class(TAO_DELIVERY_CLASS); foreach ($deliveryClass->getInstances(true) as $delivery) { self::switchType($delivery, CLASS_DELIVERY_TEMPLATE); } }
public function getData() { if (!tao_helpers_Request::isAjax()) { throw new common_exception_IsAjaxAction(__FUNCTION__); } if ($this->hasRequestParameter('classUri')) { $classUri = tao_helpers_Uri::decode($this->getRequestParameter('classUri')); $class = new core_kernel_classes_Class($classUri); $hideNode = true; } elseif ($this->hasRequestParameter('rootNode')) { $class = new core_kernel_classes_Class($this->getRequestParameter('rootNode')); $hideNode = false; } else { throw new common_Exception('Missing node information for ' . __FUNCTION__); } $openNodes = array($class->getUri()); if ($this->hasRequestParameter('openNodes') && is_array($this->getRequestParameter('openNodes'))) { $openNodes = array_merge($openNodes, $this->getRequestParameter('openNodes')); } $limit = $this->hasRequestParameter('limit') ? $this->getRequestParameter('limit') : self::DEFAULT_LIMIT; $offset = $this->hasRequestParameter('offset') ? $this->getRequestParameter('offset') : 0; $showInst = $this->hasRequestParameter('hideInstances') ? !$this->getRequestParameter('hideInstances') : true; $factory = new tao_models_classes_GenerisTreeFactory(); $array = $factory->buildTree($class, $showInst, $openNodes, $limit, $offset); if ($hideNode) { $array = isset($array['children']) ? $array['children'] : array(); } echo json_encode($array); }
/** * create a new QTI item * * @requiresRight id WRITE */ public function createItem() { if (!\tao_helpers_Request::isAjax()) { throw new \Exception("wrong request mode"); } $clazz = new \core_kernel_classes_Resource($this->getRequestParameter('id')); if ($clazz->isClass()) { $clazz = new \core_kernel_classes_Class($clazz); } else { foreach ($clazz->getTypes() as $type) { // determine class from selected instance $clazz = $type; break; } } $service = \taoItems_models_classes_ItemsService::singleton(); $label = $service->createUniqueLabel($clazz); $item = $service->createInstance($clazz, $label); if (!is_null($item)) { $service->setItemModel($item, new \core_kernel_classes_Resource(ItemModel::MODEL_URI)); $response = array('label' => $item->getLabel(), 'uri' => $item->getUri()); } else { $response = false; } $this->returnJson($response); }
/** * initialize a test method */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $activityExecutionClass = new core_kernel_classes_Class(CLASS_ACTIVITY_EXECUTION); $this->activityExecution = $activityExecutionClass->createInstance('test'); $this->service = wfEngine_models_classes_RecoveryService::singleton(); }
/** * Maps a fuly qualified or abbreviated lti role * to an existing tao role * * @param string $role * @throws common_Exception * @throws common_exception_Error * @return core_kernel_classes_Resource the tao role or null */ public static function mapLTIRole2TaoRole($role) { $taoRole = null; if (filter_var($role, FILTER_VALIDATE_URL)) { // url found $taoRole = new core_kernel_classes_Resource($role); } else { // if not fully qualified prepend LIS context role NS if (strtolower(substr($role, 0, 4)) !== 'urn:') { $role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role; } list($prefix, $nid, $nss) = explode(':', $role, 3); if ($nid != 'lti') { common_Logger::w('Non LTI URN ' . $role . ' passed via LTI'); } $urn = 'urn:' . strtolower($nid) . ':' . $nss; // search for fitting role $class = new core_kernel_classes_Class(CLASS_LTI_ROLES); $cand = $class->searchInstances(array(PROPERTY_LTI_ROLES_URN => $urn)); if (count($cand) > 1) { throw new common_exception_Error('Multiple instances share the URN ' . $urn); } if (count($cand) == 1) { $taoRole = current($cand); } else { common_Logger::w('Unknown LTI role with urn: ' . $urn); } } if (!is_null($taoRole) && $taoRole->exists()) { return $taoRole->getUri(); } else { return null; } }
/** * @param $params * @return Report */ public function __invoke($params) { $deliveryMonitoringService = $this->getServiceLocator()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $deliveries = $deliveryClass->getInstances(true); $deliveryExecutionService = \taoDelivery_models_classes_execution_ServiceProxy::singleton(); $this->report = new Report(Report::TYPE_INFO, 'Updating of delivery monitoring cache...'); foreach ($deliveries as $delivery) { if ($delivery->exists()) { $deliveryExecutions = $deliveryExecutionService->getExecutionsByDelivery($delivery); foreach ($deliveryExecutions as $deliveryExecution) { $data = $deliveryMonitoringService->getData($deliveryExecution, true); if ($deliveryMonitoringService->save($data)) { $this->report->add(new Report(Report::TYPE_SUCCESS, "Delivery execution {$deliveryExecution->getUri()} successfully updated.")); } else { $errors = $data->getErrors(); $errorsStr = " " . PHP_EOL; array_walk($errors, function ($val, $key) use(&$errorsStr) { $errorsStr .= " {$key} - {$val}" . PHP_EOL; }); $this->report->add(new Report(Report::TYPE_ERROR, "Delivery execution {$deliveryExecution->getUri()} was not updated. {$errorsStr}")); } } } } return $this->report; }
/** * tests initialization */ public function setUp() { TaoTestRunner::initTest(); $resultsService = taoResults_models_classes_ResultsService::singleton(); $this->resultsService = $resultsService; $this->statsService = taoResults_models_classes_StatisticsService::singleton(); $this->reportService = taoResults_models_classes_ReportService::singleton(); //create an activity execution $activityExecutionClass = new core_kernel_classes_Class(CLASS_ACTIVITY_EXECUTION); //create an activity definition $activityDefinitionClass = new core_kernel_classes_Class(CLASS_ACTIVITIES); $this->activityExecution = $activityExecutionClass->createInstance("MyActivityExecution"); //links the activity execution to the activity definition $this->activityDefinition = $activityDefinitionClass->createInstance("MyActivityDefinition"); $this->activityExecution->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITY_EXECUTION_ACTIVITY), $this->activityDefinition->getUri()); //links the call of service to the activity execution $interactiveServiceClass = new core_kernel_classes_Class(CLASS_CALLOFSERVICES); $this->interactiveService = $interactiveServiceClass->createInstance("MyInteractiveServiceCall"); $this->activityDefinition->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $this->interactiveService->getUri()); $this->interactiveService->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION), "#interactiveServiceDefinition"); $deliveryResult = new core_kernel_classes_Resource("#MyDeliveryResult"); $variableIDentifier = "GRADE"; $value = 0.4; //create a small delivery $this->subClass = $this->resultsService->createSubClass(new core_kernel_classes_Class(TAO_DELIVERY_RESULT), "UnitTestingGenClass"); $this->delivery = $this->subClass->createInstance("UnitTestingGenDelivery"); $this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_DELIVERY), "#unitTestResultOfDelivery"); $this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_SUBJECT), "#unitTestResultOfSubject"); $this->delivery->setPropertyValue(new core_kernel_classes_Property(PROPERTY_RESULT_OF_PROCESS), "#unitTestResultOfProcess"); //stores a grade in this delivery $this->grade = $this->resultsService->storeGrade($this->delivery, $this->activityExecution, $variableIDentifier, $value); $this->response = $this->resultsService->storeResponse($this->delivery, $this->activityExecution, $variableIDentifier, $value); }
/** * Creates a new delivery * * @param core_kernel_classes_Class $deliveryClass * @param core_kernel_classes_Resource $test * @param array $properties Array of properties of delivery * @return common_report_Report */ public static function create(\core_kernel_classes_Class $deliveryClass, \core_kernel_classes_Resource $test, $properties = array()) { \common_Logger::i('Creating delivery with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel()); $storage = new TrackedStorage(); $testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test); $compiler = new $testCompilerClass($test, $storage); $report = $compiler->compile(); if ($report->getType() == \common_report_Report::TYPE_SUCCESS) { //$tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone()); $tz = new \DateTimeZone('UTC'); if (!empty($properties[TAO_DELIVERY_START_PROP])) { $dt = new \DateTime($properties[TAO_DELIVERY_START_PROP], $tz); $properties[TAO_DELIVERY_START_PROP] = (string) $dt->getTimestamp(); } if (!empty($properties[TAO_DELIVERY_END_PROP])) { $dt = new \DateTime($properties[TAO_DELIVERY_END_PROP], $tz); $properties[TAO_DELIVERY_END_PROP] = (string) $dt->getTimestamp(); } $serviceCall = $report->getData(); $properties[PROPERTY_COMPILEDDELIVERY_DIRECTORY] = $storage->getSpawnedDirectoryIds(); $compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties); $report->setData($compilationInstance); } return $report; }
/** * * @author Lionel Lecaque, lionel@taotesting.com */ private function migrateCompiledDeliveryToAssembly() { $compiledDeliveryClass = new core_kernel_classes_Class(self::OLD_COMPILED_DELIVERY); $props = array(self::OLD_PROPERTY_COMPILEDDELIVERY_DELIVERY => PROPERTY_COMPILEDDELIVERY_DELIVERY, self::OLD_PROPERTY_COMPILEDDELIVERY_TIME => PROPERTY_COMPILEDDELIVERY_TIME, self::OLD_PROPERTY_COMPILEDDELIVERY_RUNTIME => PROPERTY_COMPILEDDELIVERY_RUNTIME, self::OLD_PROPERTY_COMPILEDDELIVERY_DIRECTORY => PROPERTY_COMPILEDDELIVERY_DIRECTORY); foreach ($compiledDeliveryClass->getInstances(true) as $compiledDelivery) { taoUpdate_scripts_update_UpdateDeliveryModel::switchType($compiledDelivery, TAO_DELIVERY_CLASS); $values = $compiledDelivery->getPropertiesValues(array_keys($props)); foreach ($values as $prop => $val) { //compiled time was not always set in 2.5 so I set a 0 will appear as 1970 in UI if ($prop == self::OLD_PROPERTY_COMPILEDDELIVERY_TIME && empty($val)) { if (isset($props[$prop])) { $compiledDelivery->setPropertyValue(new core_kernel_classes_Property($props[$prop]), '0'); } } if (!empty($val) && $prop != self::OLD_PROPERTY_COMPILEDDELIVERY_DIRECTORY) { if (isset($props[$prop])) { $compiledDelivery->removePropertyValues(new core_kernel_classes_Property($prop)); $compiledDelivery->setPropertiesValues(array($props[$prop] => $val)); } else { $this->info('could not found property ' . $prop); } //copy property value from templace to assembly if ($prop == self::OLD_PROPERTY_COMPILEDDELIVERY_DELIVERY) { if (isset($val[0]) && $val[0] instanceof core_kernel_classes_Resource) { $this->copyPropertyValuesFromTemplateToAssembly($val[0], $compiledDelivery); } } } } } }
public static function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile) { $folder = tao_helpers_File::createTempDir(); $zip = new ZipArchive(); if ($zip->open($archiveFile) === true) { if ($zip->extractTo($folder)) { $returnValue = $folder; } $zip->close(); } $manifestPath = $folder . self::MANIFEST_FILE; if (!file_exists($manifestPath)) { return common_report_Report::createFailure(__('Manifest not found in assembly')); } $manifest = json_decode(file_get_contents($manifestPath), true); $label = $manifest['label']; $serviceCall = tao_models_classes_service_ServiceCall::fromString(base64_decode($manifest['runtime'])); $dirs = $manifest['dir']; $resultServer = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer(); try { foreach ($dirs as $id => $relPath) { tao_models_classes_service_FileStorage::singleton()->import($id, $folder . $relPath); } $delivery = $deliveryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => array_keys($dirs), PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology(), TAO_DELIVERY_RESULTSERVER_PROP => $resultServer)); $report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $label), $delivery); } catch (Exception $e) { if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) { $delivery->delete(); } $report = common_report_Report::createFailure(__('Unkown error during impoort')); } return $report; }
/** * (non-PHPdoc) * @see common_user_auth_Adapter::authenticate() */ public function authenticate() { $userClass = new core_kernel_classes_Class(CLASS_GENERIS_USER); $filters = array(PROPERTY_USER_LOGIN => $this->username); $options = array('like' => false, 'recursive' => true); $users = $userClass->searchInstances($filters, $options); if (count($users) > 1) { // Multiple users matching throw new common_exception_InconsistentData("Multiple Users found with the same login '" . $this->username . "'."); } if (empty($users)) { // fake code execution to prevent timing attacks $label = new core_kernel_classes_Property(RDFS_LABEL); $hash = $label->getUniquePropertyValue($label); if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) { throw new core_kernel_users_InvalidLoginException(); } // should never happen, added for integrity throw new core_kernel_users_InvalidLoginException(); } $userResource = current($users); $hash = $userResource->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_USER_PASSWORD)); if (!core_kernel_users_Service::getPasswordHash()->verify($this->password, $hash)) { throw new core_kernel_users_InvalidLoginException(); } return new core_kernel_users_GenerisUser($userResource); }
/** * Starts the import based on the form * * @param \core_kernel_classes_Class $class * @param \tao_helpers_form_Form $form * @return \common_report_Report $report */ public function import($class, $form) { //as upload may be called multiple times, we remove the session lock as soon as possible session_write_close(); try { $file = $form->getValue('source'); $service = MediaService::singleton(); $classUri = $class->getUri(); if (is_null($this->instanceUri) || $this->instanceUri === $classUri) { //if the file is a zip do a zip import if ($file['type'] !== 'application/zip') { if (!$service->createMediaInstance($file["uploaded_file"], $classUri, \tao_helpers_Uri::decode($form->getValue('lang')), $file["name"])) { $report = \common_report_Report::createFailure(__('Fail to import media')); } else { $report = \common_report_Report::createSuccess(__('Media imported successfully')); } } else { $zipImporter = new ZipImporter(); $report = $zipImporter->import($class, $form); } } else { if ($file['type'] !== 'application/zip') { $service->editMediaInstance($file["uploaded_file"], $this->instanceUri, \tao_helpers_Uri::decode($form->getValue('lang'))); $report = \common_report_Report::createSuccess(__('Media imported successfully')); } else { $report = \common_report_Report::createFailure(__('You can\'t upload a zip file as a media')); } } return $report; } catch (\Exception $e) { $report = \common_report_Report::createFailure($e->getMessage()); return $report; } }
public function initElements() { $class = $this->data['class']; if (!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); //create the element to select the import format $formatElt = \tao_helpers_form_FormFactory::getElement('test', 'Combobox'); $formatElt->setDescription(__('Select the test you want to publish to the test-takers')); $testClass = new \core_kernel_classes_Class(TAO_TEST_CLASS); $options = array(); $testService = \taoTests_models_classes_TestsService::singleton(); foreach ($testClass->getInstances(true) as $test) { try { $testItems = $testService->getTestItems($test); //Filter tests which has no items if (!empty($testItems)) { $options[$test->getUri()] = $test->getLabel(); } } catch (\Exception $e) { \common_Logger::w('Unable to load items for test ' . $test->getUri()); } } if (empty($options)) { throw new NoTestsException(); } $formatElt->setOptions($options); $formatElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($formatElt); }
/** * Short description of method getPreviousSteps * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource step * @return array */ public function getPreviousSteps(core_kernel_classes_Resource $step) { $returnValue = array(); $stepClass = new core_kernel_classes_Class(CLASS_STEP); $returnValue = $stepClass->searchInstances(array(PROPERTY_STEP_NEXT => $step), array('like' => false, 'recursive' => true)); return (array) $returnValue; }
/** * Returns the storage engine of the result server * * @param string $deliveryId * @throws \common_exception_Error * @return \taoResultServer_models_classes_ReadableResultStorage */ public function getResultStorage($deliveryId) { if (is_null($deliveryId)) { throw new \common_exception_Error(__('This delivery doesn\'t exists')); } $delivery = $this->getResource($deliveryId); $deliveryResultServer = $delivery->getOnePropertyValue($this->getProperty(self::PROPERTY_RESULT_SERVER)); if (is_null($deliveryResultServer)) { throw new \common_exception_Error(__('This delivery has no Result Server')); } $resultServerModel = $deliveryResultServer->getPropertyValues($this->getProperty(TAO_RESULTSERVER_MODEL_PROP)); if (is_null($resultServerModel)) { throw new \common_exception_Error(__('This delivery has no readable Result Server')); } $implementations = array(); foreach ($resultServerModel as $model) { $model = new \core_kernel_classes_Class($model); /** @var $implementationClass \core_kernel_classes_Literal*/ $implementationClass = $model->getOnePropertyValue($this->getProperty(TAO_RESULTSERVER_MODEL_IMPL_PROP)); if (!is_null($implementationClass) && class_exists($implementationClass->literal)) { $className = $implementationClass->literal; $implementations[] = new $className(); } } if (empty($implementations)) { throw new \common_exception_Error(__('This delivery has no readable Result Server')); } elseif (count($implementations) == 1) { return reset($implementations); } else { return new StorageAggregation($implementations); } }
protected function getPropertiesByClass(\core_kernel_classes_Class $type) { if (!isset($this->propertyCache[$type->getUri()])) { $this->propertyCache[$type->getUri()] = $type->getProperties(true); // alternativly use non recursiv and union with getPropertiesByClass of parentclasses } return $this->propertyCache[$type->getUri()]; }
public function setUp() { parent::setUp(); TaoPhpUnitTestRunner::initTest(); $rdfClass = new core_kernel_classes_Class(CLASS_GENERIS_RESOURCE); $this->class = $rdfClass->createSubClass('test class'); $this->property = $this->class->createProperty('test property'); }
/** * 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 importDeliveryResource(core_kernel_classes_Class $deliveryClass, $manifest) { $label = $manifest['label']; $dirs = $manifest['dir']; $serviceCall = tao_models_classes_service_ServiceCall::fromString(base64_decode($manifest['runtime'])); $resultServer = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer(); $delivery = $deliveryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => array_keys($dirs), PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology(), TAO_DELIVERY_RESULTSERVER_PROP => $resultServer)); return $delivery; }
public function findParallelFromActivityBackward(core_kernel_classes_Resource $activity) { $returnValue = null; //put the activity being searched in an array to prevent searching from it again in case of back connection $this->checkedActivities[] = $activity->getUri(); $connectorClass = new core_kernel_classes_Class(CLASS_CONNECTORS); $cardinalityClass = new core_kernel_classes_Class(CLASS_ACTIVITYCARDINALITY); $activityCardinalities = $cardinalityClass->searchInstances(array(PROPERTY_STEP_NEXT => $activity->getUri()), array('like' => false)); //note: count()>1 only $nextActivities = array_merge(array($activity->getUri()), array_keys($activityCardinalities)); $previousConnectors = $connectorClass->searchInstances(array(PROPERTY_STEP_NEXT => $nextActivities), array('like' => false)); //note: count()>1 only foreach ($previousConnectors as $connector) { if (in_array($connector->getUri(), array_keys($this->checkedConnectors))) { continue; } else { $this->checkedConnectors[$connector->getUri()] = $connector; } //get the type of the connector: $connectorType = $connector->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_TYPE)); if ($connectorType instanceof core_kernel_classes_Resource) { switch ($connectorType->getUri()) { case INSTANCE_TYPEOFCONNECTORS_PARALLEL: //parallel connector found: if ($this->jump == 0) { return $returnValue = $connector; } else { $this->jump--; } break; case INSTANCE_TYPEOFCONNECTORS_JOIN: //increment the class attribute $this->jump $this->jump++; } } //if the wanted parallel connector has not be found (i.e. no value returned so far): //get the previousActivityCollection and recursively execute the same function ON ONLY ONE of the previous branches (there would be several branches only in the case of a join, otherwise it should be one anyway: $previousActivity = $connector->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE)); //Note: the use of the property activity reference allow to jump to the "main" (in case of a join connector and successive conditionnal connectors) directly //if the previousActivity happens to have already been checked, jump it if (in_array($previousActivity->getUri(), $this->checkedActivities)) { continue; } else { $parallelConnector = $this->findParallelFromActivityBackward($previousActivity); if ($parallelConnector instanceof core_kernel_classes_Resource) { //found it: if ($this->jump != 0) { throw new Exception('parallel connector returned while the "jump value" is not null (' . $this->jump . ')'); } return $returnValue = $parallelConnector; } } } return $returnValue; //null }
public static function generateTesttakers($count = 1000) { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoGroups'); $topClass = new \core_kernel_classes_Class(TAO_SUBJECT_CLASS); $role = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY); $class = self::generateUsers($count, $topClass, $role, 'Test-Taker ', 'tt'); $groupClass = new \core_kernel_classes_Class(TAO_GROUP_CLASS); $group = $groupClass->createInstanceWithProperties(array(RDFS_LABEL => $class->getLabel(), TAO_GROUP_MEMBERS_PROP => $class->getInstances())); return $class; }
/** * returns a list of active FileSources * * @access public * @author Joel Bout, <*****@*****.**> * @return array * @deprecated */ public static function getFileSources() { $classRepository = new core_kernel_classes_Class(CLASS_GENERIS_VERSIONEDREPOSITORY); $resources = $classRepository->searchInstances(array(PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED => GENERIS_TRUE), array('like' => false)); $fileSystems = array(); foreach ($resources as $resource) { $fileSystems[] = new core_kernel_fileSystem_FileSystem($resource); } return $fileSystems; }
/** * Delete a subclass * * @access public * @author Joel Bout, <*****@*****.**> * @param Class clazz * @return boolean */ public function deleteClass(core_kernel_classes_Class $clazz) { $returnValue = (bool) false; if ($clazz->isSubClassOf($this->getRootClass()) && !$clazz->equals($this->getRootClass())) { $returnValue = $clazz->delete(); } else { common_Logger::w('Tried to delete class ' . $clazz->getUri() . ' as if it were a subclass of ' . $this->getRootClass()->getUri()); } return (bool) $returnValue; }
public function testIsFile() { $clazz = new core_kernel_classes_Class(CLASS_GENERIS_FILE); $instance = $clazz->createInstance('toto.txt', 'toto'); $fileNameProp = new core_kernel_classes_Property(PROPERTY_FILE_FILENAME); $instance->setPropertyValue($fileNameProp, 'file://toto.txt'); $this->assertTrue(core_kernel_file_File::isFile($instance)); $this->assertFalse(core_kernel_file_File::isFile($clazz)); $instance->delete(); }
public function createAssemblyFromServiceCall(core_kernel_classes_Class $deliveryClass, tao_models_classes_service_ServiceCall $serviceCall, $properties = array()) { $properties[PROPERTY_COMPILEDDELIVERY_TIME] = time(); $properties[PROPERTY_COMPILEDDELIVERY_RUNTIME] = $serviceCall->toOntology(); if (!isset($properties[TAO_DELIVERY_RESULTSERVER_PROP])) { $properties[TAO_DELIVERY_RESULTSERVER_PROP] = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer(); } $compilationInstance = $deliveryClass->createInstanceWithProperties($properties); return $compilationInstance; }
/** * tests initialization */ public function setUp() { TaoPhpUnitTestRunner::initTest(); $processDefinitionClass = new core_kernel_classes_Class(CLASS_PROCESS); $processDefinition = $processDefinitionClass->createInstance('process of Checker UnitTest', 'created for the unit test of process cloner'); if ($processDefinition instanceof core_kernel_classes_Resource) { $this->proc = $processDefinition; } $this->authoringService = wfAuthoring_models_classes_ProcessService::singleton(); }
/** * recursivly add permissions to a class and all instances */ public static function addPermissionToClass(\core_kernel_classes_Class $class, $userUri, $rights) { $dbAccess = new DataBaseAccess(); $dbAccess->addPermissions($userUri, $class->getUri(), $rights); foreach ($class->getInstances(false) as $instance) { $dbAccess->addPermissions($userUri, $instance->getUri(), $rights); } foreach ($class->getSubClasses(false) as $subclass) { self::addPermissionToClass($subclass, $userUri, $rights); } }
private function abandonDeliveryExecution() { $deliveryExecutionClass = new core_kernel_classes_Class(CLASS_DELVIERYEXECUTION); $statusProp = new core_kernel_classes_Property(PROPERTY_DELVIERYEXECUTION_STATUS); foreach ($deliveryExecutionClass->getInstances(true) as $execution) { $status = $execution->getOnePropertyValue($statusProp); if ($status == null || $status->getUri() == INSTANCE_DELIVERYEXEC_ACTIVE) { $execution->editPropertyValues($statusProp, 'http://www.tao.lu/Ontologies/TAODelivery.rdf#DeliveryExecutionStatusAbandoned'); } } }