Quintiq file version 2.0
#parent: #root
Method FindCreateProcessNodeAndEdge (
  shadow[SCVNode] ownernode,
  Process_MP process,
  Boolean isupstream,
  output Number depth
) as shadow[SCVNode] id:Method_FormSupplyChainVisualization_FindCreateProcessNodeAndEdge
{
  #keys: '[134266.1.1593330686]'
  Body:
  [*
    // Generate upstream routing steps or lanes node
    scvNode := null( shadow[SCVNode] );
    scvConfig := DataHolderSCVConfiguration.Data();
    
    if( process.istype( Operation ) )
    {       
      scvNode := this.CreateSCVRoutingStepNode( ownernode, process.astype( Operation ), isupstream );
    }
    else if( process.istype( LaneLeg ) )
    {
      scvNode := this.CreateSCVLaneNode( ownernode, process.astype( LaneLeg ), isupstream ); 
    }
    
    depth := ifexpr( isupstream, scvConfig.UpstreamDepthLimit(), scvConfig.DownstreamDepthLimit() ) - scvNode.Depth();
    
    value := max( scvConfig, SCVNode, e, 
                  e.Depth() = scvNode.Depth() 
                  and e.IsUpstream() = scvNode.IsUpstream(), 
                  e.SortSequence() );
                  
    scvNode.SortSequence( value + 1 ); 
    
    return scvNode;
  *]
}
