瀏覽代碼

DELETE resource fragment.

Stefano Cossu 7 年之前
父節點
當前提交
391ccb9ab1
共有 1 個文件被更改,包括 7 次插入2 次删除
  1. 7 2
      lakesuperior/model/ldpr.py

+ 7 - 2
lakesuperior/model/ldpr.py

@@ -617,10 +617,17 @@ class Ldpr(metaclass=ABCMeta):
         Remove all traces of a resource and versions.
         '''
         self._logger.info('Purging resource {}'.format(self.urn))
+        imr = self.rdfly.extract_imr(
+                self.urn, incl_inbound=True, strict=False)
 
         # Remove resource itself.
         self.rdfly.modify_dataset({(self.urn, None, None)}, types=None)
 
+        # Remove fragments.
+        for frag_urn in imr.graph[
+                : nsc['fcsystem'].fragmentOf : self.urn]:
+            self.rdfly.modify_dataset({(frag_urn, None, None)}, types={})
+
         # Remove snapshots.
         for snap_urn in self.versions:
             remove_trp = {
@@ -631,8 +638,6 @@ class Ldpr(metaclass=ABCMeta):
 
         # Remove inbound references.
         if inbound:
-            imr = self.rdfly.extract_imr(
-                    self.urn, incl_inbound=True, strict=False)
             for ib_rsrc_uri in imr.graph.subjects(None, self.urn):
                 remove_trp = {(ib_rsrc_uri, None, self.urn)}
                 Ldpr(ib_rsrc_uri)._modify_rsrc(self.RES_UPDATED, remove_trp)