本文整理汇总了PHP中core_kernel_classes_Resource::getUniquePropertyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::getUniquePropertyValue方法的具体用法?PHP core_kernel_classes_Resource::getUniquePropertyValue怎么用?PHP core_kernel_classes_Resource::getUniquePropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::getUniquePropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddUtf8User
/**
* Test user insertion with special chars
*/
public function testAddUtf8User()
{
$this->assertTrue($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
$tmclass = new core_kernel_classes_Class(CLASS_TAO_USER);
$this->testUserUtf8 = $tmclass->createInstance();
$this->assertNotNull($this->testUserUtf8);
$this->assertTrue($this->testUserUtf8->exists());
$result = $this->userService->bindProperties($this->testUserUtf8, $this->testUserUtf8Data);
$this->assertNotNull($result);
$this->assertNotEquals($result, false);
$this->assertFalse($this->userService->loginAvailable($this->testUserUtf8Data[PROPERTY_USER_LOGIN]));
//check inserted data
$this->testUserUtf8 = $this->getUserByLogin($this->testUserUtf8Data[PROPERTY_USER_LOGIN]);
$this->assertInstanceOf('core_kernel_classes_Resource', $this->testUserUtf8);
foreach ($this->testUserUtf8Data as $prop => $value) {
try {
$p = new core_kernel_classes_Property($prop);
$v = $this->testUserUtf8->getUniquePropertyValue($p);
$v = $v instanceof core_kernel_classes_Literal ? $v->literal : $v->getUri();
$this->assertEquals($value, $v);
} catch (common_Exception $ce) {
$this->fail($ce);
}
}
}
示例2: getCode
/**
* Short description of method getCode
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource language
* @return string
*/
public function getCode(core_kernel_classes_Resource $language)
{
$returnValue = (string) '';
$valueProperty = new core_kernel_classes_Property(RDF_VALUE);
$returnValue = $language->getUniquePropertyValue($valueProperty);
return (string) $returnValue;
}
示例3: __construct
/**
*
* @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
}
示例4: getExpression
/**
* Short description of method getExpression
*
* @access public
* @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu>
* @param Resource rule
* @return mixed
*/
public function getExpression(core_kernel_classes_Resource $rule)
{
$returnValue = null;
$property = new core_kernel_classes_Property(PROPERTY_RULE_IF);
$returnValue = new core_kernel_rules_Expression($rule->getUniquePropertyValue($property)->getUri(), __METHOD__);
return $returnValue;
}
示例5: getAuthoring
/**
* @deprecated
* @see taoTests_models_classes_TestModel::getAuthoring()
*/
public function getAuthoring(core_kernel_classes_Resource $test)
{
$process = $test->getUniquePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP));
$ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoWfAdvTest');
$widget = new Renderer($ext->getConstant('DIR_VIEWS') . 'templates' . DIRECTORY_SEPARATOR . 'authoring.tpl');
$widget->setData('processUri', $process->getUri());
$widget->setData('label', __('Authoring %s', $test->getLabel()));
return $widget->render();
}
示例6: getTokenizer
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();
}
示例7: getParamName
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;
}
示例8: getThenActivity
/**
* Short description of method getThenActivity
*
* @access public
* @author Lionel Lecaque, <lionel.lecaque@tudor.lu>
* @param Resource rule
* @return core_kernel_classes_Resource
*/
public function getThenActivity(core_kernel_classes_Resource $rule)
{
$returnValue = null;
$thenProperty = new core_kernel_classes_Property(PROPERTY_TRANSITIONRULES_THEN);
try {
$returnValue = $rule->getUniquePropertyValue($thenProperty);
} catch (common_Exception $e) {
throw new wfEngine_models_classes_ProcessExecutionException('Transition Rule ' . $rule->getUri() . ' do not have value for Then Property');
}
return $returnValue;
}
示例9: getUrl
/**
* return a LTI link URI from a valid delivery id
* @author Christophe GARCIA <christopheg@taotesing.com>
*/
public function getUrl()
{
try {
if ($this->getRequestMethod() != \Request::HTTP_GET) {
throw new \common_exception_NotImplemented('Only GET method is accepted to request this service.');
}
if (!$this->hasRequestParameter('deliveryId')) {
$this->returnFailure(new \common_exception_MissingParameter('At least one mandatory parameter was required but found missing in your request'));
}
$selectedDelivery = new \core_kernel_classes_Resource($this->getRequestParameter('deliveryId'));
if (!$selectedDelivery->isInstanceOf(new \core_kernel_classes_Class(TAO_DELIVERY_CLASS))) {
$this->returnFailure(new \common_exception_NotFound('Delivery not found'));
}
try {
$selectedDelivery->getUniquePropertyValue(new \core_kernel_classes_Property(\TAO_DELIVERY_RESULTSERVER_PROP));
} catch (Exception $e) {
$this->returnFailure(new \common_exception_BadRequest('The delivery is not associated to a Result server storage policy'));
}
$this->returnSuccess(LTIDeliveryTool::singleton()->getLaunchUrl(array('delivery' => $selectedDelivery->getUri())));
} catch (Exception $ex) {
$this->returnFailure($ex);
}
}
示例10: editMediaInstance
/**
* Edit a media instance with a new file and/or a new language
* @param $fileTmp
* @param $instanceUri
* @param $language
* @return bool $instanceUri or false on error
*/
public function editMediaInstance($fileTmp, $instanceUri, $language)
{
$instance = new \core_kernel_classes_Resource($instanceUri);
$link = $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LINK));
$link = $link instanceof \core_kernel_classes_Resource ? $link->getUri() : (string) $link;
$fileManager = FileManager::getFileManagementModel();
$fileManager->deleteFile($link);
$link = $fileManager->storeFile($fileTmp, $instance->getLabel());
if ($link !== false) {
//get the file MD5
$md5 = md5_file($fileTmp);
/** @var $instance \core_kernel_classes_Resource */
if (!is_null($instance) && $instance instanceof \core_kernel_classes_Resource) {
$instance->editPropertyValues(new \core_kernel_classes_Property(MEDIA_LINK), $link);
$instance->editPropertyValues(new \core_kernel_classes_Property(MEDIA_LANGUAGE), $language);
$instance->editPropertyValues(new \core_kernel_classes_Property(MEDIA_MD5), $md5);
}
if (common_ext_ExtensionsManager::singleton()->isEnabled('taoRevision')) {
\common_Logger::i('Auto generating revision');
RevisionService::commit($instance, __('Imported new file'));
}
}
return $link !== false ? true : false;
}
示例11: getTestTaker
/**
* returns the test taker related to the delivery
*
* @author Patrick Plichart, <patrick.plichart@taotesting.com>
*/
public function getTestTaker(core_kernel_classes_Resource $deliveryResult)
{
$propResultOfSubject = new core_kernel_classes_Property(PROPERTY_RESULT_OF_SUBJECT);
return $deliveryResult->getUniquePropertyValue($propResultOfSubject);
}
示例12: getServiceDefinition
public function getServiceDefinition(core_kernel_classes_Resource $serviceCall)
{
return $serviceCall->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_SERVICEDEFINITION));
}
示例13: exportCompiledDelivery
/**
* export a compiled delivery into an archive
*
* @param core_kernel_classes_Resource $compiledDelivery
* @throws Exception
* @return string
*/
public static function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery)
{
$fileName = tao_helpers_Display::textCleaner($compiledDelivery->getLabel()) . '.zip';
$path = tao_helpers_File::concat(array(tao_helpers_Export::getExportPath(), $fileName));
if (!tao_helpers_File::securityCheck($path, true)) {
throw new Exception('Unauthorized file name');
}
$zipArchive = new ZipArchive();
if ($zipArchive->open($path, ZipArchive::CREATE) !== true) {
throw new Exception('Unable to create archive at ' . $path);
}
$taoDeliveryVersion = common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery');
$data = array('dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion);
$directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_DIRECTORY));
foreach ($directories as $id) {
$directory = tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id);
tao_helpers_File::addFilesToZip($zipArchive, $directory->getPath(), $directory->getRelativePath());
$data['dir'][$id] = $directory->getRelativePath();
}
$runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_RUNTIME));
$serviceCall = tao_models_classes_service_ServiceCall::fromResource($runtime);
$data['runtime'] = base64_encode($serviceCall->serializeToString());
$rdfExporter = new tao_models_classes_export_RdfExporter();
$rdfdata = $rdfExporter->getRdfString(array($compiledDelivery));
if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) {
throw common_Exception('Unable to add metadata to exported delivery assembly');
}
$data['meta'] = 'delivery.rdf';
$content = json_encode($data);
//'<?php return '.common_Utils::toPHPVariableString($data).";";
if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) {
$zipArchive->close();
unlink($path);
throw common_Exception('Unable to add manifest to exported delivery assembly');
}
$zipArchive->close();
return $path;
}
示例14: cloneContent
/**
* Clone a QTI Test Resource.
*
* @param core_kernel_classes_Resource $source The resource to be cloned.
* @param core_kernel_classes_Resource $destination An existing resource to be filled as the clone of $source.
*/
public function cloneContent(core_kernel_classes_Resource $source, core_kernel_classes_Resource $destination)
{
$contentProperty = new core_kernel_classes_Property(TEST_TESTCONTENT_PROP);
$existingDir = new core_kernel_file_File($source->getUniquePropertyValue($contentProperty));
$service = taoQtiTest_models_classes_QtiTestService::singleton();
$dir = $service->createContent($destination, false);
if ($existingDir->fileExists()) {
tao_helpers_File::copy($existingDir->getAbsolutePath(), $dir->getAbsolutePath(), true, false);
} else {
common_Logger::w('Test "' . $source->getUri() . '" had no content, nothing to clone');
}
}
示例15: migrateData
/**
* Migrates data between source and target storage
*
* @param array core_kernel_classes_Resource $sourceStorage
* @param array core_kernel_classes_Resource core_kernel_classes_Resource
*
* @return array
*/
public function migrateData($sourceStorages, $targetStorages)
{
$sourceImpl = array();
$targetImpl = array();
$returnValue = array('success' => false);
// holds the result of each storage
$returnData = array();
if (!is_array($sourceStorages) || !is_array($targetStorages)) {
// $sourceStorages must be an array of storages
$return['status'] = __('Invalid request');
return $return;
}
if (!is_array($targetStorages)) {
// $targetStorages must be an array of storages
$return['status'] = __('Invalid request');
return $return;
}
foreach ($sourceStorages as $sourceStorage) {
$returnData[] = array('uri' => $sourceStorage);
}
foreach ($sourceStorages as $sourceStorage) {
$sourceStorageResource = new core_kernel_classes_Resource($sourceStorage);
$implLiteral = $sourceStorageResource->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP));
$impl = $implLiteral->__toString();
$interfaces = class_implements($impl);
if (!in_array('taoResultServer_models_classes_ReadableResultStorage', $interfaces)) {
$return['status'] = __($sourceStorage . 'does not implement ReadableResultStorage');
return $return;
} else {
$sourceImpl[] = new $impl();
$returnData[] = array('uri' => $sourceStorage);
}
}
foreach ($targetStorages as $targetStorage) {
$targetStorageResource = new core_kernel_classes_Resource($targetStorage);
$implLiteral = $targetStorageResource->getUniquePropertyValue(new core_kernel_classes_Property(TAO_RESULTSERVER_MODEL_IMPL_PROP));
$impl = $implLiteral->__toString();
$interfaces = class_implements($impl);
if (!in_array('taoResultServer_models_classes_WritableResultStorage', $interfaces)) {
$return['status'] = __($sourceStorage . 'does not implement ReadableResultStorage');
return $return;
} else {
$targetImpl[] = new $impl();
}
}
foreach ($sourceImpl as $key => $storageSImpl) {
//migrate test taker data
$allTestTakerIds = $storageSImpl->getAllTestTakerIds();
foreach ($targetImpl as $storageTImpl) {
foreach ($allTestTakerIds as $resultIDentifier => $testTakerId) {
$storageTImpl->storeRelatedTestTaker($testTakerId["deliveryResultIdentifier"], $testTakerId["testTakerIdentifier"]);
}
}
//migrate Delivery data
$allDeliveryIds = $storageSImpl->getAllDeliveryIds();
foreach ($targetImpl as $storageTImpl) {
foreach ($allDeliveryIds as $resultIDentifier => $deliveryId) {
$storageTImpl->storeRelatedDelivery($deliveryId["deliveryResultIdentifier"], $deliveryId["deliveryIdentifier"]);
}
}
//migrate all service call submitted variables
$callIds = $storageSImpl->getAllCallIDs();
//o(n)
foreach ($callIds as $callId) {
$variables = $storageSImpl->getVariables($callId);
foreach ($variables as $variableIdentifier => $observations) {
foreach ($observations as $observation) {
foreach ($targetImpl as $storageTImpl) {
if (isset($observation->callIdItem)) {
//item level variable
$storageTImpl->storeItemVariable($observation->deliveryResultIdentifier, $observation->test, $observation->item, $observation->variable, $observation->callIdItem);
} else {
//test level variable
//print_r($observation);
$storageTImpl->storeTestVariable($observation->deliveryResultIdentifier, $observation->test, $observation->variable, $observation->callIdTest);
}
}
}
}
}
$returnData[$key]['testTakers'] = count($allTestTakerIds);
$returnData[$key]['deliveries'] = count($allDeliveryIds);
$returnData[$key]['callIds'] = count($callIds);
}
$returnValue['success'] = true;
$returnValue['status'] = __('Migration Successful');
$returnValue['data'] = $returnData;
return $returnValue;
}