Method: InterMine::PathQuery::Query#add_views
- Defined in:
- lib/intermine/query.rb
#add_views(*views) ⇒ Object Also known as: add_to_select
Add the given views (output columns) to the query.
Any columns ending in “*” will be interpreted as a request to add all attribute columns from that table to the query
Any columns that name a class or reference will add the id of that object to the query. This is helpful for creating lists and other specialist services.
query = service.query("Gene")
query.add_views("*")
query.add_to_select("*")
query.add_views("proteins.*")
query.add_views("pathways.*", "organism.shortName")
query.add_views("proteins", "exons")
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/intermine/query.rb', line 613 def add_views(*views) views.flatten.map do |x| y = add_prefix(x) if y.end_with?("*") prefix = y.chomp(".*") path = make_path(prefix) add_views(path.end_cd.attributes.map {|x| prefix + "." + x.name}) else path = make_path(y) path = make_path(y.to_s + ".id") unless path.is_attribute? if @root.nil? @root = path.rootClass end @views << path end end return self end |