| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod LinkOperation ( | 
|   OperationOutput sourceoperationoutput, | 
|   OperationInput destinationoperationinput, | 
|   output BaseOperationLinks trash | 
| ) as OperationLink | 
| { | 
|   Description: 'Add given operations as souce operation.' | 
|   TextBody: | 
|   [* | 
|     // DWE2 Feb-1-2016 (created) | 
|     ol := null( OperationLink ); | 
|     targetoperationlink := OperationLink::FindOperationLinkTypeIndex( sourceoperationoutput.Operation().ID(), | 
|                                                                       destinationoperationinput.Operation().ID() ); | 
|      | 
|     // Case of moving an OO to Operation that already have the OO linked | 
|     // E.g O1 have 2 OO (OO1, OO2) linked to O2 and O3, when user drag OO1 to O3, we will then link OO1 to O# and remove OO2 | 
|     if( not isnull( targetoperationlink ) | 
|         and guard( destinationoperationinput.BaseOperationLink().OperationOutput() <> sourceoperationoutput, false ) ) | 
|     { | 
|       ol := OperationLink::RecreateWithDifferentGroup( sourceoperationoutput.OperationLinkGroupID(), | 
|                                                        targetoperationlink.DestGroupID(), | 
|                                                        targetoperationlink ); | 
|     } | 
|     else | 
|     { | 
|       sourcegroupid := sourceoperationoutput.OperationLinkGroupID(); | 
|       destinationgroupid := destinationoperationinput.OperationLinkGroupID(); | 
|      | 
|       ol := OperationLink::CreateOrDelete( sourceoperationoutput.Operation(), | 
|                                            destinationoperationinput.Operation(), | 
|                                            trash, | 
|                                            sourcegroupid, | 
|                                            destinationgroupid, | 
|                                            sourceoperationoutput.Quantity(), // Source quantity | 
|                                            destinationoperationinput.HasUserQuantityInInputGroup(), | 
|                                            destinationoperationinput.Quantity(), // destination quantity | 
|                                            destinationoperationinput.MinQuantity(), // destiantion min quantity | 
|                                            destinationoperationinput.MaxQuantity(), // destination max quantity | 
|                                            destinationoperationinput.GetInputGroupQuantity() ); // destination group quantity | 
|     } | 
|      | 
|     return ol; | 
|   *] | 
| } |