Changeset 56
- Timestamp:
- 04/24/06 21:41:53 (7 years ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
db/exemplo-di.yml (modified) (6 diffs)
-
lib/model_loader.rb (modified) (3 diffs)
-
lib/query_builder.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/db/exemplo-di.yml
r24 r56 1 1 Classes: 2 2 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] ] 5 5 label: nome 6 6 indices: … … 15 15 Professor: 16 16 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 ] ] 19 19 label: nome 20 20 indices: … … 25 25 Aluno: 26 26 base: Pessoa 27 attrs: [ matricula: String]28 links: [ [ EhOrientadoPor: Professor, Orienta] ]27 attrs: [ { matricula: String } ] 28 links: [ [ { EhOrientadoPor: Professor }, Orienta] ] 29 29 label: nome 30 30 anchors: … … 34 34 label: self.nome 35 35 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] ] 38 38 label: titulo 39 39 indices: … … 43 43 position: 1 44 44 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 ] ] 47 47 label: nome 48 48 indices: … … 81 81 params: [ [Pessoa, Pessoa] ] 82 82 PublicacaoAlfa: 83 query: "[ alpha, type: Publicacao, order: titulo]"83 query: "[ alpha, { type: Publicacao }, { order: titulo } ]" 84 84 Indexes: 85 85 Alunos: -
trunk/lib/model_loader.rb
r39 r56 6 6 7 7 class ModelLoader 8 attr_reader :classes, :contexts, :indices, :links, :model, :nodes8 attr_reader :classes, :contexts, :indices, :links, :model, :nodes 9 9 10 10 module WarnIfNil … … 56 56 position = 0 57 57 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}" 59 59 @links[link_name] = Link.create("name" => link_name, "nav_class" => @classes[classe_nome], "target_nav_class" => @classes[link_target], "position" => position) 60 60 position += 1 … … 72 72 end 73 73 end 74 74 75 end 75 76 -
trunk/lib/query_builder.rb
r24 r56 1 1 class QueryBuilder 2 2 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 26 25 def parse(query) 27 26 … … 38 37 end 39 38 rescue => ex 40 raise "Invalid QueryBuilder expression - #{ex}"39 raise "Invalid QueryBuilder expression:\r\n#{ex}\r\n#{ex.backtrace}" 41 40 end 42 41
