예제 #1
0
    def cb_merge(self, obj):
        """
        Performs the merge of the places when the merge button is clicked.
        """
        self.uistate.set_busy_cursor(True)
        use_handle1 = self.get_widget("handle_btn1").get_active()
        if use_handle1:
            phoenix = self.pl1
            titanic = self.pl2
        else:
            phoenix = self.pl2
            titanic = self.pl1

        if self.get_widget("title_btn1").get_active() ^ use_handle1:
            phoenix.set_title(titanic.get_title())
        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            phoenix.set_name(titanic.get_name())
        if self.get_widget("type_btn1").get_active() ^ use_handle1:
            phoenix.set_type(titanic.get_type())
        if self.get_widget("code_btn1").get_active() ^ use_handle1:
            phoenix.set_code(titanic.get_code())
        if self.get_widget("lat_btn1").get_active() ^ use_handle1:
            phoenix.set_latitude(titanic.get_latitude())
        if self.get_widget("long_btn1").get_active() ^ use_handle1:
            phoenix.set_longitude(titanic.get_longitude())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            phoenix.set_gramps_id(titanic.get_gramps_id())

        query = MergePlaceQuery(self.dbstate, phoenix, titanic)
        query.execute()
        # Add the selected handle to history so that when merge is complete,
        # phoenix is the selected row.
        self.uistate.set_active(phoenix.get_handle(), 'Place')

        if self.callback:
            self.callback()
        self.uistate.set_busy_cursor(False)
        self.close()
예제 #2
0
    def cb_merge(self, obj):
        """
        Performs the merge of the places when the merge button is clicked.
        """
        self.uistate.set_busy_cursor(True)
        use_handle1 = self.get_widget("handle_btn1").get_active()
        if use_handle1:
            phoenix = self.pl1
            titanic = self.pl2
        else:
            phoenix = self.pl2
            titanic = self.pl1
            # Add second handle to history so that when merge is complete, 
            # phoenix is the selected row.
            self.uistate.set_active(phoenix.get_handle(), 'Place')

        if self.get_widget("title_btn1").get_active() ^ use_handle1:
            phoenix.set_title(titanic.get_title())
        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            phoenix.set_name(titanic.get_name())
        if self.get_widget("type_btn1").get_active() ^ use_handle1:
            phoenix.set_type(titanic.get_type())
        if self.get_widget("code_btn1").get_active() ^ use_handle1:
            phoenix.set_code(titanic.get_code())
        if self.get_widget("lat_btn1").get_active() ^ use_handle1:
            phoenix.set_latitude(titanic.get_latitude())
        if self.get_widget("long_btn1").get_active() ^ use_handle1:
            phoenix.set_longitude(titanic.get_longitude())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            phoenix.set_gramps_id(titanic.get_gramps_id())

        query = MergePlaceQuery(self.dbstate, phoenix, titanic)
        query.execute()
        
        if self.callback:
            self.callback()
        self.uistate.set_busy_cursor(False)
        self.close()
예제 #3
0
    def run_tool(self):
        try:
            obj_type = self.options.handler.options_dict['type']
            primary_id = self.options.handler.options_dict['primary']
            secondary_id = self.options.handler.options_dict['secondary']
            if not primary_id or not secondary_id:
                raise MergeError(
                    "Both primary and secondary object IDs need to "
                    "be specified.")

            if not obj_type:
                id2type = {
                    'I': 'Person',
                    'F': 'Family',
                    'E': 'Event',
                    'P': 'Place',
                    'C': 'Citation',
                    'S': 'Source',
                    'R': 'Repository',
                    'O': 'Media',
                    'N': 'Note'
                }
                obj_type = id2type[primary_id[0]]

            database = self.dbstate.db
            primary = database.get_from_name_and_gramps_id(
                obj_type, primary_id)
            secondary = database.get_from_name_and_gramps_id(
                obj_type, secondary_id)
            if not primary or not secondary:
                raise MergeError("Can't get object from ID.")

            if type(primary) != type(secondary):
                raise MergeError("Primary and secondary object need to be of "
                                 "the same type.")

            if obj_type == 'Person':
                from gramps.gen.merge import MergePersonQuery
                query = MergePersonQuery(database, primary, secondary)
            elif obj_type == 'Family':
                # TODO make sure father_handle is in phoenix or titanic
                father_handle = self.options.handler.options_dict['father_h']
                mother_handle = self.options.handler.options_dict['mother_h']
                from gramps.gen.merge import MergeFamilyQuery
                query = MergeFamilyQuery(database, primary, secondary,
                                         father_handle, mother_handle)
            elif obj_type == 'Event':
                from gramps.gen.merge import MergeEventQuery
                query = MergeEventQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Place':
                from gramps.gen.merge import MergePlaceQuery
                query = MergePlaceQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Citation':
                from gramps.gen.merge import MergeCitationQuery
                query = MergeCitationQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Source':
                from gramps.gen.merge import MergeSourceQuery
                query = MergeSourceQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Repository':
                from gramps.gen.merge import MergeRepositoryQuery
                query = MergeRepositoryQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Media':
                from gramps.gen.merge import MergeMediaQuery
                query = MergeMediaQuery(self.dbstate, primary, secondary)
            elif obj_type == 'Note':
                from gramps.gen.merge import MergeNoteQuery
                query = MergeNoteQuery(self.dbstate, primary, secondary)
            else:
                raise MergeError(("Merge for %s not implemented.") % \
                        str(type(primary)))

            query.execute()
        except MergeError as err:
            print(err, file=sys.stderr)
예제 #4
0
 def merge(self,phoenix,titanic):
     query = MergePlaceQuery(self, phoenix, titanic)  # titanix will sink, phoenix will rise
     query.execute()