public function tearDown() { if ($this->item) { $this->item->delete(); } parent::tearDown(); }
public function tearDown() { // removes the created user $user = new \core_kernel_classes_Resource($this->userUri); $success = $user->delete(); $this->restoreCache(); }
public static function deepDelete(\core_kernel_classes_Resource $resource) { foreach ($resource->getRdfTriples() as $triple) { self::deleteDependencies($triple); } $resource->delete(); }
/** * tests initialization */ public function setUp() { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoTestTaker'); TaoPhpUnitTestRunner::initTest(); $this->proctorManagementService = ProctorManagementService::singleton(); //clean test resources $proctor1 = new \core_kernel_classes_Resource('http://myTest.case#proctor1'); $proctor2 = new \core_kernel_classes_Resource('http://myTest.case#proctor2'); $proctor3 = new \core_kernel_classes_Resource('http://myTest.case#proctor3'); $proctor1->delete(true); $proctor2->delete(true); $proctor3->delete(true); }
/** * tests clean up */ public function tearDown() { if (!is_null($this->testUser)) { $this->testUser->delete(); } }
/** * Render the add property sub form. * @throws Exception * @return void * @requiresRight classUri WRITE */ public function removeClassProperty() { $success = false; if (!tao_helpers_Request::isAjax()) { throw new Exception("wrong request mode"); } $class = new core_kernel_classes_Class($this->getRequestParameter('classUri')); $property = new core_kernel_classes_Property($this->getRequestParameter('uri')); //delete property mode foreach ($class->getProperties() as $classProperty) { if ($classProperty->equals($property)) { $indexes = $property->getPropertyValues(new core_kernel_classes_Property(INDEX_PROPERTY)); //delete property and the existing values of this property if ($property->delete(true)) { //delete index linked to the property foreach ($indexes as $indexUri) { $index = new core_kernel_classes_Resource($indexUri); $index->delete(true); } $success = true; break; } } } if ($success) { return $this->returnJson(array('success' => true)); } else { $this->returnError(__('Unable to remove the property.')); } }
public function tearDown() { $this->assertNotNull($this->currentUser); $this->currentUser->delete(); }
/** * Removes a language from the Ontology and all triples with the related * tag. Will use command line parameters for logic. * * @access protected * @author Joel Bout, <*****@*****.**> * @return void */ protected function removeLanguageFromOntology() { $this->outVerbose("Removing RDF language description '" . $this->options['language'] . "' from ontology..."); $taoNS = 'http://www.tao.lu/Ontologies/TAO.rdf#'; $expectedDescriptionUri = $taoNS . 'Lang' . $this->options['language']; $lgResource = new core_kernel_classes_Resource($expectedDescriptionUri); if (true === $lgResource->exists()) { $lgResource->delete(); $this->outVerbose("RDF language description '" . $this->options['language'] . "' successfully removed."); } else { $this->outVerbose("RDF language description '" . $this->options['language'] . "' not found but considered removed."); } }
public function tearDown() { parent::tearDown(); $this->credentials->delete(); }
/** * Short description of method enable * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return boolean */ public function enable() { $returnValue = (bool) false; if ($this->authenticate()) { if ($this->checkout()) { // has root file? $rootFile = $this->getRootFile(); if (!is_null($rootFile)) { // delete the ressource, not the files $ressource = new core_kernel_classes_Resource($rootFile); $ressource->delete(); } $rootFile = $this->createFile(''); $this->editPropertyValues(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_ROOTFILE), $rootFile); $this->editPropertyValues(new core_kernel_classes_Property(PROPERTY_GENERIS_VERSIONEDREPOSITORY_ENABLED), GENERIS_TRUE); common_Logger::i("The remote versioning repository " . $this->getUri() . " is bound to TAO."); core_kernel_fileSystem_Cache::flushCache(); $returnValue = true; } } return (bool) $returnValue; }
/** * Short description of method deleteOperation * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource operation * @return boolean */ public function deleteOperation(core_kernel_classes_Resource $operation) { $returnValue = (bool) false; $firstOperand = $operation->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_OPERATION_FIRST_OP)); if (!is_null($firstOperand) && $firstOperand instanceof core_kernel_classes_Resource) { $this->deleteTerm($firstOperand); } $secondOperand = $operation->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_OPERATION_SECND_OP)); if (!is_null($secondOperand) && $secondOperand instanceof core_kernel_classes_Resource) { $this->deleteTerm($secondOperand); } $returnValue = $operation->delete(true); return (bool) $returnValue; }
/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; under version 2 * of the License (non-upgradable). * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Copyright (c) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER); * 2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV); * */ include_once dirname(__FILE__) . '/../../includes/raw_start.php'; if (!$_POST['uri']) { // missing parameters common_Logger::w('Missing param \'uri\''); return false; } $user = new core_kernel_classes_Resource($_POST['uri']); $success = $user->delete(); if ($success) { common_Logger::i('Deleted user ' . $user->getUri()); } echo json_encode($success);
/** * Short description of method import * * @access public * @author Cédric Alfonsi, <*****@*****.**> * @param Repository vcs * @param string src * @param string target * @param string message * @param array options * @return core_kernel_file_File */ public function import(core_kernel_versioning_Repository $vcs, $src, $target, $message = "", $options = array()) { $returnValue = null; //Save the imported resource in the onthology ? $saveResource = isset($options['saveResource']) && $options['saveResource'] ? true : false; //Import the folder in the repository $result = core_kernel_versioning_subversionWindows_Utils::exec($vcs, 'import -m "' . stripslashes($message) . '" "' . $src . '" "' . $target . '"'); $repositoryUrl = $vcs->getUrl(); $relativePath = substr($target, strlen($repositoryUrl)); $folder = $vcs->createFile('', $relativePath); $folder->update(); //Save a resource if ($saveResource) { $returnValue = $folder; } else { $resourceToDelete = new core_kernel_classes_Resource($folder); $resourceToDelete->delete(); } return $returnValue; }
/** * Import specific source from the repository to the given target at the given revision * * @access public * @author Cédric Alfonsi, <*****@*****.**> * @param Repository vcs * @param string src * @param string target * @param string message * @param array options * @return core_kernel_file_File */ public function import(core_kernel_versioning_Repository $vcs, $src, $target, $message = "", $options = array()) { $returnValue = null; //Does not work in the current version of php (try later) https://bugs.php.net/bug.php?id=60293 //$returnValue = svn_import($src, $target, true); $startTime = helpers_Time::getMicroTime(); $saveResource = isset($options['saveResource']) && $options['saveResource'] ? true : false; if (!$vcs->authenticate()) { throw new core_kernel_versioning_exception_Exception('Authentication failed on fileSource ' . $vcs->getUri()); } $repositoryUrl = $vcs->getUrl(); $relativePath = substr($target, strlen($repositoryUrl)); $absolutePath = $vcs->getPath() . $relativePath; /* // The resource could already exist, this is not a problem //check if the resource already exist if(helpers_File::resourceExists($absolutePath)){ throw new core_kernel_versioning_exception_ResourceAlreadyExistsException('The folder ('.$absolutePath.') already exists in the repository ('.$vcs->getPath().')'); } // Same thing here //check if the file already exist else if(file_exists($absolutePath)){ throw new common_exception_FileAlreadyExists($absolutePath); } */ //Copy the src folder to the target destination helpers_File::copy($src, $absolutePath); // Create the importFolder $importFolder = $vcs->createFile('', $relativePath); // //Get status of the imported folder // $importFolderStatus = $importFolder->getStatus(array('SHOW_UPDATES'=>false)); // $importFolderYetCommited = true; // if($importFolderStatus == VERSIONING_FILE_STATUS_ADDED || $importFolderStatus == VERSIONING_FILE_STATUS_UNVERSIONED){ // $importFolderYetCommited = false; // } // // //If the import folder has been yet commited, commit its content // if($importFolderYetCommited){ // $filesToCommit = tao_helpers_File::scandir($importFolder->getAbsolutePath()); // $pathsFilesToCommit = array(); // foreach($filesToCommit as $fileToCommit){ // $pathFileToCommit = $fileToCommit->getAbsolutePath(); // $pathsFilesToCommit[] = $pathFileToCommit; // //Add content of the folder if it is not versioned or partially not versioned // if(!core_kernel_versioning_FileProxy::add($importFolder, $pathFileToCommit, true, true)){ // throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The add step encountered a problem'); // } // } // //Commit all the files in one commit operation // if(!core_kernel_versioning_FileProxy::commit($VersionedUnitFolderInstance, $pathsFilesToCommit)){ // throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The commit step encountered a problem'); // } // } // //Else commit itself // else{ // //Add the folder // if(!$importFolder->add(true, true)){ // throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The add step encountered a problem'); // } // //And commit it // if(!$importFolder->commit($message, true)){ // throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The commit step encountered a problem'); // } // } //Add the folder if (!$importFolder->add(true, true)) { throw new core_kernel_versioning_exception_Exception('unable to import the folder (' . $src . ') to the destination (' . $target . '). The add step encountered a problem'); } //And commit it if (!$importFolder->commit($message, true)) { throw new core_kernel_versioning_exception_Exception('unable to import the folder (' . $src . ') to the destination (' . $target . '). The commit step encountered a problem'); } //Delete the resource if the developer does not want to keep a reference in the onthology if ($saveResource) { $returnValue = $importFolder; } else { $resourceToDelete = new core_kernel_classes_Resource($importFolder->getUri()); $resourceToDelete->delete(); } $endTime = helpers_Time::getMicroTime(); common_Logger::i("svn_import (" . $src . ' -> ' . $target . ') -> ' . ($endTime - $startTime) . 's'); return $returnValue; }
/** * (non-PHPdoc) * @see taoTests_models_classes_TestModel::delete() */ public function delete(core_kernel_classes_Resource $content) { $content->delete(); }
/** * Remove a Generis User from persistent memory. Bound roles will remain * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param Resource user A reference to the User to be removed from the persistent memory of Generis. * @return boolean */ public function removeUser(core_kernel_classes_Resource $user) { $returnValue = (bool) false; $returnValue = $user->delete(); return (bool) $returnValue; }
/** * Short description of method deleteProcessExecution * * @access public * @author Somsack Sipasseuth, <*****@*****.**> * @param Resource processExecution * @param boolean finishedOnly * @return boolean */ public function deleteProcessExecution(core_kernel_classes_Resource $processExecution, $finishedOnly = false) { $returnValue = (bool) false; if ($processExecution->hasType($this->processInstancesClass)) { if ($finishedOnly) { if (!$this->isFinished($processExecution)) { return $returnValue; } } $allActivityExecutions = $processExecution->getPropertyValues($this->processInstancesActivityExecutionsProp); $count = count($allActivityExecutions); for ($i = 0; $i < $count; $i++) { $uri = $allActivityExecutions[$i]; if (common_Utils::isUri($uri)) { $activityExecution = new core_kernel_classes_Resource($uri); $activityExecution->delete(); //no need for the second param to "true" since all the related resources are going to be deleted in this method } } $returnValue = $processExecution->delete(); } return (bool) $returnValue; }
public function testEditMediaInstance() { $fileTmp = dirname(__DIR__) . '/sample/Italy.png'; $this->initializeMock($fileTmp); $this->fileManagerMock->expects($this->once())->method('deleteFile')->with('MyLink')->willReturn(true); $lang = 'EN-en'; $instanceUri = 'http://myFancyDomain.com/myGreatInstanceUri'; $instance = new \core_kernel_classes_Class($instanceUri); $instance->setPropertyValue(new \core_kernel_classes_Property(MEDIA_LINK), 'MyLink'); $this->mediaService->editMediaInstance($fileTmp, $instanceUri, $lang); $this->assertEquals($lang, $instance->getUniquePropertyValue(new \core_kernel_classes_Property(MEDIA_LANGUAGE)), 'The instance language is wrong'); // remove what has been done $inst = new \core_kernel_classes_Resource($instanceUri); $inst->delete(); }
/** * * remove an index property * @param core_kernel_classes_Resource $index * @return bool */ public function deletePropertyIndex(core_kernel_classes_Resource $index) { return $index->delete(true); }
/** * Short description of method delete * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param boolean deleteReference * @return boolean */ public function delete($deleteReference = false) { $returnValue = (bool) false; /*if(file_exists($this->getAbsolutePath())){ if (!@unlink($this->getAbsolutePath())){ throw new Exception(__('Unable to remove the file '.$this->getAbsolutePath())); } }*/ parent::delete($deleteReference); $returnValue = true; return (bool) $returnValue; }
/** * Delete a resource * * @param core_kernel_classes_Resource $resource * @return boolean */ public function deleteResource(core_kernel_classes_Resource $resource) { return $resource->delete(); }
/** * * @author Patrick Plichart, patrick@taotesting.com * @param string $uri * @throws common_exception_InvalidArgumentType * @throws common_exception_PreConditionFailure * @throws common_exception_NoContent */ public function delete($uri) { if (!common_Utils::isUri($uri)) { throw new common_exception_InvalidArgumentType(); } if (!$this->isInScope($uri)) { throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class"); } $resource = new core_kernel_classes_Resource($uri); // if the resource does not exist, indicate a not found exception if (count($resource->getRdfTriples()->sequence) == 0) { throw new common_exception_NoContent(); } $resource->delete(); }