Esempio n. 1
0
    def load(self, query_string, check_criteria_emptiness=False):
        query_string_fetch_validation = QueryStringFetchValidation()
        query_string_fetch_validation.validate(query_string)

        if check_criteria_emptiness:
            query_string_criteria_emptiness_validation = QueryStringCriteriaEmptinessValidation()
            query_string_criteria_emptiness_validation.validate(query_string)

        if "skip" in query_string:
            self.skip = int(query_string["skip"])

        if "take" in query_string:
            self.take = int(query_string["take"])

        if "search_text" in query_string:
            self.search_text = query_string["search_text"]

        if "sort" in query_string:
            self.load_sort(query_string)

        if "operator" in query_string:
            self.operator = query_string["operator"]

        if "criteria" in query_string:
            self.load_criteria(query_string)
Esempio n. 2
0
 def load_criteria(self, query_string):
     if query_string and query_string["criteria"]:
         query_string_criteria_emptiness_validation = QueryStringCriteriaEmptinessValidation()
         query_string_criteria_emptiness_validation.validate(query_string)
         self.criteria = []
         criteria_item = query_string["criteria"]
         criteria_list = criteria_item.split(",")
         for criteria_item in criteria_list:
             criteria_item_list = criteria_item.split(":")
             criteria_field_name = criteria_item_list[0]
             criteria_field_value = criteria_item_list[1]
             self.criteria.append((criteria_field_name, criteria_field_value))
Esempio n. 3
0
 def load_criteria(self, query_string):
     if query_string and query_string["criteria"]:
         query_string_criteria_emptiness_validation = QueryStringCriteriaEmptinessValidation()
         query_string_criteria_emptiness_validation.validate(query_string)
         self.criteria = []
         criteria_item = query_string["criteria"]
         criteria_list = criteria_item.split(",")
         for criteria_item in criteria_list:
             if ":" in criteria_item:
                 criteria_item_list = criteria_item.split(":")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, criteria_field_value))
             elif "<" in criteria_item:
                 criteria_item_list = criteria_item.split("<")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, "<{}".format(criteria_field_value)))
             elif ">" in criteria_item:
                 criteria_item_list = criteria_item.split(">")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, ">{}".format(criteria_field_value)))
             elif "<=" in criteria_item:
                 criteria_item_list = criteria_item.split("<=")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, "<={}".format(criteria_field_value)))
             elif ">=" in criteria_item:
                 criteria_item_list = criteria_item.split(">=")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, ">={}".format(criteria_field_value)))
             elif "=" in criteria_item:
                 criteria_item_list = criteria_item.split("=")
                 criteria_field_name = criteria_item_list[0]
                 criteria_field_value = criteria_item_list[1]
                 self.criteria.append((criteria_field_name, format(criteria_field_value)))