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
35
36
37
38
39
Quintiq file version 2.0
#parent: #root
StaticMethod ConvertSnapshotToTransportType (
  DssKpiSnapshot snapshot
) as owning KpiSnapshotData
{
  Description: 'Converts a snapshot from storage to a KpiSnapshotData object.'
  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();
    kpis   := snapshot.Configuration().MetaDataInConfiguration( relget );
    
    // Create a KpiValueData object for each element in the configuration/vector.
    traverse( kpis, Elements, kpi )
    {
      name  := kpi.KpiName()
      value := values.Element( kpi.Index() );
      data.CreateValue( name, value );
    }
    
    // Read the Label values.
    traverse( snapshot, LabelValueInSnapshot.LabelValue, label )
    {
      data.CreateLabel( label.Label().Name(), label.Value() );
    }
                                                                
    return &data;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}