def transfer_belong_to_type(self, start_api_id):
     if start_api_id is not None:
         start_api_entity = APIEntity.find_by_id(self.session, start_api_id)
         if start_api_entity is not None:
             start_api_type = start_api_entity.api_type
             type_str = APIEntity.get_simple_type_string(start_api_type)
             type_str = type_str.replace("api", "")
             relation_str = "has" + type_str
             return relation_str
     return None
    def import_one_api_entity(self, api_entity):
        api_type = APIEntity.get_simple_type_string(api_entity.api_type)
        print(api_type)
        property_dict = api_entity.__dict__
        property_dict.pop("_sa_instance_state")
        property_dict["api_id"] = property_dict.pop("id")
        builder = NodeBuilder()
        builder.add_entity_label().add_property(
            **property_dict).add_api_label().add_label(api_type)

        node = builder.build()
        # when the node's qualifier name is "byte","int", the print will cause ValueError: Invalid identifier error
        # print node

        try:
            self.graphClient.create_or_update_api_node(node=node)
            self.logger.info('create node for api entity %s',
                             property_dict['api_id'])
        except Exception, error:
            self.logger.warn('-%s- fail for create node for api entity ',
                             property_dict['api_id'])
            self.logger.exception('this is an exception message')