lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Quintiq file version 2.0
#parent: #root
Method GetSetTypeOfInterest (LibDMF_SystemOnChannel soc_i, String setTypeName_i, Boolean isRegex_i, 
  Boolean setTypeFoundRequired_i, output String feedback_o) as owning LibDMF_SetTypes
{
  Description: 'Retrieve the SetType in the DataManager which the SOC is interested in, returns null if not used in DataManager.'
  TextBody:
  [*
    setTypes := construct( LibDMF_SetTypes );
    root     := this.CommunicationChannelRoot();
    
    if( root.IsDataManager() )
    {
      // traverse from soc for performance reason
      // match the settype name based on interest in the settype
      if( isRegex_i )
      {
        // could not take advantage of typeindex due to LIKE operation
        setTypes := selectset( soc_i, Interest.Data.astype( LibDMF_SetType ), st,
                               st.Name() ~ setTypeName_i );
      }
      else
      {
        st := LibDMF_SetType::FindSetType( setTypeName_i );
        if( not isnull( st ) )
        {
          setTypes.Add( st );
        }
      }
    
      // Retrieve IntegrationEvent
      event := root.EventGetLast( soc_i.DatasetKind(), soc_i.DatasetName() );
      activitydetails := setTypeName_i + " for System " + soc_i.SystemName() + "; Channel = " + this.Name();
    
      // 1. checks if settype exists
      if( setTypes.Size() = 0 )
      {
        // log the set type not found
        feedback_o := "Non-existent Set Type " + activitydetails;
    
        // check whether to terminate the transaction
        if( setTypeFoundRequired_i )
        {
          root.EventLogActivityError( event,
                                      "Finding Set Type " + activitydetails,
                                      feedback_o );
        }
        else
        {
          // log warning
          root.EventLogActivityWarning( event,
                                        feedback_o );
        }
      }
      else
      {
        // 2. checks if the SOC is interested when using type index
        if( not isRegex_i )
        {
          setType := setTypes.Element( 0 );
          if( not soc_i.ChecksForInterest( setType ) )
          {
            // reset to empty
            setTypes := construct( LibDMF_SetTypes );
    
            // log the soc does not have interest on settype
            feedback_o := "No interest specified of Set Type " + activitydetails;
    
            // check whether to terminate the transaction
            if( setTypeFoundRequired_i )
            {
              root.EventLogActivityError( event,
                                          "Matching interested Set Type " + activitydetails,
                                          feedback_o );
            }
            else
            {
              // log warning without marking event as failed
              root.EventLogActivity( event,
                                     feedback_o );
            }
          }
          else
          {
            // log successful
            root.EventLogActivity( event,
                                   "Found interested Set Type " + activitydetails );
          }
        }
        else
        {
          // log successful
          root.EventLogActivity( event,
                                 "Found interested Set Type " + activitydetails );
        }
      }
    }
    
    return &setTypes;
  *]
}