/// <summary> /// The build registry interface document. /// </summary> /// <param name="buildFrom"> /// The build from. /// </param> /// <param name="action"> /// The action. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildRegistryInterfaceDocument(ISdmxObjects buildFrom, DatasetAction action) { var rid = new RegistryInterface(); RegistryInterfaceType rit = rid.Content; V21Helper.Header = rit; var structureRequestType = new SubmitStructureRequestType(); rit.SubmitStructureRequest = structureRequestType; switch (action.EnumType) { case DatasetActionEnumType.Append: structureRequestType.action = ActionTypeConstants.Append; break; case DatasetActionEnumType.Replace: structureRequestType.action = ActionTypeConstants.Replace; break; case DatasetActionEnumType.Delete: structureRequestType.action = ActionTypeConstants.Delete; break; case DatasetActionEnumType.Information: structureRequestType.action = ActionTypeConstants.Information; break; } var structures = new Structures(); structureRequestType.Structures = structures; this._structureXmlBuilder.PopulateStructureType(buildFrom, structures.Content); return rid; }
/// <summary> /// Initialize the <see cref="_conceptMap"/> from ConceptSchemes contained in the specified structure /// </summary> /// <param name="structure"> /// The structure containing the ConceptSchemes /// </param> public void InitializeConceptMap(ISdmxObjects structure) { this._conceptMap.Clear(); var concepKeyToComponent = new Dictionary <string, IComponent>(); if (this._keyFamily.DimensionList != null) { foreach (IDimension component in this._keyFamily.DimensionList.Dimensions) { concepKeyToComponent.Add(Utils.MakeKeyForConcept(component), component); } } //if (this._keyFamily.TimeDimension != null) //{ // concepKeyToComponent.Add( // Utils.MakeKeyForConcept(this._keyFamily.TimeDimension), this._keyFamily.TimeDimension); //} foreach (IConceptSchemeObject conceptScheme in structure.ConceptSchemes) { foreach (IConceptObject concept in conceptScheme.Items) { string key = Utils.MakeKey(concept, conceptScheme); IComponent component; if (concepKeyToComponent.TryGetValue(key, out component)) { this._conceptMap.UpdateItemObject(component, concept); } } } }
public MetadataLoader(string QueriesPath, WebServiceLayer.classes.service.Net.WebServiceLayer WSLayer) { _queryPath = QueriesPath; _webLayer = WSLayer; _sdmxObjects = new Org.Sdmxsource.Sdmx.Util.Objects.Container.SdmxObjectsImpl(); SdmxException.SetMessageResolver(new MessageDecoder()); }
/// <summary> /// Initializes a new instance of the <see cref="AgencyMetadataImpl"/> class. /// </summary> /// <param name="agencyId"> /// The agency id. /// </param> /// <param name="objects"> /// The objects. /// </param> public AgencyMetadataImpl(string agencyId, ISdmxObjects objects) { this._structureMap = new Dictionary<SdmxStructureEnumType, int>(); this._agencyId = agencyId; this._structureMap.Add(SdmxStructureEnumType.AgencyScheme, objects.GetAgenciesScheme(agencyId) == null ? 0 : 1); this._structureMap.Add( SdmxStructureEnumType.AttachmentConstraint, objects.GetAttachmentConstraints(agencyId).Count); this._structureMap.Add( SdmxStructureEnumType.ContentConstraint, objects.GetContentConstraintObjects(agencyId).Count); this._structureMap.Add( SdmxStructureEnumType.DataProviderScheme, objects.GetDataProviderScheme(agencyId) == null ? 0 : 1); this._structureMap.Add( SdmxStructureEnumType.DataConsumerScheme, objects.GetDataConsumerScheme(agencyId) == null ? 0 : 1); this._structureMap.Add( SdmxStructureEnumType.OrganisationUnitScheme, objects.GetOrganisationUnitSchemes(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.Categorisation, objects.GetCategorisations(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.Dataflow, objects.GetDataflows(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.MetadataFlow, objects.GetMetadataflows(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.CategoryScheme, objects.GetCategorySchemes(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.ConceptScheme, objects.GetConceptSchemes(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.CodeList, objects.GetCodelists(agencyId).Count); this._structureMap.Add( SdmxStructureEnumType.HierarchicalCodelist, objects.GetHierarchicalCodelists(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.Msd, objects.GetMetadataStructures(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.Dsd, objects.GetDataStructures(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.Process, objects.GetProcesses(agencyId).Count); this._structureMap.Add( SdmxStructureEnumType.ReportingTaxonomy, objects.GetReportingTaxonomys(agencyId).Count); this._structureMap.Add(SdmxStructureEnumType.StructureSet, objects.GetStructureSets(agencyId).Count); this._structureMap.Add( SdmxStructureEnumType.ProvisionAgreement, objects.GetProvisionAgreements(agencyId).Count); }
/// <summary> /// Sets the header. /// </summary> /// <param name="header"> /// The header. /// </param> /// <param name="sdmxObjects"> /// The beans. /// </param> public static void SetHeader(HeaderType header, ISdmxObjects sdmxObjects) { header.ID = "IDREF" + refNumber; refNumber++; header.Test = false; header.Prepared = DateTime.Now; var sender = new PartyType(); header.Sender.Add(sender); string senderId; if (sdmxObjects != null && sdmxObjects.Header != null && sdmxObjects.Header.Sender != null) { // Get header information from the supplied beans senderId = sdmxObjects.Header.Sender.Id; } else { // Get header info from HeaderHelper senderId = HeaderHelper.Instance.SenderId; } sender.id = senderId; var receiver = new PartyType(); header.Receiver.Add(receiver); receiver.id = HeaderHelper.Instance.ReceiverId; }
/// <summary> /// Initializes a new instance of the <see cref="DataSetModelStore"/> class. /// Initialize a new instance of the <see cref="DataSetModelStore"/> /// </summary> /// <param name="structure"> /// The SDMX structure file /// </param> /// <param name="store"> /// The <see cref="IDataSetStore"/> /// </param> public DataSetModelStore(ISdmxObjects structure, IDataSetStore store) : base(structure, store) { if (store == null) { throw new ArgumentNullException("store"); } }
/// <summary> /// Initializes a new instance of the <see cref="DataSetModelStore"/> class. /// Initialize a new instance of the <see cref="DataSetModelStore"/> /// </summary> /// <param name="structure"> /// The SDMX structure file /// </param> /// <param name="store"> /// The <see cref="IDataSetStore"/> /// </param> public DataSetModelStore(ISdmxObjects structure, IDataSetStore store) : base(structure, store) { if (store == null) { throw new ArgumentNullException("store"); } }
public void WriteStructures(ISdmxObjects sdmxObjects) { foreach (var maintainableObject in sdmxObjects.GetAllMaintainables()) { PrintMaintainable(maintainableObject); } Close(); }
/// <summary> /// Adds a bean to the container as long as the urn of the bean to add is not contained in the set of URNs. /// <p/> /// If successfully added, will add the bean urn to the set of urns /// </summary> /// <param name="beans"> /// container to add to /// </param> /// <param name="urns"> /// to exclude /// </param> /// <param name="bean"> /// to add to the beans container /// </param> protected internal void AddIfNotDuplicateURN(ISdmxObjects beans, ISet<Uri> urns, IIdentifiableObject bean) { if (!urns.Add(bean.Urn)) { throw new SdmxSemmanticException(ExceptionCode.DuplicateUrn, bean.Urn); } beans.AddIdentifiable(bean); }
/// <summary> /// The write structures. /// </summary> /// <param name="beans"> /// The beans. /// </param> /// <exception cref="NotImplementedException"> /// SDMX EDI for structures is not implemented in this implementation. /// </exception> public virtual void WriteStructures(ISdmxObjects beans) { throw new NotImplementedException("SDMX EDI for structures is not implemented in this implementation."); ////if (editParseManager == null) { //// throw new Exception( //// "Required dependancy 'structureReaderEngine' is null, StructureWriterEngineEdi is @Configurable and requires '<context:spring-configured />' to be set"); ////} ////editParseManager.WriteToEDI(beans, xout); }
/// <summary> /// </summary> /// <param name="structures"> The structures</param> /// <param name="resolveAgencies"> Flag indicating resolve agencies .</param> /// <param name="resolutionDepth"> The resolution depth. </param> /// <param name="retrievalManager"> The retrieval manager </param> /// <returns> The references </returns> public IDictionary<IIdentifiableObject, ISet<IIdentifiableObject>> ResolveReferences( ISdmxObjects structures, bool resolveAgencies, int resolutionDepth, IIdentifiableRetrievalManager retrievalManager) { ICrossReferenceResolverEngine crossReferenceResolver = new CrossReferenceResolverEngineCore(); return crossReferenceResolver.ResolveReferences( structures, resolveAgencies, resolutionDepth, retrievalManager); }
public DataRender(IDataSetStore store, List<DataCriteria> Criterias, LayoutObj layObj, ISdmxObjects structure, ComponentCodeDescriptionDictionary codemap, bool useAttr, CultureInfo cFrom, CultureInfo cTo) { this.store = store; this.Criterias = Criterias; this.layObj = layObj; this.Structure = structure; this.codemap = codemap; this._useAttr=useAttr; this.cFrom=cFrom; this.cTo=cTo; }
/// <summary> /// Builds Mutable beans from a collection of beans /// </summary> /// <param name="buildFrom"> /// beans to build from /// </param> /// <returns> /// Mutable bean copies /// </returns> /// <exception cref="BuilderException"> /// - If anything goes wrong during the build process /// </exception> public virtual IMutableObjects Build(ISdmxObjects buildFrom) { IMutableObjects mutableBeans = new MutableObjectsImpl(); /* foreach */ foreach (IMaintainableObject currentMaintainable in buildFrom.GetAllMaintainables()) { mutableBeans.AddIdentifiable(currentMaintainable.MutableInstance); } return mutableBeans; }
/// <summary> /// The build success response. /// </summary> /// <param name="beans"> /// The beans. /// </param> /// <returns> /// The <see cref="RegistryInterface"/>. /// </returns> public RegistryInterface BuildSuccessResponse(ISdmxObjects beans) { var responseType = new RegistryInterface(); RegistryInterfaceType regInterface = responseType.Content; regInterface.Header = this._headerXmlsBuilder.Build(beans.Header); var returnType = new SubmitStructureResponseType(); regInterface.SubmitStructureResponse = returnType; this.ProcessMaintainables(returnType, beans.GetAllMaintainables()); return responseType; }
public SessionImplObject GetLayout(SessionQuery query) { try { //ISdmxObjects structure = GetKeyFamily(); //IDataflowObject df = structure.Dataflows.First(); //IDataStructureObject kf = structure.DataStructures.First(); ISdmxObjects structure = query.Structure; IDataflowObject df = query.Dataflow; IDataStructureObject kf = query.KeyFamily; if (kf == null || df == null) { throw new InvalidOperationException("DataStructure is not set"); } if (this.SessionObj.DafaultLayout == null) { this.SessionObj.DafaultLayout = new Dictionary <string, LayoutObj>(); } if (!this.SessionObj.DafaultLayout.ContainsKey(Utils.MakeKey(df))) { LayoutObj deflay = GetDefaultLayout(df, kf); this.SessionObj.DafaultLayout[Utils.MakeKey(df)] = deflay; } DefaultLayoutResponseObject defaultLayoutResponseObject = new DefaultLayoutResponseObject(); defaultLayoutResponseObject.DefaultLayout = this.SessionObj.DafaultLayout[Utils.MakeKey(df)]; this.SessionObj.SavedDefaultLayout = new JavaScriptSerializer().Serialize(defaultLayoutResponseObject); return(this.SessionObj); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
/// <summary> /// Initialie a new instance of the <see cref="RetrievalManager"/> class. /// </summary> /// <param name="_dataFlowID"> /// Dataflow ID /// </param> /// <param name="_versionType">Sdmx Version</param> public RetrievalManager(string _dataFlowID, SdmxSchemaEnumType _versionType) { try { this.DataFlowID = _dataFlowID; this.VersionType = _versionType; DataStructureEngineObject ds = new DataStructureEngineObject(); ISDMXObjectBuilder Builder = ds.CreateBuilder(new SdmxParsingObject(SdmxStructureEnumType.Dataflow) { MaintainableId = DataFlowID, References = StructureReferenceDetailEnumType.Specific, SpecificReference = new List <SdmxStructureType>() { SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme), }, QueryDetail = StructureQueryDetailEnumType.Full, }, _versionType); Builder.Build(); Builder.AddReferences(); if (Builder._KeyFamily == null || Builder._KeyFamily.Count == 0) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, new Exception(string.Format("Dsd Not found for Dataflow code: {0}", DataFlowID))); } //1DF = 1DSD this._dsd = Builder._KeyFamily[0]; if (Builder._Dataflows.Count > 0) { this.DataFlowTitle = Builder._Dataflows[0].Name; } else { throw new Exception("No Dataflow Found"); } this._sdmxObjects = Builder.CreateDSD(); this.DataFlowID = Builder._Dataflows[0].Id; GetGroups(); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.InternalError, ex); //non sono riuscito a cambiare il nome che è arrivato dalla query con quello effettivo della dsd } }
/// <summary> /// Reset everything /// </summary> public void Reset() { this._dataflow = null; this._structure = null; this._keyFamily = null; this._dataflowTreeList = null; this._componentIndex.Clear(); this._conceptMap.Clear(); this._criteriaComponentIdx = 0; this._workPageIdx = 0; this.Clear(); this._sessionPrefix = Guid.NewGuid().ToString(); }
public List<AgencyScheme> GetAgencySchemeList(ISdmxObjects sdmxObjects, string localization) { if (sdmxObjects == null || sdmxObjects.AgenciesSchemes == null) return null; List<AgencyScheme> lAS = new List<AgencyScheme>(); foreach (IAgencyScheme agency in sdmxObjects.AgenciesSchemes) { lAS.Add(new AgencyScheme(_localizedUtils.GetNameableName(agency), agency.Id, agency.AgencyId, agency.Version, agency.IsFinal.IsTrue)); } return lAS; }
/// <summary> /// Call CreateDSD and Write SdmxObject in XElement Streaming to return with processed metadata result /// </summary> /// <returns>Object for Write response in streaming <see cref="IFlyWriterBody"/></returns> public virtual IFlyWriterBody WriteDSD() { try { ISdmxObjects sdmxObject = CreateDSD(); sdmxObject.Action = DatasetAction.GetFromEnum(DatasetActionEnumType.Append); //Oggetto che crea l'output StructureWriterManager swm = new StructureWriterManager(); StructureOutputFormat sofType = null; if (VersionTypeResp == SdmxSchemaEnumType.VersionTwo) { sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument); } else if (VersionTypeResp == SdmxSchemaEnumType.VersionTwoPointOne) { sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument); } else { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.UnrecognizedVersion, new Exception("Version: " + VersionTypeResp.ToString())); } SdmxStructureFormat sof = new SdmxStructureFormat(sofType); //IStructureFormat //Dove metto il risultato Stream IFlyWriterBody WriterBody = new FlyMetadataWriterBody() { StructureFormat = sof, SdmxObject = sdmxObject }; FlyLog.WriteLog(this, FlyLog.LogTypeEnum.All, "Create Callback for Writing SDMXObject"); return(WriterBody); //MemoryStream ms = new MemoryStream(); //swm.WriteStructures(sdmxObject, sof, ms); //ms.Position = 0; //StreamReader rdr = new System.IO.StreamReader(ms); //ms.Position = 0; //string DSDris = rdr.ReadToEnd(); //return XElement.Parse(DSDris); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateSdmxObjectError, ex); } }
/// <summary> /// Populate the specified map from ConceptSchemes contained in the specified structure /// </summary> /// <param name="structure"> /// The structure containing the ConceptSchemes /// </param> /// <param name="conceptMap"> /// The concept id to concept bean map /// </param> public static void PopulateConceptMap(ISdmxObjects structure, Dictionary <string, IConceptObject> conceptMap) { conceptMap.Clear(); foreach (IConceptSchemeObject conceptScheme in structure.ConceptSchemes) { foreach (IConceptObject concept in conceptScheme.Items) { string key = MakeKey(concept, conceptScheme); if (!conceptMap.ContainsKey(key)) { conceptMap.Add(key, concept); } } } }
/* * public SessionImplObject GetTreeLocale() * { * var ser = new JavaScriptSerializer(); * string json; * * try * { * //string decimalCulture=TreeObj.Configuration.Locale; * TreeObj.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToUpper(); * CacheTree ct = new CacheTree(ConnectionString, TreeObj.Configuration); * //controlla il parametro CachedTree del webconfig se utilizzare o meno la cache * bool UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.CachedTree : false; * * string JsonTree = null; * if (UseWidgetCache) * { JsonTree = ct.GetCachedTree(); } * * if (!string.IsNullOrEmpty(JsonTree)) * return new SessionImplObject() { SavedTree = JsonTree }; * * ISdmxObjects SdmxOBJ = GetSdmxObject(TreeObj.Configuration); * * //TreeObj.Configuration.Locale = decimalCulture; * * List<JsTreeNode> nodelist = BuildJSTree(SdmxOBJ, System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName); * if (nodelist == null || nodelist.Count == 0) * {//Invio Errore * var x = new { error = true, dataflowError = true, message = ISTAT.WebClient.WidgetComplements.Model.App_GlobalResources.Messages.no_results_found }; * throw new Exception(ser.Serialize(x)); * } * * json = ser.Serialize(nodelist); * * ct.SaveCachedTree(json); * * return new SessionImplObject() { SavedTree = json, SdmxObject = SdmxOBJ }; * } * catch (InvalidOperationException ex) * { * Logger.Warn(Resources.ErrorMaxJsonLength); * Logger.Warn(ex.Message, ex); * throw new Exception(ErrorOccured); * * } * catch (ArgumentException ex) * { * Logger.Warn(Resources.ErrorRecursionLimit); * Logger.Warn(ex.Message, ex); * throw new Exception(ErrorOccured); * } * catch (Exception ex) * { * Logger.Warn(ex.Message, ex); * throw new Exception(ErrorOccured); * } * * } */ public string GetTreeforCache(string TwoLetterISO) { var ser = new JavaScriptSerializer(); ISdmxObjects SdmxOBJ = GetSdmxObject(TreeObj.Configuration); List <JsTreeNode> nodelist = BuildJSTree(SdmxOBJ, TwoLetterISO); if (nodelist == null || nodelist.Count == 0) { return(null); } return(ser.Serialize(nodelist)); }
/// <summary> /// Check the Status of a QueryStructureResponse. /// </summary> /// <remarks> /// <list type="bullet"> /// <item> /// If it doesn't exist, do nothing. Maybe there is a bug at the NSI WS implementation so we ignore it hoping that the rest of the message is ok /// </item> /// <item> /// if the status is Success do nothing. /// </item> /// <item> /// If the status is Warning only log the messages with warning. /// </item> /// <item> /// if the status is failure throw an NsiClientException /// </item> /// <item> /// if Response or response structure are null. An exception is thrown /// </item> /// </list> /// </remarks> /// <param name="response"> /// The QueryStructureResponse to check /// </param> public static void CheckResponse(ISdmxObjects response) { var error = new StringBuilder(); if (response == null) { error.Append(Resources.ExceptionMissingResponse); } if (error.Length > 0) { Logger.Error(error.ToString()); throw new NsiClientException(error.ToString()); } }
/// <summary> /// Gets Maintainable SDMX objects from workspace. /// </summary> /// <returns>Maintainable SDMX objects.</returns> private ISet <IMaintainableObject> GetMaintainableObjects() { IStructureWorkspace workspace; using (IReadableDataLocation rdl = this._readableDataLocation) { workspace = this._structureParsingManager.ParseStructures(rdl); } ISdmxObjects sdmxObjects = workspace.GetStructureObjects(false); ISet <IMaintainableObject> maintainable = sdmxObjects.GetAllMaintainables(); return(maintainable); }
/// <summary> /// Deletes the maintainable structures in the supplied sdmxObjects /// </summary> /// <param name="sdmxObjects"> /// SDMX objects /// </param> public void DeleteStructures(ISdmxObjects sdmxObjects) { this.DeleteMaintainable(sdmxObjects.Categorisations); this.DeleteMaintainable(sdmxObjects.StructureSets); this.DeleteMaintainable(sdmxObjects.ContentConstraintObjects); this.DeleteMaintainable(sdmxObjects.AgenciesSchemes); this.DeleteMaintainable(sdmxObjects.DataProviderSchemes); this.DeleteMaintainable(sdmxObjects.DataConsumerSchemes); this.DeleteMaintainable(sdmxObjects.OrganisationUnitSchemes); this.DeleteMaintainable(sdmxObjects.HierarchicalCodelists); this.DeleteMaintainable(sdmxObjects.Dataflows); this.DeleteMaintainable(sdmxObjects.CategorySchemes); this.DeleteMaintainable(sdmxObjects.DataStructures); this.DeleteMaintainable(sdmxObjects.ConceptSchemes); this.DeleteMaintainable(sdmxObjects.Codelists); }
public StreamResponseAction ExportSDMXQuery() { SessionQuery query = SessionQueryManager.GetSessionQuery(Session); //ControllerSupport CS = new ControllerSupport(); //GetCodemapObject PostDataArrived = CS.GetPostData<GetCodemapObject>(this.Request); //PostDataArrived.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; string request = ""; var xdoc = new XmlDocument(); EndpointSettings DataObjConfiguration = new EndpointSettings(); DataObjConfiguration = query._endpointSettings; //IGetSDMX GetSDMXObject = WebServiceSelector.GetSdmxImplementation(DataObjConfiguration); IGetSDMX GetSDMXObject = (query._IGetSDMX == null) ? WebServiceSelector.GetSdmxImplementation(DataObjConfiguration) : query._IGetSDMX; BaseDataObject BDO = new BaseDataObject(DataObjConfiguration, "appo.xml"); ISdmxObjects structure = query.Structure; IDataflowObject df = structure.Dataflows.First(); IDataStructureObject kf = structure.DataStructures.First(); IDataQuery sdmxQuery = BDO.CreateQueryBean(df, kf, query.GetCriteria()); GetSDMXObject.GetSdmxQuery(sdmxQuery, out request); string filename = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", query.Dataflow.Id, "xml"); this.HttpContext.Response.Clear(); this.HttpContext.Response.ContentType = "text/xml"; this.HttpContext.Response.ContentEncoding = Encoding.UTF8; string contentDisposition = string.Format( CultureInfo.InvariantCulture, Constants.AttachmentFilenameFormat, filename); this.HttpContext.Response.AddHeader(Constants.ContentDispositionHttpHeader, contentDisposition); this.HttpContext.Response.AddHeader("content-disposition", contentDisposition); this.HttpContext.Response.Write(request); this.HttpContext.Response.End(); throw new NotImplementedException(); }
private void SaveSDMXFile(ISdmxObjects sdmxObjects, StructureOutputFormatEnumType version, string outputFileName) { StructureWriterManager swm = new StructureWriterManager(); StructureOutputFormat soFormat = StructureOutputFormat.GetFromEnum(version); IStructureFormat outputFormat = new SdmxStructureFormat(soFormat); MemoryStream memoryStream = new MemoryStream(); swm.WriteStructures(sdmxObjects, outputFormat, memoryStream); byte[] bytesInStream = memoryStream.ToArray(); memoryStream.Close(); SendAttachment(bytesInStream, outputFileName); }
private List <JsTreeNode> BuildJSTree(ISdmxObjects SdmxOBJ, string TwoLetterISO) { var categorisedDataflowIndex = new Dictionary <string, IDataflowObject>(); var uncategorisedDataflow = new List <IDataflowObject>(); var nodeList = new List <JsTreeNode>(); // for each dataflows control if has a categorization // if true put it in dataflow list or in uncategorizate list foreach (IDataflowObject d in SdmxOBJ.Dataflows) { if (!d.IsExternalReference.IsTrue && SdmxOBJ.Categorisations.Count(cat => !cat.IsExternalReference.IsTrue && cat.StructureReference.TargetReference.EnumType == d.StructureType.EnumType && MaintainableUtil <IMaintainableObject> .Match(d, cat.StructureReference)) == 0) { uncategorisedDataflow.Add(d); } else { categorisedDataflowIndex.Add(Utils.MakeKey(d), d); } } nodeList.AddRange(CreateCategorisedNodes(SdmxOBJ, categorisedDataflowIndex, TwoLetterISO)); if (TreeObj.Configuration.UseUncategorysed) { var uncategorisedNode = new JsTreeNode(); uncategorisedNode.SetRel("category-scheme"); uncategorisedNode.type = "category-scheme"; uncategorisedNode.SetId("uncategorised"); uncategorisedNode.text = Messages.text_dataflows_uncategorized; foreach (IDataflowObject dataflow in uncategorisedDataflow) { JsTreeNode node = CreateDataflowNode(dataflow, SdmxOBJ, TwoLetterISO); if (node != null) { uncategorisedNode.children.Add(node); } } if (uncategorisedNode.children.Count > 0) { nodeList.Add(uncategorisedNode); } } return(nodeList); }
private void SaveSdmxOBJ(ISdmxObjects SdmxOBJ, string FileName) { if (SdmxOBJ == null) { return; } StructureWriterManager swm = new StructureWriterManager(); StructureOutputFormat sofType = StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument); SdmxStructureFormat sof = new SdmxStructureFormat(sofType); string FullNamePath = Path.Combine(Utils.GetTreeCachePath(), FileName); using (Stream ms = File.Create(FullNamePath)) { swm.WriteStructures(SdmxOBJ, sof, ms); } }
public Dictionary <string, ICodelistObject> GetCodeMap(ISdmxObjects sdmxObjects, IDataStructureObject kf, bool withAttribute) { Dictionary <string, ICodelistObject> Conceptcodelist = new Dictionary <string, ICodelistObject>(); if (kf != null) { foreach (IDimension component in kf.DimensionList.Dimensions.Where(c => c.HasCodedRepresentation() && !string.IsNullOrEmpty(c.Representation.Representation.MaintainableReference.MaintainableId))) { var codelist = (from c in sdmxObjects.Codelists where c.Id == component.Representation.CrossReferences.First().MaintainableId select c).FirstOrDefault(); if (codelist != null) { Conceptcodelist.Add(component.Id, codelist); } } var time_period = (from c in kf.DimensionList.Dimensions where c.TimeDimension == true select c).FirstOrDefault(); var time_period_codelist = (from c in sdmxObjects.Codelists where c.CrossReferences.FirstOrDefault().MaintainableId == time_period.CrossReferences.FirstOrDefault().MaintainableId select c).FirstOrDefault(); if (withAttribute && kf.AttributeList != null) { foreach (IComponent component in kf.AttributeList.Attributes.Where(c => c.HasCodedRepresentation() && !string.IsNullOrEmpty(c.Representation.Representation.MaintainableReference.MaintainableId))) { var codelist = (from c in sdmxObjects.Codelists where c.Id == component.Representation.CrossReferences.First().MaintainableId select c).FirstOrDefault(); if (codelist != null) { Conceptcodelist.Add(component.Id, codelist); } } } if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); } if (this.SessionObj.CodelistConstrained == null) { this.SessionObj.CodelistConstrained = new Dictionary <string, Dictionary <string, ICodelistObject> >(); } this.SessionObj.CodelistConstrained[Utils.MakeKey(kf)] = Conceptcodelist; } return(Conceptcodelist); }
public void SaveSDMXFile(ISdmxObjects sdmxObjects, StructureOutputFormatEnumType version, string outputFileName) { StructureWriterManager swm = new StructureWriterManager(); StructureOutputFormat soFormat = StructureOutputFormat.GetFromEnum(version); IStructureFormat outputFormat = new SdmxStructureFormat(soFormat); MemoryStream memoryStream = new MemoryStream(); swm.WriteStructures(sdmxObjects, outputFormat, memoryStream); byte[] bytesInStream = memoryStream.ToArray(); memoryStream.Close(); SendAttachment(bytesInStream, outputFileName + ".xml"); }
/// <summary> /// Checks if a structure is complete according to the requirements of <see cref="GetStructure"/> /// </summary> /// <param name="structure"> /// The StructureBean object to check. /// </param> /// <param name="dataflow"> /// The requested dataflow /// </param> /// <exception cref="NsiClientException"> /// Server response error /// </exception> public static void CheckifStructureComplete(ISdmxObjects structure, IDataflowObject dataflow) { if (structure.DataStructures.Count != 1) { Logger.Error(Resources.ExceptionKeyFamilyCountNot1); throw new NsiClientException(Resources.ExceptionKeyFamilyCountNot1); } IDataStructureObject kf = structure.DataStructures.First(); var keyFamilyRef = dataflow.DataStructureRef; if (kf.Id == null || keyFamilyRef == null || !kf.Id.Equals(keyFamilyRef.MaintainableReference.MaintainableId) || !kf.AgencyId.Equals(keyFamilyRef.MaintainableReference.AgencyId) || !kf.Version.Equals(keyFamilyRef.MaintainableReference.Version)) { Logger.Error(Resources.ExceptionServerResponseInvalidKeyFamily); throw new NsiClientException(Resources.ExceptionServerResponseInvalidKeyFamily); } }
/// <summary> /// Initializes a new instance of the <see cref="AbstractDataSetModel"/> class. /// </summary> /// <param name="structure"> /// The SDMX-ML structure /// </param> /// <param name="store"> /// The <see cref="IDataSetStore"/> containing the dataset data /// </param> protected AbstractDataSetModel(ISdmxObjects structure, IDataSetStore store) { if (structure == null) { throw new ArgumentNullException("structure"); } this._store = store; this._structure = structure; // The structure must define exactly one key family... if ((this._structure.DataStructures == null) || (this._structure.DataStructures.Count != 1)) { throw new Exception( "Invalid structure bean, it does not contain the definition for exactly one key family!"); } this._dataFlow = this._structure.Dataflows.First(); this._keyFamily = this._structure.DataStructures.First(); }
/// <summary> /// Saves the maintainable structures in the supplied sdmxObjects /// </summary> /// <param name="sdmxObjects"> /// SDMX objects /// </param> public void SaveStructures(ISdmxObjects sdmxObjects) { this.InsertMaintainable(sdmxObjects.Codelists); this.InsertMaintainable(sdmxObjects.ConceptSchemes); this.InsertMaintainable(sdmxObjects.DataStructures); this.InsertMaintainable(sdmxObjects.Dataflows); this.InsertMaintainable(sdmxObjects.CategorySchemes); this.InsertMaintainable(sdmxObjects.Categorisations); this.InsertMaintainable(sdmxObjects.HierarchicalCodelists); this.InsertMaintainable(sdmxObjects.AgenciesSchemes); this.InsertMaintainable(sdmxObjects.DataProviderSchemes); this.InsertMaintainable(sdmxObjects.DataConsumerSchemes); this.InsertMaintainable(sdmxObjects.OrganisationUnitSchemes); this.InsertMaintainable(sdmxObjects.StructureSets); this.InsertMaintainable(sdmxObjects.ContentConstraintObjects); // HACK. Handle SDMX v2.1 Measure Dimensions until proper support is added. // We create a dummy codelist for all SDMX v2.1 Measure dimensions. this._measureDimensionRepresentationEngine.CreateDummyCodelistForAll(); }
/// <summary> /// The set header. /// </summary> /// <param name="header"> /// The header. /// </param> /// <param name="sdmxObjects"> /// The sdmxObjects. /// </param> public static void SetHeader(HeaderType header, ISdmxObjects sdmxObjects) { header.ID = "IDREF" + referenceNo; referenceNo++; header.Test = false; header.Prepared = DateTime.Now; string senderId; if (sdmxObjects != null && sdmxObjects.Header != null && sdmxObjects.Header.Sender != null) { // Get header information from the supplied sdmxObjects senderId = sdmxObjects.Header.Sender.Id; } else { // Get header info from HeaderHelper senderId = HeaderHelper.Instance.SenderId; } header.Sender.id = senderId; }
/// <summary> /// Check if the specified structure has all referenced concept schemes from the first keyfamily /// </summary> /// <param name="structure"> /// The StructureBean to check /// </param> public static void CheckConcepts(ISdmxObjects structure) { var cshtMap = new Dictionary <string, IConceptSchemeObject>(); IDataStructureObject kf = structure.DataStructures.First(); foreach (IConceptSchemeObject c in structure.ConceptSchemes) { cshtMap.Add(Utils.MakeKey(c), c); } var crossDsd = kf as ICrossSectionalDataStructureObject; List <IComponent> components = new List <IComponent>(); components.AddRange(kf.GetDimensions()); components.AddRange(kf.Attributes); if (kf.PrimaryMeasure != null) { components.Add(kf.PrimaryMeasure); } if (crossDsd != null) { components.AddRange(crossDsd.CrossSectionalMeasures); } var comps = components; foreach (IComponent comp in comps) { string conceptKey = Utils.MakeKey(comp.ConceptRef.MaintainableReference.MaintainableId, comp.ConceptRef.MaintainableReference.AgencyId, comp.ConceptRef.MaintainableReference.Version); if (!cshtMap.ContainsKey(conceptKey)) { string message = string.Format(CultureInfo.InvariantCulture, Resources.ExceptionMissingConceptSchemeFormat1, conceptKey); Logger.Error(message); throw new NsiClientException(message); } } }
/////////////////////////////////////////////////////////////////////////////////////////////// ////////// VERSION 2.0 METHODS FOR STRUCTURES /////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// #region Methods /// <summary> /// Create Categorisations from Version 2.0 categories, adds the categorisations to the sdmxObjects container /// </summary> /// <param name="beans"> /// container to add to /// </param> /// <param name="categoryTypes"> /// category types to filter on /// </param> /// <param name="categoryBeans"> /// category sdmxObjects to process /// </param> protected internal void ProcessCategory( ISdmxObjects beans, IList<CategoryType> categoryTypes, IList<ICategoryObject> categoryBeans) { if (categoryTypes == null) { return; } // Note converted from recursive in Java 0.9.4 to iterative var stack = new Stack<KeyValuePair<IList<CategoryType>, IList<ICategoryObject>>>(); stack.Push(new KeyValuePair<IList<CategoryType>, IList<ICategoryObject>>(categoryTypes, categoryBeans)); while (stack.Count > 0) { KeyValuePair<IList<CategoryType>, IList<ICategoryObject>> pair = stack.Pop(); IList<CategoryType> currentTypes = pair.Key; foreach (CategoryType cat in currentTypes) { ICategoryObject processingCatBean = null; IList<ICategoryObject> currentObjects = pair.Value; foreach (ICategoryObject currentCatBean in currentObjects) { if (currentCatBean.Id.Equals(cat.id)) { processingCatBean = currentCatBean; break; } } // TODO this check doesn't exist in Java 0.9.4 if (processingCatBean != null) { stack.Push( new KeyValuePair<IList<CategoryType>, IList<ICategoryObject>>( cat.Category, processingCatBean.Items)); this.ProcessCategory(beans, cat, processingCatBean); } } } }
/// <summary> /// set the header. /// </summary> /// <param name="header"> /// The header. /// </param> /// <param name="beans"> /// The beans. /// </param> /// <param name="receivers"> /// The receivers. /// </param> public static void SetHeader(BaseHeaderType header, ISdmxObjects beans, params string[] receivers) { header.ID = "IDREF" + refNumber; refNumber++; header.Test = false; header.Prepared = DateTime.Now; var sender = new SenderType(); header.Sender = sender; string senderId; if (beans != null && beans.Header != null && beans.Header.Sender != null) { // Get header information from the supplied beans senderId = beans.Header.Sender.Id; } else { // Get header info from HeaderHelper senderId = HeaderHelper.Instance.SenderId; } sender.id = senderId; if (ObjectUtil.ValidArray(receivers)) { /* foreach */ foreach (string currentReviever in receivers) { var receiver = new PartyType(); header.Receiver.Add(receiver); receiver.id = currentReviever; } } else { var receiver0 = new PartyType(); header.Receiver.Add(receiver0); receiver0.id = HeaderHelper.Instance.ReceiverId; } }
/// <summary> /// Check if the specified structure has all referenced concept schemes from the first keyfamily /// </summary> /// <param name="structure"> /// The StructureBean to check /// </param> public static void CheckConcepts(ISdmxObjects structure) { var cshtMap = new Dictionary<string, IConceptSchemeObject>(); IDataStructureObject kf = structure.DataStructures.First(); foreach (IConceptSchemeObject c in structure.ConceptSchemes) { cshtMap.Add(Utils.MakeKey(c), c); } var crossDsd = kf as ICrossSectionalDataStructureObject; List<IComponent> components = new List<IComponent>(); components.AddRange(kf.GetDimensions()); components.AddRange(kf.Attributes); if (kf.PrimaryMeasure != null) { components.Add(kf.PrimaryMeasure); } if (crossDsd != null) { components.AddRange(crossDsd.CrossSectionalMeasures); } var comps = components; foreach (IComponent comp in comps) { string conceptKey = Utils.MakeKey(comp.ConceptRef.MaintainableReference.MaintainableId, comp.ConceptRef.MaintainableReference.AgencyId, comp.ConceptRef.MaintainableReference.Version); if (!cshtMap.ContainsKey(conceptKey)) { string message = string.Format(CultureInfo.InvariantCulture, Resources.ExceptionMissingConceptSchemeFormat1, conceptKey); Logger.Error(message); throw new NsiClientException(message); } } }
private ISdmxObjects GetKeyFamily() { if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); this.SessionObj.SdmxObject = new SdmxObjectsImpl(); } // IDataflowObject dataflow = this.SessionObj.SdmxObject.Dataflows.FirstOrDefault(d => d.AgencyId == this.LayObj.Dataflow.agency && d.Id == this.LayObj.Dataflow.id && d.Version == this.LayObj.Dataflow.version); ISdmxObjects Structure = null; /* * if (dataflow != null) * { * Structure = GetSDMXObject.GetStructure(dataflow, this.SessionObj.SdmxObject.DataStructures); * Structure.AddDataflow(dataflow); * } */ if (dataflow != null && this.SessionObj.SdmxObject.HasConceptSchemes) { Structure = this.SessionObj.SdmxObject; } else if (dataflow != null && !this.SessionObj.SdmxObject.HasConceptSchemes) { Structure = GetSDMXObject.GetStructure(dataflow, this.SessionObj.SdmxObject.DataStructures); Structure.AddDataflow(dataflow); } else { Structure = GetSDMXObject.GetStructure(this.LayObj.Dataflow.id, this.LayObj.Dataflow.agency, this.LayObj.Dataflow.version); } this.SessionObj.SdmxObject.Merge(Structure); return(Structure); }
/// <summary> /// Submits the specified structural meta-data . /// </summary> /// <param name="dataLocation">The data location pointing to the structural meta-data.</param> /// <returns>The imported objects</returns> /// <exception cref="Estat.Sri.Ws.SubmitStructure.SubmitStructureException">An error occurred while importing structural meta-data.</exception> public ISdmxObjects Submit(IReadableDataLocation dataLocation, SubmitStructureConstant.ActionType actionType = SubmitStructureConstant.ActionType.Replace) { // Parse structures IStructureParsingManager is an instance field. IStructureWorkspace structureWorkspace = this._parsingManager.ParseStructures(dataLocation); // Get immutable objects from workspace ISdmxObjects objects = structureWorkspace.GetStructureObjects(false); // create a new instance of the MappingStoreManager class which implements the IStructurePersistenceManager IList <ArtefactImportStatus> importStatus = new List <ArtefactImportStatus>(); IStructurePersistenceManager persistenceManager = new MappingStoreManager(this._connectionStringSettings, importStatus); switch (actionType) { case SubmitStructureConstant.ActionType.Append: break; case SubmitStructureConstant.ActionType.Replace: // Save the structure to the mapping store database. persistenceManager.SaveStructures(objects); // Validate objects. ValidateImport(importStatus); break; case SubmitStructureConstant.ActionType.Delete: // Delete the structure to the mapping store database. persistenceManager.DeleteStructures(objects); break; default: break; } // Return the immutable object container. return(objects); }
/// <summary> /// Gets the stream controller. /// </summary> /// <param name="structureOutputFormat">The structure output format.</param> /// <param name="sdmxObjects">The SDMX objects.</param> /// <param name="encoding">The encoding.</param> /// <returns>The <see cref="IStreamController{XmlWriter}" />.</returns> private IStreamController<Stream> GetStreamController(StructureOutputFormat structureOutputFormat, ISdmxObjects sdmxObjects, Encoding encoding) { IStreamController<Stream> streamController = new StreamController<Stream>( (writer, queue) => { using (var xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings() { Encoding = encoding })) { IStructureFormat format = new SdmxStructureXmlFormat(structureOutputFormat, WebServiceEndpoint.StandardEndpoint, xmlWriter, queue); this._writerManager.WriteStructures(sdmxObjects, format, null); } }); return streamController; }
/// <summary> /// Gets the stream controller. /// </summary> /// <param name="endpoint">The endpoint.</param> /// <param name="structureOutputFormat">The structure output format.</param> /// <param name="sdmxObjects">The SDMX objects.</param> /// <returns>The <see cref="IStreamController{XmlWriter}" />.</returns> private IStreamController<XmlWriter> GetStreamController(WebServiceEndpoint endpoint, StructureOutputFormat structureOutputFormat, ISdmxObjects sdmxObjects) { IStreamController<XmlWriter> streamController = new StreamController<XmlWriter>( (writer, queue) => { IStructureFormat format = new SdmxStructureXmlFormat(structureOutputFormat, endpoint, writer, queue); this._writerManager.WriteStructures(sdmxObjects, format, null); }); return streamController; }
/// <summary> /// Initializes a new instance of the <see cref="AbstractDataSetModel"/> class. /// </summary> /// <param name="structure"> /// The SDMX-ML structure /// </param> /// <param name="store"> /// The <see cref="IDataSetStore"/> containing the dataset data /// </param> protected AbstractDataSetModel(ISdmxObjects structure, IDataSetStore store) { if (structure == null) { throw new ArgumentNullException("structure"); } this._store = store; this._structure = structure; // The structure must define exactly one key family... if ((this._structure.DataStructures == null) || (this._structure.DataStructures.Count != 1)) { throw new Exception( "Invalid structure bean, it does not contain the definition for exactly one key family!"); } this._dataFlow = this._structure.Dataflows.First(); this._keyFamily = this._structure.DataStructures.First(); }
/// <summary> /// Builds a success response along with the query results /// </summary> /// <param name="beans"> /// - the beans that were successfully returned from the query /// </param> /// <param name="schemaVersion"> /// - the version of the schema to output the response in /// </param> /// <param name="returnAsStructureMessage"> /// returns a structure message if true, otherwise returns as a query structure response /// </param> /// <returns> /// The <see cref="XTypedElement"/>. /// </returns> public virtual XTypedElement BuildSuccessResponse( ISdmxObjects beans, SdmxSchemaEnumType schemaVersion, bool returnAsStructureMessage) { XTypedElement response = null; switch (schemaVersion) { case SdmxSchemaEnumType.VersionTwoPointOne: if (beans.GetAllMaintainables().Count == 0) { response = this._errorResponseBuilder21.BuildErrorResponse(SdmxErrorCodeEnumType.NoResultsFound); } response = this._structV21Builder.Build(beans); break; case SdmxSchemaEnumType.VersionTwo: if (returnAsStructureMessage) { response = this._structv2Builder.Build(beans); } response = this._queryStructureResponseBuilderV2.BuildSuccessResponse(beans); break; case SdmxSchemaEnumType.VersionOne: response = this._structv1Builder.Build(beans); break; default: throw new SdmxNotImplementedException(ExceptionCode.Unsupported, schemaVersion); } base.WriteSchemaLocation(response, schemaVersion); return response; }
public void SaveDotSTATFile(ISdmxObjects sdmxObjects, DotStatExportType exportType) { string ExportFileName; ExportFileName = "DotStatExport-" + sdmxObjects.DataStructures.First().Id + "_" + sdmxObjects.DataStructures.First().AgencyId + "_" + sdmxObjects.DataStructures.First().Version; List<ISTAT.IO.Utility.FileGeneric> files = new List<ISTAT.IO.Utility.FileGeneric>(); List<ContactRef> contacs = GetConfigContact(); List<SecurityDef> securities = GetConfigSecurity(); DSDExporter _dsdExp = new DSDExporter(sdmxObjects); switch (exportType) { case DotStatExportType.DSD: if (_dsdExp.CreateData( contacs, securities, true, false)) { System.Xml.XmlDocument xDoc = _dsdExp.XMLDoc; MemoryStream xmlStream = new MemoryStream(); xDoc.Save(xmlStream); xmlStream.Flush(); xmlStream.Position = 0; ISTAT.IO.Utility.FileGeneric file = new ISTAT.IO.Utility.FileGeneric(); file.filename = ExportFileName + ".xml"; file.stream = xmlStream; files.Add(file); } break; case DotStatExportType.CODELIST: if (_dsdExp.CreateData( contacs, securities, true, false)) { foreach (CodelistExporter _codeExp in _dsdExp.ExporterCodelists) { System.Xml.XmlDocument xDoc_code = _codeExp.XMLDoc; MemoryStream xmlStream_code = new MemoryStream(); xDoc_code.Save(xmlStream_code); xmlStream_code.Flush(); xmlStream_code.Position = 0; ISTAT.IO.Utility.FileGeneric file_code = new ISTAT.IO.Utility.FileGeneric(); file_code.filename = _codeExp.Code.ToString() + ".xml"; file_code.stream = xmlStream_code; files.Add(file_code); Stream streamCSV = CSVWriter.CreateStream(_codeExp.DataView); ISTAT.IO.Utility.FileGeneric file_csv = new ISTAT.IO.Utility.FileGeneric(); file_csv.filename = _codeExp.DataFilename; file_csv.stream = streamCSV; files.Add(file_csv); } } break; case DotStatExportType.ALL: if (_dsdExp.CreateData( contacs, securities, true, false)) { System.Xml.XmlDocument xDoc = _dsdExp.XMLDoc; MemoryStream xmlStream = new MemoryStream(); xDoc.Save(xmlStream); xmlStream.Flush(); xmlStream.Position = 0; ISTAT.IO.Utility.FileGeneric file = new ISTAT.IO.Utility.FileGeneric(); file.filename = ExportFileName + ".xml"; file.stream = xmlStream; files.Add(file); foreach (CodelistExporter _codeExp in _dsdExp.ExporterCodelists) { System.Xml.XmlDocument xDoc_code = _codeExp.XMLDoc; MemoryStream xmlStream_code = new MemoryStream(); xDoc_code.Save(xmlStream_code); xmlStream_code.Flush(); xmlStream_code.Position = 0; ISTAT.IO.Utility.FileGeneric file_code = new ISTAT.IO.Utility.FileGeneric(); file_code.filename = _codeExp.Code.ToString() + ".xml"; file_code.stream = xmlStream_code; files.Add(file_code); Stream streamCSV = CSVWriter.CreateStream(_codeExp.DataView); ISTAT.IO.Utility.FileGeneric file_csv = new ISTAT.IO.Utility.FileGeneric(); file_csv.filename = _codeExp.DataFilename; file_csv.stream = streamCSV; files.Add(file_csv); } } break; } string fileZip = System.Web.HttpContext.Current.Server.MapPath("OutputFiles" + "\\" + ExportFileName + ".zip"); System.IO.File.Delete(fileZip); Ionic.Utils.Zip.ZipFile zip = new Ionic.Utils.Zip.ZipFile(fileZip); foreach (ISTAT.IO.Utility.FileGeneric file in files) zip.AddFileStream(file.filename, string.Empty, file.stream); zip.Save(); SendAttachment(fileZip, ExportFileName + ".zip"); }
private IEnumerable <JsTreeNode> CreateCategorisedNodes( ISdmxObjects sdmxObject, IDictionary <string, IDataflowObject> categorisedDataflowIndex, string TwoLetterISO) { int categoryCount = 0; var categorySchemeNodes = new List <JsTreeNode>(); var childToParent = new Dictionary <JsTreeNode, JsTreeNode>(); var leafCategories = new Queue <JsTreeNode>(); IEnumerable <ICategorySchemeObject> categories = sdmxObject.CategorySchemes; foreach (ICategorySchemeObject categoryScheme in categories) { JsTreeNode categorySchemeNode = CreateCategorySchemeNode(categoryScheme, TwoLetterISO); categorySchemeNodes.Add(categorySchemeNode); var remainingCategoryNodes = new Stack <JsTreeNode>(); var remainingCategories = new Stack <ICategoryObject>(); IList <ICategoryObject> categoriesWithAnnotation = new List <ICategoryObject>(); IList <ICategoryObject> categoriesWithoutAnnotation = new List <ICategoryObject>(); foreach (var category in categoryScheme.Items) { if (category.Annotations.Count > 0 && category.Annotations[0].FromAnnotation() == CustomAnnotationType.CategorySchemeNodeOrder) { categoriesWithAnnotation.Add(category); } else { categoriesWithoutAnnotation.Add(category); } } IEnumerable <ICategoryObject> categoriesWithAnnotationOrderedBy = categoriesWithAnnotation.OrderBy(category => Convert.ToInt64(category.Annotations[0].ValueFromAnnotation())); IEnumerable <ICategoryObject> categoriesWithAndWithoutAnnotations = categoriesWithoutAnnotation.Concat(categoriesWithAnnotationOrderedBy); foreach (ICategoryObject c in categoriesWithAndWithoutAnnotations) { JsTreeNode parent = CreateCategoryNode(c, ref categoryCount, TwoLetterISO); categorySchemeNode.children.Add(parent); remainingCategoryNodes.Push(parent); remainingCategories.Push(c); childToParent.Add(parent, categorySchemeNode); } while (remainingCategoryNodes.Count > 0) { JsTreeNode currentNode = remainingCategoryNodes.Pop(); ICategoryObject currentCategory = remainingCategories.Pop(); IList <ICategoryObject> categoriesParentWithAnnotation = new List <ICategoryObject>(); IList <ICategoryObject> categoriesParentWithoutAnnotation = new List <ICategoryObject>(); foreach (var category in currentCategory.Items) { if (category.Annotations.Count > 0 && category.Annotations[0].FromAnnotation() == CustomAnnotationType.CategorySchemeNodeOrder) { categoriesParentWithAnnotation.Add(category); } else { categoriesParentWithoutAnnotation.Add(category); } } IEnumerable <ICategoryObject> categoriesParentWithAnnotationOrderedBy = categoriesParentWithAnnotation.OrderBy(category => Convert.ToInt64(category.Annotations[0].ValueFromAnnotation())); IEnumerable <ICategoryObject> categoriesParentWithAndWithoutAnnotations = categoriesParentWithoutAnnotation.Concat(categoriesParentWithAnnotationOrderedBy); foreach (ICategoryObject cc in categoriesParentWithAndWithoutAnnotations) { JsTreeNode childNode = CreateCategoryNode(cc, ref categoryCount, TwoLetterISO); remainingCategoryNodes.Push(childNode); remainingCategories.Push(cc); currentNode.children.Add(childNode); childToParent.Add(childNode, currentNode); } foreach (IMaintainableRefObject dataflowRef in GetDataFlows(currentCategory, sdmxObject.Categorisations, TwoLetterISO)) { string key = Utils.MakeKey(dataflowRef); IDataflowObject dataflow; if (categorisedDataflowIndex.TryGetValue(key, out dataflow)) { JsTreeNode dataflowNode = CreateDataflowNode(dataflow, sdmxObject, TwoLetterISO); if (dataflowNode != null) { currentNode.children.Add(dataflowNode); } } } if (currentNode.children.Count == 0) { leafCategories.Enqueue(currentNode); } } } while (leafCategories.Count > 0) { JsTreeNode current = leafCategories.Dequeue(); JsTreeNode parent; if (childToParent.TryGetValue(current, out parent)) { parent.children.Remove(current); if (parent.children.Count == 0) { leafCategories.Enqueue(parent); } } else { categorySchemeNodes.Remove(current); } } return(categorySchemeNodes); }
public InMemoryProvisionRetrievalManager(ISdmxObjects beans0) { this.beans = beans0; }
/// <summary> /// Create a Dataflow Node /// </summary> /// <param name="dataflow"> /// The SDMX Model Dataflow object /// </param> /// <returns> /// The Dataflow Node /// </returns> private JsTreeNode CreateDataflowNode( IDataflowObject dataflow, ISdmxObjects SdmxOBJ, string TwoLetterISO) { var dataflowNode = new JsTreeNode(); if (dataflow.HasAnnotationType(VirtualDataflowTypeEpAnn)) { // VIrtual DF var vrtDf = dataflow.GetAnnotationsByType(VirtualDataflowTypeEpAnn); var value = TextTypeHelper.GetText(vrtDf.FirstOrDefault().Text, TwoLetterISO); string end_key = "@"; string search_key = string.Empty; search_key = "@EP1="; string endpoint_1 = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_1 = endpoint_1.Substring(0, endpoint_1.IndexOf(end_key)); search_key = "@EP2="; string endpoint_2 = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_2 = endpoint_2.Substring(0, endpoint_2.IndexOf(end_key)); search_key = "@EPT="; string endpoint_type = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_type = endpoint_type.Substring(0, endpoint_type.IndexOf(end_key)); search_key = "@SOURCE="; string dataflow_source = value.Substring(value.IndexOf(search_key) + search_key.Length); dataflow_source = dataflow_source.Substring(0, dataflow_source.IndexOf(end_key)); search_key = "@SEP="; string decimal_separator = ""; if (value.IndexOf(search_key) != -1) { decimal_separator = value.Substring(value.IndexOf(search_key) + search_key.Length); decimal_separator = decimal_separator.Substring(0, decimal_separator.IndexOf(end_key)); } else { decimal_separator = TreeObj.Configuration.DecimalSeparator; } //fabio forzo il sep prova debug del separatore decimale //if (dataflow.Id == "PARAS") { decimal_separator = ","; } List <string> valueDesc = new List <string>(); if (dataflow.HasAnnotationType(VirtualDataflowTypeDescAnn)) { var vrtDfDesc = dataflow.GetAnnotationsByType(VirtualDataflowTypeDescAnn); foreach (var ann in vrtDfDesc) { valueDesc.Add(TextTypeHelper.GetText(ann.Text, TwoLetterISO)); } } List <DataflowMetaUrl> valueUrls = new List <DataflowMetaUrl>(); if (dataflow.HasAnnotationType(VirtualDataflowTypeUrlAnn)) { var vrtDfUrls = dataflow.GetAnnotationsByType(VirtualDataflowTypeUrlAnn); foreach (var ann in vrtDfUrls) { valueUrls.Add(new DataflowMetaUrl() { Title = TextTypeHelper.GetText(ann.Text, TwoLetterISO), URL = ann.Title }); } } dataflowNode = CreateDataflowNode( dataflow.Id, dataflow.Version, dataflow.AgencyId, TextTypeHelper.GetText(dataflow.Names, TwoLetterISO), endpoint_1, endpoint_2, endpoint_type, dataflow_source, decimal_separator, valueDesc, valueUrls); } else { // Normal DF dataflowNode.SetId(Utils.MakeKey(dataflow).Replace('.', '_').Replace('+', '-')); SetupNode(dataflowNode, dataflow, TwoLetterISO); IDataStructureObject dsd = SdmxOBJ.DataStructures.FirstOrDefault( dataStructure => dataflow.DataStructureRef.Equals(dataStructure.AsReference)); if (dsd != null && dsd is ICrossSectionalDataStructureObject) { dataflowNode.SetRel("xs-dataflow"); dataflowNode.type = "xs-dataflow"; } else { dataflowNode.SetRel("dataflow"); dataflowNode.type = "dataflow"; } dataflowNode.li_attr.Add("title", TreeObj.Configuration.Title); dataflowNode.a_attr = new JSTreeMetadata { DataflowID = dataflow.Id, DataflowVersion = dataflow.Version, DataflowAgency = dataflow.AgencyId, DataflowUrl = TreeObj.Configuration.EndPoint, DataflowUrlV20 = TreeObj.Configuration.EndPointV20, DataflowUrlType = TreeObj.Configuration.EndPointType, DataflowSource = TreeObj.Configuration.EndPointSource, DataflowDecimalCulture = TreeObj.Configuration.DecimalSeparator, }; } return(dataflowNode); }
public SessionImplObject GetLayout(SessionQuery query, ConnectionStringSettings connectionStringSetting) { try { /* * ISdmxObjects structure = GetKeyFamily(); * IDataflowObject df = structure.Dataflows.First(); * IDataStructureObject kf = structure.DataStructures.First(); */ ISdmxObjects structure = query.Structure; IDataflowObject df = query.Dataflow; IDataStructureObject kf = query.KeyFamily; if (kf == null || df == null) { throw new InvalidOperationException("DataStructure is not set"); } //if (this.SessionObj.DafaultLayout == null) this.SessionObj.DafaultLayout = new Dictionary <string, LayoutObj>(); //if (connectionStringSetting.ConnectionString!=null && connectionStringSetting.ConnectionString.ToLower() != "file") if (connectionStringSetting.ConnectionString != null) { // Get automatic timeserie layout System.Data.SqlClient.SqlConnection Sqlconn = new System.Data.SqlClient.SqlConnection(connectionStringSetting.ConnectionString); Sqlconn.Open(); string sqlquery = string.Format("Select * from Template where [tmplKey]='{0}'", new System.Web.Script.Serialization.JavaScriptSerializer().Serialize( LayObj.Dataflow.id + "+" + LayObj.Dataflow.agency + "+" + LayObj.Dataflow.version + "+" + LayObj.Configuration.EndPoint).Replace("'", "''")); using (System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(sqlquery, Sqlconn)) { var reader = comm.ExecuteReader(); if (reader.Read()) { string layout = reader.GetString(reader.GetOrdinal("Layout")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)] = (LayoutObj) new JavaScriptSerializer().Deserialize(layout, typeof(LayoutObj)); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_x = reader.GetBoolean(reader.GetOrdinal("BlockXAxe")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_y = reader.GetBoolean(reader.GetOrdinal("BlockYAxe")); this.SessionObj.DafaultLayout[Utils.MakeKey(df)].block_axis_z = reader.GetBoolean(reader.GetOrdinal("BlockZAxe")); } } Sqlconn.Close(); } DefaultLayoutResponseObject defaultLayoutResponseObject = new DefaultLayoutResponseObject(); defaultLayoutResponseObject.DefaultLayout = (this.SessionObj.DafaultLayout.ContainsKey(Utils.MakeKey(df))) ? this.SessionObj.DafaultLayout[Utils.MakeKey(df)] : null; //if (defaultLayoutResponseObject.DefaultLayout == null){ return GetLayout(); } this.SessionObj.SavedDefaultLayout = new JavaScriptSerializer().Serialize(defaultLayoutResponseObject); return(this.SessionObj); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
public List<AgencyScheme> GetAgencySchemeList(ISdmxObjects sdmxObjects) { return GetAgencySchemeList(sdmxObjects, _language); }
public List<StructureSet> GetStructureSetList(ISdmxObjects sdmxObjects, string localization) { if (sdmxObjects == null || sdmxObjects.StructureSets == null) return null; List<StructureSet> lSS = new List<StructureSet>(); foreach (IStructureSetObject ss in sdmxObjects.StructureSets) { lSS.Add(new StructureSet(_localizedUtils.GetNameableName(ss), ss.Id, ss.AgencyId, ss.Version, ss.IsFinal.IsTrue)); } return lSS; }
public SessionImplObject GetDataChart(SessionQuery sessionQuery) { try { // Init session objects if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); this.SessionObj.SdmxObject = new SdmxObjectsImpl(); } JavaScriptSerializer ser = new JavaScriptSerializer(); ser.MaxJsonLength = int.MaxValue; #region +++ Caching +++ ConnectionStringSettings connectionStringSetting; CacheWidget cache = null; bool UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.UseWidgetCache : false; if (UseWidgetCache) { connectionStringSetting = ConfigurationManager.ConnectionStrings["ISTATWebClientConnection"]; cache = new CacheWidget(connectionStringSetting.ConnectionString); } if (ChartObj.WidgetId > 0 && UseWidgetCache) { SavedWidget widget = cache.GetWidget(ChartObj.WidgetId, ChartObj.Configuration.Locale); if (widget != null && !String.IsNullOrEmpty(widget.widgetData)) { this.SessionObj.SavedChart = widget.widgetData; return(this.SessionObj); } } #endregion if (BDO == null || GetSDMXObject == null) { throw new Exception(Messages.label_error_network); } codemapWidget = new CodemapWidget( new GetCodemapObject() { PreviusCostraint = this.ChartObj.Criteria, Configuration = this.ChartObj.Configuration, Dataflow = this.ChartObj.Dataflow }, this.SessionObj, sessionQuery); //ISdmxObjects structure = codemapWidget.GetDsd(); //IDataflowObject df = structure.Dataflows.FirstOrDefault(); //IDataStructureObject kf = structure.DataStructures.First(); ISdmxObjects structure = sessionQuery.Structure; //IDataflowObject df = structure.Dataflows.First(); IDataflowObject df = sessionQuery.Dataflow; //IDataStructureObject kf = structure.DataStructures.First(); IDataStructureObject kf = sessionQuery.KeyFamily; if (kf == null) { throw new InvalidOperationException("DSD is not set"); } if (df == null) { throw new InvalidOperationException("Dataflow is not set"); } Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, false); ComponentCodeDescriptionDictionary codemap = new ComponentCodeDescriptionDictionary(); foreach (string ConceptId in ConceptCodelists.Keys) { ICodelistObject codelist = ConceptCodelists[ConceptId]; Dictionary <string, string> codes = new Dictionary <string, string>(); foreach (ICode codeItem in codelist.Items) { codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.ChartObj.Configuration.Locale)); } codemap.Add(ConceptId, codes); //var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "true"); //fabio prova var useFix20 = (ConfigurationManager.AppSettings["UseFix20Criteria"].ToString().ToLower() == "false"); if (useFix20) { if (!(codelist.Items.Count > 1)) { this.ChartObj.Criteria.Remove(ConceptId); } } } this.SessionObj.MergeObject(codemapWidget.SessionObj); #region Gestione last period int num1; if (this.ChartObj.Criteria.ContainsKey(kf.TimeDimension.Id) && this.ChartObj.Criteria[kf.TimeDimension.Id].Count == 1 && int.TryParse(this.ChartObj.Criteria[kf.TimeDimension.Id].First(), out num1) ) { int offsetTime = int.Parse(this.ChartObj.Criteria[kf.TimeDimension.Id].First()); var codMap = codemap; int lengthTime = codMap[kf.TimeDimension.Id].Count; if ((lengthTime - offsetTime) >= 0) { var codes = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime); List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last()); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First()); } else { this.ChartObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key); this.ChartObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key); } } #endregion List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.ChartObj.Criteria); //List<DataCriteria> Criterias = sessionQuery.GetCriteria(); Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache; //aggiunta da fabio //IDataSetStore store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery); IDataSetStore store = sessionQuery._store; store.SetCriteria(Criterias); /* * IDataSetStore store; * if (sessionQuery._store != null) * { store = sessionQuery._store; } * else * { * //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr); * store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false, sessionQuery); * sessionQuery._store = store; * } */ //fine nuovo //string DBFileName = null; //IDataSetStore store = BDO.FindDataCache(df, kf, Criterias, ref DataCache, false, out DBFileName); //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache); //if (store == null) store = BDO.GetDataset(df, kf, Criterias, ref DataCache, false); //da vedere se eliminare aggiunta fabio per svuotare datacache SessionObj.DataCache = null; SessionObj.DataCache = DataCache; DataObjectForStreaming DataStream = new DataObjectForStreaming() { store = store, Criterias = Criterias, structure = structure, codemap = codemap }; ChartResponseObject ChartResponse = new ChartResponseObject(); ChartResponse.series_title = TextTypeHelper.GetText(df.Names, this.ChartObj.Configuration.Locale); ChartResponse.series = BuildChart(store, kf, ConceptCodelists); ChartResponse.primary_name = (this.ChartObj.ObsValue[0] == "v") ? Messages.label_varValue : (this.ChartObj.ObsValue[0] == "vt") ? Messages.label_varTrend : (this.ChartObj.ObsValue[0] == "vc") ? Messages.label_varCyclical : string.Empty; ChartResponse.secondary_name = (this.ChartObj.ObsValue.Count > 1) ? (this.ChartObj.ObsValue[1] == "v") ? Messages.label_varValue : (this.ChartObj.ObsValue[1] == "vt") ? Messages.label_varTrend : (this.ChartObj.ObsValue[1] == "vc") ? Messages.label_varCyclical : string.Empty : string.Empty; ChartResponse.x_name = (!string.IsNullOrEmpty(ChartObj.DimensionAxe)) ? ChartObj.DimensionAxe : kf.TimeDimension.Id;; // 23/07/2015 // calcolo massimo e minimo decimal?primary_max = null; decimal?primary_min = null; decimal?secondary_max = null; decimal?secondary_min = null; decimal costantemax = 1.1m; decimal costantemin = 0.9m; foreach (serieType serie in ChartResponse.series) { if (serie.axisYType == "secondary") { //fabio 12/08/2015 //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y); decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y)); if (secondary_max == null || max > secondary_max) { secondary_max = max; } //fabio 12/08/2015 //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y); decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y)); if (secondary_min == null || min < secondary_min) { secondary_min = min; } //fabio 12/08/2015 if (secondary_min == secondary_max) { secondary_min = secondary_min * costantemin; secondary_max = secondary_max * costantemax; } } else { //fabio 12/08/2015 //decimal max = (decimal)serie.dataPoints.Where(m => m.y != null).Max(d => d.y); decimal max = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Max(d => d.y)); if (primary_max == null || max > primary_max) { primary_max = max; } //fabio 12/08/2015 //decimal min = (decimal)serie.dataPoints.Where(m => m.y != null).Min(d => d.y); decimal min = Convert.ToDecimal(serie.dataPoints.Where(m => m.y != null).Min(d => d.y)); if (primary_min == null || min < primary_min) { primary_min = min; } //fabio 12/08/2015 if (primary_min == primary_max) { primary_min = primary_min * costantemin; primary_max = primary_max * costantemax; } } } if (primary_max != null && primary_min != null) { //decimal delta = (decimal)primary_max - (decimal)primary_min; //ChartResponse.primary_max = (decimal)primary_max; //ChartResponse.primary_min = (decimal)primary_min; if (primary_max > 0) { ChartResponse.primary_max = (decimal)(primary_max * 1.1m); } else if (primary_max == 0) { ChartResponse.primary_max = (decimal) - 1.1m; } else { ChartResponse.primary_max = (decimal)(primary_max * 0.9m); } if (primary_min > 0) { ChartResponse.primary_min = (decimal)(primary_min * 0.9m); } else if (primary_min == 0) { ChartResponse.primary_min = (decimal) - 1.1m; } else { ChartResponse.primary_min = (decimal)(primary_min * 1.1m); } } if (secondary_max != null && secondary_min != null) { //ChartResponse.secondary_max = (decimal)secondary_max; //ChartResponse.secondary_min = (decimal)secondary_min; if (secondary_max > 0) { ChartResponse.secondary_max = (decimal)(secondary_max * 1.1m); } else if (secondary_max == 0) { ChartResponse.secondary_max = (decimal) - 1.1m; } else { ChartResponse.secondary_max = (decimal)(secondary_max * 0.9m); } if (secondary_min > 0) { ChartResponse.secondary_min = (decimal)(secondary_min * 0.9m); } else if (secondary_min == 0) { ChartResponse.secondary_min = (decimal) - 1.1m; } else { ChartResponse.secondary_min = (decimal)(secondary_min * 1.1m); } } this.SessionObj.SavedChart = ser.Serialize(ChartResponse); // +++ Caching +++ if (ChartObj.WidgetId > 0 && UseWidgetCache) { cache.InsertWidget(ChartObj.WidgetId, this.SessionObj.SavedChart, ChartObj.Configuration.Locale); } return(this.SessionObj); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } }
private void GetSDMXObjects() { _sdmxObjects = (ISdmxObjects)Session["SDMXObjexts"]; }
/// <summary> /// Sets the header. /// </summary> /// <param name="regInterface"> /// The registry interface. /// </param> /// <param name="sdmxObjects"> /// The beans. /// </param> public static void SetHeader(RegistryInterfaceType regInterface, ISdmxObjects sdmxObjects) { var header = new HeaderType(); regInterface.Header = header; SetHeader(header, sdmxObjects); }
/// <summary> /// Build the XSD generated class objects from the specified <paramref name="beans"/> /// </summary> /// <param name="beans"> /// The sdmxObjects. /// </param> /// <returns> /// the XSD generated class objects from the specified <paramref name="beans"/> /// </returns> protected internal override XTypedElement Build(ISdmxObjects beans) { _log.Info("Write structures as a SDMX 2.0 Registry response message"); return this._queryStructureResponseBuilderV2.BuildSuccessResponse(beans); }
public SessionImplObject GetData(out object DataStream, SessionQuery query) { try { // Init session objects if (this.SessionObj == null) { this.SessionObj = new SessionImplObject(); this.SessionObj.SdmxObject = new SdmxObjectsImpl(); } if (BDO == null || GetSDMXObject == null) { throw new Exception(Messages.label_error_network + " " + DataObj.Configuration.Title); } codemapWidget = new CodemapWidget(new GetCodemapObject() { Configuration = this.DataObj.Configuration, Dataflow = this.DataObj.Dataflow, PreviusCostraint = this.DataObj.Criteria }, this.SessionObj, query); //ISdmxObjects structure = codemapWidget.GetDsd(); ISdmxObjects structure = query.Structure; IDataflowObject df = structure.Dataflows.FirstOrDefault(); IDataStructureObject kf = structure.DataStructures.First(); if (df == null) { throw new InvalidOperationException("Dataflow is not set"); } /****************/ // Get all codelist /****************/ //Dictionary<string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(df, kf, true); Dictionary <string, ICodelistObject> ConceptCodelists = codemapWidget.GetCodelistMap(query, false); ComponentCodeDescriptionDictionary codemap = new ComponentCodeDescriptionDictionary(); foreach (string ConceptId in ConceptCodelists.Keys) { ICodelistObject codelist = ConceptCodelists[ConceptId]; Dictionary <string, string> codes = new Dictionary <string, string>(); foreach (ICode codeItem in codelist.Items) { codes.Add(codeItem.Id, TextTypeHelper.GetText(codeItem.Names, this.DataObj.Configuration.Locale)); } codemap.Add(ConceptId, codes); } /****************/ //codemapWidget.GetCodeListCostraint(df,kf,component) this.SessionObj.MergeObject(codemapWidget.SessionObj); int num1; #region Gestione last period if (this.DataObj.Criteria.ContainsKey(kf.TimeDimension.Id) && this.DataObj.Criteria[kf.TimeDimension.Id].Count == 1 && int.TryParse(this.DataObj.Criteria[kf.TimeDimension.Id].First(), out num1) && !this.DataObj.Layout.axis_z.Contains(kf.TimeDimension.Id)) { int offsetTime = int.Parse(this.DataObj.Criteria[kf.TimeDimension.Id].First()); var codMap = codemap; int lengthTime = codMap[kf.TimeDimension.Id].Count; if ((lengthTime - offsetTime) >= 0) { var codes = codMap[kf.TimeDimension.Id].Reverse().Take(offsetTime); List <string> _criteriaTime = (from c in codes select c.Key).ToList <string>(); this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.Last()); this.DataObj.Criteria[kf.TimeDimension.Id].Add(_criteriaTime.First()); } else { this.DataObj.Criteria[kf.TimeDimension.Id] = new List <string>(); this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].First().Key); this.DataObj.Criteria[kf.TimeDimension.Id].Add(codemap[kf.TimeDimension.Id].Last().Key); } } #endregion LayoutObj layObj = InitLayout(df, kf); List <DataCriteria> Criterias = BDO.InitCriteria(kf, this.DataObj.Criteria); //query.GetCriteria(); Dictionary <string, List <DataChacheObject> > DataCache = SessionObj.DataCache; List <string> ret = null; List <DataCriteria> QueryCriterias = new List <DataCriteria>(); if (query.Criteria != null) //criteri nulli se proviene da un template { if (query._store != null) //.Count == 1) { query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]); } if (query.Criteria.TryGetValue(kf.TimeDimension.Id, out ret)) { if (ret.Count == 1) { query.SetCriteriaTime(this.DataObj.Criteria[kf.TimeDimension.Id]); } } QueryCriterias = query.GetCriteria(); /*if (query._store == null) //.Count == 1) * { QueryCriterias = Criterias; } * else * { QueryCriterias = query.GetCriteria(); }*/ } else { QueryCriterias = Criterias; } //aggiunta da fabio IDataSetStore store; if (query._store != null) { store = query._store; } else { //store = BDO.GetDataset(df, kf, Criterias, ref DataCache, _useAttr); store = BDO.GetDataset(df, kf, QueryCriterias, ref DataCache, _useAttr, query); query._store = store; } //fine nuovo SessionObj.DataCache = DataCache; DataStream = new DataObjectForStreaming() { Configuration = this.DataObj.Configuration, store = store, layObj = layObj, Criterias = Criterias, structure = structure, codemap = codemap }; return(this.SessionObj); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw ex; } }
public DataRender(IDataSetStore store, List <DataCriteria> Criterias, LayoutObj layObj, ISdmxObjects structure, ComponentCodeDescriptionDictionary codemap, bool useAttr, CultureInfo cFrom, CultureInfo cTo) { this.store = store; this.Criterias = Criterias; this.layObj = layObj; this.Structure = structure; this.codemap = codemap; this._useAttr = useAttr; this.cFrom = cFrom; this.cTo = cTo; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="NotificationEventCore"/> class. /// </summary> /// <param name="notification"> /// The notification. /// </param> public NotificationEventCore(NotifyRegistryEventType notification) { this._eventTime = notification.EventTime; //TODO: True param DateUtil this._objectUrn = notification.ObjectURN; this._subscriptionUrn = notification.SubscriptionURN; this._action = (DatasetAction)Enum.Parse(typeof(DatasetAction), notification.EventAction.ToUpperInvariant()); if (notification.RegistrationEvent != null) { this._registration = new RegistrationObjectCore(notification.RegistrationEvent.Registration); } else { this.objects = new SdmxObjectsImpl(); StructuresType structures = notification.StructuralEvent.Structures.Content; if (structures.Categorisations != null) { foreach (CategorisationType type in structures.Categorisations.Categorisation) { this.objects.AddCategorisation(new CategorisationObjectCore(type)); } } if (structures.CategorySchemes != null) { foreach (CategorySchemeType type0 in structures.CategorySchemes.CategoryScheme) { this.objects.AddCategoryScheme(new CategorySchemeObjectCore(type0)); } } if (structures.Codelists != null) { foreach (CodelistType type1 in structures.Codelists.Codelist) { this.objects.AddCodelist(new CodelistObjectCore(type1)); } } if (structures.Concepts != null) { foreach (ConceptSchemeType type2 in structures.Concepts.ConceptScheme) { this.objects.AddConceptScheme(new ConceptSchemeObjectCore(type2)); } } if (structures.Constraints != null) { foreach (AttachmentConstraintType type3 in structures.Constraints.AttachmentConstraint) { this.objects.AddAttachmentConstraint(new AttachmentConstraintObjectCore(type3)); } foreach (ContentConstraintType type4 in structures.Constraints.ContentConstraint) { this.objects.AddContentConstraintObject(new ContentConstraintObjectCore(type4)); } } if (structures.Dataflows != null) { foreach (DataflowType type5 in structures.Dataflows.Dataflow) { this.objects.AddDataflow(new DataflowObjectCore(type5)); } } if (structures.DataStructures != null) { foreach (DataStructureType type6 in structures.DataStructures.DataStructure) { this.objects.AddDataStructure(new DataStructureObjectCore(type6)); } } if (structures.HierarchicalCodelists != null) { foreach (HierarchicalCodelistType type7 in structures.HierarchicalCodelists.HierarchicalCodelist) { this.objects.AddHierarchicalCodelist(new HierarchicalCodelistObjectCore(type7)); } } if (structures.Metadataflows != null) { foreach (MetadataflowType type8 in structures.Metadataflows.Metadataflow) { this.objects.AddMetadataFlow(new MetadataflowObjectCore(type8)); } } if (structures.MetadataStructures != null) { foreach (MetadataStructureType type9 in structures.MetadataStructures.MetadataStructure) { this.objects.AddMetadataStructure(new MetadataStructureDefinitionObjectCore(type9)); } } if (structures.OrganisationSchemes != null) { foreach (AgencySchemeType type10 in structures.OrganisationSchemes.AgencyScheme) { this.objects.AddAgencyScheme(new AgencySchemeCore(type10)); } foreach (DataConsumerSchemeType type11 in structures.OrganisationSchemes.DataConsumerScheme) { this.objects.AddDataConsumerScheme(new DataConsumerSchemeCore(type11)); } foreach (DataProviderSchemeType type12 in structures.OrganisationSchemes.DataProviderScheme) { this.objects.AddDataProviderScheme(new DataProviderSchemeCore(type12)); } foreach (OrganisationUnitSchemeType type13 in structures.OrganisationSchemes.OrganisationUnitScheme) { this.objects.AddOrganisationUnitScheme(new OrganisationUnitSchemeObjectCore(type13)); } } if (structures.Processes != null) { foreach (ProcessType type14 in structures.Processes.Process) { this.objects.AddProcess(new ProcessObjectCore(type14)); } } if (structures.ProvisionAgreements != null) { foreach (ProvisionAgreementType type15 in structures.ProvisionAgreements.ProvisionAgreement) { this.objects.AddProvisionAgreement(new ProvisionAgreementObjectCore(type15)); } } if (structures.ReportingTaxonomies != null) { foreach (ReportingTaxonomyType type16 in structures.ReportingTaxonomies.ReportingTaxonomy) { this.objects.AddReportingTaxonomy(new ReportingTaxonomyObjectCore(type16)); } } if (structures.StructureSets != null) { foreach (StructureSetType type17 in structures.StructureSets.StructureSet) { this.objects.AddStructureSet(new StructureSetObjectCore(type17)); } } } }
public SessionImplObject GetTree(SessionQuery sessionQuery) { var ser = new JavaScriptSerializer(); string json; try { //string decimalCulture=TreeObj.Configuration.Locale; //TreeObj.Configuration.Locale = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToUpper(); CacheTree ct = new CacheTree(ConnectionString, TreeObj.Configuration); //controlla il parametro CachedTree del webconfig se utilizzare o meno la cache bool UseWidgetCache = (WebClientSettings.Instance != null) ? WebClientSettings.Instance.CachedTree : false; string JsonTree = null; if (UseWidgetCache) { JsonTree = ct.GetCachedTree(); } if (!string.IsNullOrEmpty(JsonTree)) { return new SessionImplObject() { SavedTree = JsonTree } } ; //ISdmxObjects SdmxOBJ = GetSdmxObject(TreeObj.Configuration); ISdmxObjects SdmxOBJ = null; if (sessionQuery._IGetSDMXObject == null || TreeObj.Configuration.EndPoint != sessionQuery._endpointSettings.EndPoint) { SdmxOBJ = GetSdmxObject(TreeObj.Configuration, sessionQuery); sessionQuery._IGetSDMXObject = SdmxOBJ; } else { SdmxOBJ = sessionQuery._IGetSDMXObject; } //TreeObj.Configuration.Locale = decimalCulture; List <JsTreeNode> nodelist = BuildJSTree(SdmxOBJ, System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName); if (nodelist == null || nodelist.Count == 0) {//Invio Errore var x = new { error = true, dataflowError = true, message = ISTAT.WebClient.WidgetComplements.Model.App_GlobalResources.Messages.no_results_found }; throw new Exception(ser.Serialize(x)); } json = ser.Serialize(nodelist); JArray jobject = JArray.Parse(json); string appo = jobject.ToString(); ct.SaveCachedTree(json); return(new SessionImplObject() { SavedTree = json, SdmxObject = SdmxOBJ }); } catch (InvalidOperationException ex) { Logger.Warn(Resources.ErrorMaxJsonLength); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (ArgumentException ex) { Logger.Warn(Resources.ErrorRecursionLimit); Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } catch (Exception ex) { Logger.Warn(ex.Message, ex); throw new Exception(ErrorOccured); } }
/// <summary> /// Build the XSD generated class objects from the specified <paramref name="beans"/> /// </summary> /// <param name="beans"> /// The beans. /// </param> /// <returns> /// the XSD generated class objects from the specified <paramref name="beans"/> /// </returns> protected internal override XTypedElement Build(ISdmxObjects beans) { return this._structureXmlBuilder.Build(beans); }