Class: Dor::Workflow::Graph::Process

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/workflow/graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph, id, name) ⇒ Process


106
107
108
109
110
111
112
113
114
# File 'lib/dor/workflow/graph.rb', line 106

def initialize(graph, id, name)
  @name = name
  @graph = graph
  @node = @graph.add_nodes(id)
  @node.shape = 'box'
  @node.label = name
  @prerequisites = []
  self.set_status('unknown')
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


104
105
106
# File 'lib/dor/workflow/graph.rb', line 104

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node


104
105
106
# File 'lib/dor/workflow/graph.rb', line 104

def node
  @node
end

#prerequisitesObject (readonly)

Returns the value of attribute prerequisites


104
105
106
# File 'lib/dor/workflow/graph.rb', line 104

def prerequisites
  @prerequisites
end

#statusObject

Returns the value of attribute status


104
105
106
# File 'lib/dor/workflow/graph.rb', line 104

def status
  @status
end

Instance Method Details

#all_prerequisitesObject


158
159
160
# File 'lib/dor/workflow/graph.rb', line 158

def all_prerequisites
  prerequisites.collect { |p| p.all_prerequisites + [p.name] }.flatten.uniq
end

#depends_on(*processes) ⇒ Object


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/dor/workflow/graph.rb', line 138

def depends_on(*processes)
  wf1 = self.id.split(/:/)[0..1].join(':')
  processes.each { |process|
    wf2 = process.id.split(/:/)[0..1].join(':')
    edge = (process.node << @node)
    edge.dir = 'both'
    edge.arrowhead = 'none'
    edge.arrowtail = 'none'
    if (wf1 != wf2)
      edge.style = 'dashed'
    end
    self.prerequisites << process
  }
  return self
end

#idObject


116
117
118
# File 'lib/dor/workflow/graph.rb', line 116

def id
  @node.id
end

#same_as(process) ⇒ Object


154
155
156
# File 'lib/dor/workflow/graph.rb', line 154

def same_as(process)
  @node = process.node  
end

#set_status(s) ⇒ Object


133
134
135
136
# File 'lib/dor/workflow/graph.rb', line 133

def set_status(s)
  self.status = s
  return self
end