Class: RdfProcess

Inherits:
Object
  • Object
show all
Includes:
RdfProcessDefinitionLike
Defined in:
lib/rdf_process.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RdfProcessDefinitionLike

#addStep, #addVariable, #calculate_depends_on

Constructor Details

#initializeRdfProcess

Returns a new instance of RdfProcess.



16
17
18
19
20
21
22
# File 'lib/rdf_process.rb', line 16

def initialize
	@fresh_status = "old" #fresh  lub old
	@runtime_list = []
	@monitor_file_list = []
	@runtime_variable_list = {}
	
end

Instance Attribute Details

#fresh_statusObject

Returns the value of attribute fresh_status.



14
15
16
# File 'lib/rdf_process.rb', line 14

def fresh_status
  @fresh_status
end

#komunikatObject (readonly)

Returns the value of attribute komunikat.



14
15
16
# File 'lib/rdf_process.rb', line 14

def komunikat
  @komunikat
end

#monitor_file_listObject

Returns the value of attribute monitor_file_list.



15
16
17
# File 'lib/rdf_process.rb', line 15

def monitor_file_list
  @monitor_file_list
end

#progressObject (readonly)

Returns the value of attribute progress.



14
15
16
# File 'lib/rdf_process.rb', line 14

def progress
  @progress
end

#runtime_listObject (readonly)

Returns the value of attribute runtime_list.



14
15
16
# File 'lib/rdf_process.rb', line 14

def runtime_list
  @runtime_list
end

#runtime_variable_listObject (readonly)

Returns the value of attribute runtime_variable_list.



14
15
16
# File 'lib/rdf_process.rb', line 14

def runtime_variable_list
  @runtime_variable_list
end

Instance Method Details

#eval_file(file) ⇒ Object



126
127
128
# File 'lib/rdf_process.rb', line 126

def eval_file(file)
  instance_eval File.read(file), file
end

#get_dependent_step_from(step_id) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rdf_process.rb', line 95

def get_dependent_step_from(step_id)
	dependent_steps = []
	@runtime_list.each do |step|
		st = step[:depends_on]
		if st != nil then 
			
			if st.include?(step_id) then
				# step[:fresh_status] = "old"
				# puts step[:step_id] , step[:name]
				dependent_steps << step[:step_id]
				# puts step
			end
		end	

	end
	dependent_steps
end

#log(komunikat, progress = nil) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/rdf_process.rb', line 113

def log(komunikat, progress = nil)
	@progress = progress

	# @komunikat.disp_komunikat(komunikat, progress) 
	@komunikat = komunikat
	puts komunikat
	send_log
end

#processingObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rdf_process.rb', line 36

def processing
	s = 0
	current_step = 1
	size = @runtime_list.size
	process_pass = 0.0
	@runtime_list.each do |step|
		if step[:fresh_status] == nil or step[:fresh_status] == "old" then
			s1 = Time.now
			step[:runtime_code].call
			# instance_eval(step[:runtime_code])
			s2 = Time.now - s1 
			s += s2
			log "#{step[:name]} - Elapse time: #{s2}s"
			step[:fresh_status] = "fresh"
		end		
		process_pass = current_step * 100 / size
		log("#{step[:name]} - #{process_pass} - #{current_step} - #{size} %", process_pass.round)
		current_step += 1	
	end
	@fresh_status = "fresh"
	log "Process - Elapse time: #{s}s, #{process_pass}"
	# graphviz_filtr_value.value = @fresh_status
end

#refresh_status(step_id) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rdf_process.rb', line 74

def refresh_status(step_id)
	# puts "entry refresh_status"
	@runtime_list.each do |step|
		if step[:step_id] == step_id then
			step[:fresh_status] = "old"
		end

		st = step[:depends_on]
		if st  
			
			if st.include?(step_id) then
				# step[:fresh_status] = "old"
				# puts step[:step_id] , step[:name]
				refresh_status(step[:step_id])
				# puts step
			end
		end	
	end
	# puts @runtime_list
end

#resetObject



24
25
26
27
28
29
# File 'lib/rdf_process.rb', line 24

def reset
	@fresh_status = "old" #fresh  lub old
	@runtime_list = []
	@monitor_file_list = []
	@runtime_variable_list = {}
end

#save_variables(file) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/rdf_process.rb', line 130

def save_variables(file)
	File.open(file, "w") do |aFile|
		@runtime_variable_list.each do | name, value |
			if value[:type] != "graph" then  #.gsub!("\"",'\\"')
				# gvalue = 
			code = "addVariable '#{value[:type]}' do
				name '#{name}'
				value \"#{value[:value].gsub("\"",'\\"')}\"
				step_id '#{value[:step_id]}'
			end"
			aFile.puts code
			end
		end
	   
	    aFile.puts "# vieslav.pl "
	end
end

#send_logObject



122
123
124
# File 'lib/rdf_process.rb', line 122

def send_log
	puts "send log"
end

#set_monitor_file(index, file) ⇒ Object



67
68
69
70
71
72
# File 'lib/rdf_process.rb', line 67

def set_monitor_file(index, file)
	@monitor_file_list[index][:file] = file
	# log @monitor_file_list.to_s
	refresh_status(@monitor_file_list[index][:step_id])
	@fresh_status = "old"
end

#set_runtime_variable(name, value) ⇒ Object



60
61
62
63
64
65
# File 'lib/rdf_process.rb', line 60

def set_runtime_variable(name, value)
	@runtime_variable_list[name][:value] = value
	# log @runtime_variable_list.to_s
	refresh_status(@runtime_variable_list[name][:step_id])
	@fresh_status = "old"
end