本文整理汇总了PHP中core_kernel_classes_Resource::setPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP core_kernel_classes_Resource::setPropertyValue方法的具体用法?PHP core_kernel_classes_Resource::setPropertyValue怎么用?PHP core_kernel_classes_Resource::setPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_kernel_classes_Resource
的用法示例。
在下文中一共展示了core_kernel_classes_Resource::setPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
TaoPhpUnitTestRunner::initTest();
$this->test = new \core_kernel_classes_Resource('http://myFancyDomain.com/myGreatResourceUriForTest');
$this->item = new \core_kernel_classes_Resource('http://myFancyDomain.com/myGreatResourceUriForItem');
$this->item->setPropertyValue(new \core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAOItem.rdf#ItemModel'), 'http://www.tao.lu/Ontologies/TAOItem.rdf#QTI');
$this->testModel = new TestModel();
$this->storage = new \taoDelivery_models_classes_TrackedStorage();
$this->testModel->save($this->test, array());
}
示例2: createTestProcess
/**
* Generates a new process for a test
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param
* Resource instance
* @return core_kernel_classes_Resource
*/
public function createTestProcess(core_kernel_classes_Resource $test)
{
$processInstance = wfEngine_models_classes_ProcessDefinitionService::singleton()->createInstance(new core_kernel_classes_Class(CLASS_PROCESS), 'process generated with testsService');
// set ACL right to delivery process initialization:
$processInstance->editPropertyValues(new core_kernel_classes_Property(PROPERTY_PROCESS_INIT_ACL_MODE), INSTANCE_ACL_ROLE);
$processInstance->editPropertyValues(new core_kernel_classes_Property(PROPERTY_PROCESS_INIT_RESTRICTED_ROLE), INSTANCE_ROLE_DELIVERY);
$test->setPropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP), $processInstance->getUri());
$processInstance->setLabel("Process " . $test->getLabel());
return $processInstance;
}
示例3: add
/**
* Short description of method add
*
* @access public
* @author Jehan Bihin, <jehan.bihin@tudor.lu>
* @param string roleUri
* @param string accessUri
* @return mixed
*/
public function add($roleUri, $accessUri)
{
$module = new core_kernel_classes_Resource($accessUri);
$role = new core_kernel_classes_Resource($roleUri);
$moduleAccessProperty = new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS);
$values = $role->getPropertyValues($moduleAccessProperty);
if (!in_array($module->getUri(), $values)) {
$role->setPropertyValue($moduleAccessProperty, $module->getUri());
funcAcl_helpers_Cache::cacheModule($module);
} else {
common_Logger::w('Tried to add role ' . $role->getUri() . ' again to controller ' . $accessUri);
}
}
示例4: add
/**
* Short description of method add
*
* @access public
* @author Jehan Bihin, <jehan.bihin@tudor.lu>
* @param string roleUri
* @param string accessUri
* @return mixed
*/
public function add($roleUri, $accessUri)
{
$uri = explode('#', $accessUri);
list($type, $extId) = explode('_', $uri[1]);
$extManager = common_ext_ExtensionsManager::singleton();
$extension = $extManager->getExtensionById($extId);
$role = new core_kernel_classes_Resource($roleUri);
$values = $role->getPropertyValues(new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS));
if (!in_array($accessUri, $values)) {
$role->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS), $accessUri);
funcAcl_helpers_Cache::flushExtensionAccess($extId);
} else {
common_Logger::w('Tried to regrant access for role ' . $role->getUri() . ' to extension ' . $accessUri);
}
}
示例5: add
/**
* Short description of method add
*
* @access public
* @author Jehan Bihin, <jehan.bihin@tudor.lu>
* @param string roleUri
* @param string accessUri
* @return mixed
*/
public function add($roleUri, $accessUri)
{
$uri = explode('#', $accessUri);
list($type, $ext, $mod, $act) = explode('_', $uri[1]);
$role = new core_kernel_classes_Resource($roleUri);
$module = new core_kernel_classes_Resource($this->makeEMAUri($ext, $mod));
$actionAccessProperty = new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS);
$moduleAccessProperty = new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS);
$values = $role->getPropertyValues($actionAccessProperty);
if (!in_array($accessUri, $values)) {
$role->setPropertyValue($actionAccessProperty, $accessUri);
$controllerClassName = funcAcl_helpers_Map::getControllerFromUri($module->getUri());
funcAcl_helpers_Cache::flushControllerAccess($controllerClassName);
} else {
common_Logger::w('Tried to regrant access for role ' . $role->getUri() . ' to action ' . $accessUri);
}
}
示例6: saveGroups
/**
* Assign deliveries to groups
*
* @param \core_kernel_classes_Resource $delivery Delivery or RepeatedDelivery instance
* @param array $values List of groups (uri)
* @return boolean
*/
public function saveGroups(\core_kernel_classes_Resource $delivery, $values)
{
$property = new \core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY);
$currentValues = array();
foreach ($property->getDomain() as $domain) {
$instances = $domain->searchInstances(array($property->getUri() => $delivery), array('recursive' => true, 'like' => false));
$currentValues = array_merge($currentValues, array_keys($instances));
}
$toAdd = array_diff($values, $currentValues);
$toRemove = array_diff($currentValues, $values);
$success = true;
foreach ($toAdd as $uri) {
$subject = new \core_kernel_classes_Resource($uri);
$success = $success && $subject->setPropertyValue($property, $delivery);
}
foreach ($toRemove as $uri) {
$subject = new \core_kernel_classes_Resource($uri);
$success = $success && $subject->removePropertyValue($property, $delivery);
}
return $success;
}
示例7: createConnector
/**
* Short description of method createConnector
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param core_kernel_classes_Resource sourceStep
* @param string label
* @throws Exception
* @return core_kernel_classes_Resource
*/
public function createConnector(core_kernel_classes_Resource $sourceStep, $label = '')
{
$returnValue = null;
$label = empty($label) ? $sourceStep->getLabel() . "_c" : $label;
$connectorClass = new core_kernel_classes_Class(CLASS_CONNECTORS);
$returnValue = $connectorClass->createInstance($label, "created by ProcessService.Class");
if (is_null($returnValue)) {
throw new Exception("the connector cannot be created for the activity {$sourceStep->getUri()}");
}
$activityService = wfEngine_models_classes_ActivityService::singleton();
$connectorService = wfEngine_models_classes_ConnectorService::singleton();
//associate the connector to the activity
$sourceStep->setPropertyValue(new core_kernel_classes_Property(PROPERTY_STEP_NEXT), $returnValue);
//set the activity reference of the connector:
$activityRefProp = new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE);
if ($activityService->isActivity($sourceStep)) {
$returnValue->setPropertyValue($activityRefProp, $sourceStep);
} elseif ($connectorService->isConnector($sourceStep)) {
$returnValue->setPropertyValue($activityRefProp, $sourceStep->getUniquePropertyValue($activityRefProp));
} else {
throw new Exception("invalid resource type for the activity parameter: {$sourceStep->getUri()}");
}
return $returnValue;
}
示例8: setRelatedDeliveries
/**
* Short description of method setRelatedDeliveries
*
* @access public
* @author Joel Bout, <joel@taotesting.com>
* @param Resource campaign
* @param array deliveries
* @return boolean
*/
public function setRelatedDeliveries(core_kernel_classes_Resource $campaign, $deliveries = array())
{
$returnValue = (bool) false;
if (!is_null($campaign)) {
//the property of the DELIVERIES that will be modified
$campaignProp = new core_kernel_classes_Property(TAO_DELIVERY_CAMPAIGN_PROP);
//a way to remove the campaign property value of the delivery that are used to be associated to THIS campaign
$deliveryClass = new core_kernel_classes_Class(TAO_DELIVERY_CLASS);
$oldDeliveries = $deliveryClass->searchInstances(array(TAO_DELIVERY_CAMPAIGN_PROP => $campaign->getUri()), array('like' => false, 'recursive' => 0));
foreach ($oldDeliveries as $oldRelatedDelivery) {
//find a way to remove the property value associated to THIS campaign ONLY
$remove = $oldRelatedDelivery->removePropertyValues($campaignProp, array('pattern' => $campaign->getUri()));
}
//assign the current compaign to the selected deliveries
$done = 0;
foreach ($deliveries as $delivery) {
//the delivery instance to be modified
$deliveryInstance = new core_kernel_classes_Resource($delivery);
//remove the property value associated to another delivery in case ONE delivery can ONLY be associated to ONE campaign
//if so, then change the widget from comboBox to treeView in the delivery property definition
// $deliveryInstance->removePropertyValues($campaignProp);
//now, truly assigning the campaign uri to the affected deliveries
if ($deliveryInstance->setPropertyValue($campaignProp, $campaign->getUri())) {
$done++;
}
}
if ($done == count($deliveries)) {
$returnValue = true;
}
}
return (bool) $returnValue;
}
示例9: write
/**
* Write a value to a $resource
*
* @param \core_kernel_classes_Resource $resource
* @param $data
* @param bool $dryrun
* @return bool
* @throws MetadataWriterException
*/
public function write(\core_kernel_classes_Resource $resource, $data, $dryrun = false)
{
$propertyValue = $this->format($data);
if ($this->validate($propertyValue)) {
if (!$dryrun) {
if (!$resource->setPropertyValue($this->getPropertyToWrite(), $propertyValue)) {
throw new MetadataWriterException('A problem has occurred during writing property "' . $this->getPropertyToWrite()->getUri() . '".');
}
}
\common_Logger::d('Valid property "' . $this->getPropertyToWrite()->getUri() . '" ' . 'to add to resource "' . $resource->getUri() . '" : ' . $propertyValue);
return true;
}
throw new MetadataWriterException('Writer "' . __CLASS__ . '" cannot validate value for property "' . $this->getPropertyToWrite()->getUri() . '".');
}
示例10: cloneInstanceProperty
/**
*
* @author Lionel Lecaque, lionel@taotesting.com
* @param core_kernel_classes_Resource $source
* @param core_kernel_classes_Resource $destination
* @param core_kernel_classes_Property $property
*/
protected function cloneInstanceProperty(core_kernel_classes_Resource $source, core_kernel_classes_Resource $destination, core_kernel_classes_Property $property)
{
$range = $property->getRange();
// Avoid doublons, the RDF TYPE property will be set by the implementation layer
if ($property->getUri() != RDF_TYPE) {
foreach ($source->getPropertyValuesCollection($property)->getIterator() as $propertyValue) {
if (!is_null($range) && $range->getUri() == CLASS_GENERIS_FILE) {
$file = new core_kernel_versioning_File($propertyValue->getUri());
$newFile = $file->getRepository()->spawnFile($file->getAbsolutePath(), $file->getLabel());
$destination->setPropertyValue($property, $newFile);
} else {
$destination->setPropertyValue($property, $propertyValue);
}
}
}
}
示例11: setType
/**
* Short description of method setType
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource resource
* @param Class class
* @return boolean
*/
public function setType(\core_kernel_classes_Resource $resource, \core_kernel_classes_Class $class)
{
$returnValue = (bool) false;
$dbWrapper = \core_kernel_classes_DbWrapper::singleton();
$referencer = ResourceReferencer::singleton();
if (!$resource->hasType($class)) {
$classInfo = Utils::getClassInfo($class);
if ($classInfo !== false) {
$sql = 'INSERT INTO "resource_to_table" ("uri", "table") VALUES (?, ?)';
$rowsAffected1 = $dbWrapper->exec($sql, array($resource->getUri(), $classInfo['table']));
$sql = 'INSERT INTO "resource_has_class" ("resource_id", "class_id") VALUES (?, ?)';
$id = $dbWrapper->lastInsertId('resource_to_table');
$rowsAffected2 = $dbWrapper->exec($sql, array($id, $classInfo['id']));
$sql = 'INSERT INTO "' . $classInfo['table'] . '" ("uri") VALUES (?)';
$dbWrapper->exec($sql, array($resource->getUri()));
$referencer->clearCaches();
$sql = 'SELECT * FROM "statements" WHERE "modelid" = ? AND "subject" = ?';
$result = $dbWrapper->query($sql, array(99999, $resource->getUri()));
while ($row = $result->fetch()) {
if ($row['predicate'] !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') {
$resource->setPropertyValue(new \core_kernel_classes_Property($row['predicate']), $row['object']);
}
$sql = 'DELETE FROM "statements" WHERE "id" = ' . $row['id'];
$dbWrapper->exec($sql);
}
}
}
$returnValue = true;
return (bool) $returnValue;
}
示例12: setProcessVariable
/**
* Short description of method setProcessVariable
*
* @access public
* @author Joel Bout, <joel.bout@tudor.lu>
* @param Resource processDefinition
* @param string processVariable
* @return boolean
*/
public function setProcessVariable(core_kernel_classes_Resource $processDefinition, $processVariable)
{
$returnValue = (bool) false;
if (is_string($processVariable) && !empty($processVariable)) {
//is a code:
$variableService = wfEngine_models_classes_VariableService::singleton();
$processVariableResource = $variableService->getProcessVariable($processVariable);
if (!is_null($processVariableResource) && $processVariableResource instanceof core_kernel_classes_Resource) {
$returnValue = $processDefinition->setPropertyValue($this->processVariablesProp, $processVariableResource->getUri());
}
} elseif ($processVariable instanceof core_kernel_classes_Resource) {
$returnValue = $processDefinition->setPropertyValue($this->processVariablesProp, $processVariable->getUri());
}
return (bool) $returnValue;
}
示例13: attachResource
/**
* Short description of method attachResource
*
* @access public
* @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
* @param core_kernel_classes_Property $targetProperty
* @param core_kernel_classes_Resource $targetResource
* @param string $value
* @return mixed
*/
public function attachResource(core_kernel_classes_Property $targetProperty, core_kernel_classes_Resource $targetResource, $value)
{
// We have to check if the resource identified by value exists in the Ontology.
$resource = new core_kernel_classes_Resource($value);
if ($resource->exists()) {
// Is the range correct ?
$targetPropertyRanges = $targetProperty->getPropertyValuesCollection(new core_kernel_classes_Property(RDFS_RANGE));
$rangeCompliance = true;
// If $targetPropertyRange->count = 0, we consider that the resouce
// may be attached because $rangeCompliance = true.
foreach ($targetPropertyRanges->getIterator() as $range) {
// Check all classes in target property's range.
if ($resource->hasType(new core_kernel_classes_Class($range))) {
$rangeCompliance = false;
break;
}
}
if (true == $rangeCompliance) {
$targetResource->setPropertyValue($targetProperty, $resource->getUri());
}
}
}
示例14: setTestTakerRole
/**
* Set the proper role to the testTaker
*
* @author Lionel Lecaque, lionel@taotesting.com
* @param \core_kernel_classes_Resource $instance
*/
public function setTestTakerRole(\core_kernel_classes_Resource $instance)
{
$roleProperty = new \core_kernel_classes_Property(PROPERTY_USER_ROLES);
$subjectRole = new \core_kernel_classes_Resource(INSTANCE_ROLE_DELIVERY);
$instance->setPropertyValue($roleProperty, $subjectRole);
}
示例15: setReverseValues
public function setReverseValues()
{
if (!tao_helpers_Request::isAjax()) {
throw new common_exception_IsAjaxAction(__FUNCTION__);
}
$values = tao_helpers_form_GenerisTreeForm::getSelectedInstancesFromPost();
$resource = new core_kernel_classes_Resource($this->getRequestParameter('resourceUri'));
$property = new core_kernel_classes_Property($this->getRequestParameter('propertyUri'));
$currentValues = array();
foreach ($property->getDomain() as $domain) {
$instances = $domain->searchInstances(array($property->getUri() => $resource), array('recursive' => true, 'like' => false));
$currentValues = array_merge($currentValues, array_keys($instances));
}
$toAdd = array_diff($values, $currentValues);
$toRemove = array_diff($currentValues, $values);
$success = true;
foreach ($toAdd as $uri) {
$subject = new core_kernel_classes_Resource($uri);
$success = $success && $subject->setPropertyValue($property, $resource);
}
foreach ($toRemove as $uri) {
$subject = new core_kernel_classes_Resource($uri);
$success = $success && $subject->removePropertyValue($property, $resource);
}
echo json_encode(array('saved' => $success));
}