'Use a supplied ID (UUID or encoded stored workflow ID) to find
a workflow.'

def get_stored_workflow(self, trans, workflow_id):

    if util.is_uuid(workflow_id):
        workflow_uuid = uuid.UUID(workflow_id)
        stored_workflow = trans.sa_session.query(trans.app.model.StoredWorkflow).filter(and_((trans.app.model.StoredWorkflow.latest_workflow_id == trans.app.model.Workflow.id), (trans.app.model.Workflow.uuid == workflow_uuid))).first()
        if (stored_workflow is None):
            raise exceptions.ObjectNotFound(('Workflow    not    found:    %s' % workflow_id))
    else:
        workflow_id = decode_id(self.app, workflow_id)
        query = trans.sa_session.query(trans.app.model.StoredWorkflow)
        stored_workflow = query.get(workflow_id)
    if (stored_workflow is None):
        raise exceptions.ObjectNotFound('No    such    workflow    found.')
    return stored_workflow
