diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java index b23207a..86956b1 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/ProjectsCaller.java @@ -165,14 +165,15 @@ public class ProjectsCaller { * * @param profileID the profile ID * @param projectID the project ID + * @param relationID the relation ID * @return the relationship chain * @throws Exception the exception */ - public Iterator getRelationshipChain(String profileID, String projectID) + public Iterator getRelationshipChain(String profileID, String projectID, String relationID) throws Exception { - LOG.info("getRelationshipChain called for profileID: {}, projectID: {}", profileID, projectID); + LOG.info("getRelationshipChain called for projectID: {}, relationID: {}", projectID, projectID); Projects client = (Projects) getClient(profileID); - return client.getRelationshipChain(profileID, projectID); + return client.getRelationshipChain(projectID, relationID); } @@ -347,7 +348,7 @@ public class ProjectsCaller { * * @param fromProfileID the from profile ID * @param fromProjectID the from project ID - * @param relationshipName the relationship name + * @param relationshipId the relationship id * @param toProfileID the to profile ID * @param toProjectID the to project ID * @throws RemoteException the remote exception @@ -389,6 +390,30 @@ public class ProjectsCaller { client.deleteRelation(request); } + /** + * Simple query. + * + * @param profileID the profile ID + * @param filter the filter + * @return the iterator + * @throws Exception the exception + */ + public Iterator simpleQuery(String profileID, Document filter) throws Exception { + LOG.info("simpleQuery called for profileID {} and filter {}", profileID, filter); + try { + + Projects geoportalClient = getClient(profileID); + QueryRequest request = new QueryRequest(); + request.setFilter(filter); + return geoportalClient.query(request); + + } catch (Exception e) { + LOG.error("Error on performing query: " + filter, e); + throw new Exception("Error occurred on performing query " + filter + ". Error: " + e.getMessage()); + } + + } + /** * Query on mongo. * diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/materialization/GCubeSDIViewerLayerDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/materialization/GCubeSDIViewerLayerDV.java index 67a2f46..ce3928a 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/materialization/GCubeSDIViewerLayerDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/materialization/GCubeSDIViewerLayerDV.java @@ -11,6 +11,7 @@ public class GCubeSDIViewerLayerDV implements Serializable { private String type; private BBOXDV bbox; private HashMap ogcLinks; + private String layerName; public GCubeSDIViewerLayerDV() { @@ -28,6 +29,14 @@ public class GCubeSDIViewerLayerDV implements Serializable { return ogcLinks; } + public String getWMSLink() { + if (ogcLinks != null) { + return ogcLinks.get("wms"); + } + + return null; + } + public void setType(String type) { this.type = type; } @@ -40,6 +49,14 @@ public class GCubeSDIViewerLayerDV implements Serializable { this.ogcLinks = ogcLinks; } + public void setLayerName(String layerName) { + this.layerName = layerName; + } + + public String getLayerName() { + return layerName; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -49,6 +66,8 @@ public class GCubeSDIViewerLayerDV implements Serializable { builder.append(bbox); builder.append(", ogcLinks="); builder.append(ogcLinks); + builder.append(", layerName="); + builder.append(layerName); builder.append("]"); return builder.toString(); } diff --git a/src/test/java/org/gcube/application/Project_Tests.java b/src/test/java/org/gcube/application/Project_Tests.java index 5505133..e19ba5a 100644 --- a/src/test/java/org/gcube/application/Project_Tests.java +++ b/src/test/java/org/gcube/application/Project_Tests.java @@ -13,6 +13,7 @@ import java.util.Map; import org.gcube.application.geoportal.common.model.configuration.Configuration; import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation; +import org.gcube.application.geoportal.common.model.document.relationships.Relationship; import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject; import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; import org.gcube.application.geoportalcommon.ProjectDVBuilder; @@ -196,27 +197,40 @@ public class Project_Tests { } - @Test + //@Test public void getRelationshipsChain() throws Exception { System.out.println("getRelationshipsChain test"); + Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID); - Iterator iterator = client.getRelationshipChain(PROFILE_ID, PROJECT_ID); + List relations = project.getRelationships(); - while (iterator.hasNext()) { - RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next(); - visitRelationshipsChain(nav); + for (Relationship relationship : relations) { + System.out.println("\n\ngetRelationshipsChain for "+relationship); + Iterator iterator = client.getRelationshipChain(PROFILE_ID, PROJECT_ID, + relationship.getRelationshipName()); + + while (iterator.hasNext()) { + RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next(); + visitRelationshipsChain(nav, relationship.getRelationshipName()); + } } + } - public void visitRelationshipsChain(RelationshipNavigationObject nav) { - + public void visitRelationshipsChain(RelationshipNavigationObject nav, String relationshipName) { + System.out.println("visitRelationshipsChain of target: "+nav.getTarget().getId() +", relationshipName: "+relationshipName+", doc: "+nav.getTarget().getTheDocument()); + System.out.println("visitRelationshipsChain children "+nav.getChildren()); + if (nav == null) return; printObject(nav.getTarget()); - for (RelationshipNavigationObject relationship : nav.getChildren()) { - visitRelationshipsChain(relationship); + if (nav.getChildren() != null) { + + for (RelationshipNavigationObject relationship : nav.getChildren()) { + visitRelationshipsChain(relationship, relationshipName); + } } }