def import_all_android_method():
    # get all-version library
    cur.execute("select * from " + IMPORT_DATA_SOURCE_TABLE_NAME)
    data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(data_list)):
        method_node, old_id = create_method_node(data_list[i])
        if method_node is None:
            logger.error(data_list[i])
            logger.error("unkonwn api type")
            continue
        if KnowledgeTableRowMapRecord.exist_import_record(
                session, method_knowledge_table, api_knowledge_table, old_id):
            print old_id, " has been import to new table"
        else:
            method_node = method_node.find_or_create(session, autocommit=False)
            result_tuples.append((method_node, old_id))
    session.commit()
    for item in result_tuples:
        (method_node, old_id) = item
        record = KnowledgeTableRowMapRecord(method_knowledge_table,
                                            api_knowledge_table, old_id,
                                            method_node.id)
        record.create(session, autocommit=False)
    session.commit()

    "complete import method"
def import_all_android_package():
    jdk_package_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(session,
                                                                                     "androidAPI_support_package")
    api_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(session, APIEntity.__tablename__)

    # get all-version library
    cur.execute("select * from androidAPI_support_package")
    package_data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(package_data_list)):
        package_node, old_id = create_package_node(package_data_list[i])
        if KnowledgeTableRowMapRecord.exist_import_record(session, jdk_package_knowledge_table, api_knowledge_table,
                                                          old_id):
            print old_id, " has been import to new table"
        else:
            package_node = package_node.find_or_create(session, autocommit=False)
            result_tuples.append((package_node, old_id))
    session.commit()
    for item in result_tuples:
        (package_node, old_id) = item
        record = KnowledgeTableRowMapRecord(jdk_package_knowledge_table, api_knowledge_table, old_id,
                                            package_node.id)
        record.create(session, autocommit=False)
    session.commit()

    "reading from mysql completed!"
Example #3
0
def import_all_class():
    # get all-version library
    cur.execute("select * from " + IMPORT_DATA_SOURCE_TABLE_NAME)
    data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(data_list)):
        class_node, old_id = create_class_node(data_list[i])
        if class_node is None:
            logger.error(data_list[i])
            logger.error("unkonwn api type")
            continue
        if KnowledgeTableRowMapRecord.exist_import_record(
                session, class_knowledge_table, api_knowledge_table, old_id):
            logger.info("%d has been import to new table", old_id)
        else:
            class_node = class_node.find_or_create(session, autocommit=False)
            result_tuples.append((class_node, old_id))
    session.commit()
    for item in result_tuples:
        (class_node, old_id) = item
        record = KnowledgeTableRowMapRecord(class_knowledge_table,
                                            api_knowledge_table, old_id,
                                            class_node.id)
        record.create(session, autocommit=False)
    session.commit()

    "reading from mysql completed!"
Example #4
0
def import_all_jdk_class():
    jdk_class_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(session, "jdk_class")
    api_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(session, APIEntity.__tablename__)

    # get all-version library
    cur.execute("select * from jdk_class")
    data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(data_list)):
        class_node, old_id = create_class_node(data_list[i])
        if class_node is None:
            print "unkonwn api type", data_list[i]
            continue
        if KnowledgeTableRowMapRecord.exist_import_record(session, jdk_class_knowledge_table, api_knowledge_table,
                                                          old_id):
            print old_id, " has been import to new table"
        else:
            class_node = class_node.find_or_create(session, autocommit=False)
            result_tuples.append((class_node, old_id))
    session.commit()
    for item in result_tuples:
        (class_node, old_id) = item
        record = KnowledgeTableRowMapRecord(jdk_class_knowledge_table, api_knowledge_table, old_id,
                                            class_node.id)
        record.create(session, autocommit=False)
    session.commit()

    "reading from mysql completed!"
Example #5
0
def import_all_jdk_version():
    jdk_library_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(
        session, "jdk_library")
    library_knowledge_table = KnowledgeTableFactory.find_knowledge_table_by_name(
        session, LibraryEntity.__tablename__)

    # get all-version library
    cur.execute("select * from jdk_library")
    lib_sql_data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(lib_sql_data_list)):
        lib_node, old_id = create_library_node(lib_sql_data_list[i])
        if KnowledgeTableRowMapRecord.exist_import_record(
                session, jdk_library_knowledge_table, library_knowledge_table,
                old_id):
            print old_id, " has been import to new table"
        else:
            lib_node = lib_node.find_or_create(session, autocommit=False)
            result_tuples.append((lib_node, old_id))
    session.commit()
    for item in result_tuples:
        (lib_node, old_id) = item
        record = KnowledgeTableRowMapRecord(jdk_library_knowledge_table,
                                            library_knowledge_table, old_id,
                                            lib_node.id)
        record.create(session, autocommit=False)
    session.commit()

    "reading from mysql completed!"
Example #6
0
def import_all_method():
    # get all-version method
    cur.execute("select * from " + IMPORT_DATA_SOURCE_TABLE_NAME)
    data_list = cur.fetchall()
    result_tuples = []
    for i in range(0, len(data_list)):
        row_data = data_list[i]
        try:
            import_one_row(result_tuples, row_data)
        except Exception:
            logger.error(row_data)
            logger.error("import one row fail")
    session.commit()
    for item in result_tuples:
        (method_node, old_id) = item
        record = KnowledgeTableRowMapRecord(method_knowledge_table,
                                            api_knowledge_table, old_id,
                                            method_node.id)
        record.create(session, autocommit=False)
    session.commit()

    logger.info("import from mysql completed!")