use of gov.usgs.cida.coastalhazards.util.ogc.WFSService in project coastal-hazards by USGS-CIDA.
the class TemplateResource method makeItemsFromLayer.
private List<Item> makeItemsFromLayer(Item template, String layerId, LayerManager layerMan) throws IOException {
List<Item> items = new LinkedList<>();
Layer layer = layerMan.load(layerId);
WFSService wfs = (WFSService) Service.ogcHelper(Service.ServiceType.proxy_wfs, layer.getServices());
List<String> attrs = WFSIntrospector.getAttrs(wfs);
for (String attr : attrs) {
if (Attributes.contains(attr)) {
Summary summary = makeSummary(layer, attr);
Item item = templateItem(template, attr, layer, summary);
items.add(item);
}
}
return items;
}
use of gov.usgs.cida.coastalhazards.util.ogc.WFSService in project coastal-hazards by USGS-CIDA.
the class DataDomainUtility method retrieveDomainFromWFS.
public static SortedSet<String> retrieveDomainFromWFS(Item item) {
SortedSet<String> domain = new TreeSet<>();
WFSGetDomain client = new WFSGetDomain();
if (item == null) {
throw new IllegalArgumentException("Item must be valid data item");
} else if (item.getItemType() == Item.ItemType.aggregation || item.getItemType() == Item.ItemType.template) {
List<String> displayedIds = item.getDisplayedChildren();
for (Item child : item.getChildren()) {
if (displayedIds.contains(child.getId())) {
// recurse (again, avoiding cycles is important)
Set<String> childDomain = retrieveDomainFromWFS(child);
domain.addAll(childDomain);
}
}
} else if (item.getItemType() == Item.ItemType.data) {
WFSService service = item.fetchWfsService();
try {
Set<String> domainValuesAsStrings = client.getDomainValuesAsStrings(service, item.getAttr());
domain.addAll(domainValuesAsStrings);
} catch (IOException e) {
log.error("unable to get domain from wfs", e);
}
}
return domain;
}
use of gov.usgs.cida.coastalhazards.util.ogc.WFSService in project coastal-hazards by USGS-CIDA.
the class DownloadUtility method getWfsService.
/**
* Replaces item.getWfsService() after services were added to list
*
* @param item
* @return source wfsService representing the canonical dataset
*/
private static WFSService getWfsService(Item item) {
WFSService sourceWfs = null;
List<Service> services = item.getServices();
for (Service service : services) {
if (service.getType() == ServiceType.proxy_wfs) {
sourceWfs = new WFSService(service);
}
}
return sourceWfs;
}
use of gov.usgs.cida.coastalhazards.util.ogc.WFSService in project coastal-hazards by USGS-CIDA.
the class DownloadUtility method populateDownloadMap.
private static void populateDownloadMap(Map<WFSService, SingleDownload> downloadMap, Item item) {
SingleDownload download;
Queue<Item> itemQueue = new LinkedList<>();
itemQueue.add(item);
// (i.e. an item that sees itself in the subtree throws an exception)
while (itemQueue.peek() != null) {
Item currentItem = itemQueue.poll();
WFSService wfs = getWfsService(currentItem);
if (wfs != null && wfs.checkValidity()) {
if (downloadMap.containsKey(wfs)) {
download = downloadMap.get(wfs);
} else {
download = new SingleDownload();
download.setWfs(wfs);
download.setName(currentItem.getName());
try {
URL cswUrl = currentItem.fetchCswService().fetchUrl();
download.setMetadata(cswUrl);
} catch (MalformedURLException ex) {
LOG.info("Invalid csw url {}", currentItem.fetchCswService());
} catch (NullPointerException ex) {
LOG.info("CSW service not set");
}
downloadMap.put(wfs, download);
}
String attr = currentItem.getAttr();
if (StringUtils.isNotBlank(attr)) {
download.addAttr(attr);
}
}
List<Item> children = currentItem.getChildren();
if (children != null) {
itemQueue.addAll(children);
}
}
}
use of gov.usgs.cida.coastalhazards.util.ogc.WFSService in project coastal-hazards by USGS-CIDA.
the class SingleDownloadTest method quickStagingTest.
/**
* Same problem with external resource, but this is good for gutcheck test
* @throws IOException
*/
@Test
@Ignore
public void quickStagingTest() throws IOException {
List<String> missing = new LinkedList<>();
SingleDownload singleDownload = new SingleDownload();
singleDownload.setName("test");
WFSService wfs = new WFSService();
wfs.setEndpoint("http://cidasddvascch.cr.usgs.gov:8081/geoserver/wfs");
wfs.setTypeName("proxied:sandy_example");
singleDownload.setWfs(wfs);
singleDownload.addAttr("PCOL");
singleDownload.addAttr("POVW");
singleDownload.stage(DownloadUtility.createDownloadStagingArea(), missing);
}
Aggregations