Skip to content

Commit

Permalink
disable attributes onUpdate callbacks feature
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 7, 2023
1 parent 66e562d commit a1e3af9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/ontologies_linked_data/models/ontology.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OntologyAnalyticsError < StandardError; end

attribute :acl, enforce: [:list, :user]

attribute :viewOf, enforce: [:ontology], onUpdate: :update_submissions_has_part
attribute :viewOf, enforce: [:ontology]
attribute :views, :inverse => { on: :ontology, attribute: :viewOf }
attribute :ontologyType, enforce: [:ontology_type], default: lambda { |record| LinkedData::Models::OntologyType.find("ONTOLOGY").include(:code).first }

Expand Down
32 changes: 15 additions & 17 deletions lib/ontologies_linked_data/models/ontology_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ class OntologySubmission < LinkedData::Models::Base
attribute :URI, namespace: :omv, type: :uri, enforce: %i[existence distinct_of_identifier]
attribute :versionIRI, namespace: :owl, type: :uri, enforce: [:distinct_of_URI]
attribute :version, namespace: :omv
attribute :status, namespace: :omv, enforce: %i[existence], default: ->(x) { 'production' },
onUpdate: :retired_previous_align
attribute :deprecated, namespace: :owl, type: :boolean, enforce: [:deprecated_retired_align],
onUpdate: :deprecate_previous_submissions, default: ->(x) { false }
attribute :status, namespace: :omv, enforce: %i[existence], default: ->(x) { 'production' }
attribute :deprecated, namespace: :owl, type: :boolean, enforce: [:deprecated_retired_align], default: ->(x) { false }
attribute :hasOntologyLanguage, namespace: :omv, type: :ontology_format, enforce: [:existence]
attribute :hasFormalityLevel, namespace: :omv, type: :uri
attribute :hasOntologySyntax, namespace: :omv, type: :uri, default: ->(s) {ontology_syntax_default(s)}
Expand Down Expand Up @@ -134,22 +132,22 @@ class OntologySubmission < LinkedData::Models::Base
attribute :includedInDataCatalog, namespace: :schema, type: %i[list uri]

# Relations
attribute :hasPriorVersion, namespace: :omv, type: :uri, onUpdate: [:include_previous_submission]
attribute :hasPart, namespace: :dct, type: %i[uri list], enforce: %i[include_ontology_views]
attribute :ontologyRelatedTo, namespace: :door, type: %i[list uri], onUpdate: :enforce_symmetric_ontologies
attribute :similarTo, namespace: :door, type: %i[list uri], onUpdate: :enforce_symmetric_ontologies
attribute :comesFromTheSameDomain, namespace: :door, type: %i[list uri], onUpdate: :enforce_symmetric_ontologies
attribute :isAlignedTo, namespace: :door, type: %i[list uri], onUpdate: :enforce_symmetric_ontologies
attribute :hasPriorVersion, namespace: :omv, type: :uri
attribute :hasPart, namespace: :dct, type: %i[uri list]
attribute :ontologyRelatedTo, namespace: :door, type: %i[list uri]
attribute :similarTo, namespace: :door, type: %i[list uri]
attribute :comesFromTheSameDomain, namespace: :door, type: %i[list uri]
attribute :isAlignedTo, namespace: :door, type: %i[list uri]
attribute :isBackwardCompatibleWith, namespace: :omv, type: %i[list uri]
attribute :isIncompatibleWith, namespace: :omv, type: %i[list uri]
attribute :hasDisparateModelling, namespace: :door, type: %i[list uri], onUpdate: :enforce_symmetric_ontologies
attribute :hasDisparateModelling, namespace: :door, type: %i[list uri]
attribute :hasDisjunctionsWith, namespace: :voaf, type: %i[uri list]
attribute :generalizes, namespace: :voaf, type: %i[list uri], onUpdate: :ontology_inverse_of_callback
attribute :explanationEvolution, namespace: :door, type: %i[list uri], onUpdate: :ontology_inverse_of_callback
attribute :useImports, namespace: :omv, type: %i[list uri], onUpdate: :ontology_inverse_of_callback
attribute :usedBy, namespace: :voaf, type: %i[uri list], onUpdate: :ontology_inverse_of_callback
attribute :workTranslation, namespace: :schema, type: %i[uri list], onUpdate: :ontology_inverse_of_callback
attribute :translationOfWork, namespace: :schema, type: %i[uri list], onUpdate: :ontology_inverse_of_callback
attribute :generalizes, namespace: :voaf, type: %i[list uri]
attribute :explanationEvolution, namespace: :door, type: %i[list uri]
attribute :useImports, namespace: :omv, type: %i[list uri]
attribute :usedBy, namespace: :voaf, type: %i[uri list]
attribute :workTranslation, namespace: :schema, type: %i[uri list]
attribute :translationOfWork, namespace: :schema, type: %i[uri list]

# Content metadata
attribute :uriRegexPattern, namespace: :void, type: :uri
Expand Down
5 changes: 5 additions & 0 deletions test/models/test_ontology_submission_validators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
class TestOntologySubmissionValidators < LinkedData::TestOntologyCommon

def test_enforce_symmetric_ontologies
skip('skip new callbacks tests until reimplemented')
ontologies_properties_callbacks(:ontologyRelatedTo)
end

def test_lexvo_language_validator

submissions = sorted_submissions_init(1)

sub = submissions.first
Expand All @@ -29,6 +31,7 @@ def test_lexvo_language_validator

# Regroup all validity test related to a submission retired status (deprecated, valid date)
def test_submission_retired_validity
skip('skip new callbacks tests until reimplemented')
sorted_submissions = sorted_submissions_init

latest = sorted_submissions.first
Expand Down Expand Up @@ -114,6 +117,7 @@ def test_has_prior_version_callback
end

def test_update_submissions_has_part
skip('skip new callbacks tests until reimplemented')
ont_count, ont_acronyms, ontologies =
create_ontologies_and_submissions(ont_count: 3, submission_count: 1,
process_submission: false, acronym: 'NCBO-545')
Expand Down Expand Up @@ -186,6 +190,7 @@ def sorted_submissions_init(submission_count = 3)


def ontologies_properties_callbacks(attr, inverse_attr = nil)
skip('skip new callbacks tests until reimplemented')
inverse_attr = attr unless inverse_attr
ont_count, ont_acronyms, ontologies =
create_ontologies_and_submissions(ont_count: 3, submission_count: 1,
Expand Down

0 comments on commit a1e3af9

Please sign in to comment.