private IAnnotationMutableObject GetAnnotationOrder(int index)
        {
            IAnnotationMutableObject annotation = new AnnotationMutableCore();
            ITextTypeWrapperMutableObject iText = new TextTypeWrapperMutableCore();
            iText.Value = index.ToString();
            iText.Locale = "en";
            annotation.AddText(iText);
            annotation.Type = "@ORDER@";

            return annotation;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class.
        /// </summary>
        /// <param name="fullTarget">The SDMX v2.0 full target identifier.</param>
        /// <param name="parent">The parent.</param>
        protected internal MetadataTargetCore(FullTargetIdentifierType fullTarget, IMetadataStructureDefinitionObject parent)
            : base(fullTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), fullTarget.id, fullTarget.uri, fullTarget.Annotations, parent)
        {
            if (fullTarget.IdentifierComponent != null)
            {
                foreach (var currentIdentifier in fullTarget.IdentifierComponent)
                {
                    var identifiableTarget = new IdentifiableTargetMutableCore() { Id = currentIdentifier.id, Uri = currentIdentifier.uri };
                    if (currentIdentifier.Annotations != null && currentIdentifier.Annotations.Annotation != null)
                    {
                        foreach (var annotationType in currentIdentifier.Annotations.Annotation)
                        {
                            var annotation = new AnnotationMutableCore { Title = annotationType.AnnotationTitle, Type = annotationType.AnnotationType1, Uri = annotationType.AnnotationURL };
                            foreach (var textType in annotationType.AnnotationText)
                            {
                                annotation.AddText(textType.lang, textType.TypedValue);
                            }

                            identifiableTarget.AddAnnotation(annotation);
                        }
                    }

                    if (currentIdentifier.RepresentationScheme != null)
                    {
                        var id = currentIdentifier.RepresentationScheme.representationScheme;
                        var agency = currentIdentifier.RepresentationScheme.representationSchemeAgency;
                        var schemaType = XmlobjectsEnumUtil.GetSdmxStructureTypeFromRepresentationSchemeTypeV20(currentIdentifier.RepresentationScheme.representationSchemeType1);

                        // Only on .NET
                        var version = currentIdentifier.RepresentationScheme.RepresentationSchemeVersionEstat ?? MaintainableObject.DefaultVersion;

                        var representation = new RepresentationMutableCore();
                        var representationRef = new StructureReferenceImpl(new MaintainableRefObjectImpl(agency, id, version), schemaType);
                        representation.Representation = representationRef;
                        identifiableTarget.Representation = representation;
                    }

                    if (currentIdentifier.TargetObjectClass != null)
                    {
                        identifiableTarget.ReferencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureType(currentIdentifier.TargetObjectClass);
                    }

                    this._identifiableTarget.Add(new IdentifiableTargetCore(identifiableTarget, this));
                }
            }
        }
        /// <summary>
        /// Retrieve annotations for the specified SDMX <paramref name="annotable"/> object
        /// </summary>
        /// <param name="sysId">The artefact primary key value.</param>
        /// <param name="annotable">The SDMX object.</param>
        public void RetrieveAnnotations(long sysId, IAnnotableMutableObject annotable)
        {
            using (var command = this._annotationCommandBuilder.Build(new PrimaryKeySqlQuery(this._annotationSqlQueryInfo, sysId)))
            using (var dataReader = this._mappingStoreDb.ExecuteReader(command))
            {
                int annIdIdx = dataReader.GetOrdinal("ANN_ID");
                int idIdx = dataReader.GetOrdinal("ID");
                int txtIdx = dataReader.GetOrdinal("TEXT");
                int langIdx = dataReader.GetOrdinal("LANGUAGE");
                int typeIdx = dataReader.GetOrdinal("TYPE");
                int titleIdx = dataReader.GetOrdinal("TITLE");
                int urlIdx = dataReader.GetOrdinal("URL");

                IDictionary<long, IAnnotationMutableObject> annotationMap = new Dictionary<long, IAnnotationMutableObject>();

                while (dataReader.Read())
                {
                    var annId = dataReader.GetInt64(annIdIdx);
                    IAnnotationMutableObject annotation;
                    if (!annotationMap.TryGetValue(annId, out annotation))
                    {
                        annotation = new AnnotationMutableCore
                        {
                            Id = DataReaderHelper.GetString(dataReader, idIdx),
                            Title = DataReaderHelper.GetString(dataReader, titleIdx),
                            Type = DataReaderHelper.GetString(dataReader, typeIdx)
                        };
                        var url = DataReaderHelper.GetString(dataReader, urlIdx);
                        Uri uri;
                        if (!string.IsNullOrWhiteSpace(url) && Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
                        {
                            annotation.Uri = uri;
                        }

                        annotable.AddAnnotation(annotation);
                    }

                    var text = DataReaderHelper.GetString(dataReader, txtIdx);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        annotation.AddText(DataReaderHelper.GetString(dataReader, langIdx), text);
                    }
                }
            }
        }
 public IAnnotationMutableObject AddAnnotation(string title, string type, string url)
 {
     IAnnotationMutableObject mutable = new AnnotationMutableCore();
     mutable.Title = title;
     mutable.Type = type;
     mutable.Uri = new Uri(url);
     AddAnnotation(mutable);
     return mutable;
 }
        private IAnnotationMutableObject CreateAnnotation(string id, string title,
                                                        string type, string uri, IList<ITextTypeWrapperMutableObject> texts)
        {
            IAnnotationMutableObject annotation = new AnnotationMutableCore();

            annotation.Id = id;
            annotation.Title = title;
            annotation.Type = type;
            annotation.Uri = (uri != string.Empty) ? new Uri(uri) : null;

            foreach (ITextTypeWrapperMutableObject text in texts)
                annotation.AddText(text);

            return annotation;
        }