protected static function deleteDependencies(\core_kernel_classes_Triple $triple)
 {
     if (CloneHelper::isFileReference($triple)) {
         $referencer = ServiceManager::getServiceManager()->get(FileReferenceSerializer::SERVICE_ID);
         $source = $referencer->unserialize($triple->object);
         if ($source instanceof Directory) {
             $source->deleteSelf();
         } elseif ($source instanceof File) {
             $source->delete();
         }
         $referencer->cleanUp($triple->object);
     }
 }
 protected static function deleteDependencies(\core_kernel_classes_Triple $triple)
 {
     if ($triple->predicate == 'http://www.tao.lu/Ontologies/TAOItem.rdf#ItemContent') {
         $file = new \core_kernel_versioning_File($triple->object);
         if ($file->exists()) {
             $sourceDir = dirname($file->getAbsolutePath());
             $file->delete();
             \tao_helpers_File::delTree($sourceDir);
         }
     } elseif (CloneHelper::isFileReference($triple)) {
         $file = new \core_kernel_versioning_File($triple->object);
         if ($file->exists()) {
             $file->delete();
         }
     }
 }
 public function testIsFileReferenceResourceRange()
 {
     $classFile = new \core_kernel_classes_Class("http://www.tao.lu/Ontologies/generis.rdf#File");
     $file = $classFile->createInstance("test");
     $rdfsTriple = new \core_kernel_classes_Triple();
     $rdfsTriple->predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#value";
     $rdfsTriple->object = $file->getUri();
     $this->assertTrue(CloneHelper::isFileReference($rdfsTriple));
     $file->delete();
 }
 public function testGetPropertyMap()
 {
     $this->assertFileExists(__DIR__ . '/sample/test.xml');
     $dir = $this->getTempDirectory();
     $file = $dir->getFile('/sample/test.xml');
     $file->put(file_get_contents(__DIR__ . '/sample/test.xml'));
     /** @var FileReferenceSerializer $serializer */
     $serializer = ServiceManager::getServiceManager()->get(FileReferenceSerializer::SERVICE_ID);
     $fileUri = $serializer->serialize($file);
     //see if clone file works
     $rdfsTriple = new \core_kernel_classes_Triple();
     $rdfsTriple->predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#value";
     $rdfsTriple->object = $fileUri;
     $return = CloneHelper::getPropertyStorageMap([$rdfsTriple]);
     $this->assertEquals($dir->getFileSystemId(), reset($return));
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoRevision\model\Repository::restore()
  */
 public function restore(Revision $revision)
 {
     $resourceId = $revision->getResourceId();
     $data = $this->getStorage()->getData($revision);
     $resource = new \core_kernel_classes_Resource($resourceId);
     $originFilesystemMap = CloneHelper::getPropertyStorageMap($resource->getRdfTriples());
     DeleteHelper::deepDelete($resource);
     foreach (CloneHelper::deepCloneTriples($data, $originFilesystemMap) as $triple) {
         ModelManager::getModel()->getRdfInterface()->add($triple);
     }
     return true;
 }
 protected function deepClone(core_kernel_classes_Resource $source)
 {
     $clonedTriples = CloneHelper::deepCloneTriples($source->getRdfTriples());
     $newUri = common_Utils::getNewUri();
     $wsModel = $this->getWorkspaceModel();
     $rdfInterface = $wsModel->getRdfInterface();
     foreach ($clonedTriples as $triple) {
         $triple->subject = $newUri;
         $triple->modelid = $wsModel->getNewTripleModelId();
         $rdfInterface->add($triple);
     }
     return new core_kernel_classes_Resource($newUri);
 }