From e9b2ee83c31b361eaf5f15237726b0b0cecd99e6 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:16:07 +0100 Subject: [PATCH 1/3] add media_types to get media_type as Array --- lib/ontologies_api_client/base.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/base.rb b/lib/ontologies_api_client/base.rb index d764d7e..74273f6 100644 --- a/lib/ontologies_api_client/base.rb +++ b/lib/ontologies_api_client/base.rb @@ -6,7 +6,15 @@ class Base attr_accessor :context, :links class << self - attr_accessor :media_type, :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present + attr_accessor :act_as_media_type, :include_attrs, :include_attrs_full, :attrs_always_present + def media_types + Array(@media_type) + end + + def media_type + media_types.first + end + end ## From e12e769cdc0f320844f74244e8848165d6018b07 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:16:51 +0100 Subject: [PATCH 2/3] get the map classes using media_types and no more media_type --- lib/ontologies_api_client/base.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ontologies_api_client/base.rb b/lib/ontologies_api_client/base.rb index 74273f6..ff4aba6 100644 --- a/lib/ontologies_api_client/base.rb +++ b/lib/ontologies_api_client/base.rb @@ -39,8 +39,11 @@ def self.map_classes map = {} classes = LinkedData::Client::Models.constants.map {|c| LinkedData::Client::Models.const_get(c)} classes.each do |media_type_cls| - next if map[media_type_cls] || !media_type_cls.respond_to?(:media_type) || !media_type_cls.ancestors.include?(LinkedData::Client::Base) - map[media_type_cls.media_type] = media_type_cls + next if map[media_type_cls] || !media_type_cls.respond_to?(:media_types) || !media_type_cls.ancestors.include?(LinkedData::Client::Base) + media_type_cls.media_types.each do |type| + next if map[type] + map[type] = media_type_cls + end media_type_cls.act_as_media_type.each {|mt| map[mt] = media_type_cls} if media_type_cls.act_as_media_type end return map From c320f447da70a2c5330dfe95c9ffce80f5e85c3a Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Fri, 18 Nov 2022 09:18:44 +0100 Subject: [PATCH 3/3] add skos:Concept media type for Class model --- lib/ontologies_api_client/models/class.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index e26c9c1..f5b4708 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -6,7 +6,7 @@ module Client module Models class Class < LinkedData::Client::Base HTTP = LinkedData::Client::HTTP - @media_type = "http://www.w3.org/2002/07/owl#Class" + @media_type = %w[http://www.w3.org/2002/07/owl#Class http://www.w3.org/2004/02/skos/core#Concept] @include_attrs = "prefLabel,definition,synonym,obsolete,hasChildren" @include_attrs_full = "prefLabel,definition,synonym,obsolete,properties,hasChildren,children" @attrs_always_present = :prefLabel, :definition, :synonym, :obsolete, :properties, :hasChildren, :children