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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Quintiq file version 2.0
#parent: #root
Method UpdateTypeIndex (
  String unitid
)
{
  Description: 'Update unit TypeIndex and the linked instances.'
  TextBody:
  [*
    // Update unit TypeIndex and the linked instances if the new ID is not the same as the old ID
    if( this.ID() <> unitid )
    {   
      // Update type index of all linked UnitPeriods
      traverse( this, UnitPeriod, up )
      {
        up.UpdateTypeIndex( unitid, up.Start(), up.End() );
      }
    
      // Update foreign key of all linked Children
      traverse( this, Child, c )
      {
        c.UpdateForeignKey( c.CurrencyID(), c.GroupName(), unitid, c.UnitOfMeasureName() )
      }
    
      // Update type index of all linked CampaignType_MPs
      traverse( this, CampaignType_MP, ct )
      {
        ct.UpdateTypeIndex( ct.Name(), unitid );
      }
    
      // Update foreign key of all linked Lanes
      traverse( this, Lane, lane )
      {
        lane.UpdateForeignKey( unitid );
      }
    
      // Update foreign key of all linked Operations
      traverse( this, Operation, operation )
      {
        operation.UpdateForeignKey( unitid, operation.RoutingID(), operation.RoutingStepName() );
      }
    
      // Update foreign key of all linked StockingPoint_MPs
      traverse( this, StockingPoint_MP, sp )
      {
        sp.UpdateForeignKey( sp.UnitOfMeasureName(), sp.CurrencyID(), sp.GroupName(), unitid );
      }
    
      // Update type index of all linked StockingPointUnits
      traverse( this, StockingPointUnit, spunit )
      {
        spunit.UpdateTypeIndex( spunit.StockingPointID(), unitid, spunit.IsInput() );
      }
    
      // Update type index of all linked SupplySpecifications
      traverse( this, SupplySpecification, starget )
      {
        starget.UpdateTypeIndex( unitid, starget.ProductID(), starget.Start(), starget.End() );
      }
    
      // Update foreign key of all linked UnitAccounts
      traverse( this, UnitAccount, uaccount )
      {
        uaccount.UpdateForeignKey( unitid );
      }
    
      // Update foreign key of all linked UnitCosts
      traverse( this, UnitCost, ucost )
      {
        ucost.UpdateForeignKey( unitid );
      }
    
      // Update type index of all linked UnitAvailabilities
      traverse( this, UnitAvailability, uavailability )
      {
        uavailability.UpdateTypeIndex( unitid, uavailability.Start() );
      }
      
      // Update type index of all linked UnitCalendarElements
      traverse( this, UnitCalendarElement, ucelement )
      {
        ucelement.UpdateTypeIndex( unitid, ucelement.Start(), ucelement.End() );
      }
    
      // Update type index of all linked UnitCapacities
      traverse( this, UnitCapacity, ucapacity )
      {
        ucapacity.UpdateTypeIndex( unitid, ucapacity.Start() );
      }
      
      // Update type index of all linked TransitionType_MPs
      traverse( this, TransitionType_MP, transtype )
      {
        transtype.UpdateTypeIndex( transtype.Name(), unitid );
      }
      
      // Update type index of all linked TransportAvailabilities
      traverse( this, TransportAvailability, transcap )
      {
        transcap.UpdateTypeIndex( unitid, transcap.Start() );
      }
      
      // Update EntityID of subsets for Unit
      traverse( this, SubsetEntityInOptimizerPuzzleBase, subsets )
      {
        subsets.UpdateTypeIndex( subsets.OptimizerPuzzleName(), unitid, subsets.EntityType() );
      } 
      
      // Update type index of all linked UnitShiftPatterns
      traverse( this, UnitShiftPattern, unitshiftpattern )
      {
        unitshiftpattern.UpdateTypeIndex( unitid, unitshiftpattern.ShiftPatternName() );
      }
      
      // Update type index of this Unit
      this.IsManuallyConfigured( true );
      Unit::ChangeKeyUnitTypeIndex( this, unitid );
      
      // Update ID of the calendar associate to this Unit
      this.UnitCalendar().SetCalendarID();
    }
  *]
}