from Products.UpdateSupport.updatesupport import _updateall,_log from Products.Openflow import openflow, activity, transition, process import string # params_to_appl: 1 -> Parameters are copied to the application # params_to_act: 1 -> Parameteres are copied to the activity params_to_appl=1 params_to_act=0 def do_update_activity(self,po): appl={} return_text = '' container = self.aq_parent newparameters= string.replace(self._parameters,'token.','instance.') if self._application!='': applname=container.id+'.'+self.id if params_to_act: a=activity.activity(id=self.id, split_mode=self._mode_to, join_mode=self._mode_from,start_mode=self._auto_start, finish_mode=1, application=applname, parameters= newparameters) else: a=activity.activity(id=self.id, split_mode=self._mode_to, join_mode=self._mode_from,start_mode=self._auto_start,finish_mode=1, application=applname) appl['parameters']= newparameters appl['link']= self._application if params_to_appl: appl['name']=applname else: appl['name']='' else: a=activity.activity(id=self.id, split_mode=self._mode_to, join_mode=self._mode_from,start_mode=self._auto_start, finish_mode=1, application='', parameters= newparameters) po._setObject(self.id, a) # Copy contained object inside the new copy for (id_inside, object_inside) in self.objectItems(): cp=self.manage_copyObjects([id_inside]) # Now activity is not folderish. So the contained items are saved # outside the Openflow po.aq_parent.aq_parent.manage_pasteObjects(cp) copied_object= po.aq_parent.aq_parent._getOb(id_inside) # Rename the object to remember where it was copied_object.manage_renameObject(id_inside,id_inside+'_FROM_PROCESS_'+self.aq_parent.id+'_IN_ACTIVITY_'+self.id) return_text = _log(return_text,'Updated Activities') return return_text, appl def do_update_transaction(self,po): return_text = '' container = self.aq_parent t=transition.transition(id=self.id, From=self._From, To=self._To, condition=self._condition) po._setObject(self.id, t) return_text = _log(return_text,'Updated Transaction') return return_text def do_update_process(self,oo): appls=[] return_text = '' container = self.aq_parent p = process.process(self.id, title="", description="", BeginEnd=None) oo._setObject(self.id, p) po=getattr(oo, self.id) return_text = _log(return_text,'Created empty process') for (id_inside, object_inside) in self.objectItems('Activity'): ret,appl=do_update_activity(object_inside,po) if appl != {}: appls=appls+[appl] return_text = _log(return_text,ret) for (id_inside, object_inside) in self.objectItems('Transaction'): ret=do_update_transaction(object_inside,po) return_text = _log(return_text,ret) return return_text, appls def do_update_openflow(self): from Products.Openflow.openflow import openflow, manage_addOpenflow return_text = '' container = self.aq_parent # Create a "Upgrade" folder container.manage_addFolder(id='Upgrade', title='Openflow Upgrade Folder') root=container.Upgrade manage_addOpenflow(root,self.id) oo=getattr(root, self.id) return_text = _log(return_text,'Created empty Openflow') for (id_inside, object_inside) in self.objectItems(): ret, appls=do_update_process(object_inside,oo) for appl in appls: oo.addApplication (appl['name'], appl['link'], appl['parameters']) return_text = _log(return_text,ret) return_text = _log(return_text,'Created complete openflow object') return return_text def updateall(self): text=_updateall(self,do_update_openflow,['OpenFlow']) return text