yanweiyuan3
2023-10-10 d901b1ab0ee0b690f5ac211b9cdb1db3a58bca86
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
Quintiq file version 2.0
#parent: #root
StaticMethod ConvertSnapshotToTransportType (
  DssKpiSnapshot snapshot,
  String kpiName
) as owning KpiSnapshotData
{
  Description: 'Converts a snapshot from storage to a KpiSnapshotData object for a single KPI (kpiName).'
  TextBody:
  [*
    data := construct( KpiSnapshotData );
    
    // Read the snapshot 'identification'. 
    data.ServerDateTime( snapshot.ServerDateTime() );
    data.PlanDateTime( snapshot.PlanDateTime() );
    data.SourceDatasetMDSID( snapshot.DatasetMDSID() );
    data.RetentionPolicyIdentification( guard( snapshot.RetentionPolicy().Identification(), KpiModelExtensions::GetDefaultRetentionPolicyIdentification() ) );
    
    // Read the KPI Values.
    values := snapshot.GetValues();
    kpi    := select( snapshot, Configuration.MetaDataInConfiguration, mdic, mdic.KpiName() = kpiName );
    value  := values.Element( kpi.Index() );
    data.CreateValue( kpiName, value );
    
    // Read the Label values.
    traverse( snapshot, LabelValueInSnapshot.LabelValue, label )
    {
      data.CreateLabel( label.Label().Name(), label.Value() );
    }
                                                                
    return &data;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}