Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/ontologies_linked_data/models/ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,7 @@ def delete(*args)
index_commit = options[:index_commit] == false ? false : true

super(*args)
self.ontology.unindex(index_commit)
self.ontology.unindex_properties(index_commit)
self.ontology.unindex_all_data(index_commit)

self.bring(:metrics) if self.bring?(:metrics)
self.metrics.delete if self.metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def index(logger, commit = true, optimize = true)
begin
logger.info("Indexing ontology terms: #{@submission.ontology.acronym}...")
t0 = Time.now
@submission.ontology.unindex(false)
@submission.ontology.unindex_by_acronym(false)
logger.info("Removed ontology terms index (#{Time.now - t0}s)"); logger.flush

paging = LinkedData::Models::Class.in(@submission).include(:unmapped).aggregate(:count, :children).page(page, size)
Expand Down Expand Up @@ -304,4 +304,3 @@ def validate_class_ancestors(cls, logger)
end
end
end

37 changes: 37 additions & 0 deletions test/models/test_ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,43 @@ def test_generate_missing_labels_sets_error_status_on_initial_page_fetch_failure
assert_nil RequestStore.store[:requested_lang]
end

def test_index_terms_clears_existing_term_docs_by_acronym
ontology = mock("ontology")
ontology.stubs(:bring?).with(:acronym).returns(false)
ontology.stubs(:bring?).with(:provisionalClasses).returns(false)
ontology.stubs(:acronym).returns("NPDX")
ontology.stubs(:provisionalClasses).returns([])
ontology.expects(:unindex_by_acronym).with(false)

submission = mock("submission")
submission.stubs(:bring?).with(:ontology).returns(false)
submission.stubs(:ontology).returns(ontology)
submission.stubs(:csv_path).returns("/tmp/npdx-classes.csv")
submission.stubs(:loaded_attributes).returns([:hasOntologyLanguage])
submission.stubs(:hasOntologyLanguage).returns(stub(skos?: true))

csv_writer = mock("csv-writer")
csv_writer.expects(:open).with(ontology, "/tmp/npdx-classes.csv")
csv_writer.expects(:close)
LinkedData::Utils::OntologyCSVWriter.expects(:new).returns(csv_writer)

empty_page = stub(total_pages: 0)
paging = mock("class-paging")
paging.expects(:include).with(:unmapped).returns(paging)
paging.expects(:aggregate).with(:count, :children).returns(paging)
paging.expects(:page).with(0, 2500).returns(paging)
paging.expects(:page).with(1, 2500).returns(paging)
paging.expects(:all).returns(empty_page)
LinkedData::Models::Class.expects(:in).with(submission).returns(paging)

indexer = LinkedData::Services::OntologySubmissionIndexer.new(submission)
indexer.stubs(:compute_ancestors_map).returns({})

indexer.send(:index, Logger.new(TestLogFile.new), false, false)
ensure
LinkedData::Models::Class.ancestors_cache = nil
end

def test_skos_submission_without_skos_concept_processes_without_error
# Regression for GH-274: SKOS submissions with no skos:Concept previously entered the
# retry path and failed during missing-label generation because the CSV class_count
Expand Down
Loading