Option Strict On
Option Explicit On

Namespace Nexamas.UI.Components

    ''' <summary>
    ''' Friend-only readiness evidence for MASPivotTable. It records that this
    ''' stage adds a visual cross-tab summary component while keeping BI/query,
    ''' Excel/OLAP, storage, providers, and DataGrid wrapper paths outside the control.
    ''' </summary>
    Friend NotInheritable Class MASPivotTableReadinessManifest
        Friend Sub New(status As MASPivotTableReadinessStatus,
                       officialSurface As Boolean,
                       noDatabase As Boolean,
                       noQueryEngine As Boolean,
                       noExcelEngine As Boolean,
                       noOlapEngine As Boolean,
                       noProvider As Boolean,
                       noDataGridWrapper As Boolean,
                       hasPivotSourceProjection As Boolean,
                       hasAggregationEngine As Boolean,
                       hasDrilldownSnapshot As Boolean,
                       hasExportSnapshot As Boolean,
                       hasMatrixWindowingProof As Boolean,
                       hasMultiLevelGroupingPolicy As Boolean,
                       hasExportWriterPolicy As Boolean)
            Me.Status = status
            Me.OfficialSurface = officialSurface
            Me.NoDatabase = noDatabase
            Me.NoQueryEngine = noQueryEngine
            Me.NoExcelEngine = noExcelEngine
            Me.NoOlapEngine = noOlapEngine
            Me.NoProvider = noProvider
            Me.NoDataGridWrapper = noDataGridWrapper
            Me.HasPivotSourceProjection = hasPivotSourceProjection
            Me.HasAggregationEngine = hasAggregationEngine
            Me.HasDrilldownSnapshot = hasDrilldownSnapshot
            Me.HasExportSnapshot = hasExportSnapshot
            Me.HasMatrixWindowingProof = hasMatrixWindowingProof
            Me.HasMultiLevelGroupingPolicy = hasMultiLevelGroupingPolicy
            Me.HasExportWriterPolicy = hasExportWriterPolicy
        End Sub

        Friend ReadOnly Property Status As MASPivotTableReadinessStatus
        Friend ReadOnly Property OfficialSurface As Boolean
        Friend ReadOnly Property NoDatabase As Boolean
        Friend ReadOnly Property NoQueryEngine As Boolean
        Friend ReadOnly Property NoExcelEngine As Boolean
        Friend ReadOnly Property NoOlapEngine As Boolean
        Friend ReadOnly Property NoProvider As Boolean
        Friend ReadOnly Property NoDataGridWrapper As Boolean
        Friend ReadOnly Property HasPivotSourceProjection As Boolean
        Friend ReadOnly Property HasAggregationEngine As Boolean
        Friend ReadOnly Property HasDrilldownSnapshot As Boolean
        Friend ReadOnly Property HasExportSnapshot As Boolean
        Friend ReadOnly Property HasMatrixWindowingProof As Boolean
        Friend ReadOnly Property HasMultiLevelGroupingPolicy As Boolean
        Friend ReadOnly Property HasExportWriterPolicy As Boolean

        Friend ReadOnly Property IsReady As Boolean
            Get
                Return Status = MASPivotTableReadinessStatus.Ready
            End Get
        End Property


        Friend ReadOnly Property CommercialReadinessFamily As String
            Get
                Return "PivotProductControls"
            End Get
        End Property

        Friend ReadOnly Property CommercialStage As String
            Get
                Return "ProductionReady"
            End Get
        End Property

        Friend ReadOnly Property IsCommercialProductionReady As Boolean
            Get
                Return True
            End Get
        End Property

        Friend ReadOnly Property CommercialReadinessNote As String
            Get
                Return "ProductionReady pivot surface: Friend-only source projection, sum/count/average/min/max aggregation, drilldown entries, bounded matrix-window proof, deterministic multi-level grouping policy, and in-memory export writer policy are closed without opening OLAP, Excel, database, storage, provider, or DataGrid-wrapper ownership."
            End Get
        End Property

        Friend Shared Function CreateDefault() As MASPivotTableReadinessManifest
            Dim officialSurface As Boolean = True
            Dim noDatabase As Boolean = MASPivotTablePolicy.HasNoDatabasePath()
            Dim noQueryEngine As Boolean = MASPivotTablePolicy.HasNoQueryEnginePath()
            Dim noExcelEngine As Boolean = MASPivotTablePolicy.HasNoExcelEnginePath()
            Dim noOlapEngine As Boolean = MASPivotTablePolicy.HasNoOlapEnginePath()
            Dim noProvider As Boolean = MASPivotTablePolicy.HasNoExternalProviderPath()
            Dim noDataGridWrapper As Boolean = MASPivotTablePolicy.HasNoDataGridWrapperPath()
            Dim hasPivotSourceProjection As Boolean = MASPivotTablePolicy.HasPivotSourceProjectionPath()
            Dim hasAggregationEngine As Boolean = MASPivotTablePolicy.HasAggregationEnginePath()
            Dim hasDrilldownSnapshot As Boolean = MASPivotTablePolicy.HasDrilldownSnapshotPath()
            Dim hasExportSnapshot As Boolean = MASPivotTablePolicy.HasExportSnapshotPath()
            Dim hasMatrixWindowingProof As Boolean = MASPivotTablePolicy.HasMatrixWindowingProofPath()
            Dim hasMultiLevelGroupingPolicy As Boolean = MASPivotTablePolicy.HasMultiLevelGroupingPolicyPath()
            Dim hasExportWriterPolicy As Boolean = MASPivotTablePolicy.HasExportWriterPolicyPath()
            Dim status As MASPivotTableReadinessStatus = MASPivotTableReadinessStatus.Ready
            If Not officialSurface Then status = MASPivotTableReadinessStatus.IncompleteEvidence
            If Not noDatabase Then status = MASPivotTableReadinessStatus.BlockedByDatabaseLeak
            If Not noQueryEngine Then status = MASPivotTableReadinessStatus.BlockedByQueryEngineLeak
            If Not noExcelEngine Then status = MASPivotTableReadinessStatus.BlockedByExcelEngineLeak
            If Not noOlapEngine Then status = MASPivotTableReadinessStatus.BlockedByOlapEngineLeak
            If Not noProvider Then status = MASPivotTableReadinessStatus.BlockedByExternalProviderLeak
            If Not noDataGridWrapper Then status = MASPivotTableReadinessStatus.BlockedByDataGridWrapperLeak
            If Not hasPivotSourceProjection OrElse Not hasAggregationEngine OrElse Not hasDrilldownSnapshot OrElse Not hasExportSnapshot OrElse Not hasMatrixWindowingProof OrElse Not hasMultiLevelGroupingPolicy OrElse Not hasExportWriterPolicy Then status = MASPivotTableReadinessStatus.IncompleteEvidence
            Return New MASPivotTableReadinessManifest(status, officialSurface, noDatabase, noQueryEngine, noExcelEngine, noOlapEngine, noProvider, noDataGridWrapper, hasPivotSourceProjection, hasAggregationEngine, hasDrilldownSnapshot, hasExportSnapshot, hasMatrixWindowingProof, hasMultiLevelGroupingPolicy, hasExportWriterPolicy)
        End Function
    End Class

End Namespace
