Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method ExtendCombiwithNextElement 
 | 
{ 
 | 
  Description: 'Determine if the combi needs to be extended with an element. This is the case if the first element type in the combi has reached the expected duration.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    lastelement := this.LastCombiElement(); 
 | 
    if(  lastelement.istype( OptCampaignCombiElementCampaign ) ) 
 | 
    { 
 | 
      /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
      //Close of the campaign combi with all possible transition types 
 | 
      /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
      transitiontypes := selectsortedset( lastelement.astype( OptCampaignCombiElementCampaign ), CampaignType_MP.AsFromOfTransitionType, tt, true, tt.Name() ); 
 | 
      if( transitiontypes.Size() = 0 ) 
 | 
      { 
 | 
        /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
        //Combi cannot be extended.  
 | 
        //In principle this should not happen but is possible if the campaigns/tranisitions are not complete 
 | 
        /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
        this.IsDeadEnd( true )  
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        OptCampaignCombi::AddTransitionsTypeCombi( this, lastelement.OptCampaignUnitSubPeriod(), transitiontypes ); 
 | 
      }   
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
      //Close of the transition combi with the following campaign 
 | 
      /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
      campaigntype := guard( lastelement.astype( OptCampaignCombiElementTransition ).TransitionType_MP().ToCampaignType(), null( CampaignType_MP ) ); 
 | 
      if( isnull( campaigntype ) ) 
 | 
      { 
 | 
        /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
        //Combi cannot be extended.  
 | 
        //In principle this should not happen but is possible if the campaigns/tranisitions are not complete 
 | 
        /////////////////////////////////////////////////////////////////////////////////////////////////// 
 | 
        this.IsDeadEnd( true )   
 | 
      }   
 | 
      else 
 | 
      {  
 | 
        //Close of the transition combi with a campaign 
 | 
        OptCampaignCombi::AddCampaignTypeToCombi( this, lastelement.OptCampaignUnitSubPeriod(), campaigntype ); 
 | 
      } 
 | 
    } 
 | 
  *] 
 | 
} 
 |