Quintiq file version 2.0
|
#parent: #root
|
Method MessageReceiveSetCreated (NamedValueTree nvt_i)
|
{
|
Description:
|
[*
|
Handle and process the message received of type set created
|
(1) This method will be overridden for the HierarchyChannel in order to disallow set creation
|
*]
|
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();
|
|
set := this.GetSet( nvt_i, false );
|
|
// set should be null in order for creation
|
if( isnull( set ) )
|
{
|
// create set for the settype
|
settype := this.GetSetType( nvt_i );
|
|
if( not isnull( settype ) )
|
{
|
setName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SETNAME() );
|
set := LibDMF_Set::Create( settype, setName );
|
this.DataInstantiateInChannelOfDataManager( nvt_i, set );
|
|
// 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_SETCREATED() );
|
}
|
else
|
{
|
root.EventLogActivityWarning( event,
|
"Cannot send data to interested Systems. Reason(s) :" + String::NewLine() + feedbacks.Concatenate( String::NewLine() ) );
|
}
|
}
|
else
|
{
|
errorMessage := "Cannot create set in Data Manager. Reason: Set Type '" + settype.Name() + "' does not exist in Data Manager."
|
|
root.EventLogActivityWarning( event, errorMessage );
|
|
// TODO: send error message if set type not found or not owned by SoC
|
// Signal error: set type not found
|
this.MessageSendErrorToSystem( LibDMF_CommunicationChannel::MESSAGETYPE_SETCREATED(), errorMessage, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName() );
|
|
root.EventComplete( event );
|
}
|
}
|
else
|
{
|
errorMessage := "Cannot create set in Data Manager. Reason: Set '" + set.Name() + "' already exists 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();
|
}
|
}
|
*]
|
}
|