Fabio Sinibaldi 2017-12-14 17:47:31 +00:00
parent b6e233b644
commit 693c246600
3 changed files with 19 additions and 6 deletions

View File

@ -28,5 +28,14 @@ public class ThreddsCatalog{
private DataSetRoot declaredDataSetRoot;
private HashSet<DataSetScan> declaredDataSetScan;
private CatalogCollection subCatalogs;
public String getPathFromLocation(String location) {
if(declaredDataSetRoot!=null&&declaredDataSetRoot.getLocation()!=null&&
ThreddsInfo.matchesPath(declaredDataSetRoot.getLocation(),location)) return declaredDataSetRoot.getPath();
for(DataSetScan scan : declaredDataSetScan)
if(scan!=null&&scan.getLocation()!=null&&ThreddsInfo.matchesPath(scan.getLocation(), location))
return scan.getPath();
return null;
}
}

View File

@ -40,11 +40,15 @@ public class ThreddsInfo {
}
public ThreddsCatalog getByFittingLocation(String toMatchLocation) {
public ThreddsCatalog getCatalogByFittingLocation(String toMatchLocation) {
return getByFittingLocation(catalog, toMatchLocation);
}
private static ThreddsCatalog findById(ThreddsCatalog catalog,String id) {
public String getPathFromLocation(String location) {
return getCatalogByFittingLocation(location).getPathFromLocation(location);
}
public static ThreddsCatalog findById(ThreddsCatalog catalog,String id) {
if(catalog!=null) {
if(catalog.getID()!=null&&catalog.getID().equals(id)) return catalog;
if(catalog.getSubCatalogs()!=null&&catalog.getSubCatalogs().getLinkedCatalogs()!=null)
@ -54,7 +58,7 @@ public class ThreddsInfo {
return null;
}
private static ThreddsCatalog getByFittingLocation(ThreddsCatalog catalog,String toMatchPath) {
public static ThreddsCatalog getByFittingLocation(ThreddsCatalog catalog,String toMatchPath) {
if(catalog!=null) {
if(catalog.getDeclaredDataSetRoot()!=null&&catalog.getDeclaredDataSetRoot().getLocation()!=null&&
matchesPath(catalog.getDeclaredDataSetRoot().getLocation(),toMatchPath)) return catalog;
@ -68,7 +72,7 @@ public class ThreddsInfo {
return null;
}
private static boolean matchesPath(String catalogPath,String toMatchPath) {
public static boolean matchesPath(String catalogPath,String toMatchPath) {
return toMatchPath.startsWith(catalogPath);
}
}

View File

@ -291,8 +291,8 @@ public class MarshallUnmarshalTest {
info.setCatalog(mainCatalog);
info.getById(subCatalog.getID());
System.out.println(info.getByFittingLocation("/tmp/public/genericScanned"));
System.out.println(info.getByFittingLocation("/tmp/more_tuna/anotherfolder/inside/this/one/"));
System.out.println(info.getCatalogByFittingLocation("/tmp/public/genericScanned"));
System.out.println(info.getCatalogByFittingLocation("/tmp/more_tuna/anotherfolder/inside/this/one/"));
return info;
}