/// <summary> /// Get the latest allowed dataflow with version and agency (if are either defined) /// </summary> /// <param name="dataflowId"> /// The dataflow id /// </param> /// <returns> /// The allowed dataflow with biggest version /// </returns> public IMaintainableRefObject GetAllowedDataflow(string dataflowId) { IMaintainableRefObject actualDataflow = null; Match conventionUsed = _dataflowRegex.Match(dataflowId); if (conventionUsed.Success) { actualDataflow = new MaintainableRefObjectImpl { AgencyId = conventionUsed.Groups["agency"].Value, MaintainableId = conventionUsed.Groups["id"].Value, Version = conventionUsed.Groups["version"].Value }; if (!this._authorizationProvider.AccessControl(this._user, actualDataflow)) { actualDataflow = null; } } else { IEnumerable <IMaintainableRefObject> dataflowRefBeans = this._authorizationProvider.GetDataflows( this._user, dataflowId); foreach (IMaintainableRefObject dataflowRefBean in dataflowRefBeans) { if (actualDataflow == null || string.CompareOrdinal(actualDataflow.Version, dataflowRefBean.Version) < 0) { actualDataflow = dataflowRefBean; } } } return(actualDataflow); }
private IComplexStructureQuery RetrieveDataflow(string id, string agency, string version) { IMaintainableRefObject df = new MaintainableRefObjectImpl(agency, id, version); var dataflowRefBean = new StructureReferenceImpl(df, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)); IRestStructureQuery structureQueryDataflow = new RESTStructureQueryCore(dataflowRefBean); IBuilder <IComplexStructureQuery, IRestStructureQuery> transformerDataFlow = new StructureQuery2ComplexQueryBuilder(); IComplexStructureQuery complexStructureQueryDataflow = transformerDataFlow.Build(structureQueryDataflow); IList <SdmxStructureType> specificObjects = new List <SdmxStructureType>(); specificObjects.Add(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd)); IComplexStructureQueryMetadata complexStructureQueryMetadataWithDsd = new ComplexStructureQueryMetadataCore(false, ComplexStructureQueryDetail.GetFromEnum(ComplexStructureQueryDetailEnumType.Full), ComplexMaintainableQueryDetail.GetFromEnum(ComplexMaintainableQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), specificObjects); IComplexStructureQuery complexStructureQueryTempDataflow = new ComplexStructureQueryCore( complexStructureQueryDataflow.StructureReference, complexStructureQueryMetadataWithDsd); return(complexStructureQueryTempDataflow); }
/// <summary> /// Retrieve the primary key from mapping store for the given period code list. /// </summary> /// <param name="timeFormat"> /// The time format. /// </param> /// <returns> /// The primary key. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// Value in <paramref name="timeFormat"/> not supported. /// </exception> public ICodelistMutableObject RetrievePeriodCodelist(TimeFormat timeFormat) { PeriodObject periodObject; if (PeriodCodelist.PeriodCodelistIdMap.TryGetValue(timeFormat.FrequencyCode, out periodObject)) { var maintainableRef = new MaintainableRefObjectImpl(PeriodCodelist.Agency, periodObject.Id, PeriodCodelist.Version); return(this._mutableRetrievalManager.GetMutableCodelist(maintainableRef, false, false)); } throw new ArgumentOutOfRangeException("timeFormat", timeFormat, Resources.ErrorNotSupported); }
private string RetrieveDataflow(string id, string agency, string version) { IMaintainableRefObject df = new MaintainableRefObjectImpl(agency, id, version); var dataflowRefBean = new StructureReferenceImpl(df, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)); IRestStructureQuery structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), dataflowRefBean, true); IStructureQueryFactory factory = new RestStructureQueryFactory(); IStructureQueryBuilderManager structureQueryBuilderManager = new StructureQueryBuilderManager(factory); IStructureQueryFormat <string> structureQueryFormat = new RestQueryFormat(); string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat); return(request); }
/// <summary> /// Populates the concept scheme per measure dimension. /// </summary> /// <param name="reader"> /// The reader. /// </param> /// <param name="conceptSchemesPerMeasureDimension"> /// The concept schemes per measure dimension. /// </param> private static void PopulateConceptSchemePerMeasureDimension(IDataReader reader, IDictionary <long, IMaintainableRefObject> conceptSchemesPerMeasureDimension) { int compIdIdx = reader.GetOrdinal("COMP_ID"); int agencyIdx = reader.GetOrdinal("CONCEPTSCHEME_AGENCY"); int idIdx = reader.GetOrdinal("CONCEPTSCHEME_ID"); int versionIdx = reader.GetOrdinal("CONCEPTSCHEME_VERSION"); while (reader.Read()) { var compId = DataReaderHelper.GetInt64(reader, compIdIdx); var agencyId = DataReaderHelper.GetString(reader, agencyIdx); var id = DataReaderHelper.GetString(reader, idIdx); var version = DataReaderHelper.GetString(reader, versionIdx); var conceptSchemeReference = new MaintainableRefObjectImpl(agencyId, id, version); conceptSchemesPerMeasureDimension.Add(compId, conceptSchemeReference); } }
/// <summary> /// Retrieve allowed dataflows for user from the database /// </summary> /// <param name="user"> /// The user /// </param> protected void RetrieveAllowedDataFlows(IUser user) { this._dataflowSet.Clear(); this._dataflowIdSet.Clear(); string userParam = this._database.BuildParameterName(DbConstants.UserParamName); string sql = this._selectQuery.Replace(DbConstants.UserMacro, userParam).Replace( DbConstants.DataflowIdMacro, DbConstants.DataflowIdField).Replace( DbConstants.DataflowVersionMacro, DbConstants.DataflowVersionField).Replace( DbConstants.DataflowAgencyIdMacro, DbConstants.DataflowAgencyIdField); using (DbCommand command = this._database.GetSqlStringCommand(sql)) { this._database.AddInParameter(command, DbConstants.UserParamName, DbType.String, user.UserName); using (IDataReader reader = this._database.ExecuteReader(command)) { int idIdx = reader.GetOrdinal(DbConstants.DataflowIdField); int versionIdx = reader.GetOrdinal(DbConstants.DataflowVersionField); int agencyIdx = reader.GetOrdinal(DbConstants.DataflowAgencyIdField); while (reader.Read()) { IMaintainableRefObject dataflowRefBean = new MaintainableRefObjectImpl { MaintainableId = AuthUtils.ConvertDBValue <string>(reader.GetValue(idIdx)), AgencyId = AuthUtils.ConvertDBValue <string>(reader.GetValue(agencyIdx)), Version = AuthUtils.ConvertDBValue <string>(reader.GetValue(versionIdx)) }; if (!this._dataflowSet.ContainsKey(dataflowRefBean)) { this._dataflowSet.Add(dataflowRefBean, dataflowRefBean.MaintainableId); List <IMaintainableRefObject> dataflowRefBeans; if (!this._dataflowIdSet.TryGetValue(dataflowRefBean.MaintainableId, out dataflowRefBeans)) { dataflowRefBeans = new List <IMaintainableRefObject>(); this._dataflowIdSet.Add(dataflowRefBean.MaintainableId, dataflowRefBeans); } dataflowRefBeans.Add(dataflowRefBean); } } } } }
/// <summary> /// An empty Set will be returned if there are no matches to the query /// </summary> /// <param name="maintainableReference"> /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard). /// </param> /// <param name="returnStub"> /// If true then a stub object will be returned /// </param> /// /// <param name="returnLatest"> /// If true then the latest version is returned, regardless of whether version information is supplied /// </param> /// <returns> /// The set of <see cref="IMaintainableObject"/> . /// </returns> public ISet <T> GetMaintainableObjects <T>(IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject { ISet <T> returnSet; if (returnLatest) { maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null); } SdmxStructureType type = SdmxStructureType.ParseClass(typeof(T)); IStructureReference sRef = new StructureReferenceImpl(maintainableReference, type); switch (sRef.TargetReference.EnumType) { //case SdmxStructureEnumType.AgencyScheme: // returnSet = new HashSet<T>(base.GetAgencySchemeObjects(maintainableReference, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.DataConsumerScheme: // returnSet = new HashSet<T>(this.GetDataConsumerSchemeObjects(maintainableReference, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.AttachmentConstraint: // returnSet = new HashSet<T>(this.GetAttachmentConstraints(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; case SdmxStructureEnumType.ContentConstraint: returnSet = new HashSet <T>(this.GetContentConstraints(maintainableReference, returnLatest, returnStub).Cast <T>()); break; //case SdmxStructureEnumType.DataProviderScheme: // returnSet = new HashSet<T>(this.GetDataProviderSchemeObjects(maintainableReference, returnStub).Cast<T>()); // break; case SdmxStructureEnumType.Categorisation: returnSet = new HashSet <T>(this.GetCategorisationObjects(maintainableReference, returnStub).Cast <T>()); break; case SdmxStructureEnumType.CategoryScheme: returnSet = new HashSet <T>(this.GetCategorySchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; case SdmxStructureEnumType.CodeList: returnSet = new HashSet <T>(this.GetCodelistObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; case SdmxStructureEnumType.ConceptScheme: returnSet = new HashSet <T>(this.GetConceptSchemeObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; case SdmxStructureEnumType.Dataflow: returnSet = new HashSet <T>(this.GetDataflowObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; case SdmxStructureEnumType.HierarchicalCodelist: returnSet = new HashSet <T>(this.GetHierarchicCodeListObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; case SdmxStructureEnumType.Dsd: returnSet = new HashSet <T>(this.GetDataStructureObjects(maintainableReference, returnLatest, returnStub).Cast <T>()); break; //case SdmxStructureEnumType.MetadataFlow: // returnSet = new HashSet<T>(this.GetMetadataflowObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.Msd: // returnSet = new HashSet<T>(this.GetMetadataStructureObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.OrganisationUnitScheme: // returnSet = new HashSet<T>(this.GetOrganisationUnitSchemeObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.Process: // returnSet = new HashSet<T>(this.GetProcessObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.ReportingTaxonomy: // returnSet = new HashSet<T>(this.GetReportingTaxonomyObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.StructureSet: // returnSet = new HashSet<T>(this.GetStructureSetObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; //case SdmxStructureEnumType.ProvisionAgreement: // returnSet = new HashSet<T>(this.GetProvisionAgreementObjects(maintainableReference, returnLatest, returnStub).Cast<T>()); // break; default: throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.RetrivalParsingError, new Exception(sRef.TargetReference.EnumType.ToString())); } //if (returnStub && _serviceRetrievalManager != null) //{ // ISet<T> stubSet = new HashSet<T>(); // foreach (T returnItm in returnSet) // { // if (returnItm.IsExternalReference.IsTrue) // stubSet.Add(returnItm); // else // stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm)); // } // returnSet = stubSet; //} return(returnSet); }
/// <summary> /// An empty Set will be returned if there are no matches to the query /// </summary> /// <param name="xType"> /// Contains sdmx structure enum type /// </param> /// <param name="maintainableReference"> /// Contains the identifiers of the structures to returns, can include widcarded values (null indicates a wildcard). /// </param> /// <param name="returnStub"> /// If true then a stub object will be returned /// </param> /// /// <param name="returnLatest"> /// If true then the latest version is returned, regardless of whether version information is supplied /// </param> /// <returns> /// The set of <see cref="IMaintainableObject"/> . /// </returns> private ISet <T> GetMaintainablesOfType <T>(SdmxStructureEnumType xType, IMaintainableRefObject maintainableReference, bool returnStub, bool returnLatest) where T : IMaintainableObject { ISet <T> returnSet; if (returnLatest) { maintainableReference = new MaintainableRefObjectImpl(maintainableReference.AgencyId, maintainableReference.MaintainableId, null); } switch (xType) { case SdmxStructureEnumType.AgencyScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IAgencyScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.DataConsumerScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IDataConsumerScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.AttachmentConstraint: returnSet = new HashSet <T>(GetMaintainableObjects <IAttachmentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ContentConstraint: returnSet = new HashSet <T>(GetMaintainableObjects <IContentConstraintObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.DataProviderScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IDataProviderScheme>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Categorisation: returnSet = new HashSet <T>(GetMaintainableObjects <ICategorisationObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.CategoryScheme: returnSet = new HashSet <T>(GetMaintainableObjects <ICategorySchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.CodeList: returnSet = new HashSet <T>(GetMaintainableObjects <ICodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ConceptScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IConceptSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Dataflow: returnSet = new HashSet <T>(GetMaintainableObjects <IDataflowObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.HierarchicalCodelist: returnSet = new HashSet <T>(GetMaintainableObjects <IHierarchicalCodelistObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Dsd: returnSet = new HashSet <T>(GetMaintainableObjects <IDataStructureObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.MetadataFlow: returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataFlow>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Msd: returnSet = new HashSet <T>(GetMaintainableObjects <IMetadataStructureDefinitionObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.OrganisationUnitScheme: returnSet = new HashSet <T>(GetMaintainableObjects <IOrganisationUnitSchemeObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.Process: returnSet = new HashSet <T>(GetMaintainableObjects <IProcessObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ReportingTaxonomy: returnSet = new HashSet <T>(GetMaintainableObjects <IReportingTaxonomyObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.StructureSet: returnSet = new HashSet <T>(GetMaintainableObjects <IStructureSetObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; case SdmxStructureEnumType.ProvisionAgreement: returnSet = new HashSet <T>(GetMaintainableObjects <IProvisionAgreementObject>(maintainableReference, returnStub, returnLatest).Cast <T>()); break; default: throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.GetMaintainableFromSdmxObject, new Exception(xType.ToString())); } //if (returnStub && _serviceRetrievalManager != null) //{ // ISet<T> stubSet = new HashSet<T>(); // foreach (T returnItm in returnSet) // { // if (returnItm.IsExternalReference.IsTrue) // stubSet.Add(returnItm); // else // stubSet.Add((T)_serviceRetrievalManager.CreateStub(returnItm)); // } // returnSet = stubSet; //} return(returnSet); }