Skip to content

Commit

Permalink
bug #19739 : made sure that ActiveParticipant didn't flatten Date and…
Browse files Browse the repository at this point in the history
… Time instances found in workitem fields
  • Loading branch information
jmettraux committed Apr 24, 2008
1 parent 530da15 commit 3340464
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -4,6 +4,8 @@

== OpenWFEru - 0.9.18 not yet released

- bug #19739 : made sure that ActiveParticipant didn't flatten Date and Time
instances found in workitem fields
- todo #19704 : introduced parameter :definition_in_launchitem_allowed
(defaults to false)
- bug #19607 : preventing cancel root expression bug (in case of error
Expand Down
16 changes: 16 additions & 0 deletions lib/openwfe/extras/participants/activeparticipants.rb
Expand Up @@ -446,6 +446,12 @@ def self.merge_search_results (ids, wis, new_wis)
end
end

#
# A workaround is in place for some classes when then have to get
# serialized. The names of thoses classes are listed in this array.
#
SPECIAL_FIELD_CLASSES = [ 'Time', 'Date', 'DateTime' ]

#
# A Field (Attribute) of a Workitem.
#
Expand Down Expand Up @@ -481,14 +487,24 @@ def value= (v)
limit = connection.native_database_types[:string][:limit]

if v.is_a?(String) and v.length <= limit

self.svalue = v

elsif SPECIAL_FIELD_CLASSES.include?(v.class.to_s)

self.svalue = v.to_yaml

else

self.yvalue = v
end
end

def value

return YAML.load(self.svalue) \
if SPECIAL_FIELD_CLASSES.include?(self.vclass.to_s)

self.svalue || self.yvalue
end

Expand Down
2 changes: 1 addition & 1 deletion test/extras/active_with_engine_test.rb
Expand Up @@ -25,7 +25,7 @@ def setup
OpenWFE::Extras::Workitem.delete_all
OpenWFE::Extras::Field.delete_all

@engine = OpenWFE::Engine.new
@engine = OpenWFE::Engine.new :definition_in_launchitem_allowed => true
#require 'openwfe/engine/file_persisted_engine'
#@engine = OpenWFE::FilePersistedEngine.new

Expand Down
23 changes: 21 additions & 2 deletions test/extras/ap_0_test.rb
Expand Up @@ -158,15 +158,15 @@ def test_5
assert_equal 0, OpenWFE::Extras::Workitem.search("pet").size
end

def _test_6
def test_6

require 'date'

wi = OpenWFE::InFlowWorkItem.new
wi.fei = new_fei

wi.name = "Maarten"
wi.birthdate = Date.new
wi.start_date = Date.today

awi = OpenWFE::Extras::Workitem.from_owfe_workitem wi
awi.save!
Expand All @@ -177,6 +177,25 @@ def _test_6
assert_equal wi.fields, wi2.fields
end

def test_6b

require 'time'

wi = OpenWFE::InFlowWorkItem.new
wi.fei = new_fei
wi.start_time = Time.now

awi = OpenWFE::Extras::Workitem.from_owfe_workitem wi
awi.save!

awi = OpenWFE::Extras::Workitem.find awi.id
wi2 = awi.as_owfe_workitem

#p awi

assert_equal wi.fields, wi2.fields
end

#
# this test is used to verify the yattributes functionalty used by
# "compact_workitems"
Expand Down

0 comments on commit 3340464

Please sign in to comment.