Quintiq file version 2.0
|
#parent: #root
|
Method MessageReceiveSetRemoved (NamedValueTree nvt_i)
|
{
|
Description:
|
[*
|
Handle and process the message received of type set removed
|
(1) This method will be overridden for the HierarchyChannel in order to disallow set removal
|
*]
|
TextBody:
|
[*
|
sourceKind := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCEKIND() );
|
sourceName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME() );
|
|
// LastUpdated can be missing when the message is received from an IF-system.
|
lastUpdated := ifexpr( LibInt_MessageAccessor::HasHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_LAST_UPDATED() ),
|
LibInt_MessageAccessor::GetHeaderPropertyAsDateTime( nvt_i, LibDMF_CommunicationChannel::HEADER_LAST_UPDATED() ),
|
DateTime::MinDateTime() );
|
|
root := this.CommunicationChannelRoot();
|
|
// Retrieve IntegrationEvent.
|
event := root.EventGetLast( sourceKind, sourceName );
|
|
// Log the Activity
|
root.EventLogActivity( event, "Instantiate data" );
|
|
// For checking if error
|
allowable := true;
|
|
// TODO: disallow hierarchy
|
if( this.IsHierarchyChannel() )
|
{
|
// temporarily allowed for testing
|
//allowable := false;
|
}
|
|
if( this.CommunicationChannelRoot().IsDataManager() and allowable )
|
{
|
systemOnChannel := this.GetSystemOnChannel( sourceKind, sourceName );
|
gp := this.CommunicationChannelRoot().GlobalParameters();
|
|
// the set must exists
|
set := this.GetSet( nvt_i, true );
|
|
// set should not be null for removal
|
if( not isnull( set ))
|
{
|
// TODO: send error message if set not owned by SoC
|
|
// before sending, delete all the objects, so that the sync will replace with empty set
|
set.DeleteObjects();
|
|
// Check if the data is 'sane' and can be send to Systems that are interested in it.
|
feedbacks := construct( Strings );
|
canSend := set.DoSanityCheck( feedbacks );
|
|
if( canSend )
|
{
|
// End of event (for Interface System messages)
|
root.EventComplete( event );
|
|
// Send the data to the Systems that are interested in it.
|
set.SendToInterestedSystems( LibDMF_CommunicationChannel::MESSAGETYPE_SETREMOVED() );
|
}
|
else
|
{
|
root.EventLogActivityWarning( event,
|
"Cannot send data to interested Systems. Reason(s) :" + String::NewLine() + feedbacks.Concatenate( String::NewLine() ) );
|
}
|
|
// remove set for the settype after sending
|
set.Delete();
|
}
|
else
|
{
|
errorMessage := "Cannot remove set in Data Manager. Reason: Set " + set.Name() + " does not exist in Data Manager."
|
|
root.EventLogActivityWarning( event, errorMessage );
|
|
// Signal error: set not found
|
this.MessageSendErrorToSystem( LibDMF_CommunicationChannel::MESSAGETYPE_SETCREATED(), errorMessage, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName() );
|
|
root.EventComplete( event );
|
}
|
}
|
else if( not this.CommunicationChannelRoot().IsDataManager() and allowable )
|
{
|
data := this.DataInstantiateInChannelOfSystem( nvt_i );
|
|
// RequestID is never needed for SetCreated and SetRemoved
|
requestID := LibDMF_CommunicationChannel::REQUEST_NO_ID();
|
|
// In a System the generic data must be transformed into the target data structure.
|
activityInfo := ifexpr( requestID <> LibDMF_CommunicationChannel::REQUEST_NO_ID(), ", RequestID = " + requestID, "" );
|
root.EventLogActivity( event, "Synchronize data" + activityInfo );
|
|
// Provide the RequestID to the System so it can take action on it if required.
|
this.DataSynchronizeToSystem( data, lastUpdated, requestID );
|
|
// The data in the Channel can be deleted again.
|
traverse( data, Elements, object )
|
{
|
object.Delete();
|
}
|
}
|
*]
|
}
|