Skip to content

Commit

Permalink
Code clean and refactor ( to use newer hash syntax )
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Mar 4, 2022
1 parent eb9efc3 commit efb330f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/ontologies_linked_data/models/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ module Models
class Instance < LinkedData::Models::Base

model :named_individual, name_with: :id, collection: :submission,
namespace: :owl, :schemaless => :true , rdf_type: lambda { |*x| RDF::OWL[:NamedIndividual]}

namespace: :owl, schemaless: :true , rdf_type: lambda { |*x| RDF::OWL[:NamedIndividual]}

attribute :label, namespace: :rdfs, enforce: [:list]
attribute :prefLabel, namespace: :skos, enforce: [:existence], alias: true

attribute :types, :namespace => :rdf, enforce: [:list], property: :type
attribute :submission, :collection => lambda { |s| s.resource_id }, :namespace => :metadata
attribute :types, namespace: :rdf, enforce: [:list], property: :type
attribute :submission, collection: lambda { |s| s.resource_id }, namespace: :metadata

serialize_never :submission, :id
serialize_methods :properties
Expand All @@ -38,19 +37,18 @@ def self.get_instances_by_class(submission_id,class_id, page_no=1, size=50)

inst = self.instances_by_class_where_query(s,class_id).page(page_no,size).all

if inst.length > 0 # TODO test if "include=all" parameter is passed in the request
self.load_unmapped s,inst # For getting all the properties # For getting all the properties
end
end
# TODO test if "include=all" parameter is passed in the request
load_unmapped s,inst unless if inst.empty? # For getting all the properties # For getting all the properties

end

def self.get_instances_by_ontology(submission_id,page_no=1,size=50)
## TODO: pass directly an LinkedData::Models::OntologySubmission instance in the arguments instead of submission_id
s = LinkedData::Models::OntologySubmission.find(submission_id).first
inst = s.nil? ? [] : self.instances_by_class_where_query(s).page(page_no,size).all

if inst.length > 0 ## TODO test if "include=all" parameter is passed in the request
self.load_unmapped s,inst # For getting all the properties
## TODO test if "include=all" parameter is passed in the request
load_unmapped s,inst unless inst.empty? # For getting all the properties
end
end

Expand Down

0 comments on commit efb330f

Please sign in to comment.