/** * Override Object.hashCode() to implement equals. */ public int hashCode() { if (hashCode == 0) { int result = 17; if (null != getName()) result = 37 * result + getName().hashCode(); result = 37 * result + getServices().hashCode(); result = 37 * result + getDatasets().hashCode(); hashCode = result; } return hashCode; }
/** * Make the containing catalog of this feature collection * "http://server:port/thredds/catalog/path/catalog.xml" * * @param catURI base URI of the request * @param localState current state to use * @return the top FMRC catalog * @throws java.io.IOException on I/O error * @throws java.net.URISyntaxException if path is misformed */ protected InvCatalogImpl makeCatalogTop(URI catURI, State localState) throws IOException, URISyntaxException { InvCatalogImpl parentCatalog = (InvCatalogImpl) getParentCatalog(); InvCatalogImpl mainCatalog = new InvCatalogImpl(getName(), parentCatalog.getVersion(), catURI); mainCatalog.addDataset(localState.top); mainCatalog.addService(InvService.latest); // in case its needed mainCatalog.addService(virtualService); // top.getLocalMetadataInheritable().setServiceName(virtualService.getName()); //?? mainCatalog.finish(); return mainCatalog; }
public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; }
private void addDatasetIds(InvDatasetImpl ds) { addDatasetByID(ds); if (ds instanceof InvCatalogRef) return; //if (ds instanceof InvDatasetFmrc) return; // recurse into nested for (InvDataset invDataset : ds.getDatasets()) { InvDatasetImpl nested = (InvDatasetImpl) invDataset; addDatasetIds(nested); } }
if (cat.getName() != null) rootElem.setAttribute("name", cat.getName()); rootElem.setAttribute("version", version); rootElem.addNamespaceDeclaration(xlinkNS); if (cat.getExpires() != null) rootElem.setAttribute("expires", cat.getExpires().toString()); Iterator iter = cat.getServices().iterator(); while (iter.hasNext()) { InvService service = (InvService) iter.next(); iter = cat.getDatasetRoots().iterator(); while (iter.hasNext()) { InvProperty p = (InvProperty) iter.next(); iter = cat.getProperties().iterator(); while (iter.hasNext()) { InvProperty p = (InvProperty) iter.next(); iter = cat.getDatasets().iterator(); while (iter.hasNext()) { InvDatasetImpl ds = (InvDatasetImpl) iter.next();
InvCatalogImpl catalog = new InvCatalogImpl(name, version, makeDateType(expires, null, null), baseURI); for (Element e : sList) { InvService s = readService(e, baseURI); catalog.addService(s); for (Element e : pList) { InvProperty s = readProperty(e); catalog.addProperty(s); for (Element e : rootList) { DataRootConfig root = readDatasetRoot(e); catalog.addDatasetRoot(root); for (Element e : allChildren) { if (e.getName().equals("dataset")) { catalog.addDataset(readDataset(catalog, null, e, baseURI)); } else if (e.getName().equals("featureCollection")) { catalog.addDataset(readFeatureCollection(catalog, null, e, baseURI)); } else if (e.getName().equals("datasetScan")) { catalog.addDataset(readDatasetScan(catalog, null, e, baseURI)); } else if (e.getName().equals("catalogRef")) { catalog.addDataset(readCatalogRef(catalog, null, e, baseURI));
InvDatasetImpl topDs = (InvDatasetImpl) catalog.getDatasets().get( 0 ); catalog.removeDataset( topDs ); catalog.addDataset( actualInvDs ); catalog.finish();
InvDatasetImpl topInvDs = (InvDatasetImpl) genCatalog.getDatasets().get( 0 ); ( (InvCatalogImpl) genCatalog ).finish(); topInvDs.addDataset( index, (InvDatasetImpl) invDsToAdd ); genCatalog.addService( proxyService ); anyProxiesAdded = true; if ( anyProxiesAdded ) ( (InvCatalogImpl) genCatalog ).finish();
final Catalog catalog = xmlParser.parse(new URL(url).toURI()); System.out.println("invCatalog.getBaseUri() = " + invCatalog.getBaseURI()); System.out.println("invCatalog.getVersion() = " + invCatalog.getVersion()); final List<InvDataset> datasets = invCatalog.getDatasets();
@Override public InvCatalogImpl makeCatalog(String match, String orgPath, URI catURI) { logger.debug("FcPoint make catalog for " + match + " " + catURI); State localState = checkState(); try { if ((match == null) || (match.length() == 0)) { InvCatalogImpl main = makeCatalogTop(catURI, localState); main.addService(collectionService); main.getDataset().getLocalMetadataInheritable().setServiceName(collectionService.getName()); main.finish(); return main; } else if (match.startsWith(FILES) && wantDatasets.contains(FeatureCollectionConfig.PointDatasetType.Files)) { return makeCatalogFiles(catURI, localState, datasetCollection.getFilenames(), true); } } catch (Exception e) { logger.error("Error making catalog for " + path, e); } return null; }
/** * Debugging: dump entire data structure. * * @return String representation. */ public String dump() { StringBuilder buff = new StringBuilder(1000); buff.setLength(0); buff.append("Catalog <").append(getName()) .append("> <").append(getVersion()) .append("> <").append(getCreateFrom()).append(">\n"); buff.append(topDataset.dump(2)); return buff.toString(); }
public static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, InvDataset dataset) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); if ( dataset == null ) throw new IllegalArgumentException( "Dataset may not be null." ); if ( dataset.getParentCatalog() != catalog ) throw new IllegalArgumentException( "Catalog must contain the dataset." ); URI docBaseUri = formDocBaseUriForSubsetCatalog( catalog, dataset ); InvCatalogImpl resultCatalog = new InvCatalogImpl( dataset.getName(), "1.0", docBaseUri ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); InvDataset topDs = DeepCopyUtils.copyDataset( dataset, copiedServices, true ); resultCatalog.addDataset( (InvDatasetImpl) topDs ); resultCatalog.finish(); return resultCatalog; }
private InvCatalogImpl createSkeletonCatalog( CrawlableDataset topCrDs ) InvCatalogImpl catalog = new InvCatalogImpl( null, null, null ); catalog.addService( service ); catalog.addDataset( topDs );
uri = new URI(uriString); } catch (URISyntaxException e) { InvCatalogImpl cat = new InvCatalogImpl(uriString, null, null); cat.appendErrorMessage("**Fatal: InvCatalogFactory.readXML URISyntaxException on URL (" + uriString + ") " + e.getMessage() + "\n", true); return cat;
/** * Replace the given dataset if it is a nesetd dataset. * * @param remove - the dataset element to be removed * @param add - the dataset element to be added * @return true on success */ public boolean replaceDataset(InvDatasetImpl remove, InvDatasetImpl add) { for (int i = 0; i < datasets.size(); i++) { InvDataset dataset = datasets.get(i); if (dataset.equals(remove)) { datasets.set(i, add); InvCatalogImpl cat = (InvCatalogImpl) getParentCatalog(); if (cat != null) { cat.removeDatasetByID(remove); cat.addDatasetByID(add); } return true; } } return false; }
/** * Crawl a catalog thats already been opened. * When you get to a dataset containing leaf datasets, do all, only the first, or a randomly chosen one. * * @param cat the catalog * @param task user can cancel the task (may be null) * @param out send status messages to here (may be null) * @param context caller can pass this object in (used for thread safety) * @return number of catalog references opened and crawled */ public int crawl(InvCatalogImpl cat, CancelTask task, PrintStream out, Object context) { if (out != null) out.println("***CATALOG " + cat.getCreateFrom()); countCatrefs = 0; for (InvDataset ds : cat.getDatasets()) { if (type == Type.all) crawlDataset(ds, task, out, context, true); else crawlDirectDatasets(ds, task, out, context, true); if ((task != null) && task.isCancel()) break; } return 1 + countCatrefs; }
private static URI formDocBaseUriForSubsetCatalog( InvCatalog catalog, InvDataset dataset ) { String catDocBaseUri = catalog.getUriString(); String subsetDocBaseUriString = catDocBaseUri + "/" + ( dataset.getID() != null ? dataset.getID() : dataset.getName() ); URI thisDocBaseUri = ((InvCatalogImpl) catalog ).getBaseURI(); try { // String uriPath = thisDocBaseUri.getPath() + "/" + ( dataset.getID() != null ? dataset.getID() : dataset.getName() ); // URI subsetDocBaseUri = new URI( thisDocBaseUri.getScheme(), thisDocBaseUri.getUserInfo(), thisDocBaseUri.getHost(), // thisDocBaseUri.getPort(), uriPath, null, null ); URI subsetDocBaseUri = new URI( subsetDocBaseUriString); return subsetDocBaseUri; } catch ( URISyntaxException e ) { // This shouldn't happen. But just in case ... throw new IllegalStateException( "Bad document Base URI for new catalog [" + catalog.getUriString() + "/" + (dataset.getID() != null ? dataset.getID() : dataset.getName()) + "].", e ); } }
private static List<InvService> copyServicesIntoCopiedCatalog( InvCatalog catalog, InvCatalogImpl resultCatalog ) { List<InvService> services = catalog.getServices(); for ( InvService service : services ) { resultCatalog.addService( DeepCopyUtils.copyService( service ) ); } List<InvService> copiedServices = resultCatalog.getServices(); return copiedServices; }
private void addTopLevelMetadata( InvCatalog catalog, boolean isRegularCatalog ) { if ( this.topLevelMetadataContainer == null ) return; if ( ! catalogLevel.getPath().equals( currentLevel.getPath() ) ) return; // Transfer all metadata from given metadata container to the top // InvDataset. This propagates any public metadata from the given // metadata container to all generated catalogs. InvDatasetImpl topInvDs = (InvDatasetImpl) catalog.getDataset(); topInvDs.transferMetadata( this.topLevelMetadataContainer, true ); // LOOK experimental datasetScan may have its own access elements for ( Iterator it = this.topLevelMetadataContainer.getAccess().iterator(); it.hasNext(); ) { InvAccess invAccess = (InvAccess) it.next(); topInvDs.addAccess( invAccess ); InvService s = invAccess.getService(); ( (InvCatalogImpl) catalog ).addService( s ); } // If this is a collection level scan, set some special attributes // that transferMetadata() doesn't transfer. boolean isCollectionLevel = catalogLevel.getPath().equals( collectionLevel.getPath() ); if ( isCollectionLevel && isRegularCatalog ) { topInvDs.setHarvest( this.topLevelMetadataContainer.isHarvest() ); topInvDs.setCollectionType( this.topLevelMetadataContainer.getCollectionType() ); } // Finish catalog. ( (InvCatalogImpl) catalog ).finish(); }
public static List<InvDataset> getCatalogDatasets(InputStream catalogIS, URI catalogBaseUri) { final InvCatalogFactory factory = InvCatalogFactory.getDefaultFactory(true); final InvCatalogImpl catalog = factory.readXML(catalogIS, catalogBaseUri); return catalog.getDatasets(); }