Ejemplo n.º 1
0
    def get(self, environment, requirement):
        session_id = get_session_id(session, request)
        isAsset = request.args.get('asset', '0')
        if (isAsset == '1'):
            isAsset = True
        else:
            isAsset = False

        model_generator = get_model_generator()

        dao = RequirementDAO(session_id)
        dot_code = dao.get_concept_map_model(environment, requirement, isAsset)
        dao.close()

        if not isinstance(dot_code, str):
            raise ObjectNotFoundHTTPError('The model')

        resp = make_response(
            model_generator.generate(dot_code, 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
Ejemplo n.º 2
0
 def get(self, name):
     session_id = get_session_id(session, request)
     dao = RequirementDAO(session_id)
     reqs = dao.get_dimension_requirement_names('asset', name)
     dao.close()
     resp = make_response(json_serialize(reqs, session_id=session_id), OK)
     resp.headers['Content-type'] = 'application/json'
     return resp
Ejemplo n.º 3
0
    def get(self, shortcode):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        req = dao.get_requirement_by_shortcode(shortcode)
        dao.close()

        resp = make_response(json_serialize(req, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 4
0
    def get(self, shortcode):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        req = dao.get_requirement_by_shortcode(shortcode)
        dao.close()

        resp = make_response(json_serialize(req, session_id=session_id), OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 5
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        dao.delete_requirement(name=name)
        dao.close()

        resp_dict = {'message': 'Requirement successfully deleted'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 6
0
    def get(self, name):
        session_id = get_session_id(session, request)
        ordered = request.args.get('ordered', '1')

        dao = RequirementDAO(session_id)
        reqs = dao.get_requirements(constraint_id=name, is_asset=False, ordered=(ordered=='1'))
        dao.close()

        resp = make_response(json_serialize(reqs, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 7
0
  def get(self, name):
    session_id = get_session_id(session, request)
    ordered = request.args.get('ordered', '1')

    dao = RequirementDAO(session_id)
    reqs = dao.get_requirements(constraint_id=name, is_asset=False, ordered=(ordered=='1'))
    dao.close()

    resp = make_response(json_serialize(reqs, session_id=session_id), httplib.OK)
    resp.headers['Content-type'] = 'application/json'
    return resp
Ejemplo n.º 8
0
    def get(self):
        session_id = get_session_id(session, request)
        ordered = request.args.get('ordered', 0)
        constraint_id = request.args.get('constraint_id', '')

        dao = RequirementDAO(session_id)
        reqs = dao.get_requirements(constraint_id=constraint_id, ordered=(ordered=='1'))
        dao.close()

        resp = make_response(json_serialize(reqs, session_id=session_id), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        resp.headers['Access-Control-Allow-Origin'] = "*"
        return resp
Ejemplo n.º 9
0
  def get(self):
    session_id = get_session_id(session, request)
    ordered = request.args.get('ordered', 0)
    constraint_id = request.args.get('constraint_id', '')

    dao = RequirementDAO(session_id)
    reqs = dao.get_requirements(constraint_id=constraint_id, ordered=(ordered=='1'))
    dao.close()

    resp = make_response(json_serialize(reqs, session_id=session_id), httplib.OK)
    resp.headers['Content-type'] = 'application/json'
    resp.headers['Access-Control-Allow-Origin'] = "*"
    return resp
Ejemplo n.º 10
0
    def post(self):
        session_id = get_session_id(session, request)
        asset_name = request.args.get('asset', None)
        environment_name = request.args.get('environment', None)

        dao = RequirementDAO(session_id)
        new_req = dao.from_json(request)
        req_id = dao.add_requirement(new_req, asset_name=asset_name, environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Requirement successfully added', 'requirement_id': req_id}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
Ejemplo n.º 11
0
  def get(self, environment,requirement):
    session_id = get_session_id(session, request)
    model_generator = get_model_generator()

    if requirement == 'all':
      requirement = ''

    dao = RequirementDAO(session_id)
    dot_code = dao.get_concept_map_model(environment, requirement)
    dao.close()

    if not isinstance(dot_code, str):
      raise ObjectNotFoundHTTPError('The model')

    resp = make_response(model_generator.generate(dot_code,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
Ejemplo n.º 12
0
    def put(self, name):
        session_id = get_session_id(session, request)
        dao = RequirementDAO(session_id)
        req = dao.from_json(request)
        dao.update_requirement(req, name=name)
        dao.close()

        resp_dict = {'message': 'Requirement successfully updated'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 13
0
    def put(self):
        session_id = get_session_id(session, request)
        dao = RequirementDAO(session_id)
        req = dao.from_json(request)
        dao.update_requirement(req, req_id=req.theId)
        dao.close()

        resp_dict = {'message': 'Requirement successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 14
0
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = RequirementDAO(session_id)
        dao.delete_requirement(name=name)
        dao.close()

        resp_dict = {'message': name + ' deleted'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.headers['Content-type'] = 'application/json'
        return resp
Ejemplo n.º 15
0
    def post(self):
        session_id = get_session_id(session, request)
        asset_name = request.args.get('asset', None)
        environment_name = request.args.get('environment', None)
        dao = RequirementDAO(session_id)
        new_req = dao.from_json(request)
        dao.add_requirement(new_req,
                            asset_name=asset_name,
                            environment_name=environment_name)
        dao.close()

        resp_dict = {'message': 'Requirement successfully added'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
Ejemplo n.º 16
0
    def post(self):
        session_id = get_session_id(session, request)
        asset_name = request.args.get('asset', None)
        environment_name = request.args.get('environment', None)
        dao = RequirementDAO(session_id)

        domain_name = asset_name
        if (environment_name != None):
            domain_name = environment_name

        new_req = dao.from_json(request, domain_name)
        dao.add_requirement(new_req,
                            asset_name=asset_name,
                            environment_name=environment_name)
        dao.close()

        resp_dict = {'message': new_req.name() + ' created'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp