# ABCD/00joshi_hqapp
        PPath = printProductionPath(project_name)
        TPath = printTestPath(project_name)

        num_projects = int(len(PPath))

        if len(PPath) != 0 and len(TPath) != 0:
            try:
                # print(project_folder)
                for num_path in range(num_projects):

                    Productionmethods_list = AstProcessorProduction(
                        None, BasicInfoListener()).execute(
                            PPath[num_path])  #プロダクションファイル内のメソッド名をすべて取得
                    ProductionmethodLine_list = AstProcessorProductionLine(
                        None, BasicInfoListener()).execute(
                            PPath[num_path])  #プロダクションファイル内のメソッド名をすべて取得
                    TestmethodLine_list = AstProcessorTestLine(
                        None, BasicInfoListener()).execute(
                            TPath[num_path])  #プロダクションファイル内のメソッド名をすべて取得

                    PPath_last = PPath[num_path].replace(
                        "D:/ryosuke-ku/data_set/Git_20161108/" + project + "/",
                        "")
                    TPath_last = TPath[num_path].replace(
                        "D:/ryosuke-ku/data_set/Git_20161108/" + project + "/",
                        "")
                    print(PPath_last)
                    print(TPath_last)
                    testDict = testMethodMapCall(TPath[num_path])
                    rd = rdict(testDict)
def storeToDB(project_num, projects_key, project_name):
    for numPath in range(project_num):
        print(numPath)
        print(TPath[numPath])
        Testmethodcalls_list = AstProcessorTestMethodCall(None, BasicInfoListener()).execute(TPath[numPath]) #target_file_path(テストファイル)内のメソッド名をすべて取得
        testMethodMapcall = defaultdict(list)
        num = 0
        for i in Testmethodcalls_list:
            for j in Testmethodcalls_list[i][0]:
                if len(j) == 0:
                    pass
                else:
                    testMethodMapcall[j + '_' + str(num)] = i
                    num += 1

        # print(testMethodMapcall)
        Productionmethods_list = AstProcessorProduction(None, BasicInfoListener()).execute(PPath[numPath]) #プロダクションファイル内のメソッド名をすべて取得
        print(numPath)
        print(PPath[numPath])

        number = 0
        for ProductionMethod in Productionmethods_list:
            rd = rdict(testMethodMapcall)
            remethods = rd["^(?=.*" + ProductionMethod + ").*$"]
            if len(remethods) == 0:
                pass
            else:
                print('----------------------------------------------------')
                print('key : ' + str(ProductionMethod))
                rt = list(set(remethods))
                print('value : ' + str(rt))
    
                for rtitem in rt:
                    post2 = {
                        'clone1': ProductionMethod,
                        'clone2': rtitem,
                    }
                    db.test.insert_one(post2)  
        
                file = open('projects\\' + projects_key + '\\' + project_name + '\\main\\' + str(number) + '.java','w') # Nicad_3.javaのファイルを開く
                ProductionmethodLine_list = AstProcessorProductionLine(None, BasicInfoListener()).execute(PPath[numPath]) #プロダクションファイル内のメソッド名をすべて取得
                print(ProductionmethodLine_list[ProductionMethod])
                startline = int(ProductionmethodLine_list[ProductionMethod][0])-1
                endline = int(ProductionmethodLine_list[ProductionMethod][1])
                f = open(PPath[numPath], "r", encoding="utf-8")
                lines = f.readlines() # 1行毎にファイル終端まで全て読む(改行文字も含まれる)
                f.close()
                src = []
                print('<Production Code>')
                for x in range(startline,endline):
                    # print(lines2[x].replace('\n', ''))
                    srcLow = lines[x].replace('\n', '') + '\n'
                    print(srcLow)
                    file.write(srcLow)
                    src.append(srcLow)

                  
                file_test = open('projects\\' + projects_key + '\\' + project_name + '\\test\\' + str(number) + 'Test.java','w') # Nicad_3.javaのファイルを開く
                TestmethodLine_list = AstProcessorTestLine(None, BasicInfoListener()).execute(TPath[numPath]) #プロダクションファイル内のメソッド名をすべて取得
                # print(TestmethodLine_list)
                print(TestmethodLine_list[rtitem])
                startline_test = int(TestmethodLine_list[rtitem][0])-1
                endline_test = int(TestmethodLine_list[rtitem][1])
                f = open(TPath[numPath], "r", encoding="utf-8")
                lines = f.readlines() # 1行毎にファイル終端まで全て読む(改行文字も含まれる)
                f.close()
                src_test = []
                print('<Test Code>')
                for x in range(startline_test,endline_test):
                    # print(lines2[x].replace('\n', ''))
                    srcLow = lines[x].replace('\n', '') + '\n'
                    print(srcLow)
                    file_test.write(srcLow)
                    src_test.append(srcLow)

                number += 1