Esempio n. 1
0
def process_neo4j(args):

    # List people with the given name
    try:

        record = None
        time_stamps = []
        t = time.perf_counter()

        u = User()
        u.userid = args.userid
        result = u.get_revisions_of_the_user()
        for record in result:
            time_stamps.append(record["date"])

        if (not record):
            print("\nUnknown userid: " + args.userid)
        else:
            print("\nTime stamps of the user: "******"--------------------------------\n")
            for time_stamp in time_stamps:
                print(time_stamp)

        elapsed_time = time.perf_counter() - t
        print("\nTime needed: " + str(elapsed_time) + " seconds")

    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)
def process_neo4j(args):
    ''' 
        Compare a person from owner's set and another person in Taapeli db
        by the reference names of their first first name 
    '''
    try:
    
        t = time.perf_counter()
        print_cnt = 0

        u = User()
        u.userid = args.userid
        result = u.get_ids_and_refnames_of_people_of_user()
        for record in result:
            p = Person()
            # This id is the unique key of the node
            uniq_id = record["id"]
            p.id = uniq_id
            refname = record["refname"]
            p.get_person_and_name_data_by_id()

            # Use the first of first names of the refname as a search key,
            # E.g. refname = "Matti Johannes" ---> search with "Matti"
            names = refname.split(" ")
                
            tresult = Name.get_ids_of_people_with_refname_and_user_given('Taapeli', names[0])
            for trecord in tresult:
                tp = Person()
                tp.id = trecord["id"]
            
                if print_cnt == 0:
                    print("\nUnique id pairs of people with the same first name in")
                    print("the compared db : the Taapeli db")
                
                print("\n" + str(uniq_id) + " : " + str(tp.id))
                print_cnt += 1
          
        print("\n\nNumber of id pairs printted out: " + str(print_cnt))
        elapsed_time = time.perf_counter() - t
        print("\nTime needed: " + str(elapsed_time) + " seconds")

    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)
Esempio n. 3
0
def process_neo4j(args):

    # List people with the given name
    try:
    
        t = time.perf_counter()

        u = User()
        u.userid = args.userid
        result = u.get_refnames_of_people_of_user()
        for record in result:
            p = Person()
            p.handle = record["handle"]
            refname = record["refname"]
            p.get_person_and_name_data()

            # Use the first name of the refname as a search key,
            # E.g. refname = "Matti Johannes" ---> search with "Matti"
            names = refname.split(" ")
                
            tresult = Name.get_people_with_refname_and_user_given('Taapeli', names[0])
            for trecord in tresult:
                tp = Person()
                tp.handle = trecord["handle"]
                
                print("\nPerson in the compare db:")
                call_string = "python3 get_family_with_handle_given.py " + p.handle
                subprocess.call(call_string, shell=True)
                
                print("\nPerson in the Taapeli db:")
                call_string = "python3 get_family_with_handle_given.py " + tp.handle
                subprocess.call(call_string, shell=True)
                
                print("\n#-------------------------------------------------------------------#\n")
                                   
        elapsed_time = time.perf_counter() - t
        print("\nTime needed: " + str(elapsed_time) + " seconds")

    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)
Esempio n. 4
0
def process_neo4j(args):

    # List users in the Neo4j database
    try:

        t = time.perf_counter()

        result = User.get_all_userids()
        print("\nOwner user id: ")
        print("--------------")
        for record in result:
            userid = record["userid"]

            print(userid)

        elapsed_time = time.perf_counter() - t
        print("\nTime needed: " + str(elapsed_time) + " seconds")

    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)
Esempio n. 5
0
def process_neo4j(args):

    # Get family data of the person
    global points
    
    try:    
        t = time.perf_counter()
        print_cnt = 0
        
        total_points = []
        compared_ids = []
        taapeli_ids = []

        u = User()
        u.userid = args.userid
        result = u.get_ids_and_refnames_of_people_of_user()
        for record in result:
            p = Person()
            # This id is the unique key of the node
            p.uniq_id = record["id"]
            refname = record["refname"]
            p.get_person_and_name_data_by_id()

            # Use the first name of the refname as a search key,
            # E.g. refname = "Matti Johannes" ---> search with "Matti"
            names = refname.split(" ")
                
            tresult = Name.get_ids_of_people_with_refname_and_user_given('Taapeli', names[0])
            for trecord in tresult:
                tp = Person()
                tp.uniq_id = trecord["id"]
                
                # The fetching of the family and parents data of the main person is
                # split to two operations:
                #
                # If there are no parents in the db the result of 
                # get_parentin_id() operation is empty,
                # but the get_family_data operation prints out
                # the family of the main person.
                result = p.get_parentin_id()            
                for record in result:
                    main_parents_hlink = record["parentin_hlink"]
                    
                    result = tp.get_parentin_id()            
                    for record in result:
                        taapeli_parents_hlink = record["parentin_hlink"]
                        compare_parents_data(main_parents_hlink, taapeli_parents_hlink)
        
                compare_family_data(p, tp)
                
                total_points.append(points)
                compared_ids.append(p.uniq_id)
                taapeli_ids.append(tp.uniq_id)
                print_cnt += 1
                
        print("\nTotal points # Compared ids # Taapeli ids")
        print("-----------------------------------------")
        for i in range(len(total_points)):
            print("\n  " + str(total_points[i]) + "   #   " + str(compared_ids[i]) + "   #   " + str(taapeli_ids[i]))

        print("\nLines printted: " + str(print_cnt))
                
        elapsed_time = time.perf_counter() - t
        print("\nTime needed: " + str(elapsed_time) + " seconds")

    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)
Esempio n. 6
0
def process_xml(args):

    # Open XML document using minidom parser
    try:
        DOMTree = xml.dom.minidom.parse(open(args.input_xml))
        collection = DOMTree.documentElement

        # Create User if needed
        User.create_user(args.userid)

        t = time.perf_counter()
        handle_notes(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_notes()

        t = time.perf_counter()
        handle_repositories(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_repositories()

        t = time.perf_counter()
        handle_places(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_places()

        t = time.perf_counter()
        handle_sources(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_sources()

        t = time.perf_counter()
        handle_citations(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_citations()

        t = time.perf_counter()
        handle_events(collection, args.userid)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_events()

        t = time.perf_counter()
        handle_people(collection, args.userid)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_people()

        t = time.perf_counter()
        handle_families(collection)
        elapsed_time = time.perf_counter() - t
        print("Time needed: " + str(elapsed_time) + " seconds")
        number_of_families()

    except FileNotFoundError:
        print("Tiedostoa '{}' ei ole!".format(args.input_xml), file=stderr)
    except Exception as err:
        print("Virhe: {0}".format(err), file=stderr)