diff --git a/bin/owlapi-wrapper-1.3.8.jar b/bin/owlapi-wrapper-1.4.1.jar similarity index 95% rename from bin/owlapi-wrapper-1.3.8.jar rename to bin/owlapi-wrapper-1.4.1.jar index 1765041f..a834d38b 100644 Binary files a/bin/owlapi-wrapper-1.3.8.jar and b/bin/owlapi-wrapper-1.4.1.jar differ diff --git a/lib/ontologies_linked_data.rb b/lib/ontologies_linked_data.rb index 678e0e89..718971ea 100644 --- a/lib/ontologies_linked_data.rb +++ b/lib/ontologies_linked_data.rb @@ -35,6 +35,10 @@ # Require all models project_root = File.dirname(File.absolute_path(__FILE__)) +models = Dir.glob("#{project_root}/ontologies_linked_data/concerns/**/*.rb").sort +models.each do |m| + require m +end # We need to require deterministic - that is why we have the sort. models = Dir.glob(project_root + '/ontologies_linked_data/models/**/*.rb').sort models.each do |m| diff --git a/lib/ontologies_linked_data/concerns/ontology_submissions/submission_metadata_extractor.rb b/lib/ontologies_linked_data/concerns/ontology_submissions/submission_metadata_extractor.rb new file mode 100644 index 00000000..d8bf8019 --- /dev/null +++ b/lib/ontologies_linked_data/concerns/ontology_submissions/submission_metadata_extractor.rb @@ -0,0 +1,39 @@ +module LinkedData + module Concerns + module OntologySubmission + module MetadataExtractor + + def extract_metadata + version_info = extract_version + ontology_iri = extract_ontology_iri + + self.version = version_info if version_info + self.uri = ontology_iri if ontology_iri + + end + + def extract_version + + query = Goo.sparql_query_client.select(:versionInfo).distinct + .from(self.id) + .where([RDF::URI.new('http://bioportal.bioontology.org/ontologies/versionSubject'), + RDF::URI.new('http://www.w3.org/2002/07/owl#versionInfo'), + :versionInfo]) + + sol = query.each_solution.first || {} + sol[:versionInfo]&.to_s + end + + def extract_ontology_iri + query = Goo.sparql_query_client.select(:uri).distinct + .from(self.id) + .where([:uri, + RDF::URI.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + RDF::URI.new('http://www.w3.org/2002/07/owl#Ontology')]) + sol = query.each_solution.first || {} + sol[:uri]&.to_s + end + end + end + end +end diff --git a/lib/ontologies_linked_data/models/ontology_submission.rb b/lib/ontologies_linked_data/models/ontology_submission.rb index 050958dd..893842b6 100644 --- a/lib/ontologies_linked_data/models/ontology_submission.rb +++ b/lib/ontologies_linked_data/models/ontology_submission.rb @@ -12,6 +12,8 @@ module Models class OntologySubmission < LinkedData::Models::Base + include LinkedData::Concerns::OntologySubmission::MetadataExtractor + FILES_TO_DELETE = ['labels.ttl', 'mappings.ttl', 'obsolete.ttl', 'owlapi.xrdf', 'errors.log'] FLAT_ROOTS_LIMIT = 1000 @@ -473,28 +475,9 @@ def generate_rdf(logger, file_path, reasoning=true) logger.flush end delete_and_append(triples_file_path, logger, mime_type) - version_info = extract_version() - - if version_info - self.version = version_info - end end - def extract_version - query_version_info = < - ?versionInfo . -} -eos - Goo.sparql_query_client.query(query_version_info).each_solution do |sol| - return sol[:versionInfo].to_s - end - return nil - end def process_callbacks(logger, callbacks, action_name, &block) callbacks.delete_if do |_, callback| @@ -971,6 +954,7 @@ def process_submission(logger, options={}) zip_dst = unzip_submission(logger) file_path = zip_dst ? zip_dst.to_s : self.uploadFilePath.to_s generate_rdf(logger, file_path, reasoning=reasoning) + extract_metadata add_submission_status(status) self.save rescue Exception => e diff --git a/lib/ontologies_linked_data/parser/owlapi.rb b/lib/ontologies_linked_data/parser/owlapi.rb index 12eac979..33a7dc4a 100644 --- a/lib/ontologies_linked_data/parser/owlapi.rb +++ b/lib/ontologies_linked_data/parser/owlapi.rb @@ -13,7 +13,7 @@ class RDFFileNotGeneratedException < Parser::ParserException class OWLAPICommand def initialize(input_file, output_repo, opts = {}) - @owlapi_wrapper_jar_path = LinkedData.bindir + "/owlapi-wrapper-1.3.8.jar" + @owlapi_wrapper_jar_path = LinkedData.bindir + "/owlapi-wrapper-1.4.1.jar" @input_file = input_file @output_repo = output_repo @master_file = opts[:master_file]