Class: RDF::FCRepo4

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/fcrepo4/vocab.rb,
lib/rdf/fcrepo4/helper.rb

Class Method Summary collapse

Class Method Details

.remove_fedora_triples(graph) ⇒ Object

returns graph without any fedora-specific triples



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rdf/fcrepo4/helper.rb', line 8

def self.remove_fedora_triples graph
  if graph && graph.is_a?(RDF::Graph) && graph.count > 0
    no_fedora_graph = RDF::Graph.new
    fedora_props = RDF::FCRepo4.properties.map {|p| p.to_s}
    # the fedora vocab is not complete and also doesn't cover modeshape triples
    fedora_ns = "http://fedora.info/definitions"
    modeshape_ns = "http://www.jcp.org/jcr"
    graph.each { |stmt|  
      no_fedora_graph << stmt unless fedora_props.include?(stmt.predicate.to_s) || 
                                  fedora_props.include?(stmt.object.to_s) ||
                                  fedora_props.include?(stmt.subject.to_s) ||
                                  stmt.predicate.to_s.match(fedora_ns) ||
                                  stmt.predicate.to_s.match(modeshape_ns) || 
                                  stmt.subject.to_s.match(fedora_ns) ||
                                  stmt.object.to_s.match(fedora_ns) ||
                                  stmt.object.to_s.match(modeshape_ns)
    }
    no_fedora_graph
  else
    graph
  end
end