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()); }
/** * Generates a new process for a test * * @access public * @author Joel Bout, <*****@*****.**> * @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; }
/** * Short description of method add * * @access public * @author Jehan Bihin, <*****@*****.**> * @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); } }
/** * Short description of method add * * @access public * @author Jehan Bihin, <*****@*****.**> * @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); } }
/** * Short description of method add * * @access public * @author Jehan Bihin, <*****@*****.**> * @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); } }
/** * 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; }
/** * Short description of method createConnector * * @access public * @author Joel Bout, <*****@*****.**> * @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; }
/** * Short description of method setRelatedDeliveries * * @access public * @author Joel Bout, <*****@*****.**> * @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; }
/** * 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() . '".'); }
/** * * @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); } } } }
/** * Short description of method setType * * @access public * @author Joel Bout, <*****@*****.**> * @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; }
/** * Short description of method setProcessVariable * * @access public * @author Joel Bout, <*****@*****.**> * @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; }
/** * Short description of method attachResource * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @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()); } } }
/** * 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); }
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)); }
} else { $userData = DataGeneration::createUser($toAdd, $lang); try { $persistence->insert('redis', array('subject' => $userData['uri'], 'predicate' => PROPERTY_USER_LOGIN, 'object' => $userData[PROPERTY_USER_LOGIN])); // insert user data to statements as well to be able to show the user label on the results page $persistence->insert('statements', array('modelid' => 1, 'subject' => $userData['uri'], 'predicate' => RDFS_LABEL, 'object' => $userData[PROPERTY_USER_LOGIN], 'l_language' => $lang)); } catch (PDOException $e) { echo 'please make sure that called redis exists with subject,predicate,object' . "\n"; echo 'insert as first line : ' . $userData['uri'] . " , " . PROPERTY_USER_LOGIN . " , " . $userData[PROPERTY_USER_LOGIN]; die(1); } } } $row++; } fclose($handle); echo PHP_EOL . $row . ' test takers imported.' . PHP_EOL; } //----------- Import test from ZIP package echo 'Importing test...' . PHP_EOL; $report = \taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests(new \core_kernel_classes_Class("http://www.tao.lu/Ontologies/TAOTest.rdf#Test"), $test_package); foreach ($report as $r) { $test = $r->getData()->rdfsResource; } $label = __("Benchmark test"); $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $report = \oat\taoDeliveryRdf\model\SimpleDeliveryFactory::create($deliveryClass, $test, $label); $delivery = $report->getData(); $property = new \core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY); $group->setPropertyValue($property, $delivery); echo 'Test successfully imported.' . PHP_EOL;
/** * Short description of method applyAclDefinitionToExecution * * @access protected * @author Somsack Sipasseuth, <*****@*****.**> * @param Resource activityDefinition * @param Resource activityExecution * @return boolean */ protected function applyAclDefinitionToExecution(core_kernel_classes_Resource $activityDefinition, core_kernel_classes_Resource $activityExecution) { $returnValue = (bool) false; $ACLmode = $activityDefinition->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_ACL_MODE)); if (!is_null($ACLmode)) { switch ($ACLmode->getUri()) { case INSTANCE_ACL_USER: $user = $activityDefinition->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_RESTRICTED_USER)); if (!is_null($user)) { $activityExecution->setPropertyValue($this->ACLModeProperty, $ACLmode); $returnValue = $activityExecution->setPropertyValue($this->restrictedUserProperty, $user); } break; case INSTANCE_ACL_ROLE: case INSTANCE_ACL_ROLE_RESTRICTED_USER: case INSTANCE_ACL_ROLE_RESTRICTED_USER_INHERITED: case INSTANCE_ACL_ROLE_RESTRICTED_USER_DELIVERY: $role = $activityDefinition->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_RESTRICTED_ROLE)); if (!is_null($role)) { $activityExecution->setPropertyValue($this->ACLModeProperty, $ACLmode); $returnValue = $activityExecution->setPropertyValue($this->restrictedRoleProperty, $role); } break; } } return (bool) $returnValue; }
/** * Short description of method addService * * @access protected * @author Joel Bout, <*****@*****.**> * @param Resource activity * @return core_kernel_classes_Resource */ protected function addService(core_kernel_classes_Resource $activity, $serviceDefinition) { $returnValue = null; //an interactive service of an activity is a call of service: $callOfServiceClass = new core_kernel_classes_Class(CLASS_CALLOFSERVICES); //create new resource for the property value of the current call of service PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN or PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT $returnValue = $callOfServiceClass->createInstance($activity->getLabel() . "_service"); if (empty($returnValue)) { throw new Exception("the interactive service cannot be created for the activity {$activity->getUri()}"); } //associate the new instance to the activity instance $activity->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES), $returnValue->getUri()); tao_models_classes_InteractiveServiceService::singleton()->setCallOfServiceDefinition($returnValue, $serviceDefinition); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_WIDTH), 100); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_HEIGHT), 100); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_TOP), 0); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_CALLOFSERVICES_LEFT), 0); $defaultParams = tao_models_classes_InteractiveServiceService::singleton()->setDefaultParameters($returnValue); return $returnValue; }
/** * Make a Role include another Role. * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param core_kernel_classes_Resource role The role that needs to include another role. * @param core_kernel_classes_Resource Resource roleToInclude The role to be included. */ public function includeRole(core_kernel_classes_Resource $role, core_kernel_classes_Resource $roleToInclude) { $includesRoleProperty = new core_kernel_classes_Property(PROPERTY_ROLE_INCLUDESROLE); // Clean to avoid double entries... $role->removePropertyValues($includesRoleProperty, array('like' => false, 'pattern' => $roleToInclude->getUri())); // Include the Role. $role->setPropertyValue($includesRoleProperty, $roleToInclude->getUri()); // Reset cache. core_kernel_users_Cache::removeIncludedRoles($role); }
/** * @depends testInstantiateClass * @param \core_kernel_classes_Resource $instance */ public function testClone($instance) { $propertyLogin = new \core_kernel_classes_Property(PROPERTY_USER_LOGIN); $instance->setPropertyValue($propertyLogin, 'testUser'); $propertyName = new \core_kernel_classes_Property(PROPERTY_USER_FIRSTNAME); $instance->setPropertyValue($propertyName, 'Cool Name'); $clone = $this->subjectsService->cloneInstance($instance); $instanceValues = $instance->getPropertyValues($propertyName); $cloneValues = $clone->getPropertyValues($propertyName); $this->assertEquals($instanceValues[0], $cloneValues[0]); $instanceValues = $instance->getPropertyValues($propertyLogin); $cloneValues = $clone->getPropertyValues($propertyLogin); $this->assertNotEquals($instanceValues[0], $cloneValues[0]); $this->assertNotEquals($instance, $clone); $this->assertTrue($this->subjectsService->deleteSubject($clone)); $this->assertFalse($clone->exists()); }
/** * * @author Lionel Lecaque, lionel@taotesting.com * @param core_kernel_classes_Resource $resource * @param string $newType */ public static function switchType(core_kernel_classes_Resource $resource, $newType) { $resource->removePropertyValues(new core_kernel_classes_Property(RDF_TYPE)); $resource->setPropertyValue(new core_kernel_classes_Property(RDF_TYPE), $newType); }
/** * Import the properties of the resource * * @param core_kernel_classes_Resource $resource * @param array $propertiesValues * @param array $map * @param core_kernel_classes_Class $class * @return common_report_Report */ private function importProperties(core_kernel_classes_Resource $resource, $propertiesValues, $map, $class) { $isClass = false; if (isset($propertiesValues[RDF_TYPE])) { // assuming single Type if (count($propertiesValues[RDF_TYPE]) > 1) { return new common_report_Report(common_report_Report::TYPE_ERROR, __('Resource not imported due to multiple types')); } else { foreach ($propertiesValues[RDF_TYPE] as $k => $v) { $classType = isset($map[$v['value']]) ? new core_kernel_classes_Class($map[$v['value']]) : $class; //$resource->setType($classType); $classType->createInstance(null, null, $resource->getUri()); } } unset($propertiesValues[RDF_TYPE]); } if (isset($propertiesValues[RDFS_SUBCLASSOF])) { $isClass = true; // assuming single subclass if (isset($propertiesValues[RDF_TYPE]) && count($propertiesValues[RDF_TYPE]) > 1) { return new common_report_Report(common_report_Report::TYPE_ERROR, __('Resource not imported due to multiple super classes')); } foreach ($propertiesValues[RDFS_SUBCLASSOF] as $k => $v) { $classSup = isset($map[$v['value']]) ? new core_kernel_classes_Class($map[$v['value']]) : $class; $classSup->createSubClass(null, null, $resource->getUri()); } unset($propertiesValues[RDFS_SUBCLASSOF]); } foreach ($propertiesValues as $prop => $values) { $property = new core_kernel_classes_Property(isset($map[$prop]) ? $map[$prop] : $prop); foreach ($values as $k => $v) { $value = isset($map[$v['value']]) ? $map[$v['value']] : $v['value']; if (isset($v['lang'])) { $resource->setPropertyValueByLg($property, $value, $v['lang']); } else { $resource->setPropertyValue($property, $value); } } } $msg = $isClass ? __('Successfully imported class "%s"', $resource->getLabel()) : __('Successfully imported "%s"', $resource->getLabel()); return new common_report_Report(common_report_Report::TYPE_SUCCESS, $msg); }
/** * Short description of method setActualParameter * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource callOfService * @param Resource formalParam * @param string value * @param string parameterInOrOut * @param string actualParameterType * @return boolean */ public function setActualParameter(core_kernel_classes_Resource $callOfService, core_kernel_classes_Resource $formalParam, $value, $parameterInOrOut = PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN, $actualParameterType = PROPERTY_ACTUALPARAMETER_CONSTANTVALUE) { $returnValue = (bool) false; //must exist: if ($formalParam->hasType(new core_kernel_classes_Class(CLASS_FORMALPARAMETER))) { if (in_array($parameterInOrOut, array(PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN, PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT)) && in_array($actualParameterType, array(PROPERTY_ACTUALPARAMETER_CONSTANTVALUE, PROPERTY_ACTUALPARAMETER_PROCESSVARIABLE))) { //create new resource for the property value of the current call of service PROPERTY_CALLOFSERVICES_ACTUALPARAMETERIN or PROPERTY_CALLOFSERVICES_ACTUALPARAMETEROUT $actualParameterClass = new core_kernel_classes_Class(CLASS_ACTUALPARAMETER); $newActualParameter = $actualParameterClass->createInstance($formalParam->getLabel(), "actual parameter created by Process Authoring Service"); $newActualParameter->setPropertyValue(new core_kernel_classes_Property(PROPERTY_ACTUALPARAMETER_FORMALPARAMETER), $formalParam->getUri()); $newActualParameter->setPropertyValue(new core_kernel_classes_Property($actualParameterType), $value); $returnValue = $callOfService->setPropertyValue(new core_kernel_classes_Property($parameterInOrOut), $newActualParameter->getUri()); } } else { throw new Exception('the formal parameter ' . $formalParam->getUri() . ' does not exist'); } return (bool) $returnValue; }
/** * (non-PHPdoc) * @see taoTests_models_classes_TestModel::onTestModelSet() */ public function prepareContent(core_kernel_classes_Resource $test, $items = array()) { $class = new core_kernel_classes_Class(CLASS_LTI_TESTCONTENT); $content = $class->createInstance(); $test->setPropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP), $content); }
/** * Short description of method sendNotifications * * @access public * @author Somsack Sipasseuth, <*****@*****.**> * @param Adapter adapter * @return boolean */ public function sendNotifications(tao_helpers_transfert_Adapter $adapter) { $returnValue = (bool) false; if (!is_null($adapter)) { //initialize properties used in the loop $userMailProp = new core_kernel_classes_Property(PROPERTY_USER_MAIL); $processExecutionOfProp = new core_kernel_classes_Property(PROPERTY_PROCESSINSTANCES_EXECUTIONOF); //create messages from the notifications resources $messages = array(); $notificationsToSend = $this->getNotificationsToSend(); foreach ($notificationsToSend as $notificationResource) { //get the message content from the notification //@TODO: "getNotificationMessage" can be cached $content = (string) $notificationResource->getOnePropertyValue($this->notificationMessageProp); //get the email of the user $toEmail = ''; $to = $notificationResource->getOnePropertyValue($this->notificationToProp); if (!is_null($to)) { $toEmail = (string) $to->getOnePropertyValue($userMailProp); } //get the name of the concerned process $processName = ''; $processExec = $notificationResource->getOnePropertyValue($this->notificationProcessExecProp); if ($processExec instanceof core_kernel_classes_Resource) { $process = $processExec->getOnePropertyValue($processExecutionOfProp); if ($process instanceof core_kernel_classes_Resource) { $processName = $process->getLabel() . " / " . $processExec->getLabel(); } } //create the message instance if (!empty($toEmail) && !empty($content)) { $message = new tao_helpers_transfert_Message(); $message->setTitle(__("[TAO Notification System] Workflow") . ' : ' . $processName); $message->setBody($content); $message->setTo($toEmail); $message->setFrom("*****@*****.**"); $messages[$notificationResource->getUri()] = $message; } } if (count($messages) > 0) { $adapter->setMessages($messages); $returnValue = count($messages) == $adapter->send(); foreach ($adapter->getMessages() as $notificationUri => $message) { if ($message->getStatus() == tao_helpers_transfert_Message::STATUS_SENT) { $notificationResource = new core_kernel_classes_Resource($notificationUri); $notificationResource->editPropertyValues($this->notificationSentProp, GENERIS_TRUE); } //add a new date at each sending try $notificationResource->setPropertyValue($this->notificationDateProp, date("Y-m-d H:i:s")); } } } return (bool) $returnValue; }