Changeset 56

Show
Ignore:
Timestamp:
04/24/06 21:41:53 (7 years ago)
Author:
dema
Message:

Fixed exemplo-di.yml to work with the fixed YAML parser in Ruby 1.8.4

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/db/exemplo-di.yml

    r24 r56  
    11Classes: 
    22  Pessoa: 
    3     attrs: [ nome: String, email: Email, homepage: Url, telefone: String, foto: Image ] 
    4     links: [ [Trabalha: AreaDePesquisa ], [Escreve: Publicacao, EscritaPor] ] 
     3    attrs: [ { nome: String }, { email: Email }, { homepage: Url }, { telefone: String }, { foto: Image } ] 
     4    links: [ [ { Trabalha: AreaDePesquisa } ], [ { Escreve: Publicacao }, EscritaPor] ] 
    55    label: nome 
    66    indices: 
     
    1515  Professor: 
    1616    base: Pessoa 
    17     attrs: [ titulacao: String, origem_titulacao: String, ano_titulacao: String, atuacao: Text ] 
    18     links: [ [Orienta: Aluno, EhOrientadoPor] ] 
     17    attrs: [ { titulacao: String }, { origem_titulacao: String }, { ano_titulacao: String }, { atuacao: Text } ] 
     18    links: [ [ { Orienta: Aluno }, EhOrientadoPor ] ] 
    1919    label: nome 
    2020    indices: 
     
    2525  Aluno: 
    2626    base: Pessoa 
    27     attrs: [ matricula: String ] 
    28     links: [ [EhOrientadoPor: Professor, Orienta] ] 
     27    attrs: [ { matricula: String } ] 
     28    links: [ [ { EhOrientadoPor: Professor }, Orienta] ] 
    2929    label: nome 
    3030    anchors: 
     
    3434        label: self.nome 
    3535  Publicacao: 
    36     attrs: [ titulo: String, ano: String, observacao: Text ] 
    37     links: [ [EscritaPor: Pessoa, Escreve] ] 
     36    attrs: [ { titulo: String }, { ano: String }, { observacao: Text } ] 
     37    links: [ [ { EscritaPor: Pessoa }, Escreve] ] 
    3838    label: titulo 
    3939    indices: 
     
    4343        position: 1 
    4444  AreaDePesquisa: 
    45     attrs: [ nome: String, apresentacao: Text ] 
    46     links: [ [TemProfessorPesquisador: Professor, Trabalha], [TemAlunoPesquisador: Aluno, Trabalha] ] 
     45    attrs: [ { nome: String }, { apresentacao: Text } ] 
     46    links: [ [ { TemProfessorPesquisador: Professor }, Trabalha], [ { TemAlunoPesquisador: Aluno }, Trabalha ] ] 
    4747    label: nome 
    4848    indices: 
     
    8181      params: [ [Pessoa, Pessoa] ] 
    8282    PublicacaoAlfa:  
    83       query: "[ alpha, type: Publicacao, order: titulo ]" 
     83      query: "[ alpha, { type: Publicacao }, { order: titulo } ]" 
    8484Indexes: 
    8585  Alunos: 
  • trunk/lib/model_loader.rb

    r39 r56  
    66 
    77class ModelLoader 
    8         attr_reader :classes, :contexts, :indices, :links, :model, :nodes 
     8  attr_reader :classes, :contexts, :indices, :links, :model, :nodes 
    99   
    1010  module WarnIfNil 
     
    5656        position = 0 
    5757        link.first.each do |link_name, link_target|  
    58           @stdout.puts "Link: #{link_name} in Class: #{classe_nome}" 
     58          @stdout.puts "Link: #{classe_nome} #{link_name} #{link_target}" 
    5959          @links[link_name] = Link.create("name" => link_name, "nav_class" => @classes[classe_nome], "target_nav_class" => @classes[link_target], "position" => position)  
    6060          position += 1 
     
    7272      end 
    7373    end 
     74   
    7475  end 
    7576 
  • trunk/lib/query_builder.rb

    r24 r56  
    11class QueryBuilder 
    22 
    3         TEMPLATES = { 
    4                 :alpha => " 
    5                   SELECT * FROM {id} rdf:type {sr:@@type}; serql:directType {type}; [ sr:@@order {@@order} ] 
    6                   ORDER BY @@order USING NAMESPACE sr = <http://sr#>", 
    7                 :x_by_y => " 
    8                   SELECT DISTINCT id, type, @@order FROM {id} rdf:type {sr:@@source_type}; serql:directType {type}; [ sr:@@order {@@order} ], 
    9                   {link} sr:node_id {id}; rdf:type {sr:@@link_type}; sr:target_node_id {?} rdf:type {sr:@@target_type}  
    10                   ORDER BY @@order USING NAMESPACE sr = <http://sr#>", 
    11                 :y_by_x => " 
    12                   SELECT DISTINCT id, type, @@order FROM {id} rdf:type {sr:@@source_type}; serql:directType {type}; [ sr:@@order {@@order} ], 
    13                   {link} sr:target_node_id {id}; rdf:type {sr:@@link_type}; sr:node_id {?} rdf:type {sr:@@target_type}  
    14                   ORDER BY @@order USING NAMESPACE sr = <http://sr#>" 
    15         } 
    16          
    17         class << self 
    18  
    19           def params_for(template) 
    20             tmpl = TEMPLATES[template] 
    21             raise "Invalid template key" if tmpl.nil?  
    22             params = tmpl.scan(/@@(\w+)/).flatten.uniq 
    23                         params.size > 0 ? params : nil 
    24                 end 
    25                  
     3  TEMPLATES = { 
     4    :alpha => " 
     5      SELECT * FROM {id} rdf:type {sr:@@type}; serql:directType {type}; [ sr:@@order {@@order} ] 
     6      ORDER BY @@order USING NAMESPACE sr = <http://sr#>", 
     7    :x_by_y => " 
     8      SELECT DISTINCT id, type, @@order FROM {id} rdf:type {sr:@@source_type}; serql:directType {type}; [ sr:@@order {@@order} ], 
     9      {link} sr:node_id {id}; rdf:type {sr:@@link_type}; sr:target_node_id {?} rdf:type {sr:@@target_type}  
     10      ORDER BY @@order USING NAMESPACE sr = <http://sr#>", 
     11    :y_by_x => " 
     12      SELECT DISTINCT id, type, @@order FROM {id} rdf:type {sr:@@source_type}; serql:directType {type}; [ sr:@@order {@@order} ], 
     13      {link} sr:target_node_id {id}; rdf:type {sr:@@link_type}; sr:node_id {?} rdf:type {sr:@@target_type}  
     14      ORDER BY @@order USING NAMESPACE sr = <http://sr#>" 
     15  } 
     16   
     17  class << self 
     18    def params_for(template) 
     19      tmpl = TEMPLATES[template] 
     20      raise "Invalid template key" if tmpl.nil?  
     21      params = tmpl.scan(/@@(\w+)/).flatten.uniq 
     22      params.size > 0 ? params : nil 
     23    end 
     24     
    2625    def parse(query) 
    2726     
     
    3837      end 
    3938    rescue => ex 
    40       raise "Invalid QueryBuilder expression - #{ex}" 
     39      raise "Invalid QueryBuilder expression:\r\n#{ex}\r\n#{ex.backtrace}" 
    4140    end 
    4241