Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method InitializeLaneAfterImport 
 | 
{ 
 | 
  Description: 'Set StockingPointInLane after import Lane & LaneLeg' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Jian Giang Aug-17-2016 (created) 
 | 
     
 | 
    //traverse laneleg for origin 
 | 
    traverse( this, Unit.Lane, lane ) 
 | 
    { 
 | 
      originSPs := construct( StockingPoint_MPs ); 
 | 
      destSPs := construct( StockingPoint_MPs ); 
 | 
       
 | 
      oristockingpointinlanes := construct( StockingPointInLanes );  
 | 
      desstockingpointinlanes := construct( StockingPointInLanes );  
 | 
       
 | 
      // select the old stockingpointinlanes  
 | 
      oldoristockingpointinlanes := selectset( lane, Origin, ori, true, true ); 
 | 
      olddesstockingpointinlanes := selectset( lane, Destination, dest, true, true ); 
 | 
       
 | 
      traverse( lane, LaneLeg, laneleg ) 
 | 
      { 
 | 
        laneid := lane.ID(); 
 | 
        orispil := select( lane, Origin, o,  
 | 
                           o.OriginLaneID() = laneid and o.StockingPointID() = laneleg.OriginStockingPointID() ); 
 | 
        desspil := select( lane, Destination, d,  
 | 
                           d.DestinationLaneID() = laneid and d.StockingPointID() = laneleg.DestinationStockingPointID() ); 
 | 
         
 | 
        oristockingpointinlanes.Add( orispil ); 
 | 
        desstockingpointinlanes.Add( desspil ); 
 | 
         
 | 
        orisp := StockingPoint_MP::FindStockingPointTypeIndex( laneleg.OriginStockingPointID() ); 
 | 
        if( not isnull( orisp ) ) 
 | 
        { 
 | 
          originSPs.Add( orisp ); 
 | 
        } 
 | 
        destsp := StockingPoint_MP::FindStockingPointTypeIndex( laneleg.DestinationStockingPointID() ); 
 | 
        if( not isnull( destsp ) ) 
 | 
        { 
 | 
          destSPs.Add( destsp ); 
 | 
        } 
 | 
      } 
 | 
      originSPs := originSPs.Unique(); 
 | 
      if( originSPs.Size() > 0 ) 
 | 
      { 
 | 
        lane.AddStockingPoints( originSPs, true, true ); 
 | 
      } 
 | 
       
 | 
      destSPs := destSPs.Unique(); 
 | 
      if( destSPs.Size() > 0 ) 
 | 
      { 
 | 
        lane.AddStockingPoints( destSPs, false, true ); 
 | 
      } 
 | 
      //delete unused stockingointinlanes 
 | 
      obsoleteoristockingpointinlanes := oldoristockingpointinlanes.Difference( oristockingpointinlanes ); 
 | 
      obsoletedesstockingpointinlanes := olddesstockingpointinlanes.Difference( desstockingpointinlanes ); 
 | 
      Lane::DeleteLaneLegs( lane, obsoleteoristockingpointinlanes, true ); 
 | 
      Lane::DeleteLaneLegs( lane, obsoletedesstockingpointinlanes, false ); 
 | 
    } 
 | 
  *] 
 | 
} 
 |