def insert_with_session(self, session, obj): obj.hpoId = self._get_hpo_id(obj) obj.version = 1 obj.signUpTime = clock.CLOCK.now().replace(microsecond=0) obj.lastModified = obj.signUpTime if obj.withdrawalStatus is None: obj.withdrawalStatus = WithdrawalStatus.NOT_WITHDRAWN if obj.suspensionStatus is None: obj.suspensionStatus = SuspensionStatus.NOT_SUSPENDED super(ParticipantDao, self).insert_with_session(session, obj) history = ParticipantHistory() history.fromdict(obj.asdict(), allow_pk=True) session.add(history) return obj
def _participant_history_with_defaults(**kwargs): common_args = { 'hpoId': UNSET_HPO_ID, 'version': 1, 'withdrawalStatus': WithdrawalStatus.NOT_WITHDRAWN, 'suspensionStatus': SuspensionStatus.NOT_SUSPENDED, } common_args.update(kwargs) return ParticipantHistory(**common_args)
def _update_history(self, session, obj, existing_obj): # Increment the version and add a new history entry. obj.version = existing_obj.version + 1 history = ParticipantHistory() history.fromdict(obj.asdict(), allow_pk=True) session.add(history)