Quintiq file version 2.0
|
#parent: #root
|
StaticMethod ValidateInput (
|
output String feedback_o,
|
output String sanitycheckfeedback_o,
|
Unit unit,
|
CampaignType_MP fromcampaigntype,
|
CampaignType_MP tocampaigntype,
|
Real minquantity,
|
Real maxquantity,
|
Duration minduration,
|
Duration maxduration,
|
TransitionType_MP transitiontype,
|
Boolean checkunique,
|
String inputType,
|
Boolean checkmaxqty,
|
Boolean checkmaxdur
|
) declarative remote as Boolean
|
{
|
Description: 'Checks the correctness of input data from Create/Edit dialog.'
|
TextBody:
|
[*
|
// Validate input for TransitionType_MP
|
feedback_o := '';
|
sanitycheckfeedback_o := '';
|
isDurationInput := inputType = GlobalParameters_MP::GetCampaignTransitionsTypeDuration();
|
|
// Check if unit is null
|
if( isnull( unit ) )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNullUnit() ;
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if from/to campaign type is null
|
else if( isnull( fromcampaigntype ) or isnull( tocampaigntype ) )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNullFromToCampaignType() ;
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if from & to campaign type has different UnitID
|
else if( fromcampaigntype.UnitID() <> tocampaigntype.UnitID() )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsDifferentUnit();
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if from & to campaign type is the same campaign type
|
else if( TransitionType_MP::ValidateDistinctOriginDestination( feedback_o, sanitycheckfeedback_o, fromcampaigntype.Name(), tocampaigntype.Name() ) )
|
{
|
// Check if the name is unique
|
if( checkunique )
|
{
|
units := construct( Units )
|
units.Add( unit )
|
TransitionType_MP::CheckIsUnique( feedback_o, sanitycheckfeedback_o, units, transitiontype, fromcampaigntype.Name(), tocampaigntype.Name() )
|
}
|
}
|
if( feedback_o.Length() = 0 )
|
{
|
if( not isDurationInput )
|
{
|
// Check if minimum quantity is valid
|
if( minquantity <= 0 )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMinQuantity( minquantity );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if the maximum quantity is valid
|
else if( checkmaxqty and maxquantity <= 0 )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMaxQuantity( maxquantity );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if min vs max quantity is valid
|
else if( checkmaxqty and maxquantity < minquantity )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsMinQuantityGreaterThanMaxQuantity( minquantity, maxquantity );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
}
|
else if ( isDurationInput )
|
{
|
// Check if min duration is greater than zero
|
if( minduration <= Duration::Zero() )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMinDuration( minduration );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if max duration is greater than zero
|
else if( checkmaxdur and maxduration < Duration::Zero() )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsNegativeMaxDuration( maxduration );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
// Check if min vs max duration is valid
|
else if( checkmaxdur and maxduration < minduration )
|
{
|
feedback_o := Translations::MP_TransitionType_ValidateInput_IsMinDurationGreaterThanMaxDuration( minduration, maxduration );
|
sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
|
}
|
}
|
}
|
|
return feedback_o.Length() = 0;
|
*]
|
}
|