Quintiq file version 2.0
|
#parent: #root
|
Method SetIsActiveStatus (
|
Date earlieststart,
|
Date lateststart
|
) as Boolean
|
{
|
TextBody:
|
[*
|
startdatecombi := this.OptCampaignUnitSubPeriod().UnitPeriod().StartDate()
|
isactive := true; // active by default
|
if ( not this.IsSelectedByOptimizer() ) // selected combis are active for the new iteration. For non selected combis we do some checks to see whether we want to throw them into active set
|
{
|
isactive := startdatecombi >= earlieststart and startdatecombi <= lateststart; // if outside of window and not selected, then disactivate combi
|
if ( isactive ) // otherwise do some additional checking to see whether it should be active
|
{
|
// clear help relation. Use to go over combi elements for current combi only from unit sub period
|
unitsubperiods := construct( OptCampaignUnitSubPeriods );
|
traverse( this, OptCampaignCombiElement.astype( OptCampaignCombiElementCampaign ).OptCampaignUnitSubPeriod, period )
|
{
|
period.OptCampaignCombiElementHelper( relflush );
|
unitsubperiods.Add( period );
|
}
|
|
// set help relation
|
traverse( this, OptCampaignCombiElement.astype( OptCampaignCombiElementCampaign ), element )
|
{
|
element.OptCampaignUnitSubPeriod().OptCampaignCombiElementHelper( relinsert, element );
|
}
|
|
// for each unitsubperiod of the combi we must check the usage, exit if at any point we set it to not 'isactive'
|
traverse( unitsubperiods, Elements, period, isactive )
|
{
|
traverse( period, OptCampaignCTypeCPeriod, typeperiod, isactive ) // go over all campaign types
|
{
|
usage := typeperiod.IsUsingCampaignTypeForSubPeriod(); // usage based on currently selected combis
|
// if the campaign type is not active we are only interested in combis that have the same usage for the period
|
// if the campaign type is active there is no restriction
|
if ( not typeperiod.OptCampaignCampaignType().IsActive() )
|
{
|
usageforcombi := exists( period,
|
OptCampaignCombiElementHelper.astype( OptCampaignCombiElementCampaign ),
|
elementofcombi,
|
elementofcombi.OptCampaignElementType() = typeperiod.OptCampaignCampaignType() );
|
isactive := usageforcombi = usage;
|
}
|
}
|
}
|
}
|
}
|
this.IsActive( isactive );
|
return isactive;
|
*]
|
}
|