Class: Buhos::GraphML_Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/buhos/graphml_builder.rb

Overview

Builds a GraphML XML for a given systematic review and stage

Instance Method Summary collapse

Constructor Details

#initialize(sr, stage) ⇒ GraphML_Builder

Returns a new instance of GraphML_Builder.

Parameters:



36
37
38
39
# File 'lib/buhos/graphml_builder.rb', line 36

def initialize(sr, stage)
  @sr=sr
  @stage=stage
end

Instance Method Details

#generate_graphmlString

Return a string with GraphML XML

Returns:

  • (String)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/buhos/graphml_builder.rb', line 42

def generate_graphml
  ars=AnalysisSystematicReview.new(@sr)
  if @stage
    cd_hash=CanonicalDocument.where(:id=>@sr.cd_id_by_stage(@stage)).order(:year).as_hash
  else
    cd_hash=@sr.canonical_documents.order(:year).as_hash
  end

  head=build_head
  nodos = build_nodes(ars, cd_hash)
  edges= build_edges(ars, cd_hash)
  footer="\n</graph>\n</graphml>"
  [head, nodos, edges, footer].join("\n")
end

#prepare_stream(app) ⇒ Object



57
58
59
60
# File 'lib/buhos/graphml_builder.rb', line 57

def prepare_stream(app)
  app.headers["Content-Disposition"] = "attachment;filename=graphml_review_#{@sr.id}_stage_#{@stage}.graphml"
  app.content_type 'application/graphml+xml'
end