Example #1
0
  def post(self):
    session_id = get_session_id(session, request)

    dao = UseCaseDAO(session_id)
    new_usecase,ucContribs = dao.from_json(request)
    usecase_id = dao.add_usecase(new_usecase)
    for rc in ucContribs:
      dao.assign_usecase_contribution(rc)
    dao.close()

    resp_dict = {'message': 'UseCase successfully added', 'usecase_id': usecase_id}
    resp = make_response(json_serialize(resp_dict), OK)
    resp.contenttype = 'application/json'
    return resp
Example #2
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = UseCaseDAO(session_id)
        uc, ucContribs = dao.from_json(request)
        dao.update_usecase(uc, name=name)
        dao.remove_usecase_contributions(uc)
        if (len(ucContribs) > 0):
            for rc in ucContribs:
                dao.assign_usecase_contribution(rc)
        dao.close()

        resp_dict = {'message': 'UseCase successfully updated'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.headers['Content-type'] = 'application/json'
        return resp