/// <summary> /// Build dataflow query. Override to alter the default behavior /// </summary> /// <param name="dataflowRefType"> /// The Dataflow reference (SDMX v2.0 /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> protected override IStructureReference BuildDataflowQuery(DataflowRefType dataflowRefType) { var urn = dataflowRefType.URN; var immutableInstance = BuildConstraintObject(dataflowRefType); StructureReferenceImpl structureReferenceImpl; if (ObjectUtil.ValidString(urn)) { structureReferenceImpl = new ConstrainableStructureReference(urn); } else { string agencyId16 = dataflowRefType.AgencyID; string maintId17 = dataflowRefType.DataflowID; string version18 = dataflowRefType.Version; structureReferenceImpl = new ConstrainableStructureReference(agencyId16, maintId17, version18, SdmxStructureEnumType.Dataflow, immutableInstance); } return structureReferenceImpl; }
/// <summary> /// Build dataflow query. Override to alter the default behavior /// </summary> /// <param name="refType"> /// The Dataflow reference (SDMX v2.0 /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> protected virtual IStructureReference BuildDataflowQuery(DataflowRefType refType) { var urn = refType.URN; StructureReferenceImpl structureReferenceImpl; if (ObjectUtil.ValidString(urn)) { structureReferenceImpl = new StructureReferenceImpl(urn); } else { string agencyID = refType.AgencyID; string dataflowID = refType.DataflowID; string version = refType.Version; structureReferenceImpl = new StructureReferenceImpl(agencyID, dataflowID, version, SdmxStructureEnumType.Dataflow); } return structureReferenceImpl; }
/// <summary> /// The build constraint object. /// </summary> /// <param name="dataflowRefType"> /// The dataflow ref type. /// </param> /// <returns> /// The <see cref="IContentConstraintObject"/>. /// </returns> private static IContentConstraintObject BuildConstraintObject(DataflowRefType dataflowRefType) { IContentConstraintObject immutableInstance = null; if (dataflowRefType.Constraint != null) { string id = dataflowRefType.Constraint.ConstraintID; IContentConstraintMutableObject mutable = new ContentConstraintMutableCore(); AddDummyValuesForValidity(dataflowRefType, mutable); mutable.Id = id; foreach (CubeRegionType cubeRegionType in dataflowRefType.Constraint.CubeRegion) { ICubeRegionMutableObject cubeRegion = BuildCubeRegion(cubeRegionType); if (cubeRegionType.isIncluded && mutable.IncludedCubeRegion == null) { mutable.IncludedCubeRegion = cubeRegion; } else if (mutable.ExcludedCubeRegion == null) { mutable.ExcludedCubeRegion = cubeRegion; } } if (dataflowRefType.Constraint.ReferencePeriod != null) { mutable.ReferencePeriod = new ReferencePeriodMutableCore { StartTime = dataflowRefType.Constraint.ReferencePeriod.startTime, EndTime = dataflowRefType.Constraint.ReferencePeriod.endTime }; } immutableInstance = mutable.ImmutableInstance; } return immutableInstance; }
/// <summary> /// Add dummy values for validity. /// </summary> /// <param name="dataflowRefType"> /// The dataflow ref type. /// </param> /// <param name="mutable"> /// The mutable. /// </param> private static void AddDummyValuesForValidity(DataflowRefType dataflowRefType, IMaintainableMutableObject mutable) { mutable.AddName("en", "Content Constraint for dataflow"); // TODO: Name is hardcoded. mutable.AgencyId = dataflowRefType.AgencyID; }
/// <summary> /// Adds new dataflow ref submission result. /// </summary> /// <param name="returnType"> /// The return type. /// </param> /// <param name="structureReference"> /// The structure reference. /// </param> /// <param name="th"> /// The exception. /// </param> private static void AddNewDataflowRefSubmissionResult( SubmitStructureResponseType returnType, IStructureReference structureReference, Exception th) { SubmissionResultType result = GetNewSubmissionResultType(returnType, th); var submittedStructure = new SubmittedStructureType(); result.SubmittedStructure = submittedStructure; var refType = new DataflowRefType(); submittedStructure.DataflowRef = refType; IMaintainableRefObject maintainableReference = structureReference.MaintainableReference; refType.AgencyID = maintainableReference.AgencyId; refType.DataflowID = maintainableReference.MaintainableId; if (ObjectUtil.ValidString(structureReference.MaintainableUrn)) { refType.URN = structureReference.MaintainableUrn; } string value = maintainableReference.Version; if (!string.IsNullOrWhiteSpace(value)) { refType.Version = maintainableReference.Version; } }
/// <summary> /// Handles the dataflow. /// </summary> /// <param name="complexDataQuery">The complex data query.</param> /// <param name="whereType">Type of the where.</param> private static void HandleDataflow(IComplexDataQuery complexDataQuery, DataParametersAndType whereType) { var dataflowReferenceType = new DataflowReferenceType(); RefBaseType dataflowRefType = new DataflowRefType(); dataflowRefType.agencyID = complexDataQuery.Dataflow.AgencyId; dataflowRefType.id = complexDataQuery.Dataflow.Id; dataflowRefType.version = complexDataQuery.Dataflow.Version; dataflowReferenceType.Ref = dataflowRefType; whereType.Dataflow.Add(dataflowReferenceType); }