/// <summary> /// Gets a collection of resources associated to the specified URI. /// </summary> /// <param name="args">The <see cref="ProtocolEventArgs{GetResources, IList}"/> instance containing the event data.</param> public void GetResources(ProtocolEventArgs <GetResources, IList <Resource> > args) { if (EtpUris.IsRootUri(args.Message.Uri)) { args.Context.Add(DiscoveryStoreProvider.NewProtocol(EtpUris.Witsml131, "WITSML Store (1.3.1.1)")); return; } var uri = new EtpUri(args.Message.Uri); var parentUri = uri.Parent; // Append query string, if any if (!string.IsNullOrWhiteSpace(uri.Query)) { parentUri = new EtpUri(parentUri + uri.Query); } if (!uri.IsRelatedTo(EtpUris.Witsml131)) { return; } if (uri.IsBaseUri || (string.IsNullOrWhiteSpace(uri.ObjectId) && ObjectTypes.Well.EqualsIgnoreCase(uri.ObjectType))) { _wellDataProvider.GetAll(uri) .ForEach(x => args.Context.Add(ToResource(x))); } else if (string.IsNullOrWhiteSpace(uri.ObjectId) && ObjectTypes.Wellbore.EqualsIgnoreCase(parentUri.ObjectType)) { var dataProvider = _container.Resolve <IEtpDataProvider>(new ObjectName(uri.ObjectType, uri.Version)); dataProvider .GetAll(parentUri) .Cast <IWellboreObject>() .ForEach(x => args.Context.Add(ToResource(x))); } else if (ObjectTypes.Well.EqualsIgnoreCase(uri.ObjectType)) { _wellboreDataProvider.GetAll(uri) .ForEach(x => args.Context.Add(ToResource(x))); } else if (ObjectTypes.Wellbore.EqualsIgnoreCase(uri.ObjectType)) { var wellboreObjectType = typeof(IWellboreObject); Providers .OfType <IWitsmlDataAdapter>() .Where(x => wellboreObjectType.IsAssignableFrom(x.DataObjectType)) .Select(x => EtpContentTypes.GetContentType(x.DataObjectType)) .OrderBy(x => x.ObjectType) .ForEach(x => args.Context.Add(DiscoveryStoreProvider.NewFolder(uri, x, x.ObjectType))); } else if (ObjectTypes.Log.EqualsIgnoreCase(uri.ObjectType)) { var log = _logDataProvider.Get(uri); log?.LogCurveInfo?.ForEach(x => args.Context.Add(ToResource(log, x))); } }
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); //} }
/// <summary> /// Gets a collection of resources associated to the specified URI. /// </summary> /// <param name="args">The <see cref="ProtocolEventArgs{GetResources, IList}"/> instance containing the event data.</param> public void GetResources(ProtocolEventArgs <GetResources, IList <Resource> > args) { if (EtpUris.IsRootUri(args.Message.Uri)) { // NOTE: This entry added by the Witsml200Provider so that it appears at the end of the list //args.Context.Add(DiscoveryStoreProvider.NewProtocol(EtpUris.Eml210, "EML Common (2.1)")); return; } var uri = new EtpUri(args.Message.Uri); var parentUri = uri.Parent; // Append query string, if any if (!string.IsNullOrWhiteSpace(uri.Query)) { parentUri = new EtpUri(parentUri + uri.Query); } if (!uri.IsRelatedTo(EtpUris.Eml210)) { return; } if (uri.IsBaseUri) { CreateFoldersByObjectType(uri) .ForEach(args.Context.Add); } else if (string.IsNullOrWhiteSpace(uri.ObjectId)) { var objectType = ObjectTypes.GetObjectType(uri.ObjectType, uri.Version); var contentType = EtpContentTypes.GetContentType(objectType); var hasChildren = contentType.IsRelatedTo(EtpContentTypes.Eml210) ? 0 : -1; var dataProvider = GetDataProvider(uri.ObjectType); dataProvider .GetAll(parentUri) .Cast <AbstractObject>() .ForEach(x => args.Context.Add(ToResource(x, hasChildren))); } //else //{ // var propertyName = uri.ObjectType.ToPascalCase(); // // CreateFoldersByObjectType(uri, propertyName) // .ForEach(args.Context.Add); //} }
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); //} }
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; } }
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.Witsml200, skipChildCount: true).Count; resources.Add(etpAdapter.NewProtocol(EtpUris.Witsml200, "WITSML Store (2.0)", 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.Witsml200) || !IsValidUri(etpUri)) { return; } if (etpUri.IsBaseUri) { CreateFoldersByObjectType(etpAdapter, etpUri) .ForEach(resources.Add); } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId)) { var isChannelDataAdapterEnabled = WitsmlSettings.IsChannelDataAdapterEnabled; if (!isChannelDataAdapterEnabled && ObjectTypes.ChannelSet.EqualsIgnoreCase(etpUri.ObjectType) && ObjectTypes.Log.EqualsIgnoreCase(parentUri.ObjectType)) { var log = _logDataProvider.Get(parentUri); log?.ChannelSet?.OrderBy(x => x.Citation.Title).ForEach(x => resources.Add(ToResource(etpAdapter, x, parentUri))); serverSortOrder = _channelSetDataProvider.ServerSortOrder; } else if (!isChannelDataAdapterEnabled && ObjectTypes.Channel.EqualsIgnoreCase(etpUri.ObjectType) && ObjectTypes.ChannelSet.EqualsIgnoreCase(parentUri.ObjectType)) { var set = _channelSetDataProvider.Get(parentUri); set?.Channel?.OrderBy(x => x.Citation.Title).ForEach(x => resources.Add(ToResource(etpAdapter, x, parentUri))); serverSortOrder = _channelSetDataProvider.ServerSortOrder; } else { 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 if (ObjectTypes.Log.EqualsIgnoreCase(etpUri.ObjectType)) { var log = _logDataProvider.Get(etpUri); var hasChildren = log?.ChannelSet?.Count ?? 0; CreateFoldersByObjectType(etpAdapter, etpUri, "Log", ObjectTypes.ChannelSet, hasChildren) .ForEach(resources.Add); } else if (ObjectTypes.ChannelSet.EqualsIgnoreCase(etpUri.ObjectType)) { var set = _channelSetDataProvider.Get(etpUri); var hasChildren = set?.Channel?.Count ?? 0; CreateFoldersByObjectType(etpAdapter, etpUri, "ChannelSet", ObjectTypes.Channel, hasChildren) .ForEach(resources.Add); } else if (ObjectTypes.WellboreGeology.EqualsIgnoreCase(etpUri.ObjectType)) { const int childCount = 0; resources.Add(etpAdapter.NewFolder(etpUri, EtpContentTypes.GetContentType(typeof(CuttingsGeology)), ObjectTypes.CuttingsGeology.ToPascalCase(), childCount)); resources.Add(etpAdapter.NewFolder(etpUri, EtpContentTypes.GetContentType(typeof(InterpretedGeology)), ObjectTypes.InterpretedGeology.ToPascalCase(), childCount)); resources.Add(etpAdapter.NewFolder(etpUri, EtpContentTypes.GetContentType(typeof(ShowEvaluation)), ObjectTypes.ShowEvaluation.ToPascalCase(), childCount)); } else { var propertyName = etpUri.ObjectType.ToPascalCase(); CreateFoldersByObjectType(etpAdapter, etpUri, propertyName) .ForEach(resources.Add); } }
/// <summary> /// Gets a collection of resources associated to the specified URI. /// </summary> /// <param name="args">The <see cref="ProtocolEventArgs{GetResources, IList}"/> instance containing the event data.</param> public void GetResources(ProtocolEventArgs <GetResources, IList <Resource> > args) { if (EtpUris.IsRootUri(args.Message.Uri)) { args.Context.Add(DiscoveryStoreProvider.NewProtocol(EtpUris.Witsml200, "WITSML Store (2.0)")); args.Context.Add(DiscoveryStoreProvider.NewProtocol(EtpUris.Eml210, "EML Common (2.1)")); return; } var uri = new EtpUri(args.Message.Uri); var parentUri = uri.Parent; // Append query string, if any if (!string.IsNullOrWhiteSpace(uri.Query)) { parentUri = new EtpUri(parentUri + uri.Query); } if (!uri.IsRelatedTo(EtpUris.Witsml200)) { return; } if (uri.IsBaseUri) { CreateFoldersByObjectType(uri) .ForEach(args.Context.Add); } else if (string.IsNullOrWhiteSpace(uri.ObjectId)) { if (ObjectTypes.ChannelSet.EqualsIgnoreCase(uri.ObjectType) && ObjectTypes.Log.EqualsIgnoreCase(parentUri.ObjectType)) { var log = _logDataProvider.Get(parentUri); log?.ChannelSet?.ForEach(x => args.Context.Add(ToResource(x))); } else if (ObjectTypes.Channel.EqualsIgnoreCase(uri.ObjectType) && ObjectTypes.ChannelSet.EqualsIgnoreCase(parentUri.ObjectType)) { var set = _channelSetDataProvider.Get(parentUri); set?.Channel?.ForEach(x => args.Context.Add(ToResource(set, x))); } else { var objectType = ObjectTypes.GetObjectType(uri.ObjectType, uri.Version); var contentType = EtpContentTypes.GetContentType(objectType); var hasChildren = contentType.IsRelatedTo(EtpContentTypes.Eml210) ? 0 : -1; var dataProvider = GetDataProvider(uri.ObjectType); dataProvider .GetAll(parentUri) .Cast <AbstractObject>() .ForEach(x => args.Context.Add(ToResource(x, hasChildren))); } } else if (ObjectTypes.Log.EqualsIgnoreCase(uri.ObjectType)) { var log = _logDataProvider.Get(uri); var hasChildren = log?.ChannelSet?.Count ?? 0; CreateFoldersByObjectType(uri, "Log", ObjectTypes.ChannelSet, hasChildren) .ForEach(args.Context.Add); } else if (ObjectTypes.ChannelSet.EqualsIgnoreCase(uri.ObjectType)) { var set = _channelSetDataProvider.Get(uri); var hasChildren = set?.Channel?.Count ?? 0; CreateFoldersByObjectType(uri, "ChannelSet", ObjectTypes.Channel, hasChildren) .ForEach(args.Context.Add); } else { var propertyName = uri.ObjectType.ToPascalCase(); CreateFoldersByObjectType(uri, propertyName) .ForEach(args.Context.Add); } }
private void GetResources <T>(IEtpAdapter etpAdapter, string uri, IList <T> resources) where T : IResource { if (EtpUris.IsRootUri(uri)) { resources.Add(etpAdapter.NewProtocol(EtpUris.Witsml131, "WITSML Store (1.3.1.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.Witsml131)) { return; } if (etpUri.IsBaseUri || (string.IsNullOrWhiteSpace(etpUri.ObjectId) && ObjectTypes.Well.EqualsIgnoreCase(etpUri.ObjectType))) { _wellDataProvider.GetAll(etpUri) .ForEach(x => resources.Add(ToResource(etpAdapter, x))); } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId) && ObjectTypes.Wellbore.EqualsIgnoreCase(parentUri.ObjectType)) { var dataProvider = _container.Resolve <IEtpDataProvider>(new ObjectName(etpUri.ObjectType, etpUri.Version)); 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))); } else if (ObjectTypes.Wellbore.EqualsIgnoreCase(etpUri.ObjectType)) { var wellboreObjectType = typeof(IWellboreObject); Providers .OfType <IWitsmlDataAdapter>() .Where(x => wellboreObjectType.IsAssignableFrom(x.DataObjectType)) .Select(x => EtpContentTypes.GetContentType(x.DataObjectType)) .OrderBy(x => x.ObjectType) .ForEach(x => { var hasChildren = ObjectTypes.Log.EqualsIgnoreCase(x.ObjectType) ? _logDataProvider.Count(etpUri) : -1; resources.Add(etpAdapter.NewFolder(etpUri, x, x.ObjectType, hasChildren)); }); } else if (ObjectTypes.Log.EqualsIgnoreCase(etpUri.ObjectType)) { var log = _logDataProvider.Get(etpUri); log?.LogCurveInfo?.ForEach(x => resources.Add(ToResource(etpAdapter, log, x))); } }
private void GetResources <T>(IEtpAdapter etpAdapter, string uri, IList <T> resources) where T : IResource { if (EtpUris.IsRootUri(uri)) { resources.Add(etpAdapter.NewProtocol(EtpUris.Witsml200, "WITSML Store (2.0)")); 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.Witsml200)) { return; } if (etpUri.IsBaseUri) { CreateFoldersByObjectType(etpAdapter, etpUri) .ForEach(resources.Add); } else if (string.IsNullOrWhiteSpace(etpUri.ObjectId)) { var isChannelDataAdapterEnabled = WitsmlSettings.IsChannelDataAdapterEnabled; if (!isChannelDataAdapterEnabled && ObjectTypes.ChannelSet.EqualsIgnoreCase(etpUri.ObjectType) && ObjectTypes.Log.EqualsIgnoreCase(parentUri.ObjectType)) { var log = _logDataProvider.Get(parentUri); log?.ChannelSet?.ForEach(x => resources.Add(ToResource(etpAdapter, x, parentUri))); } else if (!isChannelDataAdapterEnabled && ObjectTypes.Channel.EqualsIgnoreCase(etpUri.ObjectType) && ObjectTypes.ChannelSet.EqualsIgnoreCase(parentUri.ObjectType)) { var set = _channelSetDataProvider.Get(parentUri); set?.Channel?.ForEach(x => resources.Add(ToResource(etpAdapter, x, parentUri))); } else { 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, parentUri, hasChildren))); } } else if (ObjectTypes.Log.EqualsIgnoreCase(etpUri.ObjectType)) { var log = _logDataProvider.Get(etpUri); var hasChildren = log?.ChannelSet?.Count ?? 0; CreateFoldersByObjectType(etpAdapter, etpUri, "Log", ObjectTypes.ChannelSet, hasChildren) .ForEach(resources.Add); } else if (ObjectTypes.ChannelSet.EqualsIgnoreCase(etpUri.ObjectType)) { var set = _channelSetDataProvider.Get(etpUri); var hasChildren = set?.Channel?.Count ?? 0; CreateFoldersByObjectType(etpAdapter, etpUri, "ChannelSet", ObjectTypes.Channel, hasChildren) .ForEach(resources.Add); } else { var propertyName = etpUri.ObjectType.ToPascalCase(); CreateFoldersByObjectType(etpAdapter, etpUri, propertyName) .ForEach(resources.Add); } }