def save(self):
        """
        save or update this node in Ariane server
        :return:
        """
        LOGGER.debug("Node.save")
        if self.container is not None:
            if self.container.id is None:
                self.container.save()
            self.container_id = self.container.id

        if self.parent_node is not None:
            if self.parent_node.id is None:
                self.parent_node.save()
            self.parent_node_id = self.parent_node.id

        post_payload = {}
        consolidated_twin_nodes_id = []
        consolidated_properties = {}
        consolidated_node_properties = []

        if self.id is not None:
            post_payload['nodeID'] = self.id

        if self.name is not None:
            post_payload['nodeName'] = self.name

        if self.container_id is not None:
            post_payload['nodeContainerID'] = self.container_id

        if self.parent_node_id is not None:
            post_payload['nodeParentNodeID'] = self.parent_node_id

        if self.child_nodes_id is not None:
            post_payload['nodeChildNodesID'] = self.child_nodes_id

        if self.twin_nodes_id is not None:
            consolidated_twin_nodes_id = copy.deepcopy(self.twin_nodes_id)
        if self.twin_nodes_2_rm is not None:
            for twin_node_2_rm in self.twin_nodes_2_rm:
                if twin_node_2_rm.id is None:
                    twin_node_2_rm.sync()
                consolidated_twin_nodes_id.remove(twin_node_2_rm.id)
        if self.twin_nodes_2_add is not None:
            for twin_node_2_add in self.twin_nodes_2_add:
                if twin_node_2_add.id is None:
                    twin_node_2_add.save()
                consolidated_twin_nodes_id.append(twin_node_2_add.id)
        post_payload['nodeTwinNodesID'] = consolidated_twin_nodes_id

        if self.endpoints_id is not None:
            post_payload['nodeEndpointsID'] = self.endpoints_id

        if self.properties is not None:
            consolidated_properties = copy.deepcopy(self.properties)
        if self.properties_2_rm is not None:
            for n_property_name in self.properties_2_rm:
                consolidated_properties.pop(n_property_name, 0)
        if self.properties_2_add is not None:
            for n_property_tuple in self.properties_2_add:
                consolidated_properties[n_property_tuple[0]] = n_property_tuple[1]
        if consolidated_properties.__len__() > 0:
            for key, value in consolidated_properties.items():
                    consolidated_node_properties.append(DriverTools.property_params(key, value))
        post_payload['nodeProperties'] = consolidated_node_properties

        params = SessionService.complete_transactional_req({'payload': json.dumps(post_payload)})
        if MappingService.driver_type != DriverFactory.DRIVER_REST:
            params['OPERATION'] = 'createNode'
            args = {'properties': params}
        else:
            args = {
                'http_operation': 'POST',
                'operation_path': '',
                'parameters': params
            }

        response = NodeService.requester.call(args)

        if MappingService.driver_type != DriverFactory.DRIVER_REST:
            response = response.get()

        if response.rc != 0:
            LOGGER.warning('Node.save - Problem while saving node' + self.name +
                           '. Reason: ' + str(response.response_content) + ' - ' + str(response.error_message) +
                           " (" + str(response.rc) + ")")
            if response.rc == 500 and ArianeMappingOverloadError.ERROR_MSG in response.error_message:
                raise ArianeMappingOverloadError("Node.save",
                                                 ArianeMappingOverloadError.ERROR_MSG)
            # traceback.print_stack()
        else:
            self.id = response.response_content['nodeID']
            if self.twin_nodes_2_add is not None:
                for twin_node_2_add in self.twin_nodes_2_add:
                    twin_node_2_add.sync()
            if self.twin_nodes_2_rm is not None:
                for twin_node_2_rm in self.twin_nodes_2_rm:
                    twin_node_2_rm.sync()
            if self.container is not None:
                self.container.sync()
            if self.parent_node is not None:
                self.parent_node.sync()
            self.sync(json_obj=response.response_content)
        self.twin_nodes_2_add.clear()
        self.twin_nodes_2_rm.clear()
        self.properties_2_add.clear()
        self.properties_2_rm.clear()
def save ( self ) : LOGGER . debug ( "Node.save" ) if self . container is not None : if self . container . id is None : self . container . save ( ) self . container_id = self . container . id if self . parent_node is not None : if self . parent_node . id is None : self . parent_node . save ( ) self . parent_node_id = self . parent_node . id post_payload = { } consolidated_twin_nodes_id = [ ] consolidated_properties = { } consolidated_node_properties = [ ] if self . id is not None : post_payload [ 'nodeID' ] = self . id if self . name is not None : post_payload [ 'nodeName' ] = self . name if self . container_id is not None : post_payload [ 'nodeContainerID' ] = self . container_id if self . parent_node_id is not None : post_payload [ 'nodeParentNodeID' ] = self . parent_node_id if self . child_nodes_id is not None : post_payload [ 'nodeChildNodesID' ] = self . child_nodes_id if self . twin_nodes_id is not None : consolidated_twin_nodes_id = copy . deepcopy ( self . twin_nodes_id ) if self . twin_nodes_2_rm is not None : for twin_node_2_rm in self . twin_nodes_2_rm : if twin_node_2_rm . id is None : twin_node_2_rm . sync ( ) consolidated_twin_nodes_id . remove ( twin_node_2_rm . id ) if self . twin_nodes_2_add is not None : for twin_node_2_add in self . twin_nodes_2_add : if twin_node_2_add . id is None : twin_node_2_add . save ( ) consolidated_twin_nodes_id . append ( twin_node_2_add . id ) post_payload [ 'nodeTwinNodesID' ] = consolidated_twin_nodes_id if self . endpoints_id is not None : post_payload [ 'nodeEndpointsID' ] = self . endpoints_id if self . properties is not None : consolidated_properties = copy . deepcopy ( self . properties ) if self . properties_2_rm is not None : for n_property_name in self . properties_2_rm : consolidated_properties . pop ( n_property_name , 0 ) if self . properties_2_add is not None : for n_property_tuple in self . properties_2_add : consolidated_properties [ n_property_tuple [ 0 ] ] = n_property_tuple [ 1 ] if consolidated_properties . __len__ ( ) > 0 : for key , value in consolidated_properties . items ( ) : consolidated_node_properties . append ( DriverTools . property_params ( key , value ) ) post_payload [ 'nodeProperties' ] = consolidated_node_properties params = SessionService . complete_transactional_req ( { 'payload' : json . dumps ( post_payload ) } ) if MappingService . driver_type != DriverFactory . DRIVER_REST : params [ 'OPERATION' ] = 'createNode' args = { 'properties' : params } else : args = { 'http_operation' : 'POST' , 'operation_path' : '' , 'parameters' : params } response = NodeService . requester . call ( args ) if MappingService . driver_type != DriverFactory . DRIVER_REST : response = response . get ( ) if response . rc != 0 : LOGGER . warning ( 'Node.save - Problem while saving node' + self . name + '. Reason: ' + str ( response . response_content ) + ' - ' + str ( response . error_message ) + " (" + str ( response . rc ) + ")" ) if response . rc == 500 and ArianeMappingOverloadError . ERROR_MSG in response . error_message : raise ArianeMappingOverloadError ( "Node.save" , ArianeMappingOverloadError . ERROR_MSG ) else : self . id = response . response_content [ 'nodeID' ] if self . twin_nodes_2_add is not None : for twin_node_2_add in self . twin_nodes_2_add : twin_node_2_add . sync ( ) if self . twin_nodes_2_rm is not None : for twin_node_2_rm in self . twin_nodes_2_rm : twin_node_2_rm . sync ( ) if self . container is not None : self . container . sync ( ) if self . parent_node is not None : self . parent_node . sync ( ) self . sync ( json_obj = response . response_content ) self . twin_nodes_2_add . clear ( ) self . twin_nodes_2_rm . clear ( ) self . properties_2_add . clear ( ) self . properties_2_rm . clear ( )
save or update this node in Ariane server
        :return: