Exemplo n.º 1
0
    def delete_entity(self, entity_name):
        """
        use this service to delete entity from config data
        :param entity_name: entity name
        :return:  update config data
        """
        temp = copy.deepcopy(self._config_dict)
        old_res = is_entity_exist(temp, entity_name)
        if old_res == -1:
            return self._messages.append(
                self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                    entity_name, ""))

        del temp['entities'][old_res]
        self._validate_operation(temp)
Exemplo n.º 2
0
    def update_entity(self, old_entity, new_entity):
        """
        use this service to update entity in config data
        :param old_entity: origin entity name
        :param new_entity: updated data of entity
        :return:  update config data
       """
        temp = copy.deepcopy(self._config_dict)
        old_res = is_entity_exist(temp, old_entity)
        if old_res == -1:
            return self._messages.append(
                self._error_message(old_entity, "entity", old_entity, "Entity is not found",
                                    old_entity, ""))

        del temp['entities'][old_res]
        temp['entities'].append(new_entity)
        self._validate_operation(temp)
Exemplo n.º 3
0
    def add_field(self, entity_name, field):
        """
        use this service to add field to config data
        :param entity_name: name of entity
        :param field: data of field
        :return:  update config data
        """
        temp = copy.deepcopy(self._config_dict)
        res = is_entity_exist(temp, entity_name)
        if res == -1:
            return self._messages.append(
                self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                    entity_name, ""))
        if "fields" not in temp['entities'][res]:
            temp['entities'][res]['fields'] = []

        temp['entities'][res]['fields'].append(field)
        self._validate_operation(temp)
Exemplo n.º 4
0
 def add_generation(self, entity_name, generation=None):
     """
     use this service to add generation to config data
     :param entity_name: name of entity
     :param generation: data of generation
     :return:  update config data
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     if "generation" not in temp['entities'][res]:
         temp['entities'][res]['generation'] = {}
     if generation is None:
         generation = {}
     temp['entities'][res]['generation'] = generation
     self._validate_operation(temp)
Exemplo n.º 5
0
 def add_extra_properties(self, entity_name, extra_properties=None):
     """
     use this service to add extra properties to config data
     :param entity_name: name of entity
     :param extra_properties: data of extra properties
     :return:  update config data
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     if "extraProperties" not in temp['entities'][res]:
         temp['entities'][res]['extraProperties'] = {}
     if extra_properties is None:
         extra_properties = {}
     temp['entities'][res]['extraProperties'] = extra_properties
     self._validate_operation(temp)
Exemplo n.º 6
0
 def delete_relation(self, entity_name, relation_name):
     """
     use this service to delete relation from config data
     :param entity_name: entity name
     :param relation_name:  relation name
     :return:  update config data
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     relation_index = is_relation_exist(temp, entity_name, relation_name)
     if relation_index == -2:
         return self._messages.append(
             self._error_message(entity_name, "relation", relation_name, "field is not found",
                                 relation_name, ""))
     del temp['entities'][res]["relations"][relation_index]
     self._validate_operation(temp)
Exemplo n.º 7
0
 def add_db_type(self, entity_name, field_name, db_type):
     """
     use this service to add db type to config data
     :param entity_name:entity name
     :param field_name: field name
     :param db_type: data of db type
     :return:  update config data
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     field_index = is_field_exist(temp, entity_name, field_name)
     if field_index == -2:
         return self._messages.append(
             self._error_message(entity_name, "field", field_name, "field is not found", field_name, ""))
     temp['entities'][res]['fields'][field_index]['dbType'] = db_type
     self._validate_operation(temp)
Exemplo n.º 8
0
 def delete_field(self, entity_name, field_name):
     """
     use this service to update field in config data
     :param entity_name: entity name
     :param field_name: field name
     :return:  update config data 
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     field_index = is_field_exist(temp, entity_name, field_name)
     if field_index == -2:
         return self._messages.append(
             self._error_message(entity_name, "field", field_name, "field is not found",
                                 field_name, ""))
     del temp['entities'][res]["fields"][field_index]
     self._validate_operation(temp)
Exemplo n.º 9
0
 def update_relation(self, entity_name, old_relation_name, new_relation):
     """
     use this service to update relation in config data
     :param entity_name: entity name
     :param old_relation_name: origin relation name
     :param new_relation: data of new relation
     :return:  update config data
     """
     temp = copy.deepcopy(self._config_dict)
     res = is_entity_exist(temp, entity_name)
     if res == -1:
         return self._messages.append(
             self._error_message(entity_name, "entity", entity_name, "Entity is not found",
                                 entity_name, ""))
     relation_index = is_relation_exist(temp, entity_name, old_relation_name)
     if relation_index == -2:
         return self._messages.append(
             self._error_message(entity_name, "relation", old_relation_name, "field is not found",
                                 old_relation_name, ""))
     del temp['entities'][res]["relations"][relation_index]
     temp['entities'][res]["relations"].append(new_relation)
     self._validate_operation(temp)