Class: LD4L::WorksRDF::AttemptGenericMetadataExtraction

Inherits:
Object
  • Object
show all
Defined in:
lib/ld4l/works_rdf/services/attempt_generic_metadata_extraction.rb

Class Method Summary collapse

Class Method Details

.call(uri) ⇒ Object

Attempt to get metadata from the source of the URI via content negotiation.

Parameters:

  • uri (String, RDF::URI)

    for the work

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ld4l/works_rdf/services/attempt_generic_metadata_extraction.rb', line 11

def self.call( uri )
  raise ArgumentError, 'uri argument must be a uri string or an instance of RDF::URI'  unless
      uri.kind_of?(String) && uri.size > 0 || uri.kind_of?(RDF::URI)

  begin
    turtle     = LD4L::WorksRDF::GetTurtleFromURI.call(uri)
    graph      = LD4L::WorksRDF::PopulateGraphFromTurtle.call(turtle)
  rescue
    begin
      rdfxml     = LD4L::WorksRDF::GetRdfxmlFromURI.call(uri)
      graph      = LD4L::WorksRDF::PopulateGraphFromRdfxml.call(rdfxml)
    rescue
         = LD4L::WorksRDF::SetErrorInMetadata.call(uri,'ERROR: Unable to extract metadata as turtle or rdfxml from URI')
      return 
    end
  end

  repository = LD4L::WorksRDF::PopulateRepositoryFromGraph.call(graph) if graph
     = LD4L::WorksRDF::SetErrorInMetadata.call(uri,'ERROR: Unable to populate repository from graph') unless repository

  model      = LD4L::WorksRDF::PopulateGenericModelFromRepository.call(uri,repository) if repository
     = LD4L::WorksRDF::SetErrorInMetadata.call(uri,'ERROR: Unable to populate models from repository') unless model

     = LD4L::WorksRDF::GetMetadataFromGenericModel.call(uri,model) if model
  

end