xiaoding721
2023-11-13 e4edcfd0b987b239526f5375881b919789782dad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Routing owner,
  RoutingStep routingstep,
  String name,
  Boolean checkuniqueid
) declarative remote as Boolean
{
  Description: 'Check input is valid'
  TextBody:
  [*
    // Adhi Feb-10-2016 (created)
    maxnamelength := GlobalParameters_MP::GetLengthOfNames();
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    
    if( checkuniqueid
         and exists( owner, RoutingStep, rs, rs <> routingstep, rs.Name() = name ) )
    {
      feedback_o := Translations::MP_RoutingStep_ValidateInput_IsNameExists();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Invalid name
    else if( name = '' or name.Length() > maxnamelength )
    {
      feedback_o := Translations::MP_RoutingStep_ValidateInput_IsInvalidName( maxnamelength );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Operations LeadTime should be the same for all operations
    else if(  not isnull( routingstep ) and not routingstep.IsLeadTimeAmongOperationsUnique() )
    {
      feedback_o := Translations::MP_RoutingStep_ValidateInput_IsLeadTimeNotUnique();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); 
    }
    
    
    // Add instance text
    if( feedback_o <> '' )
    {
      rsname := MacroPlan::GetSubstituteName( name );
      instance := Translations::MP_RoutingStep_Instance( rsname, owner.Name() );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance,
                                                             feedback_o );
    }
    
    return feedback_o = '';
  *]
}