fix up export service
This commit is contained in:
parent
9c302d1779
commit
b9c5b59269
1 changed files with 18 additions and 40 deletions
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
class MapExportService
|
||||
attr_reader :user, :map
|
||||
def initialize(user, map)
|
||||
attr_reader :user, :map, :base_url
|
||||
|
||||
def initialize(user, map, opts = {})
|
||||
@user = user
|
||||
@map = map
|
||||
@base_url = opts[:base_url] || 'https://metamaps.cc'
|
||||
end
|
||||
|
||||
def json
|
||||
|
@ -24,10 +26,20 @@ class MapExportService
|
|||
|
||||
def rdf
|
||||
output = ''
|
||||
output += rdf_header
|
||||
output += rdf_mappers
|
||||
output += rdf_topics
|
||||
output += rdf_synapses
|
||||
output += "PREFIX d: <#{base_url}/maps/#{map.id}>\n"
|
||||
output += "PREFIX mm: <#{base_url}/owl/map.owl.ttl>\n"
|
||||
output += "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
|
||||
output += "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
|
||||
output += "\n"
|
||||
map.contributors.each do |mapper|
|
||||
output += mapper.as_rdf
|
||||
end
|
||||
map.topics.each do |topic|
|
||||
output += topic.as_rdf
|
||||
end
|
||||
map.synapses.each do |synapse|
|
||||
output += synapse.as_rdf
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
|
@ -96,38 +108,4 @@ class MapExportService
|
|||
|
||||
spreadsheet
|
||||
end
|
||||
|
||||
def rdf_header
|
||||
output = ''
|
||||
output += "PREFIX d: <https://metamaps.cc/maps/#{map.id}>\n"
|
||||
output += "PREFIX mm: <https://metamaps.cc/owl/map.owl.ttl>\n"
|
||||
output += "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
|
||||
output += "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
|
||||
output += "\n"
|
||||
output
|
||||
end
|
||||
|
||||
def rdf_mappers
|
||||
output = ''
|
||||
map.contributors.each do |mapper|
|
||||
output += mapper.as_rdf
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
def rdf_topics
|
||||
output = ''
|
||||
map.topics.each do |topic|
|
||||
output += topic.as_rdf
|
||||
end
|
||||
output
|
||||
end
|
||||
|
||||
def rdf_synapses
|
||||
output = ''
|
||||
map.synapses.each do |synapse|
|
||||
output += synapse.as_rdf
|
||||
end
|
||||
output
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue