git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@76859 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
524e38b0d8
commit
f112b50e35
|
@ -20,8 +20,9 @@ import org.opengis.metadata.identification.Identification;
|
||||||
import org.opengis.metadata.identification.Resolution;
|
import org.opengis.metadata.identification.Resolution;
|
||||||
|
|
||||||
public class FeaturesManager {
|
public class FeaturesManager {
|
||||||
// private String geonetworkUrl = "http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork/";
|
// private String geonetworkUrl = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geonetwork/";
|
||||||
private String geonetworkUrl = "http://geoserver-last.d4science-ii.research-infrastructures.eu/geonetwork/";
|
private String geonetworkUrl = "http://geoserver-last.d4science-ii.research-infrastructures.eu/geonetwork/";
|
||||||
|
// private String geonetworkUrl = "http://geoserver.d4science-ii.research-infrastructures.eu/geonetwork/";
|
||||||
private String geonetworkUser = "admin";
|
private String geonetworkUser = "admin";
|
||||||
private String geonetworkPwd = "admin";
|
private String geonetworkPwd = "admin";
|
||||||
private String scope = "/gcube/devsec";
|
private String scope = "/gcube/devsec";
|
||||||
|
@ -62,9 +63,12 @@ public class FeaturesManager {
|
||||||
public String getGeoserverLink(Metadata meta) {
|
public String getGeoserverLink(Metadata meta) {
|
||||||
String link = null;
|
String link = null;
|
||||||
String geoserverString = "/geoserver/";
|
String geoserverString = "/geoserver/";
|
||||||
|
String geoserverEndString = "/geoserver?";
|
||||||
String wmslink = getWMSLink(meta);
|
String wmslink = getWMSLink(meta);
|
||||||
if (wmslink!=null){
|
if (wmslink!=null){
|
||||||
int idx = wmslink.indexOf(geoserverString);
|
int idx = wmslink.indexOf(geoserverString);
|
||||||
|
if (idx<0)
|
||||||
|
idx = wmslink.indexOf(geoserverEndString);
|
||||||
if (idx>0){
|
if (idx>0){
|
||||||
link = wmslink.substring(0,idx+geoserverString.length()-1);
|
link = wmslink.substring(0,idx+geoserverString.length()-1);
|
||||||
return link;
|
return link;
|
||||||
|
@ -73,6 +77,9 @@ public class FeaturesManager {
|
||||||
String wfslink = getWFSLink(meta);
|
String wfslink = getWFSLink(meta);
|
||||||
if (wfslink!=null){
|
if (wfslink!=null){
|
||||||
int idx = wfslink.indexOf(geoserverString);
|
int idx = wfslink.indexOf(geoserverString);
|
||||||
|
if (idx<0)
|
||||||
|
idx = wfslink.indexOf(geoserverEndString);
|
||||||
|
|
||||||
if (idx>0){
|
if (idx>0){
|
||||||
link = wfslink.substring(0,idx+geoserverString.length()-1);
|
link = wfslink.substring(0,idx+geoserverString.length()-1);
|
||||||
return link;
|
return link;
|
||||||
|
@ -81,6 +88,9 @@ public class FeaturesManager {
|
||||||
String wcslink = getWCSLink(meta);
|
String wcslink = getWCSLink(meta);
|
||||||
if (wcslink!=null){
|
if (wcslink!=null){
|
||||||
int idx = wcslink.indexOf(geoserverString);
|
int idx = wcslink.indexOf(geoserverString);
|
||||||
|
if (idx<0)
|
||||||
|
idx = wcslink.indexOf(geoserverEndString);
|
||||||
|
|
||||||
if (idx>0){
|
if (idx>0){
|
||||||
link = wcslink.substring(0,idx+geoserverString.length()-1);
|
link = wcslink.substring(0,idx+geoserverString.length()-1);
|
||||||
return link;
|
return link;
|
||||||
|
@ -217,7 +227,7 @@ public class FeaturesManager {
|
||||||
return gn.getConfiguration().getGeoNetworkPassword();
|
return gn.getConfiguration().getGeoNetworkPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Metadata getGNInfobyTitle(String info) throws Exception {
|
private Metadata getGNInfobyTitle(String info) throws Exception {
|
||||||
|
|
||||||
GeoNetworkReader gn = initGeoNetworkReader();
|
GeoNetworkReader gn = initGeoNetworkReader();
|
||||||
// Form query object
|
// Form query object
|
||||||
|
@ -288,7 +298,7 @@ public class FeaturesManager {
|
||||||
return metadatalist;
|
return metadatalist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Metadata> getFastGNInfobyTitle(String info, String completeTitle, String tolerance) throws Exception {
|
private List<Metadata> getFastGNInfobyTitle(String info, String completeTitle, String tolerance) throws Exception {
|
||||||
|
|
||||||
GeoNetworkReader gn = initGeoNetworkReader();
|
GeoNetworkReader gn = initGeoNetworkReader();
|
||||||
// Form query object
|
// Form query object
|
||||||
|
@ -297,6 +307,7 @@ public class FeaturesManager {
|
||||||
req.addParam(GNSearchRequest.Param.title, info);
|
req.addParam(GNSearchRequest.Param.title, info);
|
||||||
req.addConfig(GNSearchRequest.Config.similarity, tolerance);
|
req.addConfig(GNSearchRequest.Config.similarity, tolerance);
|
||||||
GNSearchResponse resp = gn.query(req);
|
GNSearchResponse resp = gn.query(req);
|
||||||
|
|
||||||
Metadata meta = null;
|
Metadata meta = null;
|
||||||
List<Metadata> metadatalist = new ArrayList<Metadata>();
|
List<Metadata> metadatalist = new ArrayList<Metadata>();
|
||||||
if (resp.getCount() != 0){
|
if (resp.getCount() != 0){
|
||||||
|
@ -307,6 +318,7 @@ public class FeaturesManager {
|
||||||
Identification id = meta.getIdentificationInfo().iterator().next();
|
Identification id = meta.getIdentificationInfo().iterator().next();
|
||||||
String title = id.getCitation().getTitle().toString();
|
String title = id.getCitation().getTitle().toString();
|
||||||
if (title.equalsIgnoreCase(completeTitle)){
|
if (title.equalsIgnoreCase(completeTitle)){
|
||||||
|
AnalysisLogger.getLogger().debug("Found UUID:"+metadata.getUUID());
|
||||||
metadatalist.add(meta);
|
metadatalist.add(meta);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -320,11 +332,44 @@ public class FeaturesManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Metadata checkForMetadatabyTitle(String searchString, String completetitle) throws Exception {
|
private Metadata getGNInfobyUUID(String UUID) throws Exception {
|
||||||
|
|
||||||
|
GeoNetworkReader gn = initGeoNetworkReader();
|
||||||
|
// Form query object
|
||||||
|
gn.login();
|
||||||
|
Metadata meta = gn.getById(UUID);
|
||||||
|
AnalysisLogger.getLogger().debug("Layer with UUID: "+UUID+" successfully Retrieved!");
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Metadata getGNInfobyUUIDorName(String layerUUIDorTitle) throws Exception {
|
||||||
|
|
||||||
|
AnalysisLogger.getLogger().debug("MapsComparator: Getting layer with UUID..."+layerUUIDorTitle);
|
||||||
|
Metadata meta = null;
|
||||||
|
try{
|
||||||
|
meta = getGNInfobyUUID(layerUUIDorTitle);
|
||||||
|
}catch(Exception e){
|
||||||
|
AnalysisLogger.getLogger().debug("MapsComparator: Impossible to get layer as UUID");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta==null){
|
||||||
|
AnalysisLogger.getLogger().debug("MapsComparator: NO UUID Available - Trying with NAME..."+layerUUIDorTitle);
|
||||||
|
try{
|
||||||
|
meta = checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerUUIDorTitle), layerUUIDorTitle);
|
||||||
|
}catch(Exception e){
|
||||||
|
throw new Exception("Layer does not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Metadata checkForMetadatabyTitle(String searchString, String completetitle) throws Exception {
|
||||||
return checkForMetadatabyTitle(searchString, completetitle, "");
|
return checkForMetadatabyTitle(searchString, completetitle, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Metadata checkForMetadatabyTitle(String searchString, String completetitle, String filename) throws Exception {
|
private Metadata checkForMetadatabyTitle(String searchString, String completetitle, String filename) throws Exception {
|
||||||
AnalysisLogger.getLogger().debug("Searching for: "+searchString);
|
AnalysisLogger.getLogger().debug("Searching for: "+searchString);
|
||||||
List<Metadata> mlist = getFastGNInfobyTitle(searchString, completetitle,"1");
|
List<Metadata> mlist = getFastGNInfobyTitle(searchString, completetitle,"1");
|
||||||
AnalysisLogger.getLogger().debug("Found:"+mlist.size()+" results");
|
AnalysisLogger.getLogger().debug("Found:"+mlist.size()+" results");
|
||||||
|
|
Loading…
Reference in New Issue