| 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() ); | 
|       }  | 
|     } | 
|   *] | 
| } |