Giter VIP home page Giter VIP logo

goo's People

Contributors

alexskr avatar dependabot[bot] avatar jvendetti avatar mdorf avatar msalvadores avatar palexander avatar stdotjohn avatar syphax-bouazzouni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goo's Issues

Return instance of Object when calling object.load

Right now, calling object.load returns a boolean (I think?). It would be really nice for chaining if you could call object.load and have the instance returned. Here's a use case:

ont = Ontology.find("SNOMED").load
latest = ont.latest_submission.load

instance_of validation

We need to configure models with the following:

validates :hasContact, :instance_of => :contact_details

To enforce that in

 object.hasContact << inst

inst is type of Contact. Where Contact is a the :contact_details model.

Error when not using model call in class definition

There is a problem when using goo objects without making the model call in the class definition. It happens when there is a dependent object. See code below.

class Ontology < Goo::Base::Resource
  attribute :acronym, :unique => true, :cardinality => { :max => 1, :min => 1 }
  attribute :name, :cardinality => { :max => 1, :min => 1 }
end

class Project < Goo::Base::Resource
  attribute :name, :cardinality => { :max => 1, :min => 1 }
  attribute :ontologyUsed, :instance_of => { :with => :ontology }, :cardinality => { :min => 1 }
end

p = LinkedData::Models::Project.new({
    :name => "Great Project",
    :ontologyUsed => [LinkedData::Models::Ontology.new(acronym: "SNOMED", name: "SNOMED CT")]
  })

assert_equal false, p.exist?(reload=true)
p.save
assert_equal true, p.exist?(reload=true)
p.delete
assert_equal false, p.exist?(reload=true)

The following code results in an error when running p.save:
ArgumentError: Model ontology is not registered.

Create email validator

Add a custom validator for email addresses. This is needed on User, possibly elsewhere.

Support ActiveModel-type find functionality

Supporting a "find" functionality similar to ActiveModel would be great. This will help people familiar with ActiveRecord and other common Ruby ORMs to use Goo a little easier.

I imagine several types of calls:

Person.find(:all)
Person.find(["paul", "manuel"])
Person.find("paul")
Person.find("http://goo.org/metadata/person/paul")
Person.all # wraps Person.find(:all)
Person.where(:name => "paul", :phone => "555-555-5555")

More examples here:
http://guides.rubyonrails.org/active_record_querying.html

Tests for validators

Would be nice to see a test file for validators so we know what's available and how to use them all in one place

Default values show as nil during validation

Using this user model

module LinkedData
  module Models
    class User < LinkedData::Models::Base
      model :user
      attribute :username, :unique => true, :single_value => true, :not_nil => true
      attribute :firstName, :single_value => true
      attribute :lastName, :single_value => true
      attribute :created, :date_time_xsd => true, :single_value => true, :not_nil => true, :default => lambda { |record| DateTime.now }
    end
  end
end

The following happens

u = LinkedData::Models::User.new
u.username = "test_user"
u.valid?
=> false
u.errors
=> {:created=>
  ["created is nil. It does not satisfy cardinality {:max=>1, :min=>1, :instance=>#<Goo::Validators::CardinalityValidator:0x007fb3b42b7a68 @options={...}>}"]}
u.created = u.created
u.valid?
=> true

Custom validations

Need to have custom validations that can be defined outside of the framework base code.

Disable inferencing by default on all queries

We can save time by disabling reasoning by default. The only queries that actually need enabling reasoning are some class queries to retrieve standard slots. All metadata queries do not require reasoning.

Conjuctive or disjunctive search queries

At the moment there is no support to choose conjunctive or disjunctive.

Any color that has blue AND white as code and maybe not only those values. Same as AND_INCLUSIVE:

 Color.search({:code => ["blue","white"]})

A color that contains blue OR white and no other values.

 Color.search({:code =>  [ ["blue","white"], OR_EXCLUSIVE ] })

Same for AND_EXCLUSIVE and OR_INCLUSIVE.

Search by fields

At the moment we do not have the ability to search. It would be useful to do things like this.

 personList = Person.search(:name , "foo")
 personList.each do |p|
      puts p.resource_id #lazy loading at this point
      p.load #loads the entire object
 end

Also the ability to search by Resources.

 personList = Person.search(:friendOf , otherPerson)
 personList.each do |p|
      puts p.resource_id #lazy loading at this point
      p.load #loads the entire object
 end

Pagination in search (count and sorting)

Offset limit and some kind of ordering when retrieving Goo objects.

Project.all(:limit=> 10, :offset => 100, :sort => { :with => [:name, :asc] )
Project.find(:attribute => "value" :limit=> 10, :offset => 100, :sort => { :with => [:name, :asc] )
Project.count({})

This should be done accordingly to the issue about changing the API for search

Calling valid? can result in an exception

In some conditions calling the valid? method results in an exception. It looks like when there are two attributes with :unqiue => true and only one has been set. For example:

os = LinkedData::Models::OntologySubmission.new
os.submissionId = 1
os.valid?
=> ArgumentError: Field acronym has no value. Value is needed to generate resource id

RDF::IRI attributes generate duplicates on updates

In models with this definition:

attribute :iri_value, :instance_of => { :with => RDF::IRI }, :single_value => true

if the object is updated then a duplicated triple is generated for this attribute.

Leave vocab registration for just namespace (the rest to models)

Reviews goes into the default namespace:

class Review
    attribute :name 
    attribute :name , { options }
end 

or in this second case the default namespace for Review is :other_ns. That ns is use by default by attributes unless stated otherwise in options:

class Review
    namespace :other_ns
    attribute :name 
    attribute :name , { options }
end 

Static load resources without knowing model

At the moment we need to do this to load a resource:

x = Person.new
x.load("http://foo.bar/x")
puts x.name

We need to support also the creation without knowing the model. Something like:

x = Goo.load("http://foo.bar/x")
puts x.class #returns Person
puts x.name

to_turtle method for objects

It would be nice to have a to_turtle method that would convert objects to turtle triples. This would get used the in BP objects as a basis for outputting RDF-serialized versions of the objects.

Offline mode

We should have an offline mode that doesn't interact with the triplestore and instead uses some internal mechanism to store and retrieve data. This would be useful in allowing basic development and testing without a 4store instance.

Auto-populate date fields (optional)

Would be cool to have an option to have date fields populated on save or instantiation. Here's what I imagine:

class Category < Goo::Base::Resource
  model :project
  attribute :creator, :cardinality => { :max => 1, :min => 1 }
  attribute :created, :date_time_xsd => true, :populate_date => :create, :cardinality => { :max => 1, :min => 1 }
  attribute :updated, :date_time_xsd => true, :populate_date => :update, :cardinality => { :max => 1, :min => 1 }
end

This would save a lot of boilerplate code. In ActiveRecord you get the "created" and "updated" fields for every object unless you specify otherwise.

๐Ÿ‘

Default values for objects

When creating a goo object, it would be good to be able to define default values for attributes that would get created on initialization. Some way to override the default would be nice.

Allow unique name to be created from lambda

When we name a resource, we should be allowed to specify how the naming happens using a lambda

After this is done, we should consider removing the acronym attribute from OntologySubmission in the ontologies_linked_data library

Inverse attributes

Support something like ...

class Ontology
       attribute :submissions, 
              :inverse_of => { :with => :ontology_submission , 
              :attribute => :ontology }
end

It basically allow us to have the connection only in one place in the triple and represent an inverse property in code.

Search by dependent object

Something like

ontST = OntologyStatus
list = Ontology.search(:status, ontST)

Even better

list = Ontology.search(:status, { :code => "PARSED" })

This would search for things that have one property with code "PARSED"

Refactor resource.rb

This component is becoming too big. The following methods need to be reviewed:

  • saved
  • shape and shape_attribute

Provide lookup for range class of given attribute

For a goo object, we should provide an option to retrieve the class for a given attribute when that attribute is associated to another object via the :instance_of option in the attribute DSL.

For example:

class Review < Goo::Base::Resource
  model :review
  attribute :creator, :instance_of => { :with => :user }, :cardinality => { :max => 1, :min => 1 }
end

> cls = Review.range_class(:creator)
> cls == User
=> true

Optional argument when intiitalizing objects

When initializing, it would be nice to not have to provide an empty attributes array. Unless there is a reason to require it, I mean.

Would make it so you could just do:
GooObject.new
instead of:
GooObject.new({})

Nested blank node query error.

Code like ...

contact_a = ContactDetails.new({:contact_name => "name a"})
contact_b = ContactDetails.new({:contact_name => "name b"})
ont = Ontology.new({:name => "SNOMED Clinical Terms",
            (...)
            :hasContact => [contact_a, contact_b]})
ont.save

Generates the following query that is wrong ...

 'INSERT DATA { GRAPH <http://data.bioontology.org/metadata/Ontology> {
 (...)
 <http://data.bioontology.org/metadata/ontology/SNOMEDCT> <http://data.bioontology.org/metadata/hasContact> [
    _:bNode3499835456282537575 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.bioontology.org/metadata/ContactDetails>;
    _:bNode3499835456282537575 <http://data.bioontology.org/metadata/contactName> """name a"""^^<http://www.w3.org/2001/XMLSchema#string>;
    _:bNode3499835456282537575 <http://data.bioontology.org/metadata/uuid> """4c1eaf50-1684-0130-6005-64ce8f34ad34"""^^<http://www.w3.org/2001/XMLSchema#string> ] .
 <http://data.bioontology.org/metadata/ontology/SNOMEDCT> <http://data.bioontology.org/metadata/hasContact> [
    _:bNode155722364050198075 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://data.bioontology.org/metadata/ContactDetails>;
    _:bNode155722364050198075 <http://data.bioontology.org/metadata/contactName> """name b"""^^<http://www.w3.org/2001/XMLSchema#string>;
    _:bNode155722364050198075 <http://data.bioontology.org/metadata/uuid> """4c1eb3e0-1684-0130-6005-64ce8f34ad34"""^^<http://www.w3.org/2001/XMLSchema#string> ] .
 } }

The blank nodes are included in the query with a three element triple.

Find on encoded attributes

URI encoding when generating IDs. Initial implementation allow spaces. It is unclear if find works with encoded characters.

This need to revised. @palexander what characters do we allow for fields that are going to be used for generating IRIs. Somehow we have to validate for that and encode the ones that are valid.

Reverse behaviour in optional load_attrs

The way it works now it makes to work as in where SQL clause and it is confusing. Default behaviour should be

:load_attrs => [ :name ]

and that should run with optional in the SPARQL query.

Allow 'find' to use id fragments for lookup

We will need to support lookups based on the last fragment of an id IRI. For example:

# This works
Ontology.find("http://blah.org/ontologies/snomed")

# So should this
Ontology.find("snomed")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.