/// <summary> /// Initializes a new instance of the <see cref="SdmxXmlStream"/> class. /// </summary> /// <param name="reader"> /// The reader. /// </param> /// <param name="messageType"> /// The message type. /// </param> /// <param name="sdmxVersion"> /// The schema enum type. /// </param> /// <param name="registryType"> /// The registry type. /// </param> public SdmxXmlStream(XmlReader reader, MessageEnumType messageType, SdmxSchemaEnumType sdmxVersion, RegistryMessageEnumType registryType) { if (!SdmxSchema.GetFromEnum(sdmxVersion).IsXmlFormat()) { throw new ArgumentException("Input not an SDMX-ML file", "sdmxVersion"); } this._reader = reader; this._messageType = messageType; this._sdmxVersion = sdmxVersion; this._registryType = registryType; }
/// <summary> /// Initializes a new instance of the <see cref="BaseParsingManager"/> class. /// </summary> /// <param name="sdmxSchema"> /// The sdmx schema. /// </param> /// <param name="messageType"> /// The message Type. /// </param> protected BaseParsingManager(SdmxSchemaEnumType sdmxSchema, MessageEnumType messageType) { this._sdmxSchema = sdmxSchema; this._messageType = messageType; }
public void TestGetMessageType(string file, MessageEnumType expectedResult) { using (var readable = new FileReadableDataLocation(file)) { Assert.AreEqual(expectedResult, SdmxMessageUtil.GetMessageType(readable)); } }
public static string Enum_MessageEnumType_ToString(MessageEnumType v) { switch (v) { case MessageEnumType.aEurobalise: return "Eurobalise"; case MessageEnumType.aEuroloop: return "Euroloop"; case MessageEnumType.aValidatedTrainData: return "ValidatedTrainData"; case MessageEnumType.aRequestForShunting: return "RequestForShunting"; case MessageEnumType.aMARequest: return "MARequest"; case MessageEnumType.aTrainPositionReport: return "TrainPositionReport"; case MessageEnumType.aRequestToShortenMAIsGranted: return "RequestToShortenMAIsGranted"; case MessageEnumType.aRequestToShortenMAIsRejected: return "RequestToShortenMAIsRejected"; case MessageEnumType.aAcknowledgement: return "Acknowledgement"; case MessageEnumType.aAcknowledgementOfEmergencyStop: return "AcknowledgementOfEmergencyStop"; case MessageEnumType.aTrackAheadFreeGranted: return "TrackAheadFreeGranted"; case MessageEnumType.aEndOfMission: return "EndOfMission"; case MessageEnumType.aRadioInFillRequest: return "RadioInFillRequest"; case MessageEnumType.aTrain_NoCompatibleVersionSupported: return "Train_NoCompatibleVersionSupported"; case MessageEnumType.aTrain_InitiationOfACommunicationSession: return "Train_InitiationOfACommunicationSession"; case MessageEnumType.aTrain_TerminationOfACommunicationSession: return "Train_TerminationOfACommunicationSession"; case MessageEnumType.aSoMPositionReport: return "SoMPositionReport"; case MessageEnumType.aTrain_SessionEstablished: return "Train_SessionEstablished"; case MessageEnumType.aSRAuthorization: return "SRAuthorization"; case MessageEnumType.aMovementAuthority: return "MovementAuthority"; case MessageEnumType.aRecognitionOfExitFromTripMode: return "RecognitionOfExitFromTripMode"; case MessageEnumType.aAcknowledgementOfTrainData: return "AcknowledgementOfTrainData"; case MessageEnumType.aRequestToShortenMA: return "RequestToShortenMA"; case MessageEnumType.aConditionalEmergencyStop: return "ConditionalEmergencyStop"; case MessageEnumType.aUnconditionalEmergencyStop: return "UnconditionalEmergencyStop"; case MessageEnumType.aRevocationOfEmergencyStop: return "RevocationOfEmergencyStop"; case MessageEnumType.aGeneralMessage: return "GeneralMessage"; case MessageEnumType.aSHRefused: return "SHRefused"; case MessageEnumType.aSHAuthorized: return "SHAuthorized"; case MessageEnumType.aRBCRIUSystemVersion: return "RBCRIUSystemVersion"; case MessageEnumType.aMAWithShiftedLocationReference: return "MAWithShiftedLocationReference"; case MessageEnumType.aTrackAheadFreeRequest: return "TrackAheadFreeRequest"; case MessageEnumType.aInFillMA: return "InFillMA"; case MessageEnumType.aTrack_InitiationOfACommunicationSession: return "Track_InitiationOfACommunicationSession"; case MessageEnumType.aAcknowledgementOfTerminationOfACommunicationSession: return "AcknowledgementOfTerminationOfACommunicationSession"; case MessageEnumType.aTrainRejected: return "TrainRejected"; case MessageEnumType.aTrainAccepted: return "TrainAccepted"; case MessageEnumType.aSomPositionReportConfirmedByRBC: return "SomPositionReportConfirmedByRBC"; case MessageEnumType.aAssignmentOfCoordinateSystem: return "AssignmentOfCoordinateSystem"; } return ""; }
/// <summary> /// Initializes a new instance of the <see cref="SdmxXmlStream"/> class. /// </summary> /// <param name="readableDataLocation"> /// The readable data location. /// </param> /// <exception cref="ArgumentException"> /// Input not an SDMX-ML file /// </exception> public SdmxXmlStream(IReadableDataLocation readableDataLocation) { var xmlStream = readableDataLocation as ISdmxXmlStream; if (xmlStream != null) { this._reader = xmlStream.Reader; this._messageType = xmlStream.MessageType; this._sdmxVersion = xmlStream.SdmxVersion; this._registryType = xmlStream.RegistryType; this._queryMessageTypes = xmlStream.QueryMessageTypes; } else { this._sdmxVersion = SdmxMessageUtil.GetSchemaVersion(readableDataLocation); if (!SdmxSchema.GetFromEnum(this._sdmxVersion).IsXmlFormat()) { throw new ArgumentException("Input not an SDMX-ML file", "readableDataLocation"); } this._messageType = SdmxMessageUtil.GetMessageType(readableDataLocation); this._registryType = this._messageType != MessageEnumType.RegistryInterface ? RegistryMessageEnumType.Null : SdmxMessageUtil.GetRegistryMessageType(readableDataLocation); if (this._messageType == MessageEnumType.Query) { this._queryMessageTypes = SdmxMessageUtil.GetQueryMessageTypes(readableDataLocation); } this._reader = XMLParser.CreateSdmxMlReader(readableDataLocation.InputStream, this._sdmxVersion); this.AddDisposable(this._reader); } }
/// <summary> /// Gets the data format. /// </summary> /// <param name="sourceData">The source data.</param> /// <param name="messageType">Type of the message.</param> /// <returns>The <see cref="IDataFormat"/></returns> private IDataFormat GetDataFormat(IReadableDataLocation sourceData, MessageEnumType messageType) { switch (messageType) { case MessageEnumType.Error: SdmxMessageUtil.ParseSdmxErrorMessage(sourceData); break; case MessageEnumType.GenericData: case MessageEnumType.CompactData: case MessageEnumType.CrossSectionalData: case MessageEnumType.UtilityData: case MessageEnumType.SdmxEdi: try { return this._dataInformationManager.GetDataType(sourceData); } catch (Exception e) { _log.Error("While trying to get the data format", e); } break; default: throw new ArgumentException(Resources.ExceptionCannotProccessMessage + MessageType.GetFromEnum(messageType).NodeName, "sourceData"); } return null; }
/// <summary> /// parses the sdmx structure message. /// </summary> /// <param name="stream"> /// The stream. /// </param> /// <param name="schemaVersion"> /// The schema version type. /// </param> /// <param name="messageType"> /// The message type. /// </param> /// <returns> /// The <see cref="ISdmxObjects"/>. /// </returns> private ISdmxObjects ParseSdmxStructureMessage(XmlReader reader, SdmxSchemaEnumType schemaVersion, MessageEnumType messageType) { switch (schemaVersion) { case SdmxSchemaEnumType.VersionOne: //Org.Sdmx.Resources.SdmxMl.Schemas.V10.message.Structure sdV1 = Org.Sdmx.Resources.SdmxMl.Schemas.V10.message.Structure.Factory.Parse(stream); Org.Sdmx.Resources.SdmxMl.Schemas.V10.message.Structure sdV1 = Org.Sdmx.Resources.SdmxMl.Schemas.V10.MessageFactory.Load<Org.Sdmx.Resources.SdmxMl.Schemas.V10.message.Structure, Org.Sdmx.Resources.SdmxMl.Schemas.V10.message.StructureType>(reader); return _sdmxBeansBuilder.Build(sdV1); case SdmxSchemaEnumType.VersionTwo: switch (messageType) { case MessageEnumType.Structure: Structure sdV2 = MessageFactory.Load<Structure, Org.Sdmx.Resources.SdmxMl.Schemas.V20.message.StructureType>(reader); //Structure sdV2 = Structure.Parse(stream);//.Factory.Parse(stream); return _sdmxBeansBuilder.Build(sdV2); case MessageEnumType.RegistryInterface: RegistryInterface rid = RegistryInterface.Load(reader); return _sdmxBeansBuilder.Build(rid); default: throw new ArgumentException("StructureParsingManagerImpl can not parse document '" + messageType + "' was expecting Structure document or RegistryInterface document"); } case SdmxSchemaEnumType.VersionTwoPointOne: switch (messageType) { case MessageEnumType.Structure: Org.Sdmx.Resources.SdmxMl.Schemas.V21.Message.Structure sdV2_1 = Org.Sdmx.Resources.SdmxMl.Schemas.V21.MessageFactory.Load<Org.Sdmx.Resources.SdmxMl.Schemas.V21.Message.Structure, Org.Sdmx.Resources.SdmxMl.Schemas.V21.Message.StructureType>(reader); //Org.Sdmx.Resources.SdmxMl.Schemas.V21.Message.Structure sdV2_1 = Org.Sdmx.Resources.SdmxMl.Schemas.V21.Message.Structure.Parse();//.Factory.Parse(stream); return _sdmxBeansBuilder.Build(sdV2_1); case MessageEnumType.Error: return new SdmxObjectsImpl(); default: throw new ArgumentException("StructureParsingManagerImpl can not parse document '" + messageType + "' was expecting Structure document or Error document"); } } return null; }
/// <summary> /// Initializes a new instance of the <see cref="SdmxStructureParserFactory" /> class. /// </summary> /// <param name="messageType">Type of the message.</param> /// <param name="sdmxSchema">The SDMX schema.</param> /// <param name="registryMessageType">Type of the registry message.</param> /// <param name="sdmxBeansBuilder">The SDMX beans builder.</param> /// <param name="provisionParsingManager">The provision parsing manager.</param> /// <param name="registrationParsingManager">The registration parsing manager.</param> /// <param name="subscriptionParsingManager">The subscription parsing manager.</param> public SdmxStructureParserFactory(MessageEnumType messageType, SdmxSchemaEnumType sdmxSchema, RegistryMessageEnumType registryMessageType, ISdmxObjectsBuilder sdmxBeansBuilder, IProvisionParsingManager provisionParsingManager, IRegistrationParsingManager registrationParsingManager, ISubscriptionParsingManager subscriptionParsingManager) { this._messageType = messageType; this._sdmxSchema = sdmxSchema; this._registryMessageType = registryMessageType; this._sdmxBeansBuilder = sdmxBeansBuilder ?? new SdmxObjectsBuilder(); this._provisionParsingManager = provisionParsingManager ?? new ProvisionParsingManager(); this._registrationParsingManager = registrationParsingManager ?? new RegistrationParsingManager(); this._subscriptionParsingManager = subscriptionParsingManager ?? new SubscriptionParsingManager(); }
/// <summary> /// Initializes a new instance of the <see cref="RegistrationParsingManager"/> class. /// </summary> /// <param name="sdmxSchema"> /// The sdmx schema. /// </param> /// <param name="messageType"> /// The message type. /// </param> public RegistrationParsingManager(SdmxSchemaEnumType sdmxSchema, MessageEnumType messageType) : base(sdmxSchema, messageType) { }