2018-03-31 03:30:30 +08:00
|
|
|
import {IUserManager} from './interfaces/IUserManager';
|
|
|
|
import {IGalleryManager} from './interfaces/IGalleryManager';
|
|
|
|
import {ISearchManager} from './interfaces/ISearchManager';
|
|
|
|
import {SQLConnection} from './sql/SQLConnection';
|
|
|
|
import {ISharingManager} from './interfaces/ISharingManager';
|
|
|
|
import {Logger} from '../Logger';
|
2019-01-14 00:38:39 +08:00
|
|
|
import {IIndexingTaskManager} from './interfaces/IIndexingTaskManager';
|
2018-03-31 03:30:30 +08:00
|
|
|
import {IIndexingManager} from './interfaces/IIndexingManager';
|
2019-01-14 00:38:39 +08:00
|
|
|
import {IPersonManager} from './interfaces/IPersonManager';
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2016-05-09 23:04:56 +08:00
|
|
|
export class ObjectManagerRepository {
|
|
|
|
|
2018-05-13 00:19:51 +08:00
|
|
|
private static _instance: ObjectManagerRepository = null;
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private _galleryManager: IGalleryManager;
|
|
|
|
private _userManager: IUserManager;
|
|
|
|
private _searchManager: ISearchManager;
|
2017-07-04 01:17:49 +08:00
|
|
|
private _sharingManager: ISharingManager;
|
2017-07-26 03:09:37 +08:00
|
|
|
private _indexingManager: IIndexingManager;
|
2019-01-14 00:38:39 +08:00
|
|
|
private _indexingTaskManager: IIndexingTaskManager;
|
|
|
|
private _personManager: IPersonManager;
|
|
|
|
|
|
|
|
get PersonManager(): IPersonManager {
|
|
|
|
return this._personManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
set PersonManager(value: IPersonManager) {
|
|
|
|
this._personManager = value;
|
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-26 03:09:37 +08:00
|
|
|
get IndexingManager(): IIndexingManager {
|
|
|
|
return this._indexingManager;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
|
|
|
|
2017-07-26 03:09:37 +08:00
|
|
|
set IndexingManager(value: IIndexingManager) {
|
|
|
|
this._indexingManager = value;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-05-09 23:04:56 +08:00
|
|
|
|
2019-01-14 00:38:39 +08:00
|
|
|
get IndexingTaskManager(): IIndexingTaskManager {
|
|
|
|
return this._indexingTaskManager;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-12-27 23:09:47 +08:00
|
|
|
|
2019-01-14 00:38:39 +08:00
|
|
|
set IndexingTaskManager(value: IIndexingTaskManager) {
|
|
|
|
this._indexingTaskManager = value;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
get GalleryManager(): IGalleryManager {
|
2017-06-11 04:32:56 +08:00
|
|
|
return this._galleryManager;
|
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
set GalleryManager(value: IGalleryManager) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this._galleryManager = value;
|
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
get UserManager(): IUserManager {
|
2017-06-11 04:32:56 +08:00
|
|
|
return this._userManager;
|
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
set UserManager(value: IUserManager) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this._userManager = value;
|
|
|
|
}
|
2016-04-22 19:23:44 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
get SearchManager(): ISearchManager {
|
2017-06-11 04:32:56 +08:00
|
|
|
return this._searchManager;
|
|
|
|
}
|
2016-05-05 00:34:54 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
set SearchManager(value: ISearchManager) {
|
2017-06-11 04:32:56 +08:00
|
|
|
this._searchManager = value;
|
|
|
|
}
|
2016-05-05 00:34:54 +08:00
|
|
|
|
2017-07-04 01:17:49 +08:00
|
|
|
get SharingManager(): ISharingManager {
|
|
|
|
return this._sharingManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
set SharingManager(value: ISharingManager) {
|
|
|
|
this._sharingManager = value;
|
|
|
|
}
|
|
|
|
|
2019-01-14 00:38:39 +08:00
|
|
|
public static getInstance() {
|
|
|
|
if (this._instance === null) {
|
|
|
|
this._instance = new ObjectManagerRepository();
|
|
|
|
}
|
|
|
|
return this._instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static async reset() {
|
|
|
|
await SQLConnection.close();
|
|
|
|
this._instance = null;
|
|
|
|
}
|
|
|
|
|
2017-07-26 03:09:37 +08:00
|
|
|
public static async InitMemoryManagers() {
|
|
|
|
await ObjectManagerRepository.reset();
|
2018-03-31 03:30:30 +08:00
|
|
|
const GalleryManager = require('./memory/GalleryManager').GalleryManager;
|
|
|
|
const UserManager = require('./memory/UserManager').UserManager;
|
|
|
|
const SearchManager = require('./memory/SearchManager').SearchManager;
|
|
|
|
const SharingManager = require('./memory/SharingManager').SharingManager;
|
2019-01-14 00:38:39 +08:00
|
|
|
const IndexingTaskManager = require('./memory/IndexingTaskManager').IndexingTaskManager;
|
2018-03-31 03:30:30 +08:00
|
|
|
const IndexingManager = require('./memory/IndexingManager').IndexingManager;
|
2019-01-14 00:38:39 +08:00
|
|
|
const PersonManager = require('./memory/PersonManager').PersonManager;
|
2017-07-26 03:09:37 +08:00
|
|
|
ObjectManagerRepository.getInstance().GalleryManager = new GalleryManager();
|
|
|
|
ObjectManagerRepository.getInstance().UserManager = new UserManager();
|
|
|
|
ObjectManagerRepository.getInstance().SearchManager = new SearchManager();
|
|
|
|
ObjectManagerRepository.getInstance().SharingManager = new SharingManager();
|
2019-01-14 00:38:39 +08:00
|
|
|
ObjectManagerRepository.getInstance().IndexingTaskManager = new IndexingTaskManager();
|
2017-07-26 03:09:37 +08:00
|
|
|
ObjectManagerRepository.getInstance().IndexingManager = new IndexingManager();
|
2019-01-14 00:38:39 +08:00
|
|
|
ObjectManagerRepository.getInstance().PersonManager = new PersonManager();
|
2017-07-26 03:09:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static async InitSQLManagers() {
|
|
|
|
await ObjectManagerRepository.reset();
|
|
|
|
await SQLConnection.init();
|
2018-03-31 03:30:30 +08:00
|
|
|
const GalleryManager = require('./sql/GalleryManager').GalleryManager;
|
|
|
|
const UserManager = require('./sql/UserManager').UserManager;
|
|
|
|
const SearchManager = require('./sql/SearchManager').SearchManager;
|
|
|
|
const SharingManager = require('./sql/SharingManager').SharingManager;
|
2019-01-14 03:18:18 +08:00
|
|
|
const IndexingTaskManager = require('./sql/IndexingTaskManager').IndexingTaskManager;
|
2018-03-31 03:30:30 +08:00
|
|
|
const IndexingManager = require('./sql/IndexingManager').IndexingManager;
|
2019-01-14 00:38:39 +08:00
|
|
|
const PersonManager = require('./sql/PersonManager').PersonManager;
|
2017-07-26 03:09:37 +08:00
|
|
|
ObjectManagerRepository.getInstance().GalleryManager = new GalleryManager();
|
|
|
|
ObjectManagerRepository.getInstance().UserManager = new UserManager();
|
|
|
|
ObjectManagerRepository.getInstance().SearchManager = new SearchManager();
|
|
|
|
ObjectManagerRepository.getInstance().SharingManager = new SharingManager();
|
2019-01-14 00:38:39 +08:00
|
|
|
ObjectManagerRepository.getInstance().IndexingTaskManager = new IndexingTaskManager();
|
2017-07-26 03:09:37 +08:00
|
|
|
ObjectManagerRepository.getInstance().IndexingManager = new IndexingManager();
|
2019-01-14 00:38:39 +08:00
|
|
|
ObjectManagerRepository.getInstance().PersonManager = new PersonManager();
|
2018-03-31 03:30:30 +08:00
|
|
|
Logger.debug('SQL DB inited');
|
2017-07-26 03:09:37 +08:00
|
|
|
}
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|