server/handlerwrappers/log.rb in cpee-1.3.187 vs server/handlerwrappers/log.rb in cpee-1.3.188

- old
+ new

@@ -11,26 +11,33 @@ # You should have received a copy of the GNU General Public License along with # CPEE (file COPYING in the main directory). If not, see # <http://www.gnu.org/licenses/>. class LogHandlerWrapper < WEEL::HandlerWrapperBase + LOGTEMPLATE = <<-END + <log xmlns="http://www.xes-standard.org/" xes.version="1.0" xes.features="nested-attributes" openxes.version="1.0RC7"> + <extension name="Time" prefix="time" uri="http://www.xes-standard.org/time.xesext"/> + <extension name="Concept" prefix="concept" uri="http://www.xes-standard.org/concept.xesext"/> + <extension name="Organizational" prefix="org" uri="http://www.xes-standard.org/org.xesext"/> + <trace/> + </log> + END + def initialize(arguments,endpoint=nil,position=nil,continue=nil) # {{{ @controller = arguments[0] @log_hash = {} @handler_continue = continue @handler_endpoint = endpoint @handler_position = position @handler_passthrough = nil @handler_returnValue = nil instancenr=@controller.instance.split('/').last instance_dir = @controller.instance_variable_get(:@opts)[:instances] - unless File.exist?(instance_dir+'/'+instancenr+'/log.xes') - FileUtils.cp(instance_dir+'/template.xes', instance_dir+'/'+instancenr+'/log.xes') - XML::Smart.modify(instance_dir+'/'+instancenr+'/log.xes') do |xml| - trace = xml.find("/xmlns:log/xmlns:trace").first - trace.add 'string', :key => "concept:name", :value => "Instance #{instancenr}" - end + + XML::Smart.modify(instance_dir+'/'+instancenr+'/log.xes',LOGTEMPLATE) do |xml| + trace = xml.find("/xmlns:log/xmlns:trace").first + trace.add 'string', :key => "concept:name", :value => "Instance #{instancenr}" end end # }}} def activity_handle(passthrough, parameters) # {{{ @controller.notify("activity/calling", :instance => @controller.instance, :activity => @handler_position, :passthrough => passthrough, :endpoint => @handler_endpoint, :parameters => parameters, :log_hash => @log_hash) @@ -109,12 +116,10 @@ true end # }}} def inform_activity_done # {{{ @controller.notify("activity/done", :endpoint => @handler_endpoint, :instance => @controller.instance, :activity => @handler_position,:log_hash => @log_hash) - p "log" - p @log_hash time_added=false XML::Smart.modify(@controller.instance_variable_get(:@opts)[:instances]+'/'+@controller.instance.split('/').last+'/log.xes') do |xml| trace = xml.find("/xmlns:log/xmlns:trace").first event = trace.add "event" event.add 'string', :key => "concept:name", :value => @log_hash[:label] @@ -229,10 +234,9 @@ [result,tmp] end def callback(result=nil,options={}) result,notify_result = simplify_result(result) - pp result @controller.notify("activity/change", :instance => @controller.instance, :activity => @handler_position, :endpoint => @handler_endpoint, :params => notify_result) @log_hash[:data_received]||=notify_result unless notify_result.nil? if options['CPEE_UPDATE'] @handler_returnValue = result if options['CPEE_UPDATE_STATUS']