/** * render the main layout */ public function index() { $uri = tao_helpers_Uri::decode($this->getRequestParameter('uri')); $links = array(); $class = new core_kernel_classes_Class(CLASS_LTI_CONSUMER); foreach ($class->getInstances() as $consumer) { $links[] = array('key' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_KEY)), 'secret' => $consumer->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_OAUTH_SECRET)), 'url' => $this->service->getLaunchUrl(array('delivery' => $uri))); } $this->setData('links', $links); $this->setData('launchUrl', $this->service->getLaunchUrl(array('delivery' => $uri))); $this->setData('consumers', $class->getInstances()); $this->setData('delivery', $uri); $this->setView('linkManagement.tpl', 'taoLti'); }
/** * * @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); } } } } } }
/** * @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; }
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); }
/** * get a formal parameter * @param string $key * @param string $value * @return core_kernel_classes_Resource */ private function getFormalParameter($key, $value) { foreach ($this->formalParamClass->getInstances(false) as $formalParam) { $name = $formalParam->getOnePropertyValue($this->formalParamNameProp); if (trim($key) == trim($name)) { $foundProcessVar = $this->getProcessVar(str_replace('^', '', $value)); if (!is_null($foundProcessVar)) { try { $processVar = $formalParam->getUniquePropertyValue($this->formalParamDefProcessVarProp); if ($foundProcessVar->getUri() == $processVar->getUri()) { return $formalParam; } } catch (common_Exception $ce) { } } try { if ($value == $formalParam->getUniquePropertyValue($this->formalParamDefConstantProp)) { return $formalParam; } } catch (common_Exception $ce) { } } } return null; }
/** * * @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 testResourceIterator() { $expected1 = array(); foreach ($this->topClass->getInstances(true) as $resource) { $expected1[] = $resource->getUri(); } sort($expected1); $iterator = new core_kernel_classes_ResourceIterator($this->topClass); $found1 = array(); foreach ($iterator as $instance) { $this->assertIsA($instance, 'core_kernel_classes_Resource'); $found1[] = $instance->getUri(); } sort($found1); $this->assertEquals($expected1, $found1); $found2 = array(); foreach ($iterator as $instance) { $found2[] = $instance->getUri(); } sort($found2); $this->assertEquals($expected1, $found2); $iterator = new core_kernel_classes_ResourceIterator($this->emptyClass); $this->assertFalse($iterator->valid()); $this->assertEquals('1#0', $iterator->key()); }
/** * 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'); } } }
private static function migrateAllResults() { $variableClass = new core_kernel_classes_Class("http://www.tao.lu/Ontologies/TAOResult.rdf#Variable"); $variables = $variableClass->getInstances(true); foreach ($variables as $variable) { $value = $variable->getUniquePropertyValue(new core_kernel_classes_Property(RDF_VALUE)); if (@unserialize($value) !== false) { $value = unserialize($value); $variable->editPropertyValues(new core_kernel_classes_Property(RDF_VALUE), array(base64_encode($value))); } } }
/** * Show the list of roles * @return void */ public function index() { $rolesc = new core_kernel_classes_Class(CLASS_ROLE); $roles = array(); foreach ($rolesc->getInstances(true) as $id => $r) { $roles[] = array('id' => $id, 'label' => $r->getLabel()); } usort($roles, function ($a, $b) { return strcmp($a['label'], $b['label']); }); $this->setData('roles', $roles); $this->setView('list.tpl'); }
protected function getAvailableImportHandlers() { $returnValue = parent::getAvailableImportHandlers(); $itemModelClass = new core_kernel_classes_Class(TAO_ITEM_MODEL_CLASS); foreach ($itemModelClass->getInstances() as $model) { $impl = taoItems_models_classes_ItemsService::singleton()->getItemModelImplementation($model); if (in_array('tao_models_classes_import_ImportProvider', class_implements($impl))) { foreach ($impl->getImportHandlers() as $handler) { array_unshift($returnValue, $handler); } } } return $returnValue; }
public function run() { $itemService = taoItems_models_classes_ItemsService::singleton(); $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS); $items = $itemClass->getInstances(true); foreach ($items as $item) { $itemModel = $itemService->getItemModel($item); if (!is_null($itemModel) && $itemModel->getUri() == ItemModel::MODEL_URI) { $this->out('qti item found: ' . $item->getLabel()); $this->convertQtiItem($item); } // break; } }
/** * Test the service factory: dynamical instantiation and single instance serving */ public function testMultiple() { $propClass = new core_kernel_classes_Class(RDF_PROPERTY); $q = "SELECT subject, count(object)\n FROM statements\n WHERE predicate = ?\n GROUP BY subject\n HAVING (count(object) > 1)"; foreach ($propClass->getInstances(true) as $property) { $property = new core_kernel_classes_Property($property); if (!$property->isMultiple() && !$property->isLgDependent()) { // bypass generis $result = core_kernel_classes_DbWrapper::singleton()->query($q, array($property->getUri())); while ($statement = $result->fetch()) { $this->fail($property->getUri() . ' has multiple values but is not multiple.'); } } } }
public function testCreateProcessMonitoringGrid() { //wfEngine_helpers_Monitoring_ProcessMonitoringGrid //wfEngine_helpers_Monitoring_TranslationProcessMonitoringGrid $processInstancesClass = new core_kernel_classes_Class(CLASS_PROCESSINSTANCES); $processExecutions = $processInstancesClass->getInstances(); $processMonitoringGrid = new wfAuthoring_helpers_Monitoring_TranslationProcessMonitoringGrid(array_keys($processExecutions)); /*var_dump($processMonitoringGrid->toArray()); var_dump($processMonitoringGrid->getGrid()->getColumnsModel());/*/ //wfEngine_helpers_Monitoring_ExecutionHistoryGrid //wfEngine_helpers_Monitoring_TranslationExecutionHistoryGrid if (!empty($processExecutions)) { $executionHistoryGrid = new wfAuthoring_helpers_Monitoring_TranslationExecutionHistoryGrid(reset($processExecutions)); //var_dump($executionHistoryGrid->toArray()); } }
public function testRemovePropertyValuesByLg() { $this->hardify(); $subject = $this->targetSubjectClass->createInstance("Hard Sub Subject (Unit Test)"); $subSubject = $this->targetSubjectSubClass->createInstance("Hard Sub Sub Subject (Unit Test)"); $this->setProperties(); foreach ($this->targetSubjectClass->getInstances() as $instance) { // Remove foreign single property $instance->removePropertyValueByLg(new core_kernel_classes_Property('http://www.tao.lu/Ontologies/generis.rdf#userDefLg'), 'FR'); $props = $instance->getPropertyValues(new core_kernel_classes_Property('http://www.tao.lu/Ontologies/generis.rdf#userDefLg')); $this->assertFalse(empty($props)); // Remove foreign multiple property $instance->removePropertyValueByLg(new core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAOGroup.rdf#Members'), 'FR'); $props = $instance->getPropertyValues(new core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAOGroup.rdf#Members')); $this->assertFalse(empty($props)); } }
public function run() { $oldClass = new core_kernel_classes_Class(self::OLD_CLASS); $newClass = new core_kernel_classes_Class(CLASS_GENERIS_FILE); $oldPath = new core_kernel_classes_Property(self::OLD_PROPERTY_PATH); $oldFS = new core_kernel_classes_Property(self::OLD_PROPERTY_FILESYSTEM); foreach ($oldClass->getInstances() as $file) { $file->setType($newClass); $values = $file->getPropertiesValues(array($oldPath, $oldFS)); if (count($values[self::OLD_PROPERTY_FILESYSTEM]) == 1 && count($values[self::OLD_PROPERTY_PATH]) == 1) { $file->setPropertiesValues(array(PROPERTY_FILE_FILEPATH => current($values[self::OLD_PROPERTY_PATH]), PROPERTY_FILE_FILESYSTEM => current($values[self::OLD_PROPERTY_FILESYSTEM]))); $file->removePropertyValues($oldPath); $file->removePropertyValues($oldFS); } else { common_Logger::w('Resource ' . $file->getUri() . ' is either already migrated or inconsistent'); } } }
/** * Get filter options of the tree form the HTTP paramters * - itemModel: filter by item model (or at least ensure a model is defined) * @return $propertyFilter */ private function getTreeFilter() { $propertyFilter = array(); if ($this->hasRequestParameter('itemModel')) { $propertyFilter = array(TAO_ITEM_MODEL_PROPERTY => tao_helpers_Uri::decode($this->getRequestParameter('itemModel'))); } else { //Get all item model values so we ensure the item has a model. //I know it would be better to be able to filter instances that don't have a model, //but the API is incomplete $itemModels = array(); $itemModelClass = new core_kernel_classes_Class(TAO_ITEM_MODEL_CLASS); foreach ($itemModelClass->getInstances() as $itemModel) { $itemModels[] = $itemModel->getUri(); } if (!empty($itemModels)) { $propertyFilter = array(TAO_ITEM_MODEL_PROPERTY => $itemModels); } } return $propertyFilter; }
/** * Call to launch export method of exporter * * php index.php 'oat\taoQtiItem\model\flyExporter\ExporterAction' $uri * * @param $params $params[0] is optional uri parameter * @return \common_report_Report */ public function __invoke($params) { try { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoItems'); $exporterService = $this->getServiceManager()->get(SimpleExporter::SERVICE_ID); $uri = isset($params[0]) ? $params[0] : null; if (!is_null($uri)) { $class = new \core_kernel_classes_Class($uri); if ($class->exists()) { $items = $class->getInstances(true); } else { throw new \Exception("Exporter needs a valid class uri."); } } $filename = $exporterService->export(isset($items) ? $items : $uri); return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, "\nExport end.\nCSV export is located at: " . $filename . "\n"); } catch (\Exception $e) { \common_Logger::w('Error during item metadata export: ' . $e->getMessage()); return new \common_report_Report(\common_report_Report::TYPE_ERROR, "\n" . $e->getMessage() . "\n"); } }
public function run() { common_log_Dispatcher::singleton()->init(array(array('class' => 'UDPAppender', 'host' => '127.0.0.1', 'port' => 5775, 'threshold' => 1))); // load the constants common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); common_ext_ExtensionsManager::singleton()->getExtensionById('wfEngine'); $deliveryClass = new core_kernel_classes_Class(TAO_DELIVERY_CLASS); foreach ($deliveryClass->getInstances(true) as $delivery) { $this->out('looking for compiled ' . $delivery->getLabel()); $workflow = $delivery->getOnePropertyValue(new core_kernel_classes_Property(self::OLD_DELIVERY_COMPILED)); if (!is_null($workflow) && $workflow instanceof core_kernel_classes_Resource) { $this->out('Compilation found for ' . $delivery->getLabel()); $compiled = $this->buildCompiledDelivery($delivery, $workflow); $delivery->editPropertyValues(new core_kernel_classes_Property(PROPERTY_DELIVERY_ACTIVE_COMPILATION), $compiled); } else { $this->out('No compilation found for ' . $delivery->getLabel()); } $delivery->removePropertyValues(new core_kernel_classes_Property(self::OLD_DELIVERY_COMPILED)); $delivery->removePropertyValues(new core_kernel_classes_Property(self::OLD_DELIVERY_ISCOMPILED)); } }
public function index() { // load all extensions \common_ext_ExtensionsManager::singleton()->getInstalledExtensions(); $res = $this->getCurrentResource(); $this->setData('res', $res); $this->setData('types', $res->getTypes()); //restricted on the currently selected language //$this->setData('triples', $res->getRdfTriples()->getIterator()); $this->setData('triples', $this->getRdfTriples($res, 'subject')->getIterator()); $this->setData('otriples', $this->getRdfTriples($res, 'object')->getIterator()); $this->setData('ptriples', $this->getRdfTriples($res, 'predicate')->getIterator()); if ($res->isClass()) { $class = new \core_kernel_classes_Class($res->getUri()); $this->setData('subclassOf', $class->getParentClasses(false)); $this->setData('subclasses', $class->getSubClasses()); $this->setData('instances', $class->getInstances()); } $this->setData('userLg', $dataLang = \common_session_SessionManager::getSession()->getDataLanguage()); $this->setView('browse.tpl'); }
public static function run() { // We get all the management roles and the extension they belong to. $managementRoleClass = new core_kernel_classes_Class(CLASS_MANAGEMENTROLE); $foundManagementRoles = $managementRoleClass->getInstances(true); $managementRolesByExtension = array(); foreach (common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension) { $managementRole = $extension->getManagementRole(); if (empty($managementRole)) { // try to discover it. foreach ($foundManagementRoles as $mR) { $moduleURIs = $mR->getPropertyValues(new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS)); foreach ($moduleURIs as $moduleURI) { $uri = explode('#', $moduleURI); list($type, $extId) = explode('_', $uri[1]); if ($extId == $extension->getId()) { $managementRole = $mR; break 2; } } } } if (!empty($managementRole)) { $managementRolesByExtension[$extension->getId()] = $managementRole; } } funcAcl_helpers_Cache::flush(); foreach (common_ext_ExtensionsManager::singleton()->getInstalledExtensions() as $extension) { if ($extension->getId() != 'generis') { // 2. Grant access to Management Role. if (!empty($managementRolesByExtension[$extension->getId()])) { $extAccessService = funcAcl_models_classes_ExtensionAccessService::singleton(); $extAccessService->add($managementRolesByExtension[$extension->getId()]->getUri(), $extAccessService->makeEMAUri($extension->getId())); } else { common_Logger::i('Management Role not found for extension ' . $extension->getId()); } } } }
/** * (non-PHPdoc) * @see \oat\oatbox\action\Action::__invoke() */ public function __invoke($params) { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); if (count($params) != 2) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_CLASS_URI OUTPUT_DIRECTORY', __CLASS__)); } $deliveryClassUri = array_shift($params); $deliveryClass = new \core_kernel_classes_Class($deliveryClassUri); $dir = array_shift($params); if (!file_exists($dir) && !mkdir($dir)) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Directory %s doesn\'t exist', $dir)); } $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exporting %s', $deliveryClass->getLabel())); foreach ($deliveryClass->getInstances(true) as $delivery) { $destFile = $dir . \tao_helpers_File::getSafeFileName($delivery->getLabel()) . '.zip'; $tmpFile = Assembler::exportCompiledDelivery($delivery); \tao_helpers_File::move($tmpFile, $destFile); $report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $destFile))); } return $report; }
/** * Delete a subclass * * @access public * @author Joel Bout, <*****@*****.**> * @param core_kernel_classes_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 = true; $instances = $clazz->getInstances(); foreach ($instances as $instance) { $this->deleteResource($instance); } $subclasses = $clazz->getSubClasses(false); foreach ($subclasses as $subclass) { $returnValue = $returnValue && $this->deleteClass($subclass); } foreach ($clazz->getProperties() as $classProperty) { $returnValue = $returnValue && $this->deleteClassProperty($classProperty); } $returnValue = $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; }
/** * @dataProvider serviceProvider * @author Lionel Lecaque, lionel@taotesting.com */ public function testGetAll($service, $topclass = null) { if ($topclass == null) { $this->markTestSkipped('This test do not apply to topclass', $topclass); } $url = $this->host . $service; $returnedData = $this->curl($url); $data = json_decode($returnedData, true); $this->assertArrayHasKey('success', $data); $this->assertTrue($data["success"]); $ItemClass = new \core_kernel_classes_Class($topclass); $instances = $ItemClass->getInstances(true); foreach ($data['data'] as $results) { $this->assertInternalType('array', $results); $this->assertArrayHasKey('uri', $results); $this->assertArrayHasKey('properties', $results); $this->assertInternalType('array', $instances); $this->assertArrayHasKey($results['uri'], $instances); $resource = $instances[$results['uri']]; foreach ($results['properties'] as $propArray) { $this->assertInternalType('array', $propArray); $this->assertArrayHasKey('predicateUri', $propArray); $prop = new \core_kernel_classes_Property($propArray['predicateUri']); $values = $resource->getPropertyValues($prop); $this->assertArrayHasKey('values', $propArray); $current = current($propArray['values']); $this->assertInternalType('array', $current); $this->assertArrayHasKey('valueType', $current); if (\common_Utils::isUri(current($values))) { $this->assertEquals('resource', $current['valueType']); } else { $this->assertEquals('literal', $current['valueType']); } $this->assertArrayHasKey('value', $current); $this->assertEquals(current($values), $current['value']); } } }
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(); foreach ($testClass->getInstances(true) as $test) { $options[$test->getUri()] = $test->getLabel(); } if (empty($options)) { throw new taoSimpleDelivery_actions_form_NoTestsException(); } $formatElt->setOptions($options); $formatElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($formatElt); }
public function testCreateMediaInstance() { $fileTmp = dirname(__DIR__) . '/sample/Brazil.png'; $this->initializeMock($fileTmp); $lang = 'EN-en'; $classUri = $this->testClass->getUri(); //clear previous tests $root = new \core_kernel_classes_Class($classUri); $link = $this->mediaService->createMediaInstance($fileTmp, $classUri, $lang); $root = new \core_kernel_classes_Class($classUri); $instances = $root->getInstances(); /** @var \core_kernel_classes_Resource $instance */ $instance = array_pop($instances); $thing = $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK)); $linkResult = $thing instanceof \core_kernel_classes_Resource ? $thing->getUri() : (string) $thing; $this->assertInstanceOf('\\core_kernel_classes_Resource', $instance, 'It should create an instance under the class in parameter'); $this->assertEquals('Brazil.png', $instance->getLabel(), 'The instance label is wrong'); $this->assertInternalType('string', $link, 'The method return should be a string'); $this->assertEquals($instance->getUri(), $link, 'The instance link is wrong'); $this->assertEquals($linkResult, 'MyGreatLink', 'The returned link is wrong'); $this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong'); $root->delete(true); $root->setSubClassOf($this->mediaService->getRootClass()); }
/** * * @return array readable and writable storages of results */ public function getResultStorages() { $storageClass = new core_kernel_classes_Class(TAO_RESULTSERVER_MODEL_CLASS); $readableStorages = array(); $writableStorages = array(); foreach ($storageClass->getInstances() as $storage) { $impl = $storage->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP)); $interfaces = class_implements($impl->__toString()); if (in_array('taoResultServer_models_classes_ReadableResultStorage', $interfaces)) { $readableStorages[] = $storage; } if (in_array('taoResultServer_models_classes_WritableResultStorage', $interfaces)) { $writableStorages[] = $storage; } } return array("r" => $readableStorages, "w" => $writableStorages); }
public function testDefinitions() { $serviceDefinitionClass = new core_kernel_classes_Class(CLASS_SERVICESDEFINITION); foreach ($serviceDefinitionClass->getInstances(true) as $serviceDefinition) { if ($serviceDefinition->getUri() == 'http://www.tao.lu/Ontologies/TAODelivery.rdf#ServiceTestContainer' || $serviceDefinition->getUri() == 'http://www.tao.lu/Ontologies/TAOTest.rdf#FakeItemRunner') { // don't test the item / testcontainer since it's not a real service continue; } $serviceDefinitionUrl = $serviceDefinition->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_SUPPORTSERVICES_URL)); $this->assertNotNull($serviceDefinitionUrl); $this->assertTrue(!empty($serviceDefinitionUrl)); $fullUri = ROOT_URL . ltrim($serviceDefinitionUrl, '/'); $resolver = new Resolver($fullUri); $ext = common_ext_ExtensionsManager::singleton()->getExtensionById($resolver->getExtensionFromURL()); $controller = $ext->getModule($resolver->getModule()); $this->assertTrue(method_exists($controller, $resolver->getAction()), 'action of service definition "' . $serviceDefinition->getLabel() . '" does not exist'); } }
/** * Get all items of given uri otherwise get default class * * @return array */ protected function getItems() { $class = new \core_kernel_classes_Class($this->getDefaultUriClass()); return $class->getInstances(true); }