Exemplo n.º 1
0
    def cb_merge(self, obj):
        """
        Perform the merge of the persons 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.pr1
            titanic = self.pr2
        else:
            phoenix = self.pr2
            titanic = self.pr1

        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            swapname = phoenix.get_primary_name()
            phoenix.set_primary_name(titanic.get_primary_name())
            titanic.set_primary_name(swapname)
        if self.get_widget("gender_btn1").get_active() ^ use_handle1:
            phoenix.set_gender(titanic.get_gender())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            swapid = phoenix.get_gramps_id()
            phoenix.set_gramps_id(titanic.get_gramps_id())
            titanic.set_gramps_id(swapid)

        try:
            query = MergePersonQuery(self.database, phoenix, titanic)
            family_merge_ok = query.execute()
            if not family_merge_ok:
                WarningDialog(
                    _("Warning"),
                    _("The persons have been merged.\nHowever, the families "
                      "for this merge were too complex to automatically "
                      "handle.  We recommend that you go to Relationships "
                      "view and see if additional manual merging of families "
                      "is necessary."),
                    parent=self.window)
            # Add the selected handle to history so that when merge is complete,
            # phoenix is the selected row.
            self.uistate.set_active(phoenix.get_handle(), 'Person')
        except MergeError as err:
            ErrorDialog(_("Cannot merge people"), str(err), parent=self.window)
        self.uistate.set_busy_cursor(False)
        self.close()
        if self.update:
            self.update()
Exemplo n.º 2
0
    def cb_merge(self, obj):
        """
        Perform the merge of the persons 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.pr1
            titanic = self.pr2
        else:
            phoenix = self.pr2
            titanic = self.pr1
            # Add second handle to history so that when merge is complete,
            # phoenix is the selected row.
            self.uistate.set_active(phoenix.get_handle(), 'Person')

        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            swapname = phoenix.get_primary_name()
            phoenix.set_primary_name(titanic.get_primary_name())
            titanic.set_primary_name(swapname)
        if self.get_widget("gender_btn1").get_active() ^ use_handle1:
            phoenix.set_gender(titanic.get_gender())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            swapid = phoenix.get_gramps_id()
            phoenix.set_gramps_id(titanic.get_gramps_id())
            titanic.set_gramps_id(swapid)

        try:
            query = MergePersonQuery(self.database, phoenix, titanic)
            family_merge_ok = query.execute()
            if not family_merge_ok:
                WarningDialog(
                    _("Warning"),
                    _("The persons have been merged.\nHowever, the families "
                      "for this merge were too complex to automatically "
                      "handle.  We recommend that you go to Relationships "
                      "view and see if additional manual merging of families "
                      "is necessary."), parent=self.window)
        except MergeError as err:
            ErrorDialog(_("Cannot merge people"), str(err),
                        parent=self.window)
        self.uistate.set_busy_cursor(False)
        self.close()
        if self.update:
            self.update()
Exemplo n.º 3
0
    def cb_merge(self, obj):
        """
        Perform the merge of the persons 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.pr1
            titanic = self.pr2
        else:
            phoenix = self.pr2
            titanic = self.pr1
            # Add second handle to history so that when merge is complete,
            # phoenix is the selected row.
            self.uistate.set_active(phoenix.get_handle(), 'Person')

        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            swapname = phoenix.get_primary_name()
            phoenix.set_primary_name(titanic.get_primary_name())
            titanic.set_primary_name(swapname)
        if self.get_widget("gender_btn1").get_active() ^ use_handle1:
            phoenix.set_gender(titanic.get_gender())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            swapid = phoenix.get_gramps_id()
            phoenix.set_gramps_id(titanic.get_gramps_id())
            titanic.set_gramps_id(swapid)

        try:
            query = MergePersonQuery(self.database, phoenix, titanic)
            query.execute()
        except MergeError as err:
            ErrorDialog(
                _("Cannot merge people"),
                str(err),  # parent-OK
                parent=self.uistate.window)
        self.uistate.set_busy_cursor(False)
        self.close()
        if self.update:
            self.update()
Exemplo n.º 4
0
    def cb_merge(self, obj):
        """
        Perform the merge of the persons 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.pr1
            titanic = self.pr2
        else:
            phoenix = self.pr2
            titanic = self.pr1
            # Add second handle to history so that when merge is complete,
            # phoenix is the selected row.
            self.uistate.set_active(phoenix.get_handle(), 'Person')

        if self.get_widget("name_btn1").get_active() ^ use_handle1:
            swapname = phoenix.get_primary_name()
            phoenix.set_primary_name(titanic.get_primary_name())
            titanic.set_primary_name(swapname)
        if self.get_widget("gender_btn1").get_active() ^ use_handle1:
            phoenix.set_gender(titanic.get_gender())
        if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
            swapid = phoenix.get_gramps_id()
            phoenix.set_gramps_id(titanic.get_gramps_id())
            titanic.set_gramps_id(swapid)

        try:
            query = MergePersonQuery(self.database, phoenix, titanic)
            query.execute()
        except MergeError as err:
            ErrorDialog(_("Cannot merge people"), str(err),
                        parent=self.uistate.window)
        self.uistate.set_busy_cursor(False)
        self.close()
        if self.update:
            self.update()
Exemplo n.º 5
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)
Exemplo n.º 6
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
            id_func = getattr(database,
                      'get_%s_from_gramps_id' % obj_type.lower())
            primary = id_func(primary_id)
            secondary = id_func(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)