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
|
# frozen_string_literal: true
|
||||||
class MapExportService
|
class MapExportService
|
||||||
attr_reader :user, :map
|
attr_reader :user, :map, :base_url
|
||||||
def initialize(user, map)
|
|
||||||
|
def initialize(user, map, opts = {})
|
||||||
@user = user
|
@user = user
|
||||||
@map = map
|
@map = map
|
||||||
|
@base_url = opts[:base_url] || 'https://metamaps.cc'
|
||||||
end
|
end
|
||||||
|
|
||||||
def json
|
def json
|
||||||
|
@ -24,10 +26,20 @@ class MapExportService
|
||||||
|
|
||||||
def rdf
|
def rdf
|
||||||
output = ''
|
output = ''
|
||||||
output += rdf_header
|
output += "PREFIX d: <#{base_url}/maps/#{map.id}>\n"
|
||||||
output += rdf_mappers
|
output += "PREFIX mm: <#{base_url}/owl/map.owl.ttl>\n"
|
||||||
output += rdf_topics
|
output += "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
|
||||||
output += rdf_synapses
|
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
|
output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,38 +108,4 @@ class MapExportService
|
||||||
|
|
||||||
spreadsheet
|
spreadsheet
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue