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;
|
||||
|
||||
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.d4science-ii.research-infrastructures.eu/geonetwork/";
|
||||
private String geonetworkUser = "admin";
|
||||
private String geonetworkPwd = "admin";
|
||||
private String scope = "/gcube/devsec";
|
||||
|
@ -62,9 +63,12 @@ public class FeaturesManager {
|
|||
public String getGeoserverLink(Metadata meta) {
|
||||
String link = null;
|
||||
String geoserverString = "/geoserver/";
|
||||
String geoserverEndString = "/geoserver?";
|
||||
String wmslink = getWMSLink(meta);
|
||||
if (wmslink!=null){
|
||||
int idx = wmslink.indexOf(geoserverString);
|
||||
if (idx<0)
|
||||
idx = wmslink.indexOf(geoserverEndString);
|
||||
if (idx>0){
|
||||
link = wmslink.substring(0,idx+geoserverString.length()-1);
|
||||
return link;
|
||||
|
@ -73,6 +77,9 @@ public class FeaturesManager {
|
|||
String wfslink = getWFSLink(meta);
|
||||
if (wfslink!=null){
|
||||
int idx = wfslink.indexOf(geoserverString);
|
||||
if (idx<0)
|
||||
idx = wfslink.indexOf(geoserverEndString);
|
||||
|
||||
if (idx>0){
|
||||
link = wfslink.substring(0,idx+geoserverString.length()-1);
|
||||
return link;
|
||||
|
@ -81,6 +88,9 @@ public class FeaturesManager {
|
|||
String wcslink = getWCSLink(meta);
|
||||
if (wcslink!=null){
|
||||
int idx = wcslink.indexOf(geoserverString);
|
||||
if (idx<0)
|
||||
idx = wcslink.indexOf(geoserverEndString);
|
||||
|
||||
if (idx>0){
|
||||
link = wcslink.substring(0,idx+geoserverString.length()-1);
|
||||
return link;
|
||||
|
@ -217,7 +227,7 @@ public class FeaturesManager {
|
|||
return gn.getConfiguration().getGeoNetworkPassword();
|
||||
}
|
||||
|
||||
public Metadata getGNInfobyTitle(String info) throws Exception {
|
||||
private Metadata getGNInfobyTitle(String info) throws Exception {
|
||||
|
||||
GeoNetworkReader gn = initGeoNetworkReader();
|
||||
// Form query object
|
||||
|
@ -288,7 +298,7 @@ public class FeaturesManager {
|
|||
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();
|
||||
// Form query object
|
||||
|
@ -297,6 +307,7 @@ public class FeaturesManager {
|
|||
req.addParam(GNSearchRequest.Param.title, info);
|
||||
req.addConfig(GNSearchRequest.Config.similarity, tolerance);
|
||||
GNSearchResponse resp = gn.query(req);
|
||||
|
||||
Metadata meta = null;
|
||||
List<Metadata> metadatalist = new ArrayList<Metadata>();
|
||||
if (resp.getCount() != 0){
|
||||
|
@ -307,6 +318,7 @@ public class FeaturesManager {
|
|||
Identification id = meta.getIdentificationInfo().iterator().next();
|
||||
String title = id.getCitation().getTitle().toString();
|
||||
if (title.equalsIgnoreCase(completeTitle)){
|
||||
AnalysisLogger.getLogger().debug("Found UUID:"+metadata.getUUID());
|
||||
metadatalist.add(meta);
|
||||
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, "");
|
||||
}
|
||||
|
||||
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);
|
||||
List<Metadata> mlist = getFastGNInfobyTitle(searchString, completetitle,"1");
|
||||
AnalysisLogger.getLogger().debug("Found:"+mlist.size()+" results");
|
||||
|
|
Loading…
Reference in New Issue