Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        private void GetStructureMapItems(IStructureSetMutableObject artefact, IStructureMapMutableObject sm, long sysId)
        {
            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);

            using (DbCommand command = MappingStoreDb.GetSqlStringCommandParam(StructureSetConstant.SqlSMItem, inParameter))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    ComponentMapMutableCore smComp;

                    while (dataReader.Read())
                    {
                        smComp = new ComponentMapMutableCore();

                        smComp.MapConceptRef       = dataReader["S_ID"].ToString();
                        smComp.MapTargetConceptRef = dataReader["T_ID"].ToString();

                        sm.AddComponent(smComp);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM MUTABLE OBJECTS             //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="StructureMapCore"/> class.
        /// </summary>
        /// <param name="structMapType">
        /// The struct map type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public StructureMapCore(IStructureMapMutableObject structMapType, IStructureSetObject parent)
            : base(structMapType, parent)
        {
            this.components = new List<IComponentMapObject>();
            this.extension = structMapType.Extension;
            if (structMapType.Components != null)
            {
                foreach (IComponentMapMutableObject mutable in structMapType.Components)
                {
                    this.components.Add(new ComponentMapCore(mutable, this));
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        private void UpdateSMTarget(ref IStructureMapMutableObject iStructureMapMutableObject, ArtefactIdentity artefactIdentity, string artefactType)
        {
            if (iStructureMapMutableObject == null)
                return;

            iStructureMapMutableObject.TargetRef = new StructureReferenceImpl(artefactIdentity.Agency,
                                                                            artefactIdentity.ID,
                                                                            artefactIdentity.Version,
                                                                            SdmxStructureType.GetFromEnum((SdmxStructureEnumType)Enum.Parse(typeof(SdmxStructureEnumType), artefactType)),
                                                                            null);
            SetSSToSession();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        private void GetStructureMapCrossReference(IStructureSetMutableObject artefact, IStructureMapMutableObject sm, long sysId)
        {
            var inParameter = MappingStoreDb.CreateInParameter(ParameterNameConstants.IdParameter, DbType.Int64, sysId);

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

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

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

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

                        sourceRef = new StructureReferenceImpl(s_Agency, s_ID, s_Version, (SdmxStructureEnumType)Enum.Parse(typeof(SdmxStructureEnumType), s_ArtType), "");
                        targetRef = new StructureReferenceImpl(t_Agency, t_ID, t_Version, (SdmxStructureEnumType)Enum.Parse(typeof(SdmxStructureEnumType), t_ArtType), "");

                        sm.SourceRef = sourceRef;
                        sm.TargetRef = targetRef;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="artefact"></param>
 /// <param name="sm"></param>
 /// <param name="smID"></param>
 private void GetSMItemAndReference(IStructureSetMutableObject artefact, IStructureMapMutableObject sm, long smID)
 {
     GetStructureMapCrossReference(artefact, sm, smID);
     GetStructureMapItems(artefact, sm, smID);
     artefact.AddStructureMap(sm);
 }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artefact"></param>
        /// <param name="sysId"></param>
        /// <returns></returns>
        private bool GetStructureMapInfo(IStructureSetMutableObject artefact, long sysId)
        {
            // add for estat annotation
            this._identifiableAnnotationRetrieverEngine = new IdentifiableAnnotationRetrieverEngine(_mappingStoreDb, StructureSetConstant.SMItemTableInfo);
            var itemMap = new Dictionary <long, IStructureMapMutableObject>();

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

            bool smFound = false;

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

                    IStructureMapMutableObject sm = null;

                    while (dataReader.Read())
                    {
                        smFound = true;

                        smID = (long)dataReader["ITEM_ID"];
                        if (smID != currSM)
                        {
                            if (sm != null)
                            {
                                GetSMItemAndReference(artefact, sm, currSM);
                            }

                            sm    = new StructureMapMutableCore();
                            ID    = dataReader["ID"].ToString();
                            sm.Id = ID;
                            //annRetrieval.AddAnnotation(sm, smID);

                            // add for estat annotation
                            itemMap.Add(smID, sm);

                            currSM = smID;
                        }

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

                    if (sm != null)
                    {
                        GetSMItemAndReference(artefact, sm, currSM);
                    }
                }
            }
            // add for estat annotation
            this.IdentifiableAnnotationRetrieverEngine.RetrieveAnnotations(sysId, itemMap);

            return(smFound);
        }