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; 
 | 
  *] 
 | 
} 
 |