Commit ccf2d7c0 authored by wenjie.zheng's avatar wenjie.zheng

Worklist.py: add setProperties which is required in unit test; improve function getVarMatch.

parent 63d75bf5
...@@ -112,7 +112,7 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject): ...@@ -112,7 +112,7 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
def getVarMatchKeys(self): def getVarMatchKeys(self):
key_list = [] key_list = []
if self.getMatchedPortalType is not None: if self.getMatchedPortalType() is not None:
key_list.append('portal_type') key_list.append('portal_type')
if self.getMatchedSimulationState() is not None: if self.getMatchedSimulationState() is not None:
key_list.append('simulation_state') key_list.append('simulation_state')
...@@ -128,28 +128,26 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject): ...@@ -128,28 +128,26 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
matches = None matches = None
matches_ref_list = [] matches_ref_list = []
if id == 'portal_type': if id == 'portal_type':
v = ''.join(self.matched_portal_type) v = self.getMatchedPortalTypeList()
if tales_re.match(v).group(1): if v is not None:
matches = Expression(v)
else:
v = [ var.strip() for var in self.matched_portal_type ]
matches = tuple(v) matches = tuple(v)
elif id in ['validation_state', 'simulation_state']: if id in ['validation_state', 'simulation_state']:
if id == 'validation_state': if id == 'validation_state':
matches_id_list = self.getMatchedValidationStateList() matches_id_list = self.getMatchedValidationStateList()
elif id == 'simulation_state': elif id == 'simulation_state':
matches_id_list = self.getMatchedSimulationStateList() matches_id_list = self.getMatchedSimulationStateList()
for state_id in matches_id_list: for state_id in matches_id_list:
matches_ref_list.append(self.getParent()._getOb(state_id).getReference()) if hasattr(self.getParent(), state_id):
matches_ref_list.append(self.getParent()._getOb(state_id).getReference())
matches = tuple(matches_ref_list) matches = tuple(matches_ref_list)
elif id == 'causality_state': if id == 'causality_state':
matches_id = self.getMatchedCausalityState() matches_id = self.getMatchedCausalityState()
if matches_id is None: if matches_id is None:
matches_id = '' matches_id = ''
matches_ref_list.append(matches_id) matches_ref_list.append(matches_id)
matches = tuple(matches_ref_list) matches = tuple(matches_ref_list)
if matches is not []: if matches is not [] and matches is not None:
if not isinstance(matches, (tuple, Expression)): if not isinstance(matches, (tuple, Expression)):
# Old version, convert it. # Old version, convert it.
matches = tuple(matches) matches = tuple(matches)
...@@ -162,3 +160,38 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject): ...@@ -162,3 +160,38 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
if isinstance(values, Expression): if isinstance(values, Expression):
return values.text return values.text
return '; '.join(values) return '; '.join(values)
def setProperties(self, description,
actbox_name='', actbox_url='', actbox_category='global',
actbox_icon='', props=None, REQUEST=None):
if props is None:
props = REQUEST
self.description = str(description)
LOG(" ***** props in worklist is '%s'"%props, 0, 0)
for k in props:
# in new worklist, use properties to set value.
v = props.get(k)
if v:
if k == 'guard_expr':
self.setExpression(v)
elif k == 'variable_portal_type':
self.setMatchedPortalTypeList(v)
elif k == 'variable_validation_state':
self.setMatchedValidationState('state_'+v)
elif k == 'variable_base_category_id':
self.setActboxCategory(v)
elif k == 'guard_roles':
r = [ var.strip() for var in v.split(';') ]
self.setRoleList(r)
else:
LOG(" dynamic variable is not supported yet.",0," Worklist.py")
self.actbox_name = str(actbox_name)
self.actbox_url = str(actbox_url)
self.actbox_category = str(actbox_category)
self.actbox_icon = str(actbox_icon)
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.guard = g
else:
self.guard = None
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment