Quintiq file version 2.0
|
#parent: #root
|
Method GenerateCombiExistingTransition (
|
Transition_MP transition,
|
output OptCampaignUnitSubPeriod lastocuspforcombicreate,
|
Boolean usemultiperiodcombi
|
) as OptCampaignCombi
|
{
|
Description: 'create combi element that reflects an existing transition object'
|
TextBody:
|
[*
|
ocusps := selectsortedset( transition, TransitionPeriod_MP.UnitPeriod.OptCampaignUnitSubPeriod, p, not p.IsFixed() and guard( p.StartTime() > lastocuspforcombicreate.StartTime(), true ), p.StartTime() );
|
combi := null( OptCampaignCombi );
|
|
if ( ocusps.Size() > 0 )
|
{
|
firstocusp := ocusps.Element( 0 );
|
if ( guard( firstocusp.PreviousSubPeriod().IsFixed() and not isnull( firstocusp.PreviousSubPeriod().Campaign_MP() ), false ) )
|
{
|
// we need to start out with a single period combi in order to get the sequence constraint right with previous fixed period at start of plan
|
combi := this.GetCombiForExistingPlan( firstocusp );
|
combi.AddCombiElementCampaign( firstocusp.PreviousSubPeriod().Campaign_MP().CampaignType_MP(), firstocusp );
|
combi.AddCombiElementTransition( transition.TransitionType_MP(), firstocusp );
|
ocusps.Remove( firstocusp );
|
lastocuspforcombicreate := firstocusp;
|
}
|
|
if ( usemultiperiodcombi )
|
{
|
firstloop := true;
|
traverse( ocusps, Elements, ocusp )
|
{
|
if ( firstloop ) // for the 1st period, if we have a previous period we must start with that combi element type
|
{
|
combi := this.GetCombiForExistingPlan( ocusp);
|
|
startingcombielement := ocusp.GetLastElementPreviousSubPeriod();
|
if ( not isnull( startingcombielement ) )
|
{
|
// start of combi with combi element of previous unit sub period
|
type := startingcombielement.GetOptCampaignElementType();
|
combi.AddCombiElement( type, ocusp );
|
}
|
} // endif firstloop
|
|
if ( not firstloop or guard( not combi.LastCombiElement().OptCampaignElementType().Name() = transition.TransitionType_MP().Name(), true ) ) // add transition type ( if not already added because of previous)
|
{
|
combi.AddCombiElementTransition( transition.TransitionType_MP(), ocusp );
|
}
|
|
lastocuspforcombicreate := ocusp;
|
firstloop := false;
|
}
|
}
|
else // not usemultiperiodcombi
|
{
|
traverse( ocusps, Elements, ocusp )
|
{
|
combi := this.GetCombiForExistingPlan( ocusp);
|
|
startingcombielement := ocusp.GetLastElementPreviousSubPeriod();
|
if ( not isnull( startingcombielement ) )
|
{
|
// start of combi with combi element of previous unit sub period
|
type := startingcombielement.GetOptCampaignElementType();
|
combi.AddCombiElement( type, ocusp );
|
}
|
if ( not guard( not combi.LastCombiElement().OptCampaignElementType().Name() = transition.TransitionType_MP().Name(), true ) )
|
{
|
combi.AddCombiElementTransition( transition.TransitionType_MP(), ocusp );
|
}
|
lastocuspforcombicreate := ocusp;
|
}
|
}
|
}
|
return combi;
|
*]
|
InterfaceProperties { Accessibility: 'Module' }
|
}
|