Skip to content

Commit

Permalink
add ontology edit metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 23, 2023
1 parent e9028e3 commit f9cf418
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 78 deletions.
57 changes: 57 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
}


def wait_for(selector, tries = 5)
tries.times.each do
break if page.has_selector?(selector)
sleep 1
end
end

def wait_for_text(text, tries = 5)
tries.times.each do
sleep 1
break if page.has_text?(text)
end
assert_text text
end

def login_in_as(user)
create_user(user)

Expand All @@ -28,6 +43,48 @@ def login_in_as(user)
click_button 'Login'
end


def assert_date(date)
assert_text I18n.l(DateTime.parse(date), format: '%B %-d, %Y')
end

def search_input(selector, value)
within "#{selector}" do
find(".search-inputs .input-field-component").last.set(value)
page.execute_script("document.querySelector('#{selector} > .search-inputs .input-field-component').dispatchEvent(new Event('input'))")
sleep 1
find(".search-inputs .search-content", text: value).click
sleep 1
find("input", text: 'Save').click
end
end
def list_checks(selected_values, all_values = [])
all_values.each do |val|
uncheck val, allow_label_click: true
end

selected_values.each do |val|
check val, allow_label_click: true
end
end

def list_inputs(parent_selector, selector, values)
within parent_selector do
all('.delete').each { |x| x.click }
find('.add-another-object', text: 'Add another').click
if values.is_a?(Hash)
values.each do |key , val|
all("[name^='#{selector}'][name$='[#{key}]']").last.set(val)
end
elsif values.is_a?(Array)
values.each do |val|
all("[name^='#{selector}']").last.set(val)
find('.add-another-object', text: 'Add another').click
end
end

end
end
def tom_select(selector, values)

multiple = values.is_a?(Array)
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/ontologies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ontology2:
notes: "This is the second ontology."
administeredBy:
group:
viewingRestriction: "public"
viewingRestriction: "private"
hasDomain:
acl:

Expand Down
147 changes: 106 additions & 41 deletions test/fixtures/submissions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ submission1:
hasFormalityLevel: "http://example.org/formality#Informal"
hasOntologySyntax: "http://www.w3.org/2002/07/owl#FunctionalSyntax"
naturalLanguage:
- "en"
- "http://lexvo.org/id/iso639-1/en"
isOfType: "http://example.org/ontologyType#DomainOntology"
identifier:
- "http://example.org/ontologies/ontology1/identifier1"
Expand Down Expand Up @@ -39,13 +39,12 @@ submission1:
valid: "2023-01-31T00:00:00Z"
curatedOn:
- "2023-01-15T12:00:00Z"
- "2023-01-20T14:30:00Z"
creationDate: "2023-01-01T00:00:00Z"
modificationDate: "2023-01-15T16:45:00Z"
contact: {
contact1: "contact1@test.com",
contact2: "contact2@test.com"
}
contact: [
{name: 'contact1' , email: "contact1@test.com"},
{name: 'contact2' , email: "contact2@test.com"},
]
pullLocation: 'https://raw.githubusercontent.com/owlcs/pizza-ontology/master/pizza.owl'

submission2:
Expand All @@ -55,11 +54,11 @@ submission2:
status: "beta"
deprecated: true
hasOntologyLanguage: "SKOS"
hasFormalityLevel: "http://example.org/formality#Formal"
hasOntologySyntax: "http://www.w3.org/2002/07/owl#ManchesterSyntax"
hasFormalityLevel: "Ontology"
hasOntologySyntax: "OWL Manchester Syntax"
naturalLanguage:
- "fr"
isOfType: "http://example.org/ontologyType#KnowledgeBase"
- "French"
isOfType: "Application Ontology"
identifier:
- "http://example.org/ontologies/ontology2/identifier1"
- "http://example.org/ontologies/ontology2/identifier2"
Expand Down Expand Up @@ -89,14 +88,86 @@ submission2:
valid: "2023-02-28T00:00:00Z"
curatedOn:
- "2023-02-15T12:00:00Z"
- "2023-02-20T14:30:00Z"
creationDate: "2023-02-01T00:00:00Z"
modificationDate: "2023-02-15T16:45:00Z"
contact: {
contact3: "contact3@test.com",
contact4: "contact4@test.com"
}
contact: [
{name: 'contact3' , email: "contact3@test.com"},
{name: 'contact4' , email: "contact4@test.com"},
]
pullLocation: 'https://www.w3.org/2009/08/skos-reference/skos.rdf'
source:
- "source 2.1"
- "source 2.2"
endpoint:
- "https://endpoint.2.1.com"
- "https://endpoint.2.2.com"
includedInDataCatalog:
- "AgroPortal"
- "MedPortal"
associatedMedia:
- "https://associatedMedia.2.1.com"
- "https://associatedMedia.2.2.com"
- "https://associatedMedia.2.3.com"
depiction:
- "https://depiction.2.1.com"
- "https://depiction.2.2.com"
logo: "https://logo.2.com"
audience: "audience 2"
repository: "https://repository.2.com"
bugDatabase: "https://bugDatabase.2.com"
mailingList: "mailingList2"
toDoList:
- 'todo2.1'
- 'todo2.2'
- 'todo2.3'
- 'todo2.4'
award:
- 'award2.1'
- 'award2.2'
knownUsage:
- 'usage2.1'
- 'usage2.2'
- 'usage2.3'
designedForOntologyTask:
- 'Search Task'
- 'Indexing Task'
hasDomain:
- "hasDomain2.1"
- "hasDomain2.2"
- "hasDomain2.3"
coverage: "coverage2"
example:
- "exmaple2.1"
- "exmaple2.2"
hasPriorVersion: "https://hasPriorVersion.2.com"
# hasPart: TODO: auto complete this programmatically
obsoleteParent: "https://obsoleteParent.2.com"
uriRegexPattern: "https://uriRegexPattern.2.com"
preferredNamespaceUri: "https://preferredNamespaceUri.2.com"
preferredNamespacePrefix: "prefix2"
exampleIdentifier: "https://exampleIdentifier.2.com"
keyClasses:
- "https://keyClasses.2.1.com"
- "https://keyClasses.2.2.com"
- "https://keyClasses.2.3.com"
metadataVoc:
- "RDF Schema (RDFS)"
- "Dublin core (DCTERMS)"
conformsToKnowledgeRepresentationParadigm: "conformsToKnowledgeRepresentationParadigm2"
usedOntologyEngineeringMethodology: "usedOntologyEngineeringMethodology2"
usedOntologyEngineeringTool:
- "Protégé"
- "SWOOP"
accrualMethod:
- "https://accrualMethod.2.1.com"
- "https://accrualMethod.2.2.com"
- "https://accrualMethod.2.3.com"
accrualPeriodicity: "Annual"
accrualPolicy: "accrualPolicy2"





submission3:
URI: "http://example.org/ontologies/ontology3"
Expand All @@ -108,7 +179,7 @@ submission3:
hasFormalityLevel: "http://example.org/formality#Informal"
hasOntologySyntax: "http://www.w3.org/2002/07/owl#FunctionalSyntax"
naturalLanguage:
- "en"
- "http://lexvo.org/id/iso639-1/en"
isOfType: "http://example.org/ontologyType#DomainOntology"
identifier:
- "http://example.org/ontologies/ontology3/identifier1"
Expand Down Expand Up @@ -137,15 +208,13 @@ submission3:
morePermissions: "Additional permissions"
released: "2023-03-01T00:00:00Z"
valid: "2023-03-31T00:00:00Z"
curatedOn:
- "2023-03-15T12:00:00Z"
- "2023-03-20T14:30:00Z"
curatedOn: "2023-03-15T12:00:00Z"
creationDate: "2023-02-01T00:00:00Z"
modificationDate: "2023-02-15T16:45:00Z"
contact: {
contact5: "contact5@test.com",
contact6: "contact6@test.com"
}
contact: [
{name: 'contact5' , email: "contact5@test.com"},
{name: 'contact6' , email: "contact6@test.com"},
]
pullLocation: 'http://example.org/pull3'

submission4:
Expand All @@ -158,7 +227,7 @@ submission4:
hasFormalityLevel: "http://example.org/formality#Formal"
hasOntologySyntax: "http://www.w3.org/2002/07/owl#ManchesterSyntax"
naturalLanguage:
- "fr"
- "http://lexvo.org/id/iso639-1/fr"
isOfType: "http://example.org/ontologyType#KnowledgeBase"
identifier:
- "http://example.org/ontologies/ontology4/identifier1"
Expand All @@ -183,19 +252,17 @@ submission4:
- "http://example.org/publication7"
- "http://example.org/publication8"
hasLicense: "http://example.org/licenses/license4"
useGuidelines: "Usage guidelines"
morePermissions: "More permissions"
useGuidelines: "Usage guidelines 2"
morePermissions: "More permissions 2"
released: "2023-04-01T00:00:00Z"
valid: "2023-04-30T00:00:00Z"
curatedOn:
- "2023-04-15T12:00:00Z"
- "2023-04-20T14:30:00Z"
curatedOn: "2023-04-15T12:00:00Z"
creationDate: "2023-04-01T00:00:00Z"
modificationDate: "2023-04-15T16:45:00Z"
contact: {
contact7: "contact7@test.com",
contact8: "contact8@test.com"
}
contact: [
{name: 'contact7' , email: "contact7@test.com"},
{name: 'contact8' , email: "contact8@test.com"},
]
pullLocation: 'http://example.org/pull4'

submission5:
Expand All @@ -208,7 +275,7 @@ submission5:
hasFormalityLevel: "http://example.org/formality#Informal"
hasOntologySyntax: "http://www.w3.org/2002/07/owl#FunctionalSyntax"
naturalLanguage:
- "en"
- "http://lexvo.org/id/iso639-1/en"
isOfType: "http://example.org/ontologyType#DomainOntology"
identifier:
- "http://example.org/ontologies/ontology5/identifier1"
Expand Down Expand Up @@ -237,13 +304,11 @@ submission5:
morePermissions: "Additional permissions"
released: "2023-05-01T00:00:00Z"
valid: "2023-05-31T00:00:00Z"
curatedOn:
- "2023-05-15T12:00:00Z"
- "2023-05-20T14:30:00Z"
curatedOn: "2023-05-15T12:00:00Z"
creationDate: "2023-05-01T00:00:00Z"
modificationDate: "2023-05-15T16:45:00Z"
contact: {
contact9: "contact9@test.com",
contact10: "contact10@test.com"
}
contact: [
{name: 'contact9' , email: "contact9@test.com"},
{name: 'contact10' , email: "contact10@test.com"},
]
pullLocation: 'http://example.org/pull5'
56 changes: 53 additions & 3 deletions test/helpers/application_test_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
require 'rails/test_help'
module ApplicationTestHelpers

def self.transform_models_to_ids(object)
object.each_pair do |key, value|
if value.is_a?(Array) && value.first.is_a?(LinkedData::Client::Base)
object[key] = value.map(&:id)
elsif value.is_a?(LinkedData::Client::Base)
object[key] = value.id
end
end
object
end

module Users
def sign_in_as(username)
user = fixtures(:users)[username]
Expand All @@ -24,10 +36,24 @@ def delete_user(user)
end
end


module Ontologies
def create_ontology(ontology)
LinkedData::Client::Models::Ontology.new(values: ontology.to_h).save
def create_ontology(ontology, submission)
ontology = LinkedData::Client::Models::Ontology.new(values: ApplicationTestHelpers.transform_models_to_ids(ontology).to_h).save
if ontology.errors
puts "Ontology creation error: #{ontology.errors}"

end
submission[:ontology] = ontology.id
submission.curatedOn = nil # TODO fix the curatedOn not saving
submission.naturalLanguage = Array(submission.naturalLanguage).map{|x| x.gsub('iso639-1','iso639-3')}
submission = LinkedData::Client::Models::OntologySubmission.new(values: ApplicationTestHelpers.transform_models_to_ids(submission).to_h).save
[ontology, submission]
end

def delete_ontologies(ontologies = @ontologies)
Array(ontologies).each do |o|
LinkedData::Client::Models::Ontology.find_by_acronym(o.acronym).first&.delete
end
end
end

Expand All @@ -37,6 +63,18 @@ def create_category(category)
return category if created.errors
created
end

def create_categories(categories_data = fixtures(:categories))
@categories = []
categories_data.to_a.each do |name, category|
@categories << create_category(category)
end
@categories
end

def delete_categories(categories = @categories)
Array(categories).each { |g| g.delete }
end
end

module Groups
Expand All @@ -45,5 +83,17 @@ def create_group(group)
return group if created.errors
created
end

def create_groups(groups_data = fixtures(:groups))
@groups = []
groups_data.to_a.each do |name, group|
@groups << create_group(group)
end
@groups
end

def delete_groups(groups = @groups)
Array(groups).each { |g| g.delete }
end
end
end
Loading

0 comments on commit f9cf418

Please sign in to comment.