| Quintiq file version 2.0 | 
| #parent: #root | 
| Method RequestReceiveGetSet (NamedValueTree nvt_i) | 
| { | 
|   Description: 'Handle the request for GetSet in the Data Manager.' | 
|   TextBody: | 
|   [* | 
|     // Jacky C Sep-4-2015 (created) | 
|     sourceKind := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCEKIND() ); | 
|     sourceName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME() ); | 
|      | 
|     // Extract requesting dataset kind and name - Used when requestor does not match source | 
|     requestingKind := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTINGDATASETKIND() ); | 
|     requestingName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTINGDATASETNAME() ); | 
|      | 
|     root := this.CommunicationChannelRoot(); | 
|      | 
|     // Retrieve IntegrationEvent | 
|     event := root.EventGetLast( sourceKind, sourceName ); | 
|      | 
|     // only DM can respond to this request type | 
|     // if this is not allowed in Hierarchy channel, additional condition will be required | 
|     if( this.CommunicationChannelRoot().IsDataManager() ) | 
|     { | 
|       systemOnChannel := this.GetSystemOnChannel( sourceKind, sourceName ); | 
|      | 
|       feedback := ''; | 
|       set := this.GetSetOfInterest( nvt_i, false, feedback ); | 
|       gp  := this.CommunicationChannelRoot().GlobalParameters(); | 
|      | 
|       // 1. checks for interest | 
|       if( not isnull( set ) ) | 
|       { | 
|         if( systemOnChannel.CanSend() ) | 
|         { | 
|           // Save requesting kind and name into SOC for the sending process. This MUST be cleared later. | 
|           systemOnChannel.SetRequestingDataset( requestingKind, requestingName ); | 
|      | 
|           // 2. checks for last updated | 
|           lastUpdated := LibInt_MessageAccessor::GetHeaderPropertyAsDateTime( nvt_i, LibDMF_CommunicationChannel::HEADER_LAST_UPDATED() ); | 
|           if( not lastUpdated < set.TimestampLastUpdated() ) | 
|           { | 
|             // do not return set objects | 
|             // RFC: instead of returning empty set, should create a header to flag it. | 
|           } | 
|      | 
|           data := this.DataCollect( set ); | 
|      | 
|           // Set isNotification to false, regardless of the setting of the interest. | 
|           // A request should return the requested data. | 
|           isNotification := false; | 
|           this.MessageSendSetUpdatedToSystem( set.SetType().Name(), set.Name(), isNotification, data, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName(), set.TimestampLastUpdated() ); | 
|         } | 
|         else | 
|         { | 
|           root.EventLogActivityError( event, | 
|                                       "SystemOnChannel is not fully configured", | 
|                                       "SystemOnChannel is not fully configured; " | 
|                                       + "Host = '" + systemOnChannel.HostName() | 
|                                       + "', Port = " + [String]systemOnChannel.PortNr() | 
|                                       + "', IsSoftDeleted = " + [String]systemOnChannel.IsSoftDeleted() ); | 
|         } | 
|       } | 
|       else | 
|       { | 
|         // Signal error: interest not found | 
|         this.MessageSendErrorToSystem( LibDMF_CommunicationChannel::REQUEST_GETSET(), feedback, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName() ); | 
|       } | 
|     } | 
|     else | 
|     { | 
|       root.EventLogActivityError( event, | 
|                                   "Request cannot be fulfilled.", | 
|                                   "Request cannot be fulfilled. System " + this.CommunicationChannelRoot().SystemShortName() + " is not a Data Manager." ); | 
|     } | 
|   *] | 
| } |