admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan macroplan,
  Unit unit,
  String id,
  String name,
  Real throughtput,
  Boolean hasuserlotsize,
  Real userminimumquantity,
  Boolean hasusermaximumquantity,
  Real usermaximumquantity,
  Real userlotsize,
  Real co2Emission,
  Operation operation,
  Boolean checkunique
) declarative remote as Boolean
{
  Description: 'Validate input, triggered when user create operation from the UI or edit it.'
  TextBody:
  [*
    isvalid := true;
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Get definition name of Operation type
    operationdefname := Operation::GetDefinitionName();
    // Get the length limit for names
    lengthlimit := GlobalParameters_MP::GetLengthOfNames();
    
    // Validate input
    if( not Process_MP::ValidateInput( feedback_o,
                                        sanitycheckfeedback_o,
                                        macroplan,
                                        unit,
                                        name,
                                        false,
                                        Date::MinDate(),
                                        false,
                                        Date::MaxDate(),
                                        hasuserlotsize,
                                        userminimumquantity,
                                        hasusermaximumquantity,
                                        usermaximumquantity,
                                        userlotsize,
                                        co2Emission,
                                        operationdefname ) ) // As we need to re-use the translation
    {
      isvalid := false;
    }
    else
    {
      // Check if throughput is valid
      if( unit.HasCapacityTypeTimeBase() and throughtput <= 0 )
      {
        isvalid := false;
        feedback_o := Translations::MP_Operation_ValidateInput_InvalidThroughput( throughtput );
        sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Check if Operation ID is unique
      else if( checkunique
               and exists( macroplan, Unit.Operation, r, r <> operation, r.ID() = id ) )
      {
        isvalid := false;
        feedback_o := Translations::MP_Operation_ValidateInput_IsNotUnique();
        sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Check if ID is valid or is within the length limit
      else if( id = '' or id.Length() > lengthlimit )
      {
        isvalid := false;
        feedback_o := Translations::MP_Operation_ValidateInput_InvalidID( lengthlimit );
        sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
      }
      
      // Add feedback text if any of the preconditions above are violated
      if( feedback_o <> '' )
      {
        feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_Process_Instance( operationdefname, MacroPlan::GetSubstituteName( name ) ), feedback_o );
      }
    }
    
    return isvalid;
  *]
}