yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method Update (
  Unit owner,
  String name,
  String inputType,
  Real defaultminqty,
  Real defaultmaxqty,
  Duration defaultmindur,
  Duration defaultmaxdur,
  String color,
  Boolean hasinputmaxquantity,
  Boolean hasinputmaxduration,
  Boolean isfromdb
)
{
  Description: 'Update CampaignType values.'
  TextBody:
  [*
    oldname := this.Name();
    
    // When change of unit, change the owner and remove operation linked
    if( owner <> this.Unit() )
    {
      owner.CampaignType_MP( relmove, this );
      OperationInCampaignType::Delete( this.OperationInCampaignType( relget ) );
    }
    
    isDuration := inputType = GlobalParameters_MP::GetCampaignTransitionsTypeDuration();
    
    defaultminqty := ifexpr( not isDuration, defaultminqty, 0 );
    defaultmaxqty := ifexpr( hasinputmaxquantity, defaultmaxqty, 0 );
    defaultmindur := ifexpr( isDuration, defaultmindur, Duration::Zero() );
    defaultmaxdur := ifexpr( hasinputmaxduration, defaultmaxdur, Duration::Zero() );
    
    this.UpdateTypeIndex( name, owner.ID() );
    
    this.HasInputMaxQuantity( hasinputmaxquantity );
    this.HasInputMaxDuration( hasinputmaxduration );
    this.DefaultMinQuantity( defaultminqty );
    this.DefaultMaxQuantity( defaultmaxqty );
    this.DefaultMinDuration( defaultmindur );
    this.DefaultMaxDuration( defaultmaxdur );
    this.Color( color );
    
    this.IsManuallyConfigured( not isfromdb );
    
    //Update TransitionType as well when CampaignType's name has been changed
    if( oldname <> name )
    {
      traverse( this, AsFromOfTransitionType, transitiontype )
      {
        transitiontype.Update( owner,
                               transitiontype.DefaultMinQuantity(),
                               transitiontype.DefaultMaxQuantity(),
                               transitiontype.DefaultMinDuration(),
                               transitiontype.DefaultMaxDuration(),
                               this,
                               transitiontype.ToCampaignType(),
                               transitiontype.InputType(),
                               transitiontype.HasInputMaxQuantity(),
                               transitiontype.HasInputMaxDuration(),
                               transitiontype.IsManuallyConfigured() );  
            
      }
      
      traverse( this, AsToOfTransitionType, transitiontype )
      {
        transitiontype.Update( owner,
                               transitiontype.DefaultMinQuantity(),
                               transitiontype.DefaultMaxQuantity(),
                               transitiontype.DefaultMinDuration(),
                               transitiontype.DefaultMaxDuration(),
                               transitiontype.FromCampaignType(),
                               this,
                               transitiontype.InputType(),
                               transitiontype.HasInputMaxQuantity(),
                               transitiontype.HasInputMaxDuration(),
                               transitiontype.IsManuallyConfigured() );
      } 
    }
  *]
}