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

Returns a new instance of Process.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#prerequisitesObject (readonly)

Returns the value of attribute prerequisites.



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

def prerequisites
  @prerequisites
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#all_prerequisitesObject



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

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

#depends_on(*processes) ⇒ Object



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

def depends_on(*processes)
  wf1 = 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'
    edge.style = 'dashed' if wf1 != wf2
    prerequisites << process
  }
  self
end

#idObject



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

def id
  @node.id
end

#same_as(process) ⇒ Object



151
152
153
# File 'lib/dor/workflow/graph.rb', line 151

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

#set_status(s) ⇒ Object



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

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