예제 #1
0
        /// <summary>
        /// Formats the trajectory station data.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="parser">The query parser.</param>
        /// <returns>A collection of formatted trajectory stations.</returns>
        protected virtual List <TChild> FormatStationData(T entity, WitsmlQueryParser parser)
        {
            var returnElements = parser.ReturnElements();
            var stations       = GetTrajectoryStations(entity);

            if (OptionsIn.ReturnElements.All.Equals(returnElements) ||
                OptionsIn.ReturnElements.DataOnly.Equals(returnElements) ||
                !parser.IncludeTrajectoryStations())
            {
                return(stations);
            }

            var stationParser = parser
                                .ForkProperties(ObjectTypes.TrajectoryStation, ObjectTypes.TrajectoryStation)
                                .FirstOrDefault();

            if ((stationParser == null && !OptionsIn.ReturnElements.StationLocationOnly.Equals(returnElements)) ||
                (stationParser != null && !stationParser.HasElements() && !stationParser.Element().HasAttributes))
            {
                return(stations);
            }

            const string prefix = "TrajectoryStation.";

            var fields = GetProjectionPropertyNames(parser)
                         .Where(x => x.StartsWith(prefix))
                         .Select(x => x.Substring(prefix.Length))
                         .ToList();

            var mapper = new DataObjectMapper <TChild>(Container, stationParser, fields);

            return(mapper.Map(stations));
        }
예제 #2
0
        /// <summary>
        /// Adds a data object to the data store.
        /// </summary>
        /// <param name="parser">The input template parser.</param>
        /// <param name="dataObject">The data object to be added.</param>
        public override void Add(WitsmlQueryParser parser, Log dataObject)
        {
            using (var transaction = GetTransaction())
            {
                transaction.SetContext(dataObject.GetUri());

                // Add ChannelSets + data via the ChannelSet data adapter
                foreach (var childParser in parser.ForkProperties("ChannelSet", ObjectTypes.ChannelSet))
                {
                    var channelSet = WitsmlParser.Parse <ChannelSet>(childParser.Root);
                    ChannelSetDataAdapter.Add(childParser, channelSet);
                }

                // Clear ChannelSet data properties
                foreach (var channelSet in dataObject.ChannelSet)
                {
                    channelSet.Data = null;
                }

                InsertEntity(dataObject);

                // Commit transaction
                transaction.Commit();
            }
        }
예제 #3
0
        /// <summary>
        /// Formats the mudlog geology interval data.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="parser">The query parser.</param>
        /// <returns>A collection of formatted mudlog geology intervals.</returns>
        protected virtual List <TChild> FormatGeologyIntervalData(T entity, WitsmlQueryParser parser)
        {
            var returnElements   = parser.ReturnElements();
            var geologyIntervals = GetGeologyIntervals(entity);

            if (OptionsIn.ReturnElements.All.Equals(returnElements) ||
                OptionsIn.ReturnElements.DataOnly.Equals(returnElements) ||
                !parser.IncludeGeologyIntervals())
            {
                return(geologyIntervals);
            }

            var geologyIntervalParser = parser
                                        .ForkProperties(ObjectTypes.GeologyInterval, ObjectTypes.GeologyInterval)
                                        .FirstOrDefault();

            if ((geologyIntervalParser != null && !geologyIntervalParser.HasElements() && !geologyIntervalParser.Element().HasAttributes))
            {
                return(geologyIntervals);
            }

            const string prefix = "GeologyInterval.";

            var fields = GetProjectionPropertyNames(parser)
                         .Where(x => x.StartsWith(prefix))
                         .Select(x => x.Substring(prefix.Length))
                         .ToList();

            var mapper = new DataObjectMapper <TChild>(Container, geologyIntervalParser, fields);

            return(mapper.Map(geologyIntervals));
        }
예제 #4
0
        /// <summary>
        /// Updates a data object in the data store.
        /// </summary>
        /// <param name="parser">The input template parser.</param>
        /// <param name="dataObject">The data object to be updated.</param>
        public override void Update(WitsmlQueryParser parser, Log dataObject)
        {
            // Update ChannelSets + data via the ChannelSet data adapter
            foreach (var childParser in parser.ForkProperties("ChannelSet", ObjectTypes.ChannelSet))
            {
                var channelSet = WitsmlParser.Parse <ChannelSet>(childParser.Root);
                ChannelSetDataAdapter.Update(childParser, channelSet);
            }

            var uri = GetUri(dataObject);

            UpdateEntity(parser, uri);
        }
예제 #5
0
        /// <summary>
        /// Adds a data object to the data store.
        /// </summary>
        /// <param name="parser">The input template parser.</param>
        /// <param name="dataObject">The data object to be added.</param>
        public override void Add(WitsmlQueryParser parser, Log dataObject)
        {
            // Add ChannelSets + data via the ChannelSet data adapter
            foreach (var childParser in parser.ForkProperties("ChannelSet", ObjectTypes.ChannelSet))
            {
                var channelSet = WitsmlParser.Parse <ChannelSet>(childParser.Root);
                ChannelSetDataAdapter.Add(childParser, channelSet);
            }

            // Clear ChannelSet data properties
            foreach (var channelSet in dataObject.ChannelSet)
            {
                channelSet.Data = null;
            }

            InsertEntity(dataObject);
        }
예제 #6
0
        /// <summary>
        /// Updates a data object in the data store.
        /// </summary>
        /// <param name="parser">The input template parser.</param>
        /// <param name="dataObject">The data object to be updated.</param>
        public override void Update(WitsmlQueryParser parser, Log dataObject)
        {
            using (var transaction = GetTransaction())
            {
                transaction.SetContext(dataObject.GetUri());

                // Update ChannelSets + data via the ChannelSet data adapter
                foreach (var childParser in parser.ForkProperties("ChannelSet", ObjectTypes.ChannelSet))
                {
                    var channelSet = WitsmlParser.Parse <ChannelSet>(childParser.Root);
                    ChannelSetDataAdapter.Update(childParser, channelSet);
                }

                var uri = GetUri(dataObject);
                UpdateEntity(parser, uri);

                // Commit transaction
                transaction.Commit();
            }
        }