Skip to content

Commit

Permalink
update ontology_language, visibility, status and view of to use the n…
Browse files Browse the repository at this point in the history
…ew reveal
  • Loading branch information
syphax-bouazzouni committed Jan 16, 2024
1 parent 23ea7b9 commit 24bc13a
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 65 deletions.
48 changes: 25 additions & 23 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def ontologies_filter
end
] + update_filters_counts

streams =if params[:page].nil?
streams = if params[:page].nil?
[
prepend('ontologies_list_container', partial: 'ontologies/browser/ontologies'),
prepend('ontologies_list_container') {
Expand Down Expand Up @@ -157,6 +157,7 @@ def mappings
def new
@ontology = LinkedData::Client::Models::Ontology.new
@submission = LinkedData::Client::Models::OntologySubmission.new
@submission.hasOntologyLanguage = 'OWL'
@ontologies = LinkedData::Client::Models::Ontology.all(include: 'acronym', include_views: true, display_links: false, display_context: false)
@categories = LinkedData::Client::Models::Category.all
@groups = LinkedData::Client::Models::Group.all
Expand Down Expand Up @@ -209,14 +210,14 @@ def collections
end
end


def sparql
if request.xhr?
render partial: 'ontologies/sections/sparql', layout: false
else
render partial: 'ontologies/sections/sparql', layout: 'ontology_viewer'
end
end

# GET /ontologies/ACRONYM
# GET /ontologies/1.xml
def show
Expand Down Expand Up @@ -262,8 +263,7 @@ def show

# Get the latest submission (not necessarily the latest 'ready' submission)

@submission_latest = @ontology.explore.latest_submission(include: 'all', invalidate_cache: invalidate_cache?) rescue @ontology.explore.latest_submission(include: '')

@submission_latest = @ontology.explore.latest_submission(include: 'all', invalidate_cache: invalidate_cache?) rescue @ontology.explore.latest_submission(include: '')

if !helpers.submission_ready?(@submission_latest) && params[:p].present? && data_pages.include?(params[:p].to_s)
redirect_to(ontology_path(params[:ontology]), status: :temporary_redirect) and return
Expand All @@ -280,15 +280,15 @@ def show
params[:p] = 'classes'
redirect_to "/ontologies/#{params[:ontology]}#{params_string_for_redirect(params)}", status: :moved_permanently
when 'classes'
self.classes #rescue self.summary
self.classes # rescue self.summary
when 'mappings'
self.mappings #rescue self.summary
self.mappings # rescue self.summary
when 'notes'
self.notes #rescue self.summary
self.notes # rescue self.summary
when 'widgets'
self.widgets #rescue self.summary
self.widgets # rescue self.summary
when 'properties'
self.properties #rescue self.summary
self.properties # rescue self.summary
when 'summary'
self.summary
when 'instances'
Expand Down Expand Up @@ -326,7 +326,7 @@ def summary
@view_decorators = @views.map { |view| ViewDecorator.new(view, view_context) }
@ontology_relations_data = ontology_relations_data

category_attributes = submission_metadata.group_by{|x| x['category']}.transform_values{|x| x.map{|attr| attr['attribute']} }
category_attributes = submission_metadata.group_by { |x| x['category'] }.transform_values { |x| x.map { |attr| attr['attribute'] } }
@relations_array_display = @relations_array.map do |relation|
attr = relation.split(':').last
["#{helpers.attr_label(attr, attr_metadata: helpers.attr_metadata(attr), show_tooltip: false)}(#{relation})",
Expand Down Expand Up @@ -377,8 +377,8 @@ def subscriptions
end

count = helpers.count_subscriptions(params[:ontology_id])
render inline: helpers.turbo_frame_tag('subscribe_button') {
render_to_string(OntologySubscribeButtonComponent.new(id: '', ontology_id: ontology_id, subscribed: subscribed, user_id: user_id, count: count, link: link), layout: nil)
render inline: helpers.turbo_frame_tag('subscribe_button') {
render_to_string(OntologySubscribeButtonComponent.new(id: '', ontology_id: ontology_id, subscribed: subscribed, user_id: user_id, count: count, link: link), layout: nil)
}
end

Expand Down Expand Up @@ -409,19 +409,17 @@ def show_licenses

@metadata = submission_metadata
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:id]).first
@licenses= %w[hasLicense morePermissions copyrightHolder useGuidelines]
@licenses = %w[hasLicense morePermissions copyrightHolder useGuidelines]
@submission_latest = @ontology.explore.latest_submission(include: @licenses.join(","))
render partial: 'ontologies/sections/licenses'
end
def ajax_ontologies

def ajax_ontologies

render json: LinkedData::Client::Models::Ontology.all(include_views: true,
display: 'acronym,name', display_links: false, display_context: false)
end



def metrics
@ontology = LinkedData::Client::Models::Ontology.find_by_acronym(params[:ontology_id]).first
@metrics = @ontology.explore.metrics(display_context: false, display_links: false)
Expand All @@ -435,7 +433,7 @@ def metrics_evolution

# Retrieve submissions in descending submissionId order (should be reverse chronological order)
@submissions = @ontology.explore.submissions({ include: "metrics" })
.sort { |a, b| a.submissionId.to_i <=> b.submissionId.to_i }.reverse || []
.sort { |a, b| a.submissionId.to_i <=> b.submissionId.to_i }.reverse || []

metrics = @submissions.map { |s| s.metrics }

Expand All @@ -447,18 +445,19 @@ def metrics_evolution
end

private

def get_views(ontology)
views = ontology.explore.views || []
views.select!{ |view| view.access?(session[:user]) }
views.sort{ |a,b| a.acronym.downcase <=> b.acronym.downcase }
views.select! { |view| view.access?(session[:user]) }
views.sort { |a, b| a.acronym.downcase <=> b.acronym.downcase }
end

def ontology_relations_data(sub = @submission_latest)
ontology_relations_array = []
@relations_array = ["omv:useImports", "door:isAlignedTo", "door:ontologyRelatedTo", "omv:isBackwardCompatibleWith", "omv:isIncompatibleWith", "door:comesFromTheSameDomain", "door:similarTo",
"door:explanationEvolution", "voaf:generalizes", "door:hasDisparateModelling", "dct:hasPart", "voaf:usedBy", "schema:workTranslation", "schema:translationOfWork"]

return if sub.nil?
return if sub.nil?

ont = sub.ontology
# Get ontology relations between each other (ex: STY isAlignedTo GO)
Expand All @@ -475,10 +474,12 @@ def ontology_relations_data(sub = @submission_latest)
target_in_portal = false
target_ont = nil
# if we find our portal URL in the ontology URL, then we just keep the ACRONYM to try to get the ontology.
relation_value = relation_value.split('/').last if relation_value.include?(helpers.portal_name.downcase)
if relation_value.include?(helpers.portal_name.downcase)
relation_value = relation_value.split('/').last
target_ont = LinkedData::Client::Models::Ontology.find_by_acronym(relation_value).first
end

# Use acronym to get ontology from the portal
target_ont = LinkedData::Client::Models::Ontology.find_by_acronym(relation_value).first
if target_ont
target_id = target_ont.acronym
target_in_portal = true
Expand All @@ -490,6 +491,7 @@ def ontology_relations_data(sub = @submission_latest)

ontology_relations_array
end

def properties_hash_values(properties, sub: @submission_latest, custom_labels: {})
return {} if sub.nil?

Expand All @@ -500,7 +502,7 @@ def get_metrics_hash
metrics_hash = {}
# TODO: Metrics do not return for views on the backend, need to enable include_views param there
@metrics = LinkedData::Client::Models::Metrics.all(include_views: true)
@metrics.each {|m| metrics_hash[m.links['ontology']] = m }
@metrics.each { |m| metrics_hash[m.links['ontology']] = m }
return metrics_hash
end

Expand Down
105 changes: 67 additions & 38 deletions app/helpers/submission_inputs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,64 @@ def ontology_categories_input(ontology = @ontology, categories = @categories)
end
end

def ontology_skos_language_help
content_tag(:div, class: 'upload-ontology-desc has_ontology_language_input') do
link = link_to('Please refer to the documentation for more details.', "https://doc.jonquetlab.lirmm.fr/share/618372fb-a852-4f3e-8e9f-8b07ebc053e6", target: "_blank")
text = <<-EOS
SKOS vocabularies submitted to #{portal_name} shall follow a few constraints (e.g., contain a minimum of one skos:ConceptScheme also typed as owl:Ontology)
and top concept assertion. #{link}
EOS
text.html_safe
end
end

def ontology_obo_language_help
content_tag(:div, class: 'upload-ontology-desc has_ontology_language_input') do
link = link_to('the OBOinOWL parser.', "#", target: "_blank")
text = <<-EOS
OBO ontologies submitted to #{portal_name} will be parsed by the OWL-API which integrates #{link}
The resulting RDF triples will then be loaded in #{portal_name} triple-store.
EOS
text.html_safe
end
end

def ontology_owl_language_help
content_tag(:div, class: 'upload-ontology-desc has_ontology_language_input') do
link = link_to('the Protégé ', "https://protege.stanford.edu/", target: "_blank")
text = <<-EOS
OWL ontologies submitted to #{portal_name} will be parsed by the OWL-API. An easy way to verify if your ontology will parse is to open it with
#{link}
software which does use the same component.
EOS
text.html_safe
end
end

def ontology_umls_language_help
content_tag(:div, class: 'upload-ontology-desc has_ontology_language_input') do
link = link_to('by the UMLS2RDF tool.', "#", target: "_blank")
text = <<-EOS
UMLS-RRF resources are usually produced #{link}
EOS
text.html_safe
end
end

def has_ontology_language_input(submission = @submission)
content_tag(:div, 'data-controller': 'reveal-component') do
content_tag(:div, 'data-action': 'change->reveal-component#select', 'data-items': 'has_ontology_language_input') do
render(Layout::RevealComponent.new(possible_values: %w[SKOS OBO UMLS OWL], selected: @submission.hasOntologyLanguage)) do |c|
c.button do
attribute_input("hasOntologyLanguage")
end
end +
content_tag(:div, id:'SKOS', class: 'd-none upload-ontology-desc has_ontology_language_input') do
content_tag(:span, " SKOS vocabularies submitted to #{portal_name} shall follow a few constraints (e.g., contain a minimum of one skos:ConceptScheme also typed as owl:Ontology) and top concept assertion. ") +
content_tag(:span) do
link_to('Please refer to the documentation for more details.', "https://doc.jonquetlab.lirmm.fr/share/618372fb-a852-4f3e-8e9f-8b07ebc053e6", target: "_blank")
end
end +

content_tag(:div, id:'OBO', class: 'd-none upload-ontology-desc has_ontology_language_input') do
content_tag(:span, "OBO ontologies submitted to #{portal_name} will be parsed by the OWL-API which integrates ") +
content_tag(:span) do
link_to('the OBOinOWL parser.', "#", target: "_blank")
end +
content_tag(:span, " The resulting RDF triples will then be loaded in #{portal_name} triple-store. ")
end +

content_tag(:div, id:'UMLS', class: 'd-none upload-ontology-desc has_ontology_language_input') do
content_tag(:span, "UMLS-RRF resources are usually produced ") +
content_tag(:span) do
link_to('by the UMLS2RDF tool.', "#", target: "_blank")
end
end +

content_tag(:div, id:'OWL', class: 'd-none upload-ontology-desc has_ontology_language_input') do
content_tag(:span, " OWL ontologies submitted to PORTALNALE will be parsed by the OWL-API. An easy way to verify if your ontology will parse is to open it with ") +
content_tag(:span) do
link_to('the Protégé ', "https://protege.stanford.edu/", target: "_blank")
end +
content_tag(:span, "software which does use the same component.")
c.container { ontology_skos_language_help }

c.container { ontology_obo_language_help }

c.container { ontology_umls_language_help }

c.container { ontology_owl_language_help }

end
end

Expand All @@ -198,28 +222,33 @@ def ontology_visibility_input(ontology = @ontology)
@user_select_list.sort! { |a, b| a[1].downcase <=> b[1].downcase }
end

render(Layout::RevealComponent.new(init_show: ontology.viewingRestriction&.eql?('private'), show_condition: 'private')) do |c|
render(Layout::RevealComponent.new(possible_values: %w[private public], selected: ontology.viewingRestriction)) do |c|
c.button do
select_input(label: "Visibility", name: "ontology[viewingRestriction]", required: true,
values: %w[public private],
selected: ontology.viewingRestriction)
end
content_tag(:div, class: 'upload-ontology-input-field-container') do
select_input(label: "Add or remove accounts that are allowed to see this ontology in #{portal_name}.", name: "ontology[acl]", values: @user_select_list, selected: ontology.acl, multiple: true)

c.container do
content_tag(:div, class: 'upload-ontology-input-field-container') do
select_input(label: "Add or remove accounts that are allowed to see this ontology in #{portal_name}.", name: "ontology[acl]", values: @user_select_list, selected: ontology.acl, multiple: true)
end
end
end
end

def ontology_view_of_input(ontology = @ontology)
render Layout::RevealComponent.new(init_show: ontology.view?) do |c|
render Layout::RevealComponent.new(selected: !ontology.view?, toggle: true) do |c|
c.button do
content_tag(:span, class: 'd-flex') do
switch_input(id: 'ontology_isView', name: 'ontology[isView]', label: 'Is this ontology a view of another ontology?', checked: ontology.view?, style: 'font-size: 14px;')
end
end

content_tag(:div) do
render partial: "shared/ontology_picker_single", locals: { placeholder: "", field_name: "viewOf", selected: ontology.viewOf }
c.container do
content_tag(:div) do
render partial: "shared/ontology_picker_single", locals: { placeholder: "", field_name: "viewOf", selected: ontology.viewOf }
end
end
end
end
end
Expand Down Expand Up @@ -443,7 +472,7 @@ def generate_boolean_input(attr, help: nil)
name = attr.name
content_tag(:div) do
switch_input(id: name, name: name, label: attr_header_label(attr), checked: value.eql?('true'), value: value,
boolean_switch: true, style: 'font-size: 14px;', help: metadata_deprecated_help)
boolean_switch: true, style: 'font-size: 14px;', help: metadata_deprecated_help)
end
end

Expand Down
9 changes: 5 additions & 4 deletions app/views/ontologies/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
.upload-ontology-field-container
= has_ontology_language_input
.upload-ontology-field-container.mt-3
= render Layout::RevealComponent.new(init_show: @submission.status&.eql?('retired'), show_condition: 'retired') do |c|
= render Layout::RevealComponent.new(selected: @submission.status, possible_values: ['retired']) do |c|
- c.button do
= attribute_input("status")
.upload-ontology-field-container
- @submission.valid = nil unless @submission.status&.eql?('retired')
= attribute_input("valid")
- c.container do
.upload-ontology-field-container
- @submission.valid = nil unless @submission.status&.eql?('retired')
= attribute_input("valid")
.upload-ontology-field-container
= render partial: 'ontologies/submission_location_form'

Expand Down

0 comments on commit 24bc13a

Please sign in to comment.