Quintiq file version 2.0
|
#parent: #root
|
StaticMethod Synchronize (
|
FeedbackProductInTrips feedbackpits
|
) as owning ProductInTrips
|
{
|
Description: 'Create missing product in trips for feedback.'
|
TextBody:
|
[*
|
pits := construct( ProductInTrips );
|
|
if( feedbackpits.Size() > 0 )
|
{
|
// Propagate relations that are needed for feedbacks.
|
Transaction::Transaction().Propagate( relation( Feedback, UnitPeriod ) );
|
// Propagate relations that are needed for feedbacks.
|
Transaction::Transaction().Propagate( relation( FeedbackProductInTrip, LaneLeg ) );
|
// Propagate relations that are needed for feedbacks.
|
Transaction::Transaction().Propagate( relation( FeedbackProductInTrip, LaneLegOutput ) );
|
// Propagate relations that are needed for feedbacks.
|
Transaction::Transaction().Propagate( relation( FeedbackProductInTrip, ProductInTrip ) );
|
|
// Traverse all feedbacks of product in trip that is valid
|
traverse( feedbackpits, Elements, feedback,
|
feedback.GetIsValidFeedback() )
|
{
|
// Get the associated ProductInTrip and LaneLeg of the current feedback
|
pit := feedback.ProductInTrip();
|
laneleg := feedback.LaneLeg();
|
|
// Check if ProductInTrip is null
|
if( isnull( pit ) )
|
{
|
// Check if LaneLeg is enabled
|
if( guard( laneleg.GetIsEnabled(), false ) )
|
{
|
// Get the associated Trip and Product
|
trip := feedback.Trip();
|
product := guard( feedback.LaneLegOutput().ProductInStockingPoint_MP().Product_MP(), null( Product_MP ) )
|
|
// Check if product is null
|
if( not isnull( product ) )
|
{
|
// Check if trip is null, create one of trip is null
|
if( isnull( trip ) )
|
{
|
arrival := Trip::GetTripArrivalDate( feedback.UnitPeriod().Period_MP(), laneleg );
|
trip := Trip::Create( laneleg, arrival );
|
}
|
|
// Associate product to the trip
|
trip.AddProduct( product, 0.0, false );
|
|
// Propagate the declerative relations for new create trip to feedback
|
Transaction::Transaction().Propagate( relation( ProductInTrip, FeedbackProductInTrip ) );
|
}
|
}
|
}
|
|
// Check if ProductInTrip is null
|
if( not isnull( pit ) )
|
{
|
pits.Add( pit );
|
}
|
}
|
}
|
|
return &pits;
|
*]
|
}
|