--[[----------------------------------------------------------------------------

WFCatImportManifestConstants.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2017 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

local WFCatImportManifestConstants = {}

----------------------------------------------------------------------------

-- Used for entries in the status db
WFCatImportManifestConstants.status = {}
WFCatImportManifestConstants.status.pending = -1
WFCatImportManifestConstants.status.failure = 0
WFCatImportManifestConstants.status.success = 1
WFCatImportManifestConstants.status.ignored = 2

----------------------------------------------------------------------------

-- Used for validation of query data
WFCatImportManifestConstants.validation = {}
WFCatImportManifestConstants.validation.failed = 0
WFCatImportManifestConstants.validation.passed = 1
WFCatImportManifestConstants.validation.modified = 2

----------------------------------------------------------------------------

WFCatImportManifestConstants.manifestDbExtension = ".manifest"
WFCatImportManifestConstants.manifestImportStatusDbExtension = ".manifest_import_status"

----------------------------------------------------------------------------

-- Used to specify the status of the whole manifest
WFCatImportManifestConstants.importStatus = {}
WFCatImportManifestConstants.importStatus.paused = "paused"
WFCatImportManifestConstants.importStatus.completed = "completed"

----------------------------------------------------------------------------

WFCatImportManifestConstants.pauseType = {}
WFCatImportManifestConstants.pauseType.resumeAuto = "resume_auto"
WFCatImportManifestConstants.pauseType.resumeUserChoice = "resume_user_choice"

----------------------------------------------------------------------------

WFCatImportManifestConstants.variableNames = {}
WFCatImportManifestConstants.variableNames.manifestName = "manifestName"
WFCatImportManifestConstants.variableNames.lrCatStoreProviderId = "lrCatStoreProviderId"
WFCatImportManifestConstants.variableNames.manifestSourceId = "manifestSourceId"
WFCatImportManifestConstants.variableNames.catalogName = "catalogName"
WFCatImportManifestConstants.variableNames.dbVersion = "dbVersion"

----------------------------------------------------------------------------

WFCatImportManifestConstants.idCacheSets = {}
WFCatImportManifestConstants.idCacheSets.assets = "assets"
WFCatImportManifestConstants.idCacheSets.albums = "albums"
WFCatImportManifestConstants.idCacheSets.persons = "persons"
WFCatImportManifestConstants.idCacheSets.stacks = "stacks"

----------------------------------------------------------------------------

WFCatImportManifestConstants.stageNames = {}
-- we need to add display string in AgMigrateMessageReporterConstants
-- if we add a new stage 
WFCatImportManifestConstants.stageNames.markCatalogMigrated = "markCatalogMigrated"
WFCatImportManifestConstants.stageNames.assets = "assets"
WFCatImportManifestConstants.stageNames.rootAlbumSet = "root-album-set"
WFCatImportManifestConstants.stageNames.rootAlbumAllPhotos = "all-photos-album"
WFCatImportManifestConstants.stageNames.rootAlbumAssets = "root-album-assets"
WFCatImportManifestConstants.stageNames.albums = "albums"
WFCatImportManifestConstants.stageNames.albumAssets = "album-assets"
WFCatImportManifestConstants.stageNames.copies = "copies"
WFCatImportManifestConstants.stageNames.persons = "persons"
WFCatImportManifestConstants.stageNames.faces = "faces"
WFCatImportManifestConstants.stageNames.stacks = "stacks"
WFCatImportManifestConstants.stageNames.stackAlbums = "stack-albums"

----------------------------------------------------------------------------

WFCatImportManifestConstants.dataTypes = {}
WFCatImportManifestConstants.dataTypes.assets = "assets"
WFCatImportManifestConstants.dataTypes.albums = "albums"
WFCatImportManifestConstants.dataTypes.albumAssets = "album-assets"
WFCatImportManifestConstants.dataTypes.copies = "copies"
WFCatImportManifestConstants.dataTypes.persons = "persons"
WFCatImportManifestConstants.dataTypes.faces = "faces"
WFCatImportManifestConstants.dataTypes.stacks = "stacks"
WFCatImportManifestConstants.dataTypes.stackAlbums = "stack-albums"
WFCatImportManifestConstants.dataTypes.stackAssets = "stack-assets"

----------------------------------------------------------------------------

WFCatImportManifestConstants.kRootAlbumLocalId = 0
WFCatImportManifestConstants.kManifestAllPhotoAlbumLocalId = -1

WFCatImportManifestConstants.rootAlbumsWithComma = table.concat( {
	WFCatImportManifestConstants.kRootAlbumLocalId,
	WFCatImportManifestConstants.kManifestAllPhotoAlbumLocalId,
}, ',' )

----------------------------------------------------------------------------

WFCatImportManifestConstants.messageTypes = {}
WFCatImportManifestConstants.messageTypes.message = "message"
WFCatImportManifestConstants.messageTypes.status = "status"
WFCatImportManifestConstants.messageTypes.progress = "progress"
WFCatImportManifestConstants.messageTypes.progressCountDetails = "progressCountDetails"
WFCatImportManifestConstants.messageTypes.summary = "summary"

WFCatImportManifestConstants.messageSeverity = {}
WFCatImportManifestConstants.messageSeverity.error = "error"
WFCatImportManifestConstants.messageSeverity.warning = "warning"
WFCatImportManifestConstants.messageSeverity.info = "info"


local severity = WFCatImportManifestConstants.messageSeverity

WFCatImportManifestConstants.messages = {
	
	-- Catalog migration check
	markCatalogMigratedError = { severity = severity.error },
	markCatalogMigratedComplete = { severity = severity.info },
	markCatalogMigratedErrorCount = { severity = severity.error },
	
	-- Assets
	assetProcessingError = { severity = severity.error },
	skippedAssets = { severity = severity.error },
	assetProcessingNonMatchingSyncdAsset = { severity = severity.warning },
	assetProcessingMissingSyncdAsset = { severity = severity.error },
	assetImportError = { severity = severity.error },
	assetImportErrorOriginalMissing = { severity = severity.error },
	assetImportErrorNotEnoughSpace = { severity = severity.error },
	assetProcessingUnableToCopyFile = { severity = severity.error },
	assetProcessingErrorCount = { severity = severity.error },
	assetIgnoredErrorWarning = { severity = severity.warning },
	assetProcessingRevisionExists = { severity = severity.warning },
	assetProcessingComplete = { severity = severity.info },
	
	-- Root Albums
	rootAlbumCreateError = { severity = severity.error },
	rootAlbumProcessingComplete = { severity = severity.info },
	rootAlbumProcessingErrorCount = { severity = severity.error },
	rootAlbumProcessingError = { severity = severity.error },
	
	rootAlbumAssetsCreateError = { severity = severity.error },
	rootAlbumAssetsProcessingComplete = { severity = severity.info },
	rootAlbumAssetsProcessingErrorCount = { severity = severity.error },
	rootAlbumAssetsProcessingError = { severity = severity.error },
	
	-- Albums
	albumProcessingError = { severity = severity.error },
	skippedAlbums = { severity = severity.error },
	albumImportError = { severity = severity.error },
	albumReparentedWarning = { severity = severity.warning },
	albumRenamedWarning = { severity = severity.warning },
	createdMissingSyncedAlbumWarning = { severity = severity.warning },
	albumProcessingRevisionExists = { severity = severity.warning },
	albumProcessingErrorCount = { severity = severity.error },
	albumProcessingComplete = { severity = severity.info },
	
	-- Album-assets
	albumAssetProcessingError = { severity = severity.error },
	skippedAlbumAssets = { severity = severity.error },
	albumAssetImportError = { severity = severity.error },
	albumAssetProcessingErrorCount = { severity = severity.error },
	albumAssetProcessingRevisionExists = { severity = severity.warning },
	albumAssetProcessingComplete = { severity = severity.info },
	
	-- Copies
	copiesProcessingError = { severity = severity.error },
	skippedCopies = { severity = severity.error },
	copiesImportError = { severity = severity.error },
	copiesProcessingErrorCount = { severity = severity.error },
	copiesProcessingComplete = { severity = severity.info },
	
	-- Persons 
	personsProcessingError = { severity = severity.error },
	personsProcessingAddingError = { severity = severity.error },
	personsProcessingComplete = { severity = severity.info },
	personsProcessingErrorCount = { severity = severity.error },
	
	-- Faces
	facesProcessingError = { severity = severity.error },
	facesProcessingMissingAssetError = { severity = severity.error },
	facesProcessingMissingPersonWarning = { severity = severity.warning },
	facesProcessingUpdateError = { severity = severity.error },
	facesProcessingComplete = { severity = severity.info },
	facesProcessingErrorCount = { severity = severity.error },
	
	-- Stacks
	stacksProcessingError = { severity = severity.error },
	stacksProcessingDocError = { severity = severity.error },
	stacksProcessingMissingCoverError = { severity = severity.warning },
	stacksProcessingInsufficientElements = { severity = severity.error },
	stacksProcessingComplete = { severity = severity.info },
	stacksProcessingErrorCount = { severity = severity.error },
	stackProcessingMissingAssetError = { severity = severity.error },
	
	-- Stack-albums
	stackAlbumsProcessingError = { severity = severity.error },
	stackAlbumsProcessingMissingAlbumError = { severity = severity.error },
	stackAlbumsProcessingMissingStackError = { severity = severity.error },
	stackAlbumsProcessingComplete = { severity = severity.info },
	stackAlbumsProcessingErrorCount = { severity = severity.error },
	
}

-- Populate the message codes
for k, v in pairs( WFCatImportManifestConstants.messages ) do
	v.code = k
	assert( v.severity )
end

----------------------------------------------------------------------------

-- Info needed by the client to store the status of the manifest database.
-- This should ideally go away when WFCatImportManifest is refactored to 
-- let the client implement all the writing.
WFCatImportManifestConstants.tableNameForOperation = {}
for opName, opInfo in pairs( require 'WFCatImportManifestQueries'.getWriteOperations() ) do
	WFCatImportManifestConstants.tableNameForOperation[ opName ] = opInfo.tableName
end

----------------------------------------------------------------------------

return WFCatImportManifestConstants
