@Test public void checkFindService() { String name = "all"; ServiceType serviceType = ServiceType.COMPOUND; String base = ""; InvService service = new InvService( name, serviceType.toString(), base, null, null ); InvService odapService = new InvService( "odap", ServiceType.OPENDAP.toString(), "/thredds/dodsC/", null, null ); odapService.addProperty( new InvProperty( "aProp", "aPropVal" ) ); odapService.addDatasetRoot( new InvProperty( "aDsRoot", "aDsRootVal" ) ); service.addService( odapService ); service.addService( new InvService( "wms", ServiceType.WMS.toString(), "/thredds/wms/", null, null ) ); service.addService( new InvService( "wcs", ServiceType.WCS.toString(), "/thredds/wcs/", null, null ) ); List<InvService> availServices = new ArrayList<InvService>(); availServices.add( service); assertEquals( service, DeepCopyUtils.findServiceByName( "all", availServices )); assertEquals( odapService, DeepCopyUtils.findServiceByName( "odap", availServices )); InvService odapService2 = new InvService( "odap2", ServiceType.OPENDAP.toString(), "/thredds/odap/", null, null); availServices.add( odapService2); assertEquals( service, DeepCopyUtils.findServiceByName( "all", availServices ) ); assertEquals( odapService, DeepCopyUtils.findServiceByName( "odap", availServices ) ); assertEquals( odapService2, DeepCopyUtils.findServiceByName( "odap2", availServices ) ); assertNull( DeepCopyUtils.findServiceByName( "junk", availServices )); }
static InvService findServiceByName( String name, List<InvService> servicePool) { if ( servicePool == null ) return null; for ( InvService curService : servicePool ) { if (curService.getName().equals( name )) return curService; List<InvService> nestedServices = curService.getServices(); InvService target = nestedServices != null ? findServiceByName( name, nestedServices ) : null; if ( target != null ) return target; } return null; }
DeepCopyUtils { static InvService findServiceByName( String name, List<InvService> servicePool) { if ( servicePool == null ) return null; for ( InvService curService : servicePool ) { if (curService.getName().equals( name )) return curService; List<InvService> nestedServices = curService.getServices(); InvService target = nestedServices != null ? findServiceByName( name, nestedServices ) : null; if ( target != null ) return target; } return null; } }
DeepCopyUtils { static InvService findServiceByName( String name, List<InvService> servicePool) { if ( servicePool == null ) return null; for ( InvService curService : servicePool ) { if (curService.getName().equals( name )) return curService; List<InvService> nestedServices = curService.getServices(); InvService target = nestedServices != null ? findServiceByName( name, nestedServices ) : null; if ( target != null ) return target; } return null; } private  DeepCopyUtils(); }
DeepCopyUtils { static InvService findServiceByName( String name, List<InvService> servicePool) { if ( servicePool == null ) return null; for ( InvService curService : servicePool ) { if (curService.getName().equals( name )) return curService; List<InvService> nestedServices = curService.getServices(); InvService target = nestedServices != null ? findServiceByName( name, nestedServices ) : null; if ( target != null ) return target; } return null; } private  DeepCopyUtils(); static InvCatalog copyCatalog( InvCatalog catalog ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, String datasetId ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, InvDataset dataset); static InvDataset copyDataset( InvDataset dataset, List<InvService> availableServices,
                                        boolean copyInheritedMetadataFromParents ); static InvAccess copyAccess( InvAccess access, InvDataset parentDataset, List<InvService> availableServices ); static InvService copyService( InvService service ); static InvProperty copyProperty( InvProperty property); }
DeepCopyUtils { static InvService findServiceByName( String name, List<InvService> servicePool) { if ( servicePool == null ) return null; for ( InvService curService : servicePool ) { if (curService.getName().equals( name )) return curService; List<InvService> nestedServices = curService.getServices(); InvService target = nestedServices != null ? findServiceByName( name, nestedServices ) : null; if ( target != null ) return target; } return null; } private  DeepCopyUtils(); static InvCatalog copyCatalog( InvCatalog catalog ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, String datasetId ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, InvDataset dataset); static InvDataset copyDataset( InvDataset dataset, List<InvService> availableServices,
                                        boolean copyInheritedMetadataFromParents ); static InvAccess copyAccess( InvAccess access, InvDataset parentDataset, List<InvService> availableServices ); static InvService copyService( InvService service ); static InvProperty copyProperty( InvProperty property);  }