Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod ValidateInput ( 
 | 
  output String feedback_o, 
 | 
  output String sanitycheckfeedback_o, 
 | 
  String id, 
 | 
  MacroPlan macroplan, 
 | 
  PeriodSpecification_MP periodspecification, 
 | 
  String timeunit, 
 | 
  Number nroftimeunit, 
 | 
  DateTime periodalignment, 
 | 
  Number nrofhistoricalperiod, 
 | 
  Number nroffutureperiod, 
 | 
  Boolean checkunique 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Validate input entered by user at period definition' 
 | 
  TextBody: 
 | 
  [* 
 | 
    feedback_o := ''; 
 | 
    sanitycheckfeedback_o := ''; 
 | 
    instance := Translations::MP_PeriodSpecification_MP_Instance( id ); 
 | 
    // Get all time units and tokenize them into a set of structured string 
 | 
    timeunits := PeriodSpecification_MP::GetAllTimeUnit().Tokenize( ';' ); 
 | 
     
 | 
    // Check if ID is entered 
 | 
    if( id = '' ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsIDEmpty(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if time unit is valid 
 | 
    else if( timeunits.Find( timeunit ) < 0  ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_InvalidTimeUnit(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if number of time unit is valid 
 | 
    else if( nroftimeunit <= 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsInvalidNrOfTimeUnit( nroftimeunit ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if numbero f future period is valid 
 | 
    else if( nroffutureperiod < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsInvalidNrOfFuturePeriod( nroffutureperiod ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if number of historical period is valid 
 | 
    else if( nrofhistoricalperiod < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsInvalidNrOfHistoricalPeriod( nrofhistoricalperiod ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // For period specification of time unit Month, Quarter, and Year, the start of current period is not allowed to be on 29th, 30th or 31st of the month 
 | 
    // To prevent unclear specification due to variable duration of these periods. For example for monthly period with start of period 30 January, it's not clear where period should end. 
 | 
    else if( timeunit <> Translations::MP_GlobalParameters_Hour() 
 | 
             and timeunit <> Translations::MP_GlobalParameters_Day() 
 | 
             and timeunit <> Translations::MP_GlobalParameters_Week() 
 | 
             and periodalignment.Day() > 28 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsInvalidPeriodAlignment_LimitOfMonth( periodalignment, timeunit ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if ID is unique 
 | 
    else if( checkunique 
 | 
             and exists( macroplan, PeriodSpecification_MP, pdef, 
 | 
                         pdef <> periodspecification, 
 | 
                         pdef.ID() = id ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_IsNotUnique(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    else if( checkunique  
 | 
             and exists( macroplan,  
 | 
                         PeriodSpecification_MP, pdef,  
 | 
                         pdef <> periodspecification, 
 | 
                         pdef.ID() <> id 
 | 
                         and pdef.TimeUnit() = timeunit  
 | 
                         and pdef.NrOfTimeUnit() = nroftimeunit ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_PeriodSpecification_MP_ValidateInput_DuplicateGranularity(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
     
 | 
    // Add feedback text if any of the precondition above is violated 
 | 
    if( feedback_o <> '' ) 
 | 
    { 
 | 
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o ); 
 | 
    } 
 | 
     
 | 
    return feedback_o = ''; 
 | 
  *] 
 | 
} 
 |