Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod ValidateInput ( 
 | 
  output String feedback_o, 
 | 
  output String sanitychkfeedback_o, 
 | 
  MacroPlan macroplan, 
 | 
  Unit unit, 
 | 
  String name, 
 | 
  Boolean hasstart, 
 | 
  Date start, 
 | 
  Boolean hasend, 
 | 
  Date end, 
 | 
  Boolean hasuserlotsize, 
 | 
  Real userminimumquantity, 
 | 
  Boolean hasusermaximumquantity, 
 | 
  Real usermaximumquantity, 
 | 
  Real userlotsize, 
 | 
  Real co2Emission, 
 | 
  String processtype 
 | 
) declarative remote as Boolean 
 | 
{ 
 | 
  Description: 'Validate input, triggered when user create operation from the UI or edit it.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    feedback_o := ''; 
 | 
    sanitychkfeedback_o := ''; 
 | 
    lengthlimit := GlobalParameters_MP::GetLengthOfNames(); 
 | 
     
 | 
    // Check if unit is valid 
 | 
    if( isnull( unit ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_Process_ValidateInput_IsNullUnit( processtype ); 
 | 
      sanitychkfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Check if start and end window is valid 
 | 
    else if( hasend and hasstart and ( start >= end ) ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_Process_ValidateInput_IsStartDateAfterEndDate( end, start ); 
 | 
      sanitychkfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // Transport unit cannot be used for operation 
 | 
    else if( processtype = Operation::GetDefinitionName() 
 | 
             and unit.HasCapacityTypeTransportBase() ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_Process_ValidateInput_IsNotTransportUnit(); 
 | 
      sanitychkfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); 
 | 
    } 
 | 
    // if has user lot size, check the remaining 
 | 
    else if( not Process_MP::ValidateInputLotSize( feedback_o, sanitychkfeedback_o, hasuserlotsize, userminimumquantity, hasusermaximumquantity, usermaximumquantity, userlotsize ) ) 
 | 
    { 
 | 
    } 
 | 
    // name should not be blank and name length should not be more than length limit 
 | 
    else if( name = '' or name.Length() > lengthlimit ) 
 | 
    { 
 | 
      feedback_o := Translations::MP_Process_ValidateInput_IsNameEmpty( lengthlimit, processtype ); 
 | 
      sanitychkfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
 | 
    } 
 | 
    // co2 emission should >= 0 
 | 
    else if( not Process_MP::HasValidCO2( co2Emission, feedback_o ) ) 
 | 
    { 
 | 
      sanitychkfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
 | 
    } 
 | 
     
 | 
     
 | 
    // Add feedback text is any of the preconditions above are violated 
 | 
    if( feedback_o <> '' ) 
 | 
    { 
 | 
      processname := MacroPlan::GetSubstituteName( name ); 
 | 
      // add instance text 
 | 
      msg := SanityCheckMessage::GetFormattedMessage( Translations::MP_Process_Instance( processtype, processname ), 
 | 
                                                      feedback_o ); 
 | 
      feedback_o := msg;                                                    
 | 
    } 
 | 
     
 | 
    return feedback_o = ''; 
 | 
  *] 
 | 
} 
 |