Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod CreatePeriodTaskOperationMessage ( 
 | 
  MacroPlan macroplan 
 | 
) 
 | 
{ 
 | 
  Description: 'Create sanity check message for lot size' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Get the limit for number of sanity check messages 
 | 
    messagelimit := macroplan.GlobalParameters_MP().SanityCheckLimit(); 
 | 
     
 | 
    // Get PeriodTaskOperations that has sanity check violation(s) 
 | 
    invalidobjects := selectsortedset( macroplan,  
 | 
                                       SanityCheckGroup.astype( SanityCheckGroupLotSize ).InvalidPeriodTaskOperation, 
 | 
                                       invalidobject, 
 | 
                                       true, 
 | 
                                       invalidobject.SanityCheckLotSizeMostSevere() ); 
 | 
                                        
 | 
    objcount := 0; 
 | 
    // Traverse the set of PeriodTaskOperations and create sanity check message 
 | 
    // as long as the number of PeriodTaskOperations processed doesn't exceed the limit of number of messages 
 | 
    traverse( invalidobjects, 
 | 
              Elements, 
 | 
              invalidobject, 
 | 
              objcount <= messagelimit ) 
 | 
    { 
 | 
      objcount := objcount + 1; 
 | 
      feedbacks := construct( Strings ); 
 | 
      sanitycheckfeedbacks := construct( Strings ); 
 | 
       
 | 
      // Get sanity check violation messages and categories 
 | 
      invalidobject.DoSanityCheckGroupLotSize( feedbacks, sanitycheckfeedbacks ); 
 | 
       
 | 
      i := 0; 
 | 
      // Traverse each sanity check violation feedbacks 
 | 
      traverse( feedbacks, Elements, fb ) 
 | 
      { 
 | 
        // Check if there're any SanityCheckMessageLotSize with the same description, if there's none, create one 
 | 
        if( not exists( invalidobject, SanityCheckMessageLotSize, msg, msg.Description() = fb ) ) 
 | 
        { 
 | 
          //tokenize msg to retrieve category level and seperate the actual feedback 
 | 
          sanitycheckmessage := SanityCheckMessageLotSize::Create( invalidobject.SanityCheckGroupLotSize(),  
 | 
                                                                   fb,  
 | 
                                                                   true, 
 | 
                                                                   sanitycheckfeedbacks.Element( i ) ); 
 | 
          sanitycheckmessage.PeriodTaskOperation( relset, invalidobject ); 
 | 
        } 
 | 
        i := i + 1; 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
} 
 |