2005-08-18 11:28:28 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-01 01:24:35 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2005-08-18 11:28:28 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
2008-01-29 13:10:35 +05:30
|
|
|
"""Tools/Database Processing/Rebuild Secondary Indices"""
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-03-05 10:01:24 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up logging
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".Rebuild")
|
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gtk modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-11 06:42:06 +05:30
|
|
|
from PluginUtils import Tool, register_tool
|
2005-08-18 11:28:28 +05:30
|
|
|
from QuestionDialog import OkDialog
|
2006-12-01 21:56:34 +05:30
|
|
|
from BasicUtils import UpdateCallback
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# runTool
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-12-01 21:56:34 +05:30
|
|
|
class Rebuild(Tool.Tool,UpdateCallback):
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-04-10 04:23:53 +05:30
|
|
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
|
|
|
|
|
|
|
Tool.Tool.__init__(self, dbstate, options_class, name)
|
|
|
|
|
|
|
|
if self.db.readonly:
|
2006-03-05 10:01:24 +05:30
|
|
|
return
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-04-10 04:23:53 +05:30
|
|
|
self.db.disable_signals()
|
2008-03-14 09:56:44 +05:30
|
|
|
|
2006-04-10 04:23:53 +05:30
|
|
|
if uistate:
|
2006-12-01 21:56:34 +05:30
|
|
|
self.callback = uistate.pulse_progressbar
|
|
|
|
uistate.set_busy_cursor(1)
|
|
|
|
uistate.progress.show()
|
|
|
|
uistate.push_message(dbstate, _("Rebuilding secondary indices..."))
|
2008-03-14 09:56:44 +05:30
|
|
|
|
|
|
|
UpdateCallback.__init__(self,self.callback)
|
|
|
|
self.set_total(11)
|
|
|
|
self.db.rebuild_secondary(self.update)
|
|
|
|
self.reset()
|
|
|
|
|
2006-12-01 21:56:34 +05:30
|
|
|
uistate.set_busy_cursor(0)
|
|
|
|
uistate.progress.hide()
|
|
|
|
OkDialog(_("Secondary indices rebuilt"),
|
|
|
|
_('All secondary indices have been rebuilt.'))
|
|
|
|
else:
|
2008-03-14 09:56:44 +05:30
|
|
|
print "Rebuilding Secondary Indices..."
|
|
|
|
self.db.rebuild_secondary(self.update_empty)
|
2006-12-01 21:56:34 +05:30
|
|
|
print "All secondary indices have been rebuilt."
|
2008-03-14 09:56:44 +05:30
|
|
|
|
2006-12-01 21:56:34 +05:30
|
|
|
self.db.enable_signals()
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
class RebuildOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self, name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self, name,person_id)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-18 11:28:28 +05:30
|
|
|
register_tool(
|
2005-12-06 12:08:09 +05:30
|
|
|
name = 'rebuild',
|
|
|
|
category = Tool.TOOL_DBFIX,
|
|
|
|
tool_class = Rebuild,
|
|
|
|
options_class = RebuildOptions,
|
|
|
|
modes = Tool.MODE_GUI | Tool.MODE_CLI,
|
2008-01-29 02:52:06 +05:30
|
|
|
translated_name = _("Rebuild Secondary Indices"),
|
2008-03-02 04:17:48 +05:30
|
|
|
status = _("Stable"),
|
2005-12-06 12:08:09 +05:30
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2008-03-02 04:17:48 +05:30
|
|
|
description = _("Rebuilds secondary indices")
|
2005-08-18 11:28:28 +05:30
|
|
|
)
|