RatingService: Use ServerDao
I had forgotten an interface exists, and this will be needed for the next commit. Unfortunately it requires a bit of duplication with MongoServerDao.d.ts, for now.master
parent
767a248e44
commit
312142b3e8
|
@ -19,19 +19,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ServerDao, Callback } from "./ServerDao";
|
||||
|
||||
import { ClassificationData, WorksheetData } from "../rater/Rater";
|
||||
import { PositiveInteger } from "../../numeric";
|
||||
import { QuoteId } from "../../document/Document";
|
||||
import { ServerSideQuote } from "../quote/ServerSideQuote";
|
||||
|
||||
/** Success or failure callback */
|
||||
type Callback = ( quote: ServerSideQuote ) => void;
|
||||
|
||||
|
||||
/**
|
||||
* MongoDB-backed data store
|
||||
*/
|
||||
export declare class MongoServerDao
|
||||
export declare class MongoServerDao implements ServerDao
|
||||
{
|
||||
/**
|
||||
* Saves a quote to the database
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* General server database operations
|
||||
*
|
||||
* Copyright (C) 2010-2019 R-T Specialty, LLC.
|
||||
*
|
||||
* This file is part of the Liza Data Collection Framework.
|
||||
*
|
||||
* liza is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 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 Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This interface was created to satisfy MongoServerDao and may not be
|
||||
* sufficiently general for other database abstractions.
|
||||
*/
|
||||
|
||||
import { ClassificationData, WorksheetData } from "../rater/Rater";
|
||||
import { PositiveInteger } from "../../numeric";
|
||||
import { QuoteId } from "../../document/Document";
|
||||
import { ServerSideQuote } from "../quote/ServerSideQuote";
|
||||
|
||||
/** Success or failure callback */
|
||||
export type Callback = ( quote: ServerSideQuote ) => void;
|
||||
|
||||
|
||||
/**
|
||||
* Database abstraction
|
||||
*/
|
||||
export interface ServerDao
|
||||
{
|
||||
/**
|
||||
* Saves a quote to the database
|
||||
*
|
||||
* A full save will include all metadata.
|
||||
*
|
||||
* @param quote - the quote to save
|
||||
* @param success - function to call on success
|
||||
* @param failure - function to call if save fails
|
||||
* @param save_data - quote data to save (optional)
|
||||
*/
|
||||
saveQuote(
|
||||
quote: ServerSideQuote,
|
||||
success: Callback,
|
||||
failure: Callback,
|
||||
save_data: Record<string, any>,
|
||||
): this;
|
||||
|
||||
|
||||
/**
|
||||
* Merges bucket data with the existing bucket (rather than overwriting the
|
||||
* entire bucket)
|
||||
*
|
||||
* @param quote - quote to save
|
||||
* @param data - bucket data
|
||||
* @param success - successful callback
|
||||
* @param failure - failure callback
|
||||
*/
|
||||
mergeBucket(
|
||||
quote: ServerSideQuote,
|
||||
data: Record<string, any>,
|
||||
success: Callback,
|
||||
failure: Callback,
|
||||
): this;
|
||||
|
||||
|
||||
/**
|
||||
* Save quote classification data
|
||||
*
|
||||
* @param quote - quote to save
|
||||
* @param classes - classification data
|
||||
* @param success - successful callback
|
||||
* @param failure - failure callback
|
||||
*/
|
||||
saveQuoteClasses(
|
||||
quote: ServerSideQuote,
|
||||
classes: ClassificationData,
|
||||
success: Callback,
|
||||
failure: Callback,
|
||||
): this;
|
||||
|
||||
|
||||
/**
|
||||
* Saves the quote state to the database
|
||||
*
|
||||
* The quote state includes the current step, the top visited step and the
|
||||
* explicit lock message.
|
||||
*
|
||||
* @param quote - the quote to save
|
||||
* @param success - function to call on success
|
||||
* @param failure - function to call if save fails
|
||||
*/
|
||||
saveQuoteState(
|
||||
quote: ServerSideQuote,
|
||||
success: Callback,
|
||||
failure: Callback,
|
||||
): this;
|
||||
|
||||
|
||||
/**
|
||||
* Saves the quote lock state to the database
|
||||
*
|
||||
* @param quote - the quote to save
|
||||
* @param success - function to call on success
|
||||
* @param failure - function to call if save fails
|
||||
*/
|
||||
saveQuoteLockState(
|
||||
quote: ServerSideQuote,
|
||||
success: Callback,
|
||||
failure: Callback,
|
||||
): this
|
||||
|
||||
|
||||
/**
|
||||
* Save worksheet data
|
||||
*
|
||||
* @param qid - quote identifier
|
||||
* @param data - worksheet data
|
||||
* @param callback - callback
|
||||
*/
|
||||
setWorksheets(
|
||||
qid: QuoteId,
|
||||
data: WorksheetData,
|
||||
callback: NodeCallback<void>,
|
||||
): this;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve worksheet data
|
||||
*
|
||||
* @param qid - quote identifier
|
||||
* @param supplier - supplier id
|
||||
* @param index - worksheet index
|
||||
* @param callback - callback
|
||||
*/
|
||||
getWorksheet(
|
||||
qid: QuoteId,
|
||||
supplier: string,
|
||||
index: PositiveInteger,
|
||||
callback: ( data: WorksheetData | null ) => void,
|
||||
): this;
|
||||
}
|
|
@ -19,15 +19,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ClassificationData, RateResult, WorksheetData } from "../rater/Rater";
|
||||
import { ClientActions } from "../../client/action/ClientAction";
|
||||
import { MongoServerDao } from "../db/MongoServerDao";
|
||||
import { PositiveInteger } from "../../numeric";
|
||||
import { PriorityLog } from "../log/PriorityLog";
|
||||
import { ProcessManager } from "../rater/ProcessManager";
|
||||
import { Program } from "../../program/Program";
|
||||
import { QuoteId } from "../../quote/Quote";
|
||||
import { ClassificationData, RateResult, WorksheetData } from "../rater/Rater";
|
||||
import { Server } from "../Server";
|
||||
import { ServerDao } from "../db/ServerDao";
|
||||
import { ServerSideQuote } from "../quote/ServerSideQuote";
|
||||
import { UserRequest } from "../request/UserRequest";
|
||||
import { UserResponse } from "../request/UserResponse";
|
||||
|
@ -55,7 +55,7 @@ export class RatingService
|
|||
*/
|
||||
constructor(
|
||||
private readonly _logger: PriorityLog,
|
||||
private readonly _dao: MongoServerDao,
|
||||
private readonly _dao: ServerDao,
|
||||
private readonly _server: Server,
|
||||
private readonly _rater_manager: ProcessManager,
|
||||
) {}
|
||||
|
|
Loading…
Reference in New Issue