/// <summary>
 /// Insert a record with the values from <paramref name="annotations"/> to <paramref name="annotationProcedureBase"/>
 ///     for an artifact with the specified
 ///     <paramref name="annotatablePrimaryKey"/>
 /// </summary>
 /// <param name="state">
 /// The mapping store connection and transaction state
 /// </param>
 /// <param name="annotatablePrimaryKey">
 /// The artifact primary key.
 /// </param>
 /// <param name="annotationProcedureBase">
 /// The annotation procedure base.
 /// </param>
 /// <param name="annotations">
 /// The annotations.
 /// </param>
 public void Insert(DbTransactionState state, long annotatablePrimaryKey, AnnotationProcedureBase annotationProcedureBase, IList<IAnnotation> annotations)
 {
     this._decorated.Insert(
         state,
         annotatablePrimaryKey,
         annotationProcedureBase,
         annotations.Where(annotation => !string.Equals(annotation.Title, AnnotationConstant.CodeTimeDimensionTitle)).ToArray());
 }
Example #2
0
 /// <summary>
 /// Insert a record with the values from <paramref name="annotations"/> to <paramref name="annotationProcedureBase"/>
 ///     for an artifact with the specified
 ///     <paramref name="annotatablePrimaryKey"/>
 /// </summary>
 /// <param name="state">
 /// The mapping store connection and transaction state
 /// </param>
 /// <param name="annotatablePrimaryKey">
 /// The artifact primary key.
 /// </param>
 /// <param name="annotationProcedureBase">
 /// The annotation procedure base.
 /// </param>
 /// <param name="annotations">
 /// The annotations.
 /// </param>
 public void Insert(DbTransactionState state, long annotatablePrimaryKey, AnnotationProcedureBase annotationProcedureBase, IList <IAnnotation> annotations)
 {
     this._decorated.Insert(
         state,
         annotatablePrimaryKey,
         annotationProcedureBase,
         annotations.Where(annotation => !string.Equals(annotation.Title, AnnotationConstant.CodeTimeDimensionTitle)).ToArray());
 }
Example #3
0
        /// <summary>
        /// Insert a record with the values from <paramref name="annotations" /> to <paramref name="annotationProcedureBase" /> for an artifact with the specified
        /// <paramref name="annotatablePrimaryKey" />
        /// </summary>
        /// <param name="state">The mapping store connection and transaction state</param>
        /// <param name="annotatablePrimaryKey">The artifact primary key.</param>
        /// <param name="annotationProcedureBase">The annotation procedure base.</param>
        /// <param name="annotations">The annotations.</param>
        public void Insert(DbTransactionState state, long annotatablePrimaryKey, AnnotationProcedureBase annotationProcedureBase, IList <IAnnotation> annotations)
        {
            var count = annotations.Count;

            if (count == 0)
            {
                return;
            }

            var sysIdToAnnotation = new KeyValuePair <long, IAnnotation> [count];

            using (var command = annotationProcedureBase.CreateCommandWithDefaults(state))
            {
                annotationProcedureBase.CreateParentIdParameter(command, annotatablePrimaryKey);
                var outputParameter = annotationProcedureBase.CreateOutputParameter(command);
                for (int i = 0; i < count; i++)
                {
                    var annotation = annotations[i];
                    annotationProcedureBase.CreateIdParameter(command, annotation.Id);
                    annotationProcedureBase.CreateTitleParameter(command, annotation.Title);
                    annotationProcedureBase.CreateTypeParameter(command, annotation.Type);
                    annotationProcedureBase.CreateUriParameter(command, annotation.Uri != null ? annotation.Uri.ToString() : null);
                    command.ExecuteNonQuery();
                    if (annotation.Text.Count > 0)
                    {
                        sysIdToAnnotation[i] = new KeyValuePair <long, IAnnotation>((long)outputParameter.Value, annotation);
                    }
                }
            }

            using (var command = this._annotationText.CreateCommandWithDefaults(state))
            {
                for (int i = 0; i < sysIdToAnnotation.Length; i++)
                {
                    var keyValuePair = sysIdToAnnotation[i];
                    if (!keyValuePair.IsDefault())
                    {
                        this._annotationText.CreateAnnIdParameter(command).Value = keyValuePair.Key;
                        foreach (var textTypeWrapper in keyValuePair.Value.Text)
                        {
                            this._annotationText.CreateLanguageParameter(command).Value = GetLanguage(textTypeWrapper);
                            this._annotationText.CreateTextParameter(command).Value     = textTypeWrapper.Value;
                            command.ExecuteNonQuery();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Insert a record with the values from <paramref name="annotations" /> to <paramref name="annotationProcedureBase" /> for an artifact with the specified
        /// <paramref name="annotatablePrimaryKey" />
        /// </summary>
        /// <param name="state">The mapping store connection and transaction state</param>
        /// <param name="annotatablePrimaryKey">The artifact primary key.</param>
        /// <param name="annotationProcedureBase">The annotation procedure base.</param>
        /// <param name="annotations">The annotations.</param>
        public void Insert(DbTransactionState state, long annotatablePrimaryKey, AnnotationProcedureBase annotationProcedureBase, IList<IAnnotation> annotations)
        {
            var count = annotations.Count;
            if (count == 0)
            {
                return;
            }

            var sysIdToAnnotation = new KeyValuePair<long, IAnnotation>[count];
            using (var command = annotationProcedureBase.CreateCommandWithDefaults(state))
            {
                annotationProcedureBase.CreateParentIdParameter(command, annotatablePrimaryKey);
                var outputParameter = annotationProcedureBase.CreateOutputParameter(command);
                for (int i = 0; i < count; i++)
                {
                    var annotation = annotations[i];
                    annotationProcedureBase.CreateIdParameter(command, annotation.Id);
                    annotationProcedureBase.CreateTitleParameter(command, annotation.Title);
                    annotationProcedureBase.CreateTypeParameter(command, annotation.Type);
                    annotationProcedureBase.CreateUriParameter(command, annotation.Uri != null ? annotation.Uri.ToString() : null);
                    command.ExecuteNonQuery();
                    if (annotation.Text.Count > 0)
                    {
                        sysIdToAnnotation[i] = new KeyValuePair<long, IAnnotation>((long)outputParameter.Value, annotation);
                    }
                }
            }

            using (var command = this._annotationText.CreateCommandWithDefaults(state))
            {
                for (int i = 0; i < sysIdToAnnotation.Length; i++)
                {
                    var keyValuePair = sysIdToAnnotation[i];
                    if (!keyValuePair.IsDefault())
                    {
                        this._annotationText.CreateAnnIdParameter(command).Value = keyValuePair.Key;
                        foreach (var textTypeWrapper in keyValuePair.Value.Text)
                        {
                            this._annotationText.CreateLanguageParameter(command).Value = GetLanguage(textTypeWrapper);
                            this._annotationText.CreateTextParameter(command).Value = textTypeWrapper.Value;
                            command.ExecuteNonQuery();
                        }
                    }
                }
            }
        }