private InvCatalogImpl makeCatalogRuns(URI baseURI) throws IOException { if ((catalogRuns == null) || checkIfChanged()) { InvCatalogImpl parent = (InvCatalogImpl) getParentCatalog(); URI myURI = baseURI.resolve( getCatalogHref(RUNS)); InvCatalogImpl runCatalog = new InvCatalogImpl( getFullName(), parent.getVersion(), myURI); InvDatasetImpl top = new InvDatasetImpl(this); top.setParent(null); top.transferMetadata( (InvDatasetImpl) this.getParent(), true ); // make all inherited metadata local top.setName(TITLE_RUNS); runCatalog.addDataset(top); // any referenced services need to be local List<InvService> services = new ArrayList<InvService>( getServicesLocal()); InvService service = getServiceDefault(); if ((service != null) && !services.contains(service)) runCatalog.addService(service); for (InvDatasetImpl ds : makeRunDatasets()) { top.addDataset(ds); } runCatalog.finish(); this.catalogRuns = runCatalog; } return catalogRuns; }
public InvDatasetScan getRawFileScan() { if ( ! madeDatasets ) getDatasets(); return scan; }
private synchronized void makeFmrc() throws IOException { if (madeFmrc) { checkIfChanged(); return; } Element ncml = getNcmlElement(); NetcdfDataset ncd = NcMLReader.readNcML(path, ncml, null); ncd.setFileCache( fileCache); // LOOK: this dataset never gets closed fmrc = new FmrcImpl( ncd); madeFmrc = true; }
private InvCatalogImpl makeCatalogForecasts(URI baseURI) throws IOException { if ((catalogForecasts == null) || checkIfChanged()){ InvCatalogImpl parent = (InvCatalogImpl) getParentCatalog(); URI myURI = baseURI.resolve( getCatalogHref(FORECAST)); InvCatalogImpl foreCatalog = new InvCatalogImpl( getFullName(), parent.getVersion(), myURI); InvDatasetImpl top = new InvDatasetImpl(this); top.setParent(null); top.transferMetadata( (InvDatasetImpl) this.getParent(), true ); // make all inherited metadata local top.setName(TITLE_FORECAST); foreCatalog.addDataset(top); // any referenced services need to be local List<InvService> services = getServicesLocal(); InvService service = getServiceDefault(); if ((service != null) && !services.contains(service)) foreCatalog.addService(service); for (InvDatasetImpl ds : makeForecastDatasets()) { top.addDataset(ds); } foreCatalog.finish(); this.catalogForecasts = foreCatalog; } return catalogForecasts; }
if ((catalog == null) || checkIfChanged()) { InvCatalogImpl parentCatalog = (InvCatalogImpl) getParentCatalog(); URI myURI = baseURI.resolve( getXlinkHref()); InvCatalogImpl mainCatalog = new InvCatalogImpl( getFullName(), parentCatalog.getVersion(), myURI); InvDatasetImpl parent = (InvDatasetImpl) this.getParent(); if (parent != null) top.transferMetadata( parent, true ); // make all inherited metadata local String id = getID(); if (id == null) id = getPath(); top.setID(id); makeFmrc(); ThreddsMetadata tm = top.getLocalMetadata(); InvDocumentation doc = new InvDocumentation(); String path = getPath(); if (!path.endsWith("/")) path = path + "/"; doc.setXlinkHref( "/thredds/modelInventory/"+path); List serviceLocal = getServicesLocal(); for (InvService service : parentCatalog.getServices()) { if (!serviceLocal.contains(service)) mainCatalog.addService(service); findDODSService(parentCatalog.getServices()); // LOOK kludgey
private InvCatalogImpl makeCatalogOffsets(URI baseURI) throws IOException { if ((catalogOffsets == null) || checkIfChanged()) { InvCatalogImpl parent = (InvCatalogImpl) getParentCatalog(); URI myURI = baseURI.resolve( getCatalogHref(OFFSET)); InvCatalogImpl offCatalog = new InvCatalogImpl( getFullName(), parent.getVersion(), myURI); InvDatasetImpl top = new InvDatasetImpl(this); top.setParent(null); top.transferMetadata( (InvDatasetImpl) this.getParent(), true ); // make all inherited metadata local top.setName(TITLE_OFFSET); offCatalog.addDataset(top); // any referenced services need to be local List<InvService> services = getServicesLocal(); InvService service = getServiceDefault(); if ((service != null) && !services.contains(service)) offCatalog.addService(service); for (InvDatasetImpl ds : makeOffsetDatasets()) { top.addDataset(ds); } offCatalog.finish(); this.catalogOffsets = offCatalog; } return catalogOffsets; }
InvDatasetImpl ds = new InvCatalogRef(this, TITLE_RUNS, getCatalogHref(RUNS)); ds.finish(); datasets.add( ds); String id = getID(); if (id == null) id = getPath(); String name = getName()+"_"+FMRC; name = StringUtil2.replace(name, ' ', "_"); ds.setUrlPath(path+"/"+name); name = getName()+"_"+BEST; name = StringUtil2.replace(name, ' ', "_"); ds.setUrlPath(path+"/"+name); ds = new InvCatalogRef(this, TITLE_RUNS, getCatalogHref(RUNS)); ds.finish(); datasets.add( ds); ds = new InvCatalogRef(this, TITLE_OFFSET, getCatalogHref(OFFSET)); ds.finish(); datasets.add( ds); ds = new InvCatalogRef(this, TITLE_FORECAST, getCatalogHref(FORECAST)); ds.finish(); datasets.add( ds); scan = new InvDatasetScan( (InvCatalogImpl) this.getParentCatalog(), this, "File_Access", path+"/"+SCAN,
private List<InvDatasetImpl> makeOffsetDatasets() throws IOException { makeFmrc(); List<InvDatasetImpl> datasets = new ArrayList<InvDatasetImpl>(); String id = getID(); if (id == null) id = getPath(); for (Double offset : fmrc.getForecastOffsets()) { String name = getName()+"_"+OFFSET_NAME+offset+"hr"; name = StringUtil2.replace(name, ' ', "_"); InvDatasetImpl nested = new InvDatasetImpl(this, name); nested.setUrlPath(path+"/"+OFFSET+"/"+name); nested.setID(id+"/"+OFFSET+"/"+name); ThreddsMetadata tm = nested.getLocalMetadata(); tm.addDocumentation("summary", "Data from the "+offset+" hour forecasts, across different model runs."); datasets.add( nested); } return datasets; }
private Element writeDatasetFmrc( InvDatasetFmrc ds) { Element dsElem; if ( raw ) { dsElem = new Element( "datasetFmrc", defNS ); dsElem.setAttribute( "name", ds.getName() ); dsElem.setAttribute( "path", ds.getPath() ); if (ds.isRunsOnly()) dsElem.setAttribute( "runsOnly", "true" ); writeDatasetInfo( ds, dsElem, false, true ); } else { dsElem = writeCatalogRef( ds); // dsElem.addContent( writeProperty( new InvProperty( "DatasetFmrc", ds.getPath() ) ) ); /// LOOK security hole - not used anyway, I think } return dsElem; }
protected InvDatasetImpl readDatasetFmrc( InvCatalogImpl catalog, InvDatasetImpl parent, Element dsElem, URI base) { String name = dsElem.getAttributeValue("name"); String path = dsElem.getAttributeValue("path"); String runsOnly = dsElem.getAttributeValue("runsOnly"); InvDatasetFmrc dsFmrc = new InvDatasetFmrc( parent, name, path, "true".equals(runsOnly)); Element fmrcElem = dsElem.getChild( "fmrcInventory", defNS ); if (fmrcElem != null) { String location = expandDataRootLocationAlias( fmrcElem.getAttributeValue("location")); String def = fmrcElem.getAttributeValue("fmrcDefinition"); String suffix = fmrcElem.getAttributeValue("suffix"); String olderThan = fmrcElem.getAttributeValue("olderThan"); String subdirs = fmrcElem.getAttributeValue("subdirs"); dsFmrc.setFmrcInventoryParams( location, def, suffix, olderThan, subdirs); } readDatasetInfo( catalog, dsFmrc, dsElem, base); return dsFmrc; } // read a dataset scan element
private void findDODSService(List<InvService> services) { for (InvService service : services) { if ((dodsService == null) && (service.getServiceType() == ServiceType.OPENDAP)) { dodsService = service.getName(); return; } if (service.getServiceType() == ServiceType.COMPOUND) findDODSService(service.getServices()); } }
private List<InvDatasetImpl> makeForecastDatasets() throws IOException { makeFmrc(); List<InvDatasetImpl> datasets = new ArrayList<InvDatasetImpl>(); DateFormatter formatter = new DateFormatter(); String id = getID(); if (id == null) id = getPath(); for (Date forecastDate : fmrc.getForecastDates()) { String name = getName()+"_"+FORECAST_NAME+formatter.toDateTimeStringISO( forecastDate); name = StringUtil2.replace(name, ' ', "_"); InvDatasetImpl nested = new InvDatasetImpl(this, name); nested.setUrlPath(path+"/"+FORECAST+"/"+name); nested.setID(id+"/"+FORECAST+"/"+name); ThreddsMetadata tm = nested.getLocalMetadata(); tm.addDocumentation("summary", "Data with the same forecast date, "+name+", across different model runs."); datasets.add( nested); } return datasets; }
private List<InvDatasetImpl> makeRunDatasets() throws IOException { makeFmrc(); List<InvDatasetImpl> datasets = new ArrayList<InvDatasetImpl>(); DateFormatter formatter = new DateFormatter(); String id = getID(); if (id == null) id = getPath(); for (Date runDate : fmrc.getRunDates()) { //String name = StringUtil.escape(formatter.toDateTimeStringISO( runDate), ""); String name = getName()+"_"+RUN_NAME+formatter.toDateTimeStringISO( runDate); name = StringUtil2.replace(name, ' ', "_"); InvDatasetImpl nested = new InvDatasetImpl(this, name); nested.setUrlPath(path+"/"+RUNS+"/"+name); nested.setID(id+"/"+RUNS+"/"+name); ThreddsMetadata tm = nested.getLocalMetadata(); tm.addDocumentation("summary", "Data from Run "+name); datasets.add( nested); } Collections.reverse( datasets); return datasets; }
private InvCatalogImpl makeCatalogScan(String orgPath, URI baseURI) { if ( !madeDatasets) getDatasets(); return scan.makeCatalogForDirectory( orgPath, baseURI); }