import { TranslationFile } from './translation-file' ; import { TranslationFileView } from './translation-file-view' ; import { isNullOrUndefined } from 'util' ; import { AutoTranslateSummaryReport } from './auto-translate-summary-report' ; /**
 * Workflow type determines, how you work with the tool.
 * There are 2 modes:
 * SINGLE_USER: You are developer and translator in one person.
 * You just translate the messages and, when done, reimport it into your application.
 * All translations are marked as state "final" directly after input.
 * WITH_REVIEW: Developer and translator are distinct people.
 * All translation are first marked as "translated".
 * When done, the translator gives it back to the developer, who reviews all marked as "translated".
 * He then can mark them all as "final" or give them back to the translator.
 */ export enum WorkflowType { SINGLE_USER , WITH_REVIEW } /**
 * The role the user has, when working with the tool.
 * As a reviewer you can check the translations and mark them as "final" at the end.
 * As a translator you can translate and give it back to the reviever.
 */ export enum UserRole { REVIEWER , TRANSLATOR } /**
 * A Translation Project.
 * A name and a translation file.
 */ export class TranslationProject { public id : string ; private _view : TranslationFileView ; private _userRole : UserRole ; private _autoTranslateSummaryReport : AutoTranslateSummaryReport ; param serializationString return { TranslationProject } static deserialize ( serializationString ) { const deserializedObject = JSON . parse ( serializationString ) ; const project = new TranslationProject ( deserializedObject . name , TranslationFile . deserialize ( deserializedObject . translationFile ) , deserializedObject . workflowType ) ; project . id = deserializedObject . id ; project . setUserRole ( deserializedObject . userRole ) ; return project ; } constructor ( private _name , private _translationFile , private _workflowType ? ) { if ( isNullOrUndefined ( this . _workflowType ) ) { this . _workflowType = WorkflowType . SINGLE_USER ; } this . _view = new TranslationFileView ( _translationFile ) ; } /**
     * Return a string represenation of project state.
     * This will be stored in BackendService.
     */ public serialize ( ) { const serializedObject = { id : this . id , name : this . name , translationFile : this . translationFile . serialize ( ) , workflowType : this . workflowType , userRole : this . userRole } ; return JSON . stringify ( serializedObject ) ; } get name ( ) : string { return this . _name ; } public setName ( name ) { this . _name = name ; } get translationFile ( ) : TranslationFile { return this . _translationFile ; } get translationFileView ( ) : TranslationFileView { return this . _view ; } get workflowType ( ) : WorkflowType { return this . _workflowType ? this . _workflowType : WorkflowType . SINGLE_USER ; } public setWorkflowType ( type ) { this . _workflowType = type ; } get userRole ( ) : UserRole { return isNullOrUndefined ( this . _userRole ) ? UserRole . TRANSLATOR : this . _userRole ; } public setUserRole ( role ) { this . _userRole = role ; } public isReviewModeActive ( ) { return this . _userRole === UserRole . REVIEWER ; } public hasErrors ( ) { return this . translationFile && this . translationFile . hasErrors ( ) ; } public canTranslate ( ) { return this . translationFile && this . translationFile . canTranslate ( ) ; } return { AutoTranslateSummaryReport } public autoTranslateSummaryReport ( ) { return this . _autoTranslateSummaryReport ; } param summary public setAutoTranslateSummaryReport ( summary ) { this . _autoTranslateSummaryReport = summary ; } }