Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod ValidateInput ( 
 | 
  output String feedback_o, 
 | 
  output String sanitycheckfeedback_o, 
 | 
  Unit unit, 
 | 
  DateTime start, 
 | 
  String timeunit, 
 | 
  Real efficiency, 
 | 
  Real allocation, 
 | 
  ShiftPattern shiftpattern, 
 | 
  Real minloadpercentage, 
 | 
  Real maxloadpercentage, 
 | 
  Number nrofunitsopen, 
 | 
  UnitAvailability unitavailability, 
 | 
  Boolean checkunique 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Check for input obtained from UI' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Validate input for UnitAvailability 
 | 
    feedback_o := ''; 
 | 
    sanitycheckfeedback_o := ''; 
 | 
     
 | 
    // Check if the unit availability can be created. 
 | 
    // Check if the primary keys are unique 
 | 
    if( checkunique 
 | 
        and not UnitAvailability::IsPrimaryKeysUnique( unit, start, unitavailability ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsNotUnique(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if efficiency is larger than zero 
 | 
    else if( efficiency < 0.0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_InvalidEfficiency( efficiency ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if allocation is larger than zero 
 | 
    else if( allocation < 0.0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_InvalidAllocation( allocation ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if shiftpattern is provided 
 | 
    else if( isnull( shiftpattern ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsNullShiftPattern(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if max load percentage is larger than zero 
 | 
    else if( maxloadpercentage < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsNegativeMaximumLoadPercentage( maxloadpercentage ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Just to make sure max load percentage is not too large, which will cause the total available duration to be max duration. 
 | 
    else if( maxloadpercentage > 1000 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsMaximumLoadPercentageTooLarge( maxloadpercentage ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if number of unts open is larger than zero 
 | 
    else if( nrofunitsopen < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsNegativeNrOfUnitsOpen( nrofunitsopen ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Verify min load percentage is larger or equal zero 
 | 
    else if( minloadpercentage < 0 ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_MinimumLoadPercentageMustGreaterOrEqualToZero( minloadpercentage ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
 | 
    } 
 | 
    // Verify min load percentage is less or equal to max load percentage 
 | 
    else if( minloadpercentage > maxloadpercentage ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_MinimumLoadPercentageMustBeLowerThanMaximumPercentage( minloadpercentage, maxloadpercentage ); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
 | 
    } 
 | 
    // Check if unit is provided 
 | 
    else if( isnull( unit ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_UnitAvailability_ValidateInput_IsNullUnit(); 
 | 
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
 | 
    } 
 | 
     
 | 
    // Add instance text if any of the preconditions above are violated 
 | 
    if( feedback_o <> '' ) 
 | 
    { 
 | 
      unitname := MacroPlan::GetSubstituteName( guard( unit.Name(), '' ) ); 
 | 
      feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_UnitAvailability_Instance( unitname, start ), 
 | 
                                                             feedback_o ); 
 | 
    } 
 | 
     
 | 
    return feedback_o = ''; 
 | 
  *] 
 | 
} 
 |