///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CodelistMapCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The agencyScheme. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public CodelistMapCore(ICodelistMapMutableObject itemMutableObject, IStructureSetObject parent)
            : base(itemMutableObject, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeListMap), parent)
        {
            this.srcAlias = itemMutableObject.SrcAlias;
            this.targetAlias = itemMutableObject.TargetAlias;

            if (itemMutableObject.TargetRef != null)
            {
                this.TargetRef = new CrossReferenceImpl(this, itemMutableObject.TargetRef);
            }

            if (itemMutableObject.SourceRef != null)
            {
                this.SourceRef = new CrossReferenceImpl(this, itemMutableObject.SourceRef);
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        /// <returns></returns>
        private bool GetCodeListMapInfo(IStructureSetMutableObject artefact, long sysId)
        {
            // add for estat annotation
            this._identifiableAnnotationRetrieverEngine = new IdentifiableAnnotationRetrieverEngine(_mappingStoreDb, StructureSetConstant.CLMItemTableInfo);
            var itemMap = new Dictionary <long, ICodelistMapMutableObject>();

            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);
            //AnnotationRetrievalEngine annRetrieval = new AnnotationRetrievalEngine(MappingStoreDb, StructureSetConstant.TableInfo, StructureSetConstant.CLMItemTableInfo, AnnotationCommandBuilder.AnnotationType.Item, sysId);

            bool clmFound = false;

            using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(StructureSetConstant.SqlCLMInfo, inParameter))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    int    txtIdx  = dataReader.GetOrdinal("TEXT");
                    int    langIdx = dataReader.GetOrdinal("LANGUAGE");
                    int    typeIdx = dataReader.GetOrdinal("TYPE");
                    long   clmID   = 0;
                    string ID;
                    long   currCLM = 0;

                    ICodelistMapMutableObject clm = null;

                    while (dataReader.Read())
                    {
                        clmFound = true;
                        clmID    = (long)dataReader["ITEM_ID"];
                        if (clmID != currCLM)
                        {
                            if (clm != null)
                            {
                                GetCLMItemAndReference(artefact, clm, currCLM);
                            }

                            clm    = new CodelistMapMutableCore();
                            ID     = dataReader["ID"].ToString();
                            clm.Id = ID;
                            //annRetrieval.AddAnnotation(clm, clmID);

                            // add for estat annotation
                            itemMap.Add(clmID, clm);

                            currCLM = clmID;
                        }

                        ReadLocalisedString(clm, typeIdx, txtIdx, langIdx, dataReader);
                    }

                    if (clm != null)
                    {
                        GetCLMItemAndReference(artefact, clm, currCLM);
                    }
                }
            }

            // add for estat annotation
            this.IdentifiableAnnotationRetrieverEngine.RetrieveAnnotations(sysId, itemMap);
            return(clmFound);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        private void GetCodeListMapItems(IStructureSetMutableObject artefact, ICodelistMapMutableObject clm, long sysId)
        {
            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);

            using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(StructureSetConstant.SqlCLMItem, inParameter))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    ItemMapMutableCore clmItem;

                    while (dataReader.Read())
                    {
                        clmItem = new ItemMapMutableCore();

                        clmItem.SourceId = dataReader["S_ID"].ToString();
                        clmItem.TargetId = dataReader["T_ID"].ToString();

                        clm.AddItem(clmItem);
                    }
                }
            }
        }
        private void UpdateCLMTarget(ref ICodelistMapMutableObject iCodelistMapMutableObject, ArtefactIdentity artefactIdentity)
        {
            if (iCodelistMapMutableObject == null)
                return;

            iCodelistMapMutableObject.TargetRef = new StructureReferenceImpl(artefactIdentity.Agency,
                                                                            artefactIdentity.ID,
                                                                            artefactIdentity.Version,
                                                                            SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList),
                                                                            null);
            SetSSToSession();
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        private void GetCodeListMapCrossReference(IStructureSetMutableObject artefact, ICodelistMapMutableObject clm, long sysId)
        {
            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);

            using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(StructureSetConstant.SqlCLMReference, inParameter))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    if (dataReader.Read())
                    {
                        IStructureReference sourceRef;
                        IStructureReference targetRef;

                        string s_ID, s_Agency, s_Version;
                        string t_ID, t_Agency, t_Version;

                        s_ID      = dataReader["S_ID"].ToString();
                        s_Agency  = dataReader["S_AGENCY"].ToString();
                        s_Version = dataReader["S_Version"].ToString();

                        t_ID      = dataReader["T_ID"].ToString();
                        t_Agency  = dataReader["T_AGENCY"].ToString();
                        t_Version = dataReader["T_Version"].ToString();

                        sourceRef = new StructureReferenceImpl(s_Agency, s_ID, s_Version, SdmxStructureEnumType.CodeList, "");
                        targetRef = new StructureReferenceImpl(t_Agency, t_ID, t_Version, SdmxStructureEnumType.CodeList, "");

                        clm.SourceRef = sourceRef;
                        clm.TargetRef = targetRef;
                    }
                }
            }
        }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="artefact"></param>
 /// <param name="clm"></param>
 /// <param name="clmID"></param>
 private void GetCLMItemAndReference(IStructureSetMutableObject artefact, ICodelistMapMutableObject clm, long clmID)
 {
     GetCodeListMapCrossReference(artefact, clm, clmID);
     GetCodeListMapItems(artefact, clm, clmID);
     artefact.AddCodelistMap(clm);
 }