| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod CreateUnitCalendarElementMessage ( | 
|   MacroPlan macroplan | 
| ) | 
| { | 
|   Description: 'create sanity check message for unit calendar element' | 
|   TextBody: | 
|   [* | 
|     // Get the limit for the number of sanity check messages | 
|     messagelimit := macroplan.GlobalParameters_MP().SanityCheckLimit(); | 
|      | 
|     // Get the set of invalid objects | 
|     invalidobjects := selectsortedset( macroplan,  | 
|                                        SanityCheckGroupData.InvalidUnitCalendarElement, | 
|                                        invalidobject, | 
|                                        true, | 
|                                        invalidobject.SanityCheckDataMostSevere() ); | 
|                                         | 
|     objcount := 0; | 
|     // Traverse the set of invalid objects as long as the number of created message is within the limit | 
|     traverse( invalidobjects, | 
|               Elements, | 
|               invalidobject, | 
|               objcount <= messagelimit ) | 
|     { | 
|       // Update the number of created messages | 
|       objcount := objcount + 1; | 
|       feedbacks := construct( Strings ); | 
|       sanitycheckfeedbacks := construct( Strings ); | 
|       // Retrieve sanity check messages | 
|       invalidobject.DoSanityCheckData( feedbacks, sanitycheckfeedbacks ); | 
|      | 
|       i := 0; | 
|       // Traverse the set of returned feedbacks | 
|       traverse( feedbacks, Elements, fb ) | 
|       { | 
|         // Check if there are any existing sanity check message with the same feedback message | 
|         if( not exists( invalidobject, SanityCheckMessageData, msg, msg.Description() = fb ) ) | 
|         { | 
|           //tokenize msg to retrieve category level and seperate the actual feedback | 
|           sanitycheckmessage := SanityCheckMessageData::Create( invalidobject.SanityCheckGroupData(),  | 
|                                                                 fb,  | 
|                                                                 true, | 
|                                                                 sanitycheckfeedbacks.Element( i ) ); | 
|           sanitycheckmessage.UnitCalendarElement( relset, invalidobject ); | 
|         } | 
|         i := i + 1; | 
|       } | 
|     } | 
|   *] | 
| } |