yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
MethodOverride StoreSnapshot (KpiSnapshotData snapshotData)
{
  TextBody:
  [*
    // Create a real Snapshot object from the specified data object.
    snapshot := DssKpiSnapshot::Create( this, snapshotData.ServerDateTime(), snapshotData.PlanDateTime() );
    snapshot.DatasetMDSID( snapshotData.SourceDatasetMDSID() );
    
    // Store the Labels
    labelValues := this.GetOrCreateLabelValues( snapshotData.Label( relget ) );
    snapshot.AddLabelValues( labelValues );
                            
    // Create the KPIs
    kpiMetaDatas := this.GetOrCreateMatchingMetaDatas( snapshotData.Value( relget ) );
    configuration := this.GetOrCreateMatchingConfiguration( kpiMetaDatas );
    snapshot.Configuration( relset, configuration );
    
    // Prepare and store the KPI values.
    kpiValues := this.GetKpiValuesAsReals( snapshotData.Value( relget ) );
    snapshot.StoreValues( kpiValues );
    
    // Set the retention policy.
    policy := this.KpiTracker().GetRetentionPolicyByIdentifier( snapshotData.RetentionPolicyIdentification() );
    if ( isnull( policy ) )
    {
      info( "KpiTracker | Warning: could not find specified retention policy '", snapshotData.RetentionPolicyIdentification(), "', reverting to default." );
      policy := this.KpiTracker().DefaultRetentionPolicy();
    }
    snapshot.RetentionPolicy( relset, policy );
    
    // If the retention policy is 'TEMPORARY' then also remove the previous snapshot with the same 
    // label/labelvalues combination.
    if ( policy.Identification() = KpiRetentionPolicy::POLICY_TEMPORARY() )
    {
      this.RemovePreviousTemporarySnapshots( snapshot );
    }
  *]
}