Esempio n. 1
0
 def get(self):
   session_id = get_session_id(session, request)
   dao = GoalDAO(session_id)
   objts = dao.get_goals_summary()
   dao.close()
   resp = make_response(json_serialize(objts, session_id=session_id))
   resp.headers['Content-Type'] = "application/json"
   return resp
Esempio n. 2
0
 def get(self):
     session_id = get_session_id(session, request)
     dao = GoalDAO(session_id)
     objts = dao.get_goals_summary()
     dao.close()
     resp = make_response(json_serialize(objts, session_id=session_id))
     resp.headers['Content-Type'] = "application/json"
     return resp
Esempio n. 3
0
  def get(self, environment):
    session_id = get_session_id(session, request)

    dao = GoalDAO(session_id)
    goals = dao.get_goal_names(environment=environment)
    dao.close()

    resp = make_response(json_serialize(goals, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Esempio n. 4
0
    def get(self, environment):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        goals = dao.get_goal_names(environment=environment)
        dao.close()

        resp = make_response(json_serialize(goals, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Esempio n. 5
0
  def get(self, name):
    session_id = get_session_id(session, request)
    coloured = request.args.get('coloured', False)

    dao = GoalDAO(session_id)
    found_goal = dao.get_goal_by_name(name, coloured=(coloured == '1'))
    dao.close()

    resp = make_response(json_serialize(found_goal, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Esempio n. 6
0
    def get(self, name):
        session_id = get_session_id(session, request)
        coloured = request.args.get('coloured', False)

        dao = GoalDAO(session_id)
        found_goal = dao.get_goal_by_name(name, coloured=(coloured == '1'))
        dao.close()

        resp = make_response(json_serialize(found_goal, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Esempio n. 7
0
  def delete(self, name):
    session_id = get_session_id(session, request)

    dao = GoalDAO(session_id)
    dao.delete_goal(name)
    dao.close()

    resp_dict = {'message': 'Goal successfully deleted'}
    resp = make_response(json_serialize(resp_dict), httplib.OK)
    resp.contenttype = 'application/json'
    return resp
Esempio n. 8
0
  def get(self):
    session_id = get_session_id(session, request)
    constraint_id = request.args.get('constraint_id', -1)
    coloured = request.args.get('coloured', False)

    dao = GoalDAO(session_id)
    goals = dao.get_goals(constraint_id=constraint_id, coloured=(coloured == '1'))
    dao.close()

    resp = make_response(json_serialize(goals, session_id=session_id))
    resp.headers['Content-Type'] = "application/json"
    return resp
Esempio n. 9
0
  def post(self):
    session_id = get_session_id(session, request)

    dao = GoalDAO(session_id)
    new_goal = dao.from_json(request)
    new_goal_id = dao.add_goal(new_goal)
    dao.close()

    resp_dict = {'message': 'Goal successfully added', 'goal_id': new_goal_id}
    resp = make_response(json_serialize(resp_dict, session_id=session_id), httplib.OK)
    resp.contenttype = 'application/json'
    return resp
Esempio n. 10
0
    def get(self):
        session_id = get_session_id(session, request)
        constraint_id = request.args.get('constraint_id', -1)
        coloured = request.args.get('coloured', False)

        dao = GoalDAO(session_id)
        goals = dao.get_goals(constraint_id=constraint_id,
                              coloured=(coloured == '1'))
        dao.close()

        resp = make_response(json_serialize(goals, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
Esempio n. 11
0
    def get(self, environment):
        session_id = get_session_id(session, request)
        model_generator = get_model_generator()

        dao = GoalDAO(session_id)
        dot_code = dao.get_goal_model(environment)
        dao.close()

        resp = make_response(model_generator.generate(dot_code, model_type='goal'), httplib.OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'

        return resp
Esempio n. 12
0
  def get(self, environment, role):
    session_id = get_session_id(session, request)
    model_generator = get_model_generator()

    if role == 'all': role = ''

    dao = GoalDAO(session_id)
    dot_code = dao.get_responsibility_model(unquote(environment), unquote(role))
    dao.close()

    resp = make_response(model_generator.generate(dot_code, model_type='responsibility',renderer='dot'), OK)
    accept_header = request.headers.get('Accept', 'image/svg+xml')
    if accept_header.find('text/plain') > -1:
      resp.headers['Content-type'] = 'text/plain'
    else:
      resp.headers['Content-type'] = 'image/svg+xml'
    return resp
Esempio n. 13
0
  def get(self, environment, goal, usecase):
    session_id = get_session_id(session, request)
    isTopLevel = request.args.get('top', 0)

    model_generator = get_model_generator()

    dao = GoalDAO(session_id)
    if goal == 'all':  goal = ''
    if usecase == 'all': usecase = ''
    dot_code = dao.get_goal_model(environment,goal,usecase,isTopLevel)
    dao.close()

    resp = make_response(model_generator.generate(dot_code, model_type='goal',renderer='dot'), OK)
    accept_header = request.headers.get('Accept', 'image/svg+xml')
    if accept_header.find('text/plain') > -1:
      resp.headers['Content-type'] = 'text/plain'
    else:
      resp.headers['Content-type'] = 'image/svg+xml'
    return resp
Esempio n. 14
0
    def get(self, environment, goal, usecase):
        session_id = get_session_id(session, request)
        model_generator = get_model_generator()

        dao = GoalDAO(session_id)
        if goal == 'all': goal = ''
        if usecase == 'all': usecase = ''
        dot_code = dao.get_goal_model(environment, goal, usecase)
        dao.close()

        resp = make_response(
            model_generator.generate(dot_code,
                                     model_type='goal',
                                     renderer='dot'), OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'
        return resp
Esempio n. 15
0
    def get(self, environment, role):
        session_id = get_session_id(session, request)
        model_generator = get_model_generator()

        if role == 'all': role = ''

        dao = GoalDAO(session_id)
        dot_code = dao.get_responsibility_model(environment, role)
        dao.close()

        resp = make_response(
            model_generator.generate(dot_code,
                                     model_type='responsibility',
                                     renderer='neato'), httplib.OK)
        accept_header = request.headers.get('Accept', 'image/svg+xml')
        if accept_header.find('text/plain') > -1:
            resp.headers['Content-type'] = 'text/plain'
        else:
            resp.headers['Content-type'] = 'image/svg+xml'
        return resp
Esempio n. 16
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        upd_goal = dao.from_json(request)
        dao.update_goal(upd_goal, name)
        dao.close()

        resp_dict = {'message': 'Goal successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Esempio n. 17
0
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        upd_goal = dao.from_json(request)
        dao.update_goal(upd_goal, unquote(name))
        dao.close()

        resp_dict = {'message': upd_goal.name() + ' updated'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
Esempio n. 18
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        dao.delete_goal(name)
        dao.close()

        resp_dict = {'message': 'Goal successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Esempio n. 19
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        dao.delete_goal(unquote(name))
        dao.close()

        resp_dict = {'message': name + ' deleted'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
Esempio n. 20
0
  def put(self, name):
    session_id = get_session_id(session, request)

    dao = GoalDAO(session_id)
    upd_goal = dao.from_json(request)
    dao.update_goal(upd_goal, name)
    dao.close()

    resp_dict = {'message': 'Goal successfully updated'}
    resp = make_response(json_serialize(resp_dict), httplib.OK)
    resp.contenttype = 'application/json'
    return resp
Esempio n. 21
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        new_goal = dao.from_json(request)
        new_goal_id = dao.add_goal(new_goal)
        dao.close()

        resp_dict = {'message': new_goal.name() + ' created'}
        resp = make_response(json_serialize(resp_dict, session_id=session_id),
                             OK)
        resp.contenttype = 'application/json'
        return resp
Esempio n. 22
0
    def post(self):
        session_id = get_session_id(session, request)

        dao = GoalDAO(session_id)
        new_goal = dao.from_json(request)
        new_goal_id = dao.add_goal(new_goal)
        dao.close()

        resp_dict = {
            'message': 'Goal successfully added',
            'goal_id': new_goal_id
        }
        resp = make_response(json_serialize(resp_dict, session_id=session_id),
                             httplib.OK)
        resp.contenttype = 'application/json'
        return resp