陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
53
54
55
56
57
58
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan owner,
  String name,
  UnitOfMeasure_MP unitofmeasure,
  Boolean checkunique,
  Real factor
) declarative remote as Boolean
{
  Description: 'Check unique unitofmeasure name'
  TextBody:
  [*
    // Validate input for UnitOfMeasure
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Get the length limit of names
    namelengthlimit := GlobalParameters_MP::GetLengthOfNames();
    
    // Check if the name is unique
    if( checkunique
        and exists( owner, UnitOfMeasure_MP, uom,
                    uom <> unitofmeasure,
                    uom.Name() = name ) )
    {
      feedback_o := Translations::MP_UnitOfMeasure_ValidateInput_IsNotUnique();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if the name is provided or the length of the name is within the allowed range
    else if( name = ''
             or name.Length() > namelengthlimit )
    {
      feedback_o := Translations::MP_UnitOfMeasure_ValidateInput_IsNameEmptyOrExceedLengthLimit( namelengthlimit );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }    
    else if( factor.IsNaN() )
    {
      feedback_o := Translations::MP_UnitOfMeasure_ViolateDefaultFactor();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();  
    }
    else if( factor =0.0 )
    {
      feedback_o := Translations::MP_UOM_ValidateInput_GreaterThan0( factor );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();  
    }
    // Add instance text if any of the preconditions above are violated
    if( feedback_o <> '' )
    {
      instance := UnitOfMeasure_MP::GetInstanceText( name );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}