Exemple #1
0
def _add_workflow(data, user, id=0):
    logger.debug("workflow name = %s", data[NAME])

    if id:
        # get existing workflow
        workflow = Workflow.objects.get(pk=id)

        if not workflow.editable:
            raise IgniteException(ERR_WF_NOT_EDITABLE)

        for task_const in workflow.task_list:
            task.update_ref_count(task_const[TASK_ID], -1)
    else:
        # create new workflow
        workflow = Workflow()

    workflow.name = data[NAME]
    workflow.submit = data[SUBMIT]
    workflow.task_list = data[TASK_LIST]
    workflow.updated_by = user
    workflow.save()

    # increment ref count of tasks used in this workflow
    for task_const in workflow.task_list:
        task.update_ref_count(task_const[TASK_ID], 1)

    return workflow
Exemple #2
0
def _add_workflow(data, user, id=0):
    logger.debug("workflow name = %s", data[NAME])

    if id:
        # get existing workflow
        workflow = Workflow.objects.get(pk=id)

        if not workflow.editable:
            raise IgniteException(ERR_WF_NOT_EDITABLE)

        for task_const in workflow.task_list:
            task.update_ref_count(task_const[TASK_ID], -1)
    else:
        # create new workflow
        workflow = Workflow()

    workflow.name = data[NAME]
    workflow.submit = data[SUBMIT]
    workflow.task_list = data[TASK_LIST]
    workflow.updated_by = user
    workflow.save()

    # increment ref count of tasks used in this workflow
    for task_const in workflow.task_list:
        task.update_ref_count(task_const[TASK_ID], 1)

    return workflow
Exemple #3
0
def delete_workflow(id):
    workflow = Workflow.objects.get(pk=id)

    if not workflow.editable:
        raise IgniteException(ERR_WF_NOT_EDITABLE)

    # decrement ref count of tasks used in this workflow
    for task_const in workflow.task_list:
        task.update_ref_count(task_const[TASK_ID], -1)

    try:
        workflow.delete()
    except ProtectedError:
        raise IgniteException(ERR_TASK_IN_USE)
Exemple #4
0
def delete_workflow(id):
    workflow = Workflow.objects.get(pk=id)

    if not workflow.editable:
        raise IgniteException(ERR_WF_NOT_EDITABLE)

    # decrement ref count of tasks used in this workflow
    for task_const in workflow.task_list:
        task.update_ref_count(task_const[TASK_ID], -1)

    try:
        workflow.delete()
    except ProtectedError:
        raise IgniteException(ERR_TASK_IN_USE)