Exemplo n.º 1
0
    def initServices(self):

        """
        DAO ENGINE
        """
        dbPath = copy(storageManager.appFilePath)
        self._daoEngine = DaoEngine(dbPath)

        """
        CONFIG ENGINE    configEngine reads current configuration 
        """
        self.initConfigEngine()

        """
        DATA ACCESS SERVICE
        """
        self.initDataAccessService()

        """
        INDEXING SERVICE
        """
        # for the indexing service we need a different connection
        conn = self._daoEngine.getNewConnection()
        self.indexingService = IndexingService(self.configEngine.config, conn)

        """
        SEARCH SERVICE
        """
        # for the indexing service we need a different connection
        conn = self._daoEngine.connection
        self.searchService = SearchService(conn)
Exemplo n.º 2
0
class ApplicationManager(object):
    def __init__(self):

        self._daoEngine = None

        self.dataAccessService = None
        self.configEngine = None
        self.indexingService = None
        self.searchService = None

        self.initServices()

    def initServices(self):

        """
        DAO ENGINE
        """
        dbPath = copy(storageManager.appFilePath)
        self._daoEngine = DaoEngine(dbPath)

        """
        CONFIG ENGINE    configEngine reads current configuration 
        """
        self.initConfigEngine()

        """
        DATA ACCESS SERVICE
        """
        self.initDataAccessService()

        """
        INDEXING SERVICE
        """
        # for the indexing service we need a different connection
        conn = self._daoEngine.getNewConnection()
        self.indexingService = IndexingService(self.configEngine.config, conn)

        """
        SEARCH SERVICE
        """
        # for the indexing service we need a different connection
        conn = self._daoEngine.connection
        self.searchService = SearchService(conn)

    def initConfigEngine(self):
        self.configDataAccessService = ConfigDataAccessService(self._daoEngine.connection)
        self.configEngine = ConfigEngine(self.configDataAccessService)

    def initDataAccessService(self):
        self._daoEngine.initUserStorage(self.configEngine.config)
        self.dataAccessService = DataAccessService(self._daoEngine.connection)

    def updateConfiguration(self, newConfig):
        t0 = time()
        self.configEngine.update(newConfig)
        t1 = time()
        print "configEngineUpdate %f" % (t1 - t0,)

        t0 = time()
        self.initDataAccessService()
        t1 = time()
        print "initDataAccess %f" % (t1 - t0,)

    @property
    def appStorageDir(self):
        return copy(storageManager.appFolderPath)

    @property
    def appFileName(self):
        return copy(storageManager.appFileName)

    @property
    def appFilePath(self):
        return copy(storageManager.appFilePath)

    def createBackup(self, backupPath):
        storageManager.createBackup(backupPath)

    def restoreBackup(self, backupPath):
        storageManager.restoreBackup(backupPath)

    def indexData(self):
        self.indexingService.indexData()