creates unit_of_work and inserts it into the DB
            :raise DuplicateKeyError: if unit_of_work with given parameters already exists

def _insert_uow(self, freerun_entry, flow_request=None):
        """ creates unit_of_work and inserts it into the DB
            :raise DuplicateKeyError: if unit_of_work with given parameters already exists """
        process_entry = context.process_context[freerun_entry.process_name]
        arguments = process_entry.arguments
        arguments.update(freerun_entry.arguments)

        if flow_request:
            schedulable_name = flow_request.schedulable_name
            timeperiod = flow_request.timeperiod
            start_timeperiod = flow_request.start_timeperiod
            end_timeperiod = flow_request.end_timeperiod
            arguments.update(flow_request.arguments)
        else:
            schedulable_name = freerun_entry.schedulable_name
            timeperiod = time_helper.actual_timeperiod(QUALIFIER_REAL_TIME)
            start_timeperiod = timeperiod
            end_timeperiod = timeperiod

        uow = UnitOfWork()
        uow.process_name = schedulable_name
        uow.timeperiod = timeperiod
        uow.start_id = 0
        uow.end_id = 0
        uow.start_timeperiod = start_timeperiod
        uow.end_timeperiod = end_timeperiod
        uow.created_at = datetime.utcnow()
        uow.submitted_at = datetime.utcnow()
        uow.source = process_entry.source if hasattr(process_entry, 'source') else None
        uow.sink = process_entry.sink if hasattr(process_entry, 'sink') else None
        uow.state = unit_of_work.STATE_REQUESTED
        uow.unit_of_work_type = unit_of_work.TYPE_FREERUN
        uow.number_of_retries = 0
        uow.arguments = arguments
        uow.db_id = self.uow_dao.insert(uow)

        msg = 'Created: UOW {0} for {1}@{2}.' \
              .format(uow.db_id, freerun_entry.schedulable_name, timeperiod)
        self._log_message(INFO, freerun_entry, msg)
        return uow