Example #1
0
def create_parameter_node_from_mysql(l, method_node, result4):
    api_parameter_id = result4[l][0]
    api_parameter_name = result4[l][1]
    api_parameter_type_class_id = result4[l][4]
    api_parameter_type_string = result4[l][5]
    api_parameter_description = result4[l][6]
    api_parameter_description = clean_html_text(api_parameter_description)
    try:
        sql = "select name,doc_website from jdk_class where class_id = " + str(
            api_parameter_type_class_id)
        cur.execute(sql)
        class_query = cur.fetchone()
        class_name = class_query[0]
        class_doc_website = class_query[1]
    except Exception:
        traceback.print_exc()
        class_name = None
        class_doc_website = None
    parameter_node = NodeBuilder(). \
        add_label("api"). \
        add_label("java method parameter"). \
        add_one_property("name", api_parameter_type_string + " " + api_parameter_name). \
        add_one_property("formal parameter name", api_parameter_name). \
        add_one_property("formal parameter type", api_parameter_type_string). \
        add_one_property("description", api_parameter_description). \
        add_one_property("formal parameter type document website", class_doc_website). \
        add_one_property("formal parameter type full name", class_name). \
        build()
    connect_graph.merge(parameter_node)
    # connect_graph.merge(Relationship(parameter_node, 'instance of', node6para))
    connect_graph.merge(Relationship(parameter_node, 'belong to', method_node))
Example #2
0
def create_package_node_from_mysql(j, lib_node, result1):
    api_package_id = result1[j][0]
    api_package_name = result1[j][1]
    api_package_first_version = result1[j][2]
    api_package_doc_website = result1[j][4]
    api_package_description = result1[j][8]
    print api_package_id, "     ", api_package_name
    api_package_description = clean_html_text(api_package_description)
    package_node = NodeBuilder(). \
        add_label("api"). \
        add_label("java package"). \
        add_one_property("name", api_package_name). \
        add_one_property("package name", api_package_name). \
        add_one_property("first version", api_package_first_version). \
        add_one_property("api document website", api_package_doc_website). \
        add_one_property("description", api_package_description). \
        build()
    # insert package to neo4j
    connect_graph.merge(package_node)
    ## connect_graph.merge(Relationship(package_node, 'instance of', node2package))
    connect_graph.merge(Relationship(package_node, 'belong to', lib_node))
    return api_package_id, package_node
Example #3
0
def create_class_node_from_mysql(m, package_node, result2):
    api_class_id = result2[m][0]
    api_class_name = result2[m][1]
    api_class_first_version = result2[m][6]
    api_class_type = result2[m][8]
    api_class_doc_website = result2[m][9]
    api_class_description = result2[m][3]
    api_class_description = clean_html_text(api_class_description)
    class_node = NodeBuilder(). \
        add_label("api"). \
        add_label("java class"). \
        add_one_property("name", api_class_name). \
        add_one_property("class name", api_class_name). \
        add_one_property("first version", api_class_first_version). \
        add_one_property("api document website", api_class_doc_website). \
        add_one_property("description", api_class_description). \
        add_one_property("api type", api_class_type). \
        build()
    connect_graph.merge(class_node)
    # connect_graph.merge(Relationship(class_node, 'instance of', node3class))
    connect_graph.merge(Relationship(class_node, 'belong to', package_node))
    return api_class_id, class_node
Example #4
0
def create_throw_exception_node_from_mysql(l, method_node, result4):
    exception_id = result4[l][0]
    exception_name = result4[l][1]
    throw_exception_description = result4[l][4]
    throw_exception_description = clean_html_text(throw_exception_description)
    throw_exception_node = NodeBuilder(). \
        add_label("api"). \
        add_label("entity"). \
        add_label("java throw exception description"). \
        add_one_property("name", throw_exception_description). \
        add_one_property("exception type", exception_name). \
        add_one_property("description", throw_exception_description). \
        build()
    connect_graph.merge(throw_exception_node)
    connect_graph.merge(
        Relationship(method_node, 'throw exception description',
                     throw_exception_node))
    if method_node["throw exception"] is not None:
        method_node["throw exception"] = method_node["throw exception"].append(
            exception_name)
    else:
        exception_list = [exception_name]
        method_node["throw exception"] = exception_list
    connect_graph.push(method_node)
Example #5
0
def create_method_node_from_mysql(class_node, n, result3):
    api_method_id = result3[n][0]
    api_method_type = result3[n][1]
    api_method_name = result3[n][2]
    api_method_declaration = result3[n][3]
    api_method_retType = result3[n][4]
    api_method_retStr = result3[n][5]
    api_method_des = result3[n][6]
    api_method_first_version = result3[n][7]
    api_method_is_static = result3[n][8]
    api_method_override = result3[n][9]
    api_method_specify = result3[n][10]
    api_method_declaration = clean_html_text(api_method_declaration)
    api_method_retStr = clean_html_text(api_method_retStr)
    api_method_des = clean_html_text(api_method_des)
    if "Field" == api_method_type:
        method_node = NodeBuilder(). \
            add_label("api"). \
            add_label("java field"). \
            add_one_property("name", api_method_name). \
            add_one_property("field name", api_method_name). \
            add_one_property("api type", api_method_type). \
            add_one_property("declaration", api_method_declaration). \
            add_one_property("return value type", api_method_retType). \
            add_one_property("return value description", api_method_retStr). \
            add_one_property("first version", api_method_first_version). \
            add_one_property("override", api_method_override). \
            add_one_property("description", api_method_des). \
            build()

        connect_graph.merge(method_node)
        # connect_graph.merge(Relationship(method_node, 'instance of', node5field))
        connect_graph.merge(Relationship(method_node, 'belong to', class_node))

    else:
        if "Nested" == api_method_type:
            method_node = NodeBuilder(). \
                add_label("api"). \
                add_label("java nested class"). \
                add_one_property("name", api_method_name). \
                add_one_property("class name", api_method_name). \
                add_one_property("api type", "nested class"). \
                add_one_property("declaration", api_method_declaration). \
                add_one_property("return value type", api_method_retType). \
                add_one_property("class description", api_method_retStr). \
                add_one_property("first version", api_method_first_version). \
                add_one_property("override", api_method_override). \
                add_one_property("description", api_method_des). \
                build()
        else:
            if api_method_type.lower() == "optional" or api_method_type.lower(
            ) == "required":
                method_node = NodeBuilder(). \
                    add_label("api"). \
                    add_label("java abstract property"). \
                    add_one_property("name", api_method_name). \
                    add_one_property("method name", api_method_name). \
                    add_one_property("api type", api_method_type). \
                    add_one_property("declaration", api_method_declaration). \
                    add_one_property("return value type", api_method_retType). \
                    add_one_property("return value description", api_method_retStr). \
                    add_one_property("first version", api_method_first_version). \
                    add_one_property("override", api_method_override). \
                    add_one_property("description", api_method_des). \
                    build()
            else:
                method_node = NodeBuilder(). \
                    add_label("api"). \
                    add_label("java " + api_method_type.lower()). \
                    add_one_property("name", api_method_name). \
                    add_one_property("method name", api_method_name). \
                    add_one_property("api type", api_method_type). \
                    add_one_property("declaration", api_method_declaration). \
                    add_one_property("return value type", api_method_retType). \
                    add_one_property("return value description", api_method_retStr). \
                    add_one_property("first version", api_method_first_version). \
                    add_one_property("override", api_method_override). \
                    add_one_property("description", api_method_des). \
                    build()

        connect_graph.merge(method_node)
        # connect_graph.merge(Relationship(method_node, 'instance of', node4method))
        connect_graph.merge(Relationship(method_node, 'belong to', class_node))

    return api_method_id, method_node, api_method_retStr, api_method_retType
Example #6
0
filename = "github_info.data"
filepath = os.path.abspath(os.path.dirname(os.getcwd())) + "/" + filename

with open(filepath, "r") as f:
    lines = f.readlines()

github_info_list = []
for line in lines:
    github_info_dict = json.loads(line)
    github_info_list.append(github_info_dict)

for each in github_info_list:
    #print each["id"]
    if "description" in each:
        each["description"] = clean_html_text(each["description"])
    if "contributor" in each:
        if type(each["contributor"]) != int:
            each["contributor"] = clean_html_text(each["contributor"])
        elif each["contributor"] == -1:
            each["contributor"] = 0
    if "release" in each and each["release"] == -1:
        each["release"] = 0
    if "branch" in each and each["branch"] == -1:
        each["branch"] = 0
    if "commit" in each and each["commit"] == -1:
        each["commit"] = 0


temp_extended_list = []
j = 0