private void GetResources <T>(IEtpAdapter etpAdapter, string uri, IList <T> resources, out string serverSortOrder) where T : IResource { // Default to Name in IResource serverSortOrder = ObjectTypes.NameProperty; if (EtpUris.IsRootUri(uri)) { var childCount = CreateFoldersByObjectType(etpAdapter, EtpUris.Eml210).Count; resources.Add(etpAdapter.NewProtocol(EtpUris.Eml210, "EML Common (2.1)", childCount)); return; } var etpUri = new EtpUri(uri); var parentUri = etpUri.Parent; // Append query string, if any if (!string.IsNullOrWhiteSpace(etpUri.Query)) { parentUri = new EtpUri(parentUri + etpUri.Query); } if (!etpUri.IsRelatedTo(EtpUris.Eml210)) { return; } if (etpUri.IsBaseUri) { CreateFoldersByObjectType(etpAdapter, etpUri) .ForEach(resources.Add); } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId)) { var objectType = ObjectTypes.GetObjectType(etpUri.ObjectType, etpUri.Family, etpUri.Version); var contentType = EtpContentTypes.GetContentType(objectType); var hasChildren = contentType.IsRelatedTo(EtpContentTypes.Eml210) ? 0 : -1; var dataProvider = GetDataProvider(etpUri.ObjectType); serverSortOrder = dataProvider.ServerSortOrder; dataProvider .GetAll(parentUri) .Cast <AbstractObject>() .ForEach(x => resources.Add(ToResource(etpAdapter, x, parentUri, hasChildren))); } //else //{ // var propertyName = uri.ObjectType.ToPascalCase(); // // CreateFoldersByObjectType(uri, propertyName) // .ForEach(resources.Add); //} }
private IIndexMetadataRecord ToIndexMetadataRecord(IEtpAdapter etpAdapter, Trajectory entity, int scale = 3) { var metadata = etpAdapter.CreateIndexMetadata( uri: entity.GetUri().Append("md"), isTimeIndex: false, isIncreasing: true); metadata.Mnemonic = "MD"; metadata.Description = LogIndexType.measureddepth.GetName(); metadata.Uom = Units.GetUnit(entity.MDMin?.Uom.ToString()); metadata.Scale = scale; return(metadata); }
private IIndexMetadataRecord ToIndexMetadataRecord(IEtpAdapter etpAdapter, Channel entity, ChannelIndex indexChannel, int scale = 3) { var metadata = etpAdapter.CreateIndexMetadata( uri: indexChannel.GetUri(entity), isTimeIndex: indexChannel.IsTimeIndex(true), isIncreasing: indexChannel.IsIncreasing()); metadata.Mnemonic = indexChannel.Mnemonic; metadata.Description = indexChannel.Mnemonic; metadata.Uom = Units.GetUnit(indexChannel.Uom); metadata.Scale = scale; return(metadata); }
private IList <IChannelMetadataRecord> GetChannelMetadataForAnEntity(IEtpAdapter etpAdapter, Trajectory entity, params EtpUri[] uris) { var metadata = new List <IChannelMetadataRecord>(); // Get Index Metadata var indexMetadata = ToIndexMetadataRecord(etpAdapter, entity); // Get Channel Metadata var channel = ToChannelMetadataRecord(etpAdapter, entity, indexMetadata); metadata.Add(channel); return(metadata); }
/// <summary> /// Converts a logCurveInfo to an index metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="entity">The entity.</param> /// <param name="indexCurve">The index curve.</param> /// <param name="scale">The scale.</param> /// <returns></returns> protected override IIndexMetadataRecord ToIndexMetadataRecord(IEtpAdapter etpAdapter, Log entity, LogCurveInfo indexCurve, int scale = 3) { var metadata = etpAdapter.CreateIndexMetadata( uri: indexCurve.GetUri(entity), isTimeIndex: IsTimeLog(entity, true), isIncreasing: IsIncreasing(entity)); metadata.Mnemonic = indexCurve.Mnemonic; metadata.Description = indexCurve.CurveDescription; metadata.Uom = Units.GetUnit(indexCurve.Unit); metadata.Scale = scale; return(metadata); }
private void FindObjects(IEtpAdapter etpAdapter, string uri, IList <Etp12.Datatypes.Object.DataObject> context) { var etpUri = new EtpUri(uri); var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.GetDataSchemaVersion())); foreach (var result in dataAdapter.GetAll(etpUri)) { var entity = result as Witsml200.AbstractObject; var lastChanged = (entity?.Citation.LastUpdate).ToUnixTimeMicroseconds().GetValueOrDefault(); var dataObject = new Etp12.Datatypes.Object.DataObject(); etpAdapter.SetDataObject(dataObject, entity, etpUri, GetName(entity), lastChanged: lastChanged); context.Add(dataObject); } }
private void FindObjects(IEtpAdapter etpAdapter, string uri, IList <Etp12.Datatypes.Object.DataObject> context) { var etpUri = new EtpUri(uri); var dataAdapter = Container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.Version)); foreach (var result in dataAdapter.GetAll(etpUri)) { var entity = result as IDataObject; var list = GetList(entity, etpUri); var dataObject = new Etp12.Datatypes.Object.DataObject(); etpAdapter.SetDataObject(dataObject, list, etpUri, GetName(entity), lastChanged: GetLastChanged(entity)); context.Add(dataObject); } }
private static IDataObject ToDataObject(IEtpAdapter etpAdapter, Trajectory entity, TrajectoryStation trajectoryStation) { var dataObject = etpAdapter.CreateDataObject(); if (entity == null || trajectoryStation == null) { return(dataObject); } var uri = entity.GetUri(); var childUri = uri.Append(ObjectTypes.TrajectoryStation, trajectoryStation.Uid); etpAdapter.SetDataObject(dataObject, trajectoryStation, childUri, entity.Citation.Title, 0, compress: false); return(dataObject); }
/// <summary> /// Returns the specified indexValue as an object of the correct type. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index metadata.</param> /// <param name="indexValue">The index value.</param> /// <returns> /// <c>true</c> if the index is increasing; otherwise, <c>false</c>. /// </returns> public static object GetIndexValue(this IEtpAdapter etpAdapter, IIndexMetadataRecord index, long?indexValue) { if (index == null) { return(string.Empty); } var value = indexValue ?? 0; if (etpAdapter.SupportedVersion == EtpVersion.v11 || etpAdapter.IsTimeIndex(index)) { return(value); } return((double)value); }
/// <summary> /// Returns the specified indexValue as an object of the correct type. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="index">The index metadata.</param> /// <param name="indexValue">The index value.</param> /// <returns> /// <c>true</c> if the index is increasing; otherwise, <c>false</c>. /// </returns> public static object GetIndexValue(this IEtpAdapter etpAdapter, IIndexMetadataRecord index, long?indexValue) { if (index == null) { return(string.Empty); } var value = indexValue ?? 0; if (etpAdapter is Energistics.Etp.v11.Etp11Adapter || etpAdapter.IsTimeIndex(index)) { return(value); } return((double)value); }
private void GetResources <T>(IEtpAdapter etpAdapter, string uri, IList <T> resources) where T : IResource { if (EtpUris.IsRootUri(uri)) { // NOTE: This entry added by the Witsml200Provider so that it appears at the end of the list //resources.Add(etpAdapter.NewProtocol(EtpUris.Eml210, "EML Common (2.1)")); return; } var etpUri = new EtpUri(uri); var parentUri = etpUri.Parent; // Append query string, if any if (!string.IsNullOrWhiteSpace(etpUri.Query)) { parentUri = new EtpUri(parentUri + etpUri.Query); } if (!etpUri.IsRelatedTo(EtpUris.Eml210)) { return; } if (etpUri.IsBaseUri) { CreateFoldersByObjectType(etpAdapter, etpUri) .ForEach(resources.Add); } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId)) { var objectType = ObjectTypes.GetObjectType(etpUri.ObjectType, etpUri.Version); var contentType = EtpContentTypes.GetContentType(objectType); var hasChildren = contentType.IsRelatedTo(EtpContentTypes.Eml210) ? 0 : -1; var dataProvider = GetDataProvider(etpUri.ObjectType); dataProvider .GetAll(parentUri) .Cast <AbstractObject>() .ForEach(x => resources.Add(ToResource(etpAdapter, x, hasChildren))); } //else //{ // var propertyName = uri.ObjectType.ToPascalCase(); // // CreateFoldersByObjectType(uri, propertyName) // .ForEach(resources.Add); //} }
/// <summary> /// Sets the properties of the <see cref="IDataObject" /> instance. /// </summary> /// <typeparam name="T">The type of entity.</typeparam> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="dataObject">The data object.</param> /// <param name="entity">The entity.</param> /// <param name="uri">The URI.</param> /// <param name="name">The name.</param> /// <param name="childCount">The child count.</param> /// <param name="lastChanged">The last changed in microseconds.</param> /// <param name="compress">if set to <c>true</c> compress the data object.</param> public static void SetDataObject <T>(this IEtpAdapter etpAdapter, IDataObject dataObject, T entity, EtpUri uri, string name, int childCount = -1, long lastChanged = 0, bool compress = true) { // There's nothing to set if the data object is null if (dataObject == null) { return; } if (etpAdapter.SupportedVersion == EtpVersion.v11) { Store11StoreProvider.SetDataObject(dataObject, entity, uri, name, childCount, lastChanged, compress); } else { Store12StoreProvider.SetDataObject(dataObject, entity, uri, name, childCount, lastChanged); } }
/// <summary> /// Merges a sequence of channel streaming contexts based on interval ranges. /// </summary> /// <param name="adapter">The ETP adapter.</param> /// <param name="contexts">The channel streaming contexts.</param> /// <returns>Sequence of non-overlapping contexts.</returns> public static IEnumerable <ChannelStreamingContext> MergeOverlappingContexts(this IEtpAdapter adapter, IEnumerable <ChannelStreamingContext> contexts) { var intervalList = contexts.ToList(); if (!intervalList.Any()) { yield break; } var isIncreasing = adapter.IsIncreasing(intervalList[0].ChannelMetadata.Indexes[0] as IIndexMetadataRecord); var orderedIntervals = isIncreasing ? intervalList.OrderBy(x => x.StartIndex) : intervalList.OrderByDescending(x => x.StartIndex); var accumulator = orderedIntervals.First(); contexts = orderedIntervals.Skip(1); foreach (var context in contexts) { var accumulatorRange = new Range <double?>(accumulator.StartIndex, accumulator.EndIndex); var intervalRange = new Range <double?>(context.StartIndex, context.EndIndex); if (accumulatorRange.Overlaps(intervalRange, isIncreasing)) { if (!accumulatorRange.End.HasValue || !intervalRange.End.HasValue) { accumulator.EndIndex = null; } else { accumulator.EndIndex = (long?)new List <Range <double?> >() { accumulatorRange, intervalRange }.GetMaxRangeEnd(isIncreasing); } } else { yield return(accumulator); accumulator = context; } } yield return(accumulator); }
/// <summary> /// Casts a list of data attributes to the correct type /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="dataAttributes">The data attributes.</param> /// <returns> /// A new <see cref="IDataObject" /> instance. /// </returns> public static IList ToDataAttributes(this IEtpAdapter etpAdapter, IList dataAttributes) { var castedDataAttribtes = new List <IDataAttribute>(); foreach (var dataAttribute in dataAttributes) { if (etpAdapter is Energistics.Etp.v11.Etp11Adapter) { castedDataAttribtes.Add(dataAttribute as Energistics.Etp.v11.Datatypes.DataAttribute); } else { castedDataAttribtes.Add(dataAttribute as Energistics.Etp.v12.Datatypes.DataAttribute); } } return(castedDataAttribtes); }
/// <summary> /// Gets the channel metadata for the specified data object URI. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="uris">The parent data object URI.</param> /// <returns>A collection of channel metadata.</returns> public IList <IChannelMetadataRecord> GetChannelMetadata(IEtpAdapter etpAdapter, params EtpUri[] uris) { var metaDatas = new List <IChannelMetadataRecord>(); if (uris == null) { return(metaDatas); } var entities = GetChannelSetByUris(uris.ToList()); foreach (var entity in entities) { metaDatas.AddRange(GetChannelMetadataForAnEntity(etpAdapter, entity, uris)); } return(metaDatas); }
/// <summary> /// Gets the channels metadata. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="uris">The collection of URI to describe.</param> /// <returns>A collection of channel metadata.</returns> public IList <IChannelMetadataRecord> GetChannelMetadata(IEtpAdapter etpAdapter, params EtpUri[] uris) { var metadatas = new List <IChannelMetadataRecord>(); var channels = GetChannelsByUris(uris); foreach (var channel in channels) { Logger.Debug($"Getting channel metadata for URI: {channel.GetUri()}"); var indexMetadata = channel.Index .Select(x => ToIndexMetadataRecord(etpAdapter, channel, x)) .ToList(); metadatas.Add(ToChannelMetadataRecord(etpAdapter, channel, indexMetadata)); } return(metadatas); }
private IResource ToResource(IEtpAdapter etpAdapter, AbstractObject entity, EtpUri parentUri, int hasChildren = -1) { var name = entity.Citation.Title; var channel = entity as Channel; if (channel != null) { name = $"{name} ({channel.Mnemonic})"; } return(etpAdapter.CreateResource( uuid: entity.Uuid, uri: entity.GetUri(parentUri), resourceType: ResourceTypes.DataObject, name: name, count: hasChildren, lastChanged: entity.GetLastChangedMicroseconds())); }
/// <summary> /// Creates a new <see cref="IDataItem"/> instance using the specified parameters. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="channelId">The channel identifier.</param> /// <param name="value">The channel data value.</param> /// <param name="indexes">The channel index values.</param> /// <param name="attributes">The data attributes.</param> /// <returns>A new <see cref="IDataItem"/> instance.</returns> public static IDataItem CreateDataItem(this IEtpAdapter etpAdapter, long channelId, object value = null, IList <object> indexes = null, IList <object> attributes = null) { if (etpAdapter.SupportedVersion == EtpVersion.v11) { return(new Energistics.Etp.v11.Datatypes.ChannelData.DataItem { ChannelId = channelId, Indexes = indexes?.Cast <long>().ToArray() ?? new long[0], Value = new Energistics.Etp.v11.Datatypes.DataValue { Item = value }, ValueAttributes = attributes? .Select((x, i) => new Energistics.Etp.v11.Datatypes.DataAttribute { AttributeId = i, AttributeValue = new Energistics.Etp.v11.Datatypes.DataValue { Item = x } }) .ToArray() ?? new Energistics.Etp.v11.Datatypes.DataAttribute[0] }); } return(new Energistics.Etp.v12.Datatypes.ChannelData.DataItem { ChannelId = channelId, Indexes = indexes?.Select(i => new Energistics.Etp.v12.Datatypes.IndexValue { Item = i }).ToList() ?? new List <Energistics.Etp.v12.Datatypes.IndexValue>(), Value = new Energistics.Etp.v12.Datatypes.DataValue { Item = value }, ValueAttributes = attributes? .Select((x, i) => new Energistics.Etp.v12.Datatypes.DataAttribute { AttributeId = i, AttributeValue = new Energistics.Etp.v12.Datatypes.DataValue { Item = x } }) .ToArray() ?? new Energistics.Etp.v12.Datatypes.DataAttribute[0] }); }
/// <summary> /// Creates a new <see cref="IDataItem"/> instance using the specified parameters. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="channelId">The channel identifier.</param> /// <param name="value">The channel data value.</param> /// <param name="indexes">The channel index values.</param> /// <param name="attributes">The data attributes.</param> /// <returns>A new <see cref="IDataItem"/> instance.</returns> public static IDataItem CreateDataItem(this IEtpAdapter etpAdapter, long channelId = 0, object value = null, IList <long> indexes = null, IList <object> attributes = null) { if (etpAdapter is Energistics.Etp.v11.Etp11Adapter) { return(new Energistics.Etp.v11.Datatypes.ChannelData.DataItem { ChannelId = channelId, Indexes = indexes?.ToArray() ?? new long[0], Value = new Energistics.Etp.v11.Datatypes.DataValue { Item = value }, ValueAttributes = attributes? .Select((x, i) => new Energistics.Etp.v11.Datatypes.DataAttribute { AttributeId = i, AttributeValue = new Energistics.Etp.v11.Datatypes.DataValue { Item = x } }) .ToArray() ?? new Energistics.Etp.v11.Datatypes.DataAttribute[0] }); } return(new Energistics.Etp.v12.Datatypes.ChannelData.DataItem { ChannelId = channelId, Indexes = indexes?.ToArray() ?? new long[0], Value = new Energistics.Etp.v12.Datatypes.DataValue { Item = value }, ValueAttributes = attributes? .Select((x, i) => new Energistics.Etp.v12.Datatypes.DataAttribute { AttributeId = i, AttributeValue = new Energistics.Etp.v12.Datatypes.DataValue { Item = x } }) .ToArray() ?? new Energistics.Etp.v12.Datatypes.DataAttribute[0] }); }
/// <summary> /// Creates a new channel metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="uri">The URI.</param> /// <returns>A new <see cref="IChannelMetadataRecord"/> instance.</returns> public static IChannelMetadataRecord CreateChannelMetadata(this IEtpAdapter etpAdapter, EtpUri?uri = null) { if (etpAdapter is Energistics.Etp.v11.Etp11Adapter) { return(new Energistics.Etp.v11.Datatypes.ChannelData.ChannelMetadataRecord { ChannelUri = uri?.ToString(), ContentType = uri?.ContentType.ToString(), Status = Energistics.Etp.v11.Datatypes.ChannelData.ChannelStatuses.Active, CustomData = new Dictionary <string, Energistics.Etp.v11.Datatypes.DataValue>() }); } return(new Energistics.Etp.v12.Datatypes.ChannelData.ChannelMetadataRecord { ChannelUri = uri?.ToString(), ContentType = uri?.ContentType.ToString(), Status = Energistics.Etp.v12.Datatypes.ChannelData.ChannelStatuses.Active, AttributeMetadata = new List <Energistics.Etp.v12.Datatypes.AttributeMetadataRecord>(), CustomData = new Dictionary <string, Energistics.Etp.v12.Datatypes.DataValue>() }); }
/// <summary> /// Creates a new channel metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="messageId">The message identifier.</param> /// <returns>A new <see cref="IMessageHeader" /> instance.</returns> public static IMessageHeader CreateChannelMetadataHeader(this IEtpAdapter etpAdapter, long messageId = 0) { if (etpAdapter is Energistics.Etp.v11.Etp11Adapter) { return(new Energistics.Etp.v11.Datatypes.MessageHeader { MessageId = messageId, Protocol = (int)Energistics.Etp.v11.Protocols.ChannelStreaming, MessageType = (int)Energistics.Etp.v11.MessageTypes.ChannelStreaming.ChannelMetadata, MessageFlags = (int)MessageFlags.None, CorrelationId = 0 }); } return(new Energistics.Etp.v11.Datatypes.MessageHeader { MessageId = messageId, Protocol = (int)Energistics.Etp.v12.Protocols.ChannelStreaming, MessageType = (int)Energistics.Etp.v12.MessageTypes.ChannelStreaming.ChannelMetadata, MessageFlags = (int)MessageFlags.None, CorrelationId = 0 }); }
/// <summary> /// Creates a new channel metadata record. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="uri">The URI.</param> /// <returns>A new <see cref="IChannelMetadataRecord"/> instance.</returns> public static IChannelMetadataRecord CreateChannelMetadata(this IEtpAdapter etpAdapter, EtpUri?uri = null) { if (etpAdapter.SupportedVersion == EtpVersion.v11) { return(new Energistics.Etp.v11.Datatypes.ChannelData.ChannelMetadataRecord { ChannelUri = uri?.ToString(), ContentType = uri?.ContentType.ToString(), Status = Energistics.Etp.v11.Datatypes.ChannelData.ChannelStatuses.Active, CustomData = new Dictionary <string, Energistics.Etp.v11.Datatypes.DataValue>() }); } return(new Energistics.Etp.v12.Datatypes.ChannelData.ChannelMetadataRecord { ChannelUri = uri?.ToString(), ContentType = uri?.ContentType.ToString(), Status = Energistics.Etp.v12.Datatypes.ChannelData.ChannelStatusKind.Active, AttributeMetadata = new List <Energistics.Etp.v12.Datatypes.AttributeMetadataRecord>(), CustomData = new Dictionary <string, Energistics.Etp.v12.Datatypes.DataValue>(), AxisVectorLengths = new List <int>() }); }
private IList <IChannelMetadataRecord> GetChannelMetadataForAnEntity(IEtpAdapter etpAdapter, ChannelSet entity, params EtpUri[] uris) { var metadata = new List <IChannelMetadataRecord>(); var index = 0; if (entity.Channel == null || !entity.Channel.Any()) { return(metadata); } var indexMetadata = entity.Index .Select(x => ToIndexMetadataRecord(etpAdapter, entity, x)) .ToList(); metadata.AddRange(entity.Channel.Where(c => IsChannelMetaDataRequested(c.GetUri(entity), uris)).Select(x => { var channel = ToChannelMetadataRecord(etpAdapter, entity, x, indexMetadata); channel.ChannelId = index++; return(channel); })); return(metadata); }
/// <summary> /// Gets a list of protocols supported by the specified <see cref="IProtocolHandler"/>s. /// </summary> /// <param name="adapter">The ETP adapter.</param> /// <param name="handlers">The <see cref="IProtocolHandler"/>s.</param> /// <param name="isClient">Whether the client or server roles should be checked in the protocol handlers.</param> /// <returns>The list of supported protocols.</returns> public static IList <ISupportedProtocol> GetSupportedProtocols(this IEtpAdapter adapter, IEnumerable <IProtocolHandler> handlers, bool isClient) { var supportedProtocols = new List <ISupportedProtocol>(); // Skip Core protocol (0) foreach (var handler in handlers.Where(x => x.Protocol > 0)) { var role = isClient ? handler.RequestedRole : handler.Role; if (supportedProtocols.Contains(handler.Protocol, role)) { continue; } var supportedProtocol = adapter.GetSupportedProtocol(handler, role); if (supportedProtocol != null) { supportedProtocols.Add(supportedProtocol); } } return(supportedProtocols); }
/// <summary> /// Puts the growing part for a growing object. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="uri">The growing obejct's URI.</param> /// <param name="contentType">Type of the content.</param> /// <param name="data">The data.</param> public override void PutGrowingPart(IEtpAdapter etpAdapter, EtpUri uri, string contentType, byte[] data) { var dataObject = etpAdapter.CreateDataObject(); dataObject.Data = data; // Convert byte array to TrajectoryStation var trajectoryStationXml = dataObject.GetString(); var tsDocument = WitsmlParser.Parse(trajectoryStationXml); var trajectoryStation = WitsmlParser.Parse <TrajectoryStation>(tsDocument.Root); // Merge TrajectoryStation into the Trajectory if it is not null if (trajectoryStation != null) { // Get the Trajectory for the uri var entity = GetEntity(uri); entity.TrajectoryStation = trajectoryStation.AsList(); var document = WitsmlParser.Parse(WitsmlParser.ToXml(entity)); var parser = new WitsmlQueryParser(document.Root, ObjectTypes.GetObjectType <Trajectory>(), null); UpdateTrajectoryWithStations(parser, entity, uri, true); } }
/// <summary> /// Gets the object details for the specified URI. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param> public void FindObjects(IEtpAdapter etpAdapter, ProtocolEventArgs <Etp12.Protocol.StoreQuery.FindObjects, IList <Etp12.Datatypes.Object.DataObject> > args) { FindObjects(etpAdapter, args.Message.Uri, args.Context); }
/// <summary> /// Gets the object details for the specified URI. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="args">The <see cref="ProtocolEventArgs{GetObject, DataObject}" /> instance containing the event data.</param> public void GetObject(IEtpAdapter etpAdapter, ProtocolEventArgs <Etp12.Protocol.Store.GetObject, Etp12.Datatypes.Object.DataObject> args) { GetObject(etpAdapter, args.Message.Uri, args.Context); }
/// <summary> /// Gets a collection of resources associated to the specified URI. /// </summary> /// <param name="etpAdapter">The ETP adapter.</param> /// <param name="args">The <see cref="ProtocolEventArgs{GetResources, IList}" /> instance containing the event data.</param> public void GetResources(IEtpAdapter etpAdapter, ProtocolEventArgs <Etp11.Protocol.Discovery.GetResources, IList <Etp11.Datatypes.Object.Resource> > args) { string serverSortOrder; GetResources(etpAdapter, args.Message.Uri, args.Context, out serverSortOrder); }
private IList <IResource> CreateFoldersByObjectType(IEtpAdapter etpAdapter, EtpUri uri, string propertyName = null, string additionalObjectType = null, int childCount = 0, bool skipChildCount = false) { if (!_contentTypes.Any()) { lock (_contentTypesLock) { if (!_contentTypes.Any()) { var contentTypes = new List <EtpContentType>(); Providers.ForEach(x => x.GetSupportedObjects(contentTypes)); _contentTypes = contentTypes .Where(x => x.IsRelatedTo(EtpContentTypes.Eml210) || x.IsRelatedTo(EtpContentTypes.Witsml200)) .OrderBy(x => x.ObjectType) .ToList(); } } } return(_contentTypes .Select(x => new { ContentType = x, DataType = ObjectTypes.GetObjectType(x.ObjectType, x.Family, DataSchemaVersion) }) .Select(x => new { x.ContentType, x.DataType, PropertyInfo = string.IsNullOrWhiteSpace(propertyName) ? null : x.DataType.GetProperty(propertyName), ReferenceInfo = x.DataType.GetProperties().FirstOrDefault(p => p.PropertyType == typeof(DataObjectReference)) }) .Where(x => { // Top level folders if (string.IsNullOrWhiteSpace(uri.ObjectId) || string.IsNullOrWhiteSpace(propertyName)) { return x.ContentType.IsRelatedTo(EtpContentTypes.Witsml200); // || x.ReferenceInfo == null; } // Fix for child data object references being treated as parent references if (ObjectTypes.IsChildObjectReference(x.ContentType, propertyName)) { return false; } // Data object sub folders, e.g. Well and Wellbore return (x.ContentType.IsRelatedTo(EtpContentTypes.Eml210) && x.ReferenceInfo != null) || x.PropertyInfo?.PropertyType == typeof(DataObjectReference) || x.ContentType.ObjectType.EqualsIgnoreCase(additionalObjectType) || ObjectTypes.IsDecoratorObject(x.ContentType.ObjectType); }) .Select(x => { var folderName = ObjectTypes.SingleToPlural(x.ContentType.ObjectType, false).ToPascalCase(); var dataProvider = GetDataProvider(x.ContentType.ObjectType); var hasChildren = childCount; // Query for child object count if this is not the specified "additionalObjectType" if (!skipChildCount && !x.ContentType.ObjectType.EqualsIgnoreCase(additionalObjectType)) { hasChildren = dataProvider.Count(uri); } return etpAdapter.NewFolder(uri, x.ContentType, folderName, hasChildren); }) .ToList()); }
private void GetResources <T>(IEtpAdapter etpAdapter, string uri, IList <T> resources, out string serverSortOrder) where T : IResource { // Default to Name in IResource serverSortOrder = ObjectTypes.NameProperty; var etpUri = new EtpUri(uri); var parentUri = etpUri.Parent; if (EtpUris.IsRootUri(uri)) { resources.Add(etpAdapter.NewProtocol(EtpUris.Witsml131, "WITSML Store (1.3.1.1)", _wellDataProvider.Count(etpUri))); return; } // Append query string, if any if (!string.IsNullOrWhiteSpace(etpUri.Query)) { parentUri = new EtpUri(parentUri + etpUri.Query); } if (!etpUri.IsRelatedTo(EtpUris.Witsml131)) { return; } if (etpUri.IsBaseUri || (string.IsNullOrWhiteSpace(etpUri.ObjectId) && ObjectTypes.Well.EqualsIgnoreCase(etpUri.ObjectType))) { _wellDataProvider.GetAll(etpUri) .ForEach(x => resources.Add(ToResource(etpAdapter, x))); serverSortOrder = _wellDataProvider.ServerSortOrder; } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId) && ObjectTypes.Wellbore.EqualsIgnoreCase(parentUri.ObjectType)) { var dataProvider = _container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.Version)); serverSortOrder = dataProvider.ServerSortOrder; dataProvider .GetAll(parentUri) .Cast <IWellboreObject>() .ForEach(x => resources.Add(ToResource(etpAdapter, x))); } else if (ObjectTypes.Well.EqualsIgnoreCase(etpUri.ObjectType)) { _wellboreDataProvider.GetAll(etpUri) .ForEach(x => resources.Add(ToResource(etpAdapter, x))); serverSortOrder = _wellboreDataProvider.ServerSortOrder; } else if (ObjectTypes.Wellbore.EqualsIgnoreCase(etpUri.ObjectType)) { foreach (var adapter in GetWellboreDataAdapters()) { var type = EtpContentTypes.GetContentType(adapter.DataObjectType); var count = adapter.Count(etpUri); resources.Add(etpAdapter.NewFolder(etpUri, type, type.ObjectType, count)); } } else if (ObjectTypes.Log.EqualsIgnoreCase(etpUri.ObjectType)) { var log = _logDataProvider.Get(etpUri); log?.LogCurveInfo?.ForEach(x => resources.Add(ToResource(etpAdapter, log, x))); serverSortOrder = string.Empty; } }