Ejemplo n.º 1
0
class CaseDetBus(OrcBus):
    def __init__(self):

        OrcBus.__init__(self, "case_det", CaseDetMod)

        self._bus_step_def = StepDefBus()

    def bus_delete(self, p_id):
        """
        删除
        :param p_id:
        :return:
        """
        try:
            # case det
            case_det = self._model.usr_search(dict(id=p_id))

            # step ids
            step_ids = [step.step_id for step in case_det]

            # delete steps
            self._bus_step_def.bus_list_delete(step_ids)

            # delete case det
            self._model.usr_delete(p_id)

        except Exception:
            self._logger.error("Del case_det error, input: %s" % p_id)
            raise OrcApiModelFailException

        return True
Ejemplo n.º 2
0
    def __init__(self):

        object.__init__(self)

        init_log()

        self.__logger = OrcLog("api.case.bus.case_det")
        self.__model_case_det = CaseDetMod()
        self.__bus_step_def = StepDefBus()
Ejemplo n.º 3
0
class StepDefListAPI(Resource):
    def __init__(self):

        self.__logger = OrcLog("resource.steps.api.def")
        self.__model = StepDefBus()

    def dispatch_request(self, *args, **kwargs):
        return super(Resource, self).dispatch_request()

    @orc_api
    def post(self):
        """
        Add
        :return:
        """
        parameter = OrcParameter.receive_para()

        self.__logger.info("Add step, parameter is: %s" % parameter)

        return self.__model.bus_list_add(parameter)

    @orc_api
    def get(self):
        """
        Search
        :return:
        """
        parameter = OrcParameter.receive_para()

        self.__logger.info("Search step, parameter is: %s" % parameter)

        return self.__model.bus_list_search(parameter)

    @orc_api
    def delete(self):
        """
        Delete
        :return:
        """
        parameter = OrcParameter.receive_para()

        self.__logger.info("Delete step, parameter is: %s" % parameter)

        return self.__model.bus_list_delete(parameter)
Ejemplo n.º 4
0
class StepDefAPI(Resource):
    def __init__(self):

        self.__logger = OrcLog("resource.step.api.def")
        self.__model = StepDefBus()

    def dispatch_request(self, *args, **kwargs):
        return super(Resource, self).dispatch_request(*args, **kwargs)

    @orc_api
    def get(self, p_id):
        """
        Search
        :param p_id:
        :return:
        """
        self.__logger.info("Search step, parameter is: %s" % p_id)

        return self.__model.bus_search(p_id)

    @orc_api
    def put(self, p_id):
        """
        Update
        :param p_id:
        :return:
        """
        parameter = OrcParameter.receive_para()

        self.__logger.info("Update step, parameter is: %s, %s" %
                           (p_id, parameter))

        return self.__model.bus_update(p_id, parameter)

    @orc_api
    def delete(self, p_id):
        """
        Delete
        :param p_id:
        :return:
        """
        self.__logger.info("Delete step, parameter is: %s" % p_id)

        return self.__model.bus_delete(p_id)
Ejemplo n.º 5
0
    def __init__(self):

        OrcBus.__init__(self, "case_det", CaseDetMod)

        self._bus_step_def = StepDefBus()
Ejemplo n.º 6
0
    def __init__(self):

        self.__logger = OrcLog("resource.step.api.def")
        self.__model = StepDefBus()
Ejemplo n.º 7
0
class CaseDetBus(object):
    def __init__(self):

        object.__init__(self)

        init_log()

        self.__logger = OrcLog("api.case.bus.case_det")
        self.__model_case_det = CaseDetMod()
        self.__bus_step_def = StepDefBus()

    def bus_list_add(self, p_data):
        """
        查询
        :param p_data:
        :return:
        """
        try:
            result = self.__model_case_det.usr_add(p_data)
        except Exception:
            self.__logger.error("Add batch error, input: %s" % p_data)
            raise OrcApiModelFailException

        return result

    def bus_list_delete(self, p_list):
        """
        删除
        :param p_list:
        :return:
        """
        try:
            for _id in p_list:
                self.bus_delete(_id)
        except Exception:
            self.__logger.error("Delete batch error, input: %s" % p_list)
            raise OrcApiModelFailException

        return True

    def bus_list_search(self, p_cond):
        """
        查询
        :param p_cond:
        :return:
        """
        try:
            result = self.__model_case_det.usr_search(p_cond)
        except Exception:
            self.__logger.error("Search batch error, input: %s" % p_cond)
            raise OrcApiModelFailException

        return result

    def bus_delete(self, p_id):
        """
        删除
        :param p_id:
        :return:
        """
        try:
            # case det
            case_det = self.__model_case_det.usr_search(dict(id=p_id))

            # step ids
            step_ids = [step.step_id for step in case_det]

            # delete steps
            self.__bus_step_def.bus_list_delete(step_ids)

            # delete case det
            self.__model_case_det.usr_delete(p_id)

        except Exception:
            self.__logger.error("Del case from batch error, input: %s" % p_id)
            raise OrcApiModelFailException

        return True

    def bus_update(self, p_id, p_cond):
        """
        更新
        :param p_id:
        :param p_cond:
        :return:
        """
        cond = dict(id=p_id)
        cond.update(p_cond)

        try:
            self.__model_case_det.usr_update(cond)
        except Exception:
            self.__logger.error("Update case error, input: %s" % cond)
            raise OrcApiModelFailException

        return True

    def bus_search(self, p_id):
        """
        查询
        :param p_id:
        :return:
        """
        try:
            result = self.__model_case_det.usr_search(dict(id=p_id))
            result = None if not result else result[0]
        except Exception:
            self.__logger.error("Search case from batch error, input: %s" %
                                p_id)
            raise OrcApiModelFailException

        return result