lib/openwfe/extras/participants/activeparticipants.rb in openwferu-extras-0.9.14 vs lib/openwfe/extras/participants/activeparticipants.rb in openwferu-extras-0.9.15

- old
+ new

@@ -36,13 +36,16 @@ # # John Mettraux at openwfe.org # require 'rubygems' -require_gem 'activerecord' +#require_gem 'activerecord' +gem 'activerecord' +require 'active_record' + require 'openwfe/workitem' require 'openwfe/flowexpressionid' require 'openwfe/engine/engine' require 'openwfe/participants/participant' @@ -64,32 +67,42 @@ # For centralization purposes, the migration and the model are located # in the same source file. It should be quite easy for the Rails hackers # among you to sort that out for a Rails based usage. # class OwfeTables < ActiveRecord::Migration + def self.up + create_table :workitems do |t| t.column :fei, :string t.column :wfid, :string t.column :wf_name, :string t.column :wf_revision, :string t.column :participant_name, :string t.column :store_name, :string t.column :dispatch_time, :timestamp t.column :last_modified, :timestamp end + add_index :workitems, :wfid + add_index :workitems, :wf_name + add_index :workitems, :wf_revision + add_index :workitems, :participant_name + add_index :workitems, :store_name + create_table :fields do |t| - t.column :key, :string, :null => false + t.column :fkey, :string, :null => false t.column :svalue, :string t.column :yvalue, :text t.column :workitem_id, :integer, :null => false end - add_index :fields, [ :workitem_id, :key ], :unique => true - add_index :fields, :key + add_index :fields, [ :workitem_id, :fkey ], :unique => true + add_index :fields, :fkey add_index :fields, :svalue end + def self.down + drop_table :workitems drop_table :fields end end @@ -140,11 +153,11 @@ # # This is a 'static' method : # # awi = OpenWFE::Extras::Workitem.from_owfe_workitem(wi) # - # (This method will not save the 'ActiveWorkitem'). + # (This method saves the 'ActiveWorkitem'). # def Workitem.from_owfe_workitem (wi, store_name=nil) i = nil @@ -192,11 +205,11 @@ # def fields_hash h = {} fields.each do |f| - h[f.key] = f.value + h[f.fkey] = f.value end h end # @@ -226,11 +239,11 @@ # wi.field("customer_name") # wi.field :customer_name # def field (key) - fields.find_by_key(key.to_s) + fields.find_by_fkey(key.to_s) end # # A shortcut method, replies to the workflow engine and removes self # from the database. @@ -313,10 +326,10 @@ # This method does not save the new Field. # def self.new_field (key, value) f = Field.new - f.key = key + f.fkey = key f.value = value f end def value= (v)