public void SetDataSourceDescriptionTest() { db.TruncateTables(); db.AddDataSource( "NCEP/NCAR Reanalysis 1 (regular grid)", "MyDescription", "NCEP Reanalysis data provided by the NOAA/OAR/ESRL PSD, Boulder, Colorado, USA, from their Web site at http://www.esrl.noaa.gov/psd/", "Microsoft.Research.Science.FetchClimate2.DataSources.NCEPReanalysisRegularGridDataSource, NCEPReanalysisDataSource", "msds:az?name=ReanalysisRegular&DefaultEndpointsProtocol=http&AccountName=fetch&AccountKey=1Y0EOrnCX6ULY8c3iMHg9rrul2BWbPHKsHUceZ7SSh+ShM/q9K0ml49gQm+PE7G7i7zCvrpuT", null, null); var d = db.GetDataSources(DateTime.UtcNow).Where(x => x.Name == "NCEP/NCAR Reanalysis 1 (regular grid)").ToList(); Assert.AreEqual(d.Count, 1); Assert.AreEqual(d[0].Description, "MyDescription"); db.SetDataSourceDescription("NCEP/NCAR Reanalysis 1 (regular grid)", "NewMyDescription"); var d2 = db.GetDataSources(DateTime.UtcNow).Where(x => x.Name == "NCEP/NCAR Reanalysis 1 (regular grid)").ToList(); Assert.AreEqual(d2.Count, 1); Assert.AreEqual(d2[0].Description, "NewMyDescription"); }
public void DataSourceSet(string name, string handler = null, string remotename = null, string uri = null, string copyright = null, string description = null, List <DataSourceMapping> addMapping = null, List <String> removeMapping = null) { var localDs = db.GetDataSources(DateTime.MaxValue).ToArray(); if (localDs.All(x => x.Name != name)) { throw new ArgumentException("Specified data source does not exist."); } ushort?remoteID = null; if (!String.IsNullOrEmpty(handler) && String.IsNullOrEmpty(remotename)) { AssemblyStore gac = null; if (isConnectedToCloud) { gac = new AssemblyStore(storageConnectionString); } var resolvedHandlerAssemblyQualifiedName = ExtractHandlerAssemblyAndTypeName(handler, gac); db.SetDataSourceProcessor(name, resolvedHandlerAssemblyQualifiedName, null, null); } else if (String.IsNullOrEmpty(handler) && !String.IsNullOrEmpty(remotename)) { IFetchConfiguration remoteConfig; try { RemoteFetchClient client = new RemoteFetchClient(new Uri(uri)); remoteConfig = client.GetConfiguration(DateTime.MaxValue); } catch (Exception ex) { throw new ArgumentException("Failed to retrieve configuration of the remote service.\n Exception message: " + ex.Message); } if (!remoteConfig.DataSources.Any(ds => ds.Name == remotename)) { throw new ArgumentException("Data source with given name does not exist on the remote service."); } remoteID = remoteConfig.DataSources.Where(ds => ds.Name == remotename).FirstOrDefault().ID; db.SetDataSourceProcessor(name, null, remoteID, remotename); } if (!string.IsNullOrEmpty(remotename) && !String.IsNullOrEmpty(handler)) { throw new ArgumentException("Handler and remote name can not be specified simultaneously."); } if (!String.IsNullOrEmpty(uri)) { db.SetDataSourceUri(name, ParserHelper.AppendDataSetUriWithDimensions(uri)); } //if (isHidden != null) // db.SetDataSourceHidden(name, isHidden); if (copyright != null) { db.SetDataSourceCopyright(name, copyright); } if (description != null) { db.SetDataSourceDescription(name, description); } SetMappings(name, addMapping, removeMapping); }