def update_workprogress(workprogress_id, parameters, new_transforms=None, update_transforms=None, session=None): """ update a workprogress. :param workprogress_id: the workprogress id. :param parameters: A dictionary of parameters. :param session: The database session in use. :raises NoObject: If no workprogress is founded. :raises DatabaseException: If there is a database error. """ if new_transforms: for tf in new_transforms: orginal_work = tf['transform_metadata']['orginal_work'] del tf['transform_metadata']['orginal_work'] tf_id = orm_transforms.add_transform(**tf, session=session) # work = tf['transform_metadata']['work'] orginal_work.set_work_id(tf_id, transforming=True) orginal_work.set_status(WorkStatus.New) if update_transforms: for tr_id in update_transforms: orm_transforms.update_transform( transform_id=tr_id, parameters=update_transforms[tr_id], session=session) return orm_workprogress.update_workprogress( workprogress_id=workprogress_id, parameters=parameters, session=session)
def delete_workprogress(workprogress_id=None, session=None): """ delete a workprogress. :param workprogress_id: The id of the workprogress. :param session: The database session in use. :raises NoObject: If no workprogress is founded. :raises DatabaseException: If there is a database error. """ return orm_workprogress.update_workprogress(workprogress_id=workprogress_id, session=session)
def update_request_with_workprogresses(request_id, parameters, new_workprogresses=None, update_workprogresses=None, session=None): """ update an request. :param request_id: the request id. :param parameters: A dictionary of parameters. :param new_workprogresses: list of new workprogresses. """ if new_workprogresses: orm_workprogresses.add_workprogresses(new_workprogresses, session=session) if update_workprogresses: for workprogress_id in update_workprogresses: orm_workprogresses.update_workprogress( workprogress_id, update_workprogresses[workprogress_id], session=session) return orm_requests.update_request(request_id, parameters, session=session)