@@ -871,7 +871,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
871
871
}
872
872
873
873
/**
874
- * Removes all statements in a doc, along with the related metadata including request/response
874
+ * Removes all statements in a doc, along with the related metadata including request/response/status
875
875
* @param doc - The document / graph
876
876
*/
877
877
removeDocument ( doc : Quad_Graph ) : IndexedFormula {
@@ -881,27 +881,42 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
881
881
for ( var i = 0 ; i < sts . length ; i ++ ) {
882
882
this . removeStatement ( sts [ i ] )
883
883
}
884
+ this . removeMatches ( doc as Quad_Subject , null , null )
884
885
return this
885
886
}
886
887
887
888
removeMetadata ( doc : Quad_Graph ) : IndexedFormula {
888
889
const meta = this . sym ( 'chrome://TheCurrentSession' ) // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
889
- const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#' // alain
890
- // remove request /response and metadata
890
+ const linkNamespaceURI = 'http://www.w3.org/2007/ont/link#'
891
+ // remove status /response/request metadata
891
892
const requests = this . statementsMatching ( undefined , this . sym ( `${ linkNamespaceURI } requestedURI` ) , this . rdfFactory . literal ( doc . value ) , meta ) . map ( st => st . subject )
892
893
for ( var r = 0 ; r < requests . length ; r ++ ) {
893
894
const request = requests [ r ]
894
895
if ( request != undefined ) {
896
+ // removeMatches unresolved issue with collection https://github.com/linkeddata/rdflib.js/issues/631
897
+ let sts : Quad [ ]
898
+ // status collection
899
+ const status = this . any ( request , this . sym ( `${ linkNamespaceURI } status` ) , null , meta ) as Quad_Subject
900
+ if ( status != undefined ) {
901
+ sts = this . statementsMatching ( status , this . sym ( `${ linkNamespaceURI } status` ) , null , meta ) . slice ( )
902
+ for ( var i = 0 ; i < sts . length ; i ++ ) {
903
+ this . removeStatement ( sts [ i ] )
904
+ }
905
+ }
906
+ // response items list
895
907
const response = this . any ( request , this . sym ( `${ linkNamespaceURI } response` ) , null , meta ) as Quad_Subject
896
- if ( response != undefined ) { // ts
897
- this . removeMatches ( response , null , null , meta )
908
+ if ( response != undefined ) {
909
+ sts = this . statementsMatching ( response , null , null , meta ) . slice ( )
910
+ for ( var i = 0 ; i < sts . length ; i ++ ) {
911
+ this . removeStatement ( sts [ i ] )
912
+ }
898
913
}
899
- // may be not needed
900
- const status = this . any ( request , this . sym ( ` ${ linkNamespaceURI } status` ) , null , meta ) as Quad_Subject
901
- if ( status != undefined ) { // ts
902
- this . removeMatches ( status , null , null , meta )
914
+ // request triples
915
+ sts = this . statementsMatching ( request , null , null , meta ) . slice ( )
916
+ for ( var i = 0 ; i < sts . length ; i ++ ) {
917
+ this . removeStatement ( sts [ i ] )
903
918
}
904
- this . removeMatches ( request , null , null , meta )
919
+
905
920
}
906
921
}
907
922
this . removeMatches ( this . sym ( doc . value ) , null , null , meta ) // content-type
0 commit comments