Added getRelationshipChain
This commit is contained in:
parent
2a6e51b238
commit
e8a52bcf7e
|
@ -18,6 +18,7 @@ import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Archive;
|
import org.gcube.application.geoportal.common.model.configuration.Archive;
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
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.Project;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||||
import org.gcube.application.geoportal.common.model.rest.CreateRelationshipRequest;
|
import org.gcube.application.geoportal.common.model.rest.CreateRelationshipRequest;
|
||||||
import org.gcube.application.geoportal.common.model.rest.DeleteRelationshipRequest;
|
import org.gcube.application.geoportal.common.model.rest.DeleteRelationshipRequest;
|
||||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||||
|
@ -159,6 +160,22 @@ public class ProjectsCaller {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the relationship chain.
|
||||||
|
*
|
||||||
|
* @param profileID the profile ID
|
||||||
|
* @param projectID the project ID
|
||||||
|
* @return the relationship chain
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public Iterator<RelationshipNavigationObject> getRelationshipChain(String profileID, String projectID)
|
||||||
|
throws Exception {
|
||||||
|
LOG.info("getRelationshipChain called for profileID: {}, projectID: {}", profileID, projectID);
|
||||||
|
Projects<Project> client = (Projects<Project>) getClient(profileID);
|
||||||
|
return client.getRelationshipChain(profileID, projectID);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configuration.
|
* Gets the configuration.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
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.Project;
|
||||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||||
|
@ -43,7 +44,7 @@ public class Project_Tests {
|
||||||
// private static String TOKEN = ""; //preVRE
|
// private static String TOKEN = ""; //preVRE
|
||||||
|
|
||||||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||||
private static String TOKEN = "c41a00c0-7897-48d2-a67a-05190d6ce5e6-98187548"; // devVRE
|
private static String TOKEN = ""; // devVRE
|
||||||
private static String PROFILE_ID = "profiledConcessioni";
|
private static String PROFILE_ID = "profiledConcessioni";
|
||||||
private static String PROJECT_ID = "632c633155e2947b0278c999";
|
private static String PROJECT_ID = "632c633155e2947b0278c999";
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class Project_Tests {
|
||||||
client = GeoportalClientCaller.projects();
|
client = GeoportalClientCaller.projects();
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getList() throws Exception {
|
public void getList() throws Exception {
|
||||||
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||||
|
|
||||||
|
@ -65,17 +66,17 @@ public class Project_Tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getByID() throws Exception {
|
public void getByID() throws Exception {
|
||||||
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||||
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||||||
System.out.println(projectDV);
|
System.out.println(projectDV);
|
||||||
|
|
||||||
LinkedHashMap<String, Object> theMap = projectDV.getTheDocument().getDocumentAsMap();
|
LinkedHashMap<String, Object> theMap = projectDV.getTheDocument().getDocumentAsMap();
|
||||||
for (String key : theMap.keySet()) {
|
for (String key : theMap.keySet()) {
|
||||||
Object theValue = theMap.get(key);
|
Object theValue = theMap.get(key);
|
||||||
System.out.println("The key: "+key+" has value: "+theValue);
|
System.out.println("The key: " + key + " has value: " + theValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +91,8 @@ public class Project_Tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
// @Test
|
||||||
public void getResultDocumentForID() {
|
public void getResultDocumentForID() {
|
||||||
try {
|
try {
|
||||||
ProjectsCaller projects = GeoportalClientCaller.projects();
|
ProjectsCaller projects = GeoportalClientCaller.projects();
|
||||||
|
@ -182,7 +183,7 @@ public class Project_Tests {
|
||||||
System.out.println(client.getTotalDocument(PROFILE_ID));
|
System.out.println(client.getTotalDocument(PROFILE_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void getListPhases() throws Exception {
|
public void getListPhases() throws Exception {
|
||||||
|
|
||||||
List<String> idsPhases = client.getIDsPhases(PROFILE_ID);
|
List<String> idsPhases = client.getIDsPhases(PROFILE_ID);
|
||||||
|
@ -195,29 +196,63 @@ public class Project_Tests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
@Test
|
||||||
|
public void getRelationshipsChain() throws Exception {
|
||||||
|
System.out.println("getRelationshipsChain test");
|
||||||
|
|
||||||
|
Iterator<RelationshipNavigationObject> iterator = client.getRelationshipChain(PROFILE_ID, PROJECT_ID);
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next();
|
||||||
|
visitRelationshipsChain(nav);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void visitRelationshipsChain(RelationshipNavigationObject nav) {
|
||||||
|
|
||||||
|
if (nav == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printObject(nav.getTarget());
|
||||||
|
|
||||||
|
for (RelationshipNavigationObject relationship : nav.getChildren()) {
|
||||||
|
visitRelationshipsChain(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printObject(Project project) {
|
||||||
|
|
||||||
|
System.out.println("Project id: " + project.getId() + ", profile: " + project.getProfileID() + ", doc: "
|
||||||
|
+ project.getTheDocument().toJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
public void deserializeISOJSONObjectAsDate() throws Exception {
|
public void deserializeISOJSONObjectAsDate() throws Exception {
|
||||||
|
|
||||||
String jsonDate = "{hour=0, minute=0, " + "dayOfYear=259, " + "dayOfWeek=MONDAY, " + "dayOfMonth=16, "
|
String jsonDate = "{hour=0, minute=0, " + "dayOfYear=259, " + "dayOfWeek=MONDAY, " + "dayOfMonth=16, "
|
||||||
+ "monthValue=9, " + "year=2019, " + "month=SEPTEMBER, " + "second=0, " + "nano=0, "
|
+ "monthValue=9, " + "year=2019, " + "month=SEPTEMBER, " + "second=0, " + "nano=0, "
|
||||||
+ "chronology={calendarType=iso8601, id=ISO}" + "}";
|
+ "chronology={calendarType=iso8601, id=ISO}" + "}";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/*ObjectMapper objectMapper = new ObjectMapper();
|
/*
|
||||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
* ObjectMapper objectMapper = new ObjectMapper(); JavaTimeModule javaTimeModule
|
||||||
javaTimeModule.addDeserializer(LocalDate.class, new MyLocalDateDeserializer());
|
* = new JavaTimeModule(); javaTimeModule.addDeserializer(LocalDate.class, new
|
||||||
javaTimeModule.addSerializer(LocalDate.class, new MyLocalDateSerializer());
|
* MyLocalDateDeserializer()); javaTimeModule.addSerializer(LocalDate.class, new
|
||||||
objectMapper.registerModule(javaTimeModule);
|
* MyLocalDateSerializer()); objectMapper.registerModule(javaTimeModule);
|
||||||
|
*
|
||||||
|
* objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
* objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
|
||||||
|
* false); objectMapper.configure(SerializationFeature.
|
||||||
|
* WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); LocalDate date =
|
||||||
|
* objectMapper.readerFor(LocalDate.class).readValue(jsonDate);
|
||||||
|
* System.out.println(date);
|
||||||
|
*/
|
||||||
|
|
||||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
// checking if the jsonDate is a LocalDate
|
||||||
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
// LocalDateTime date =
|
||||||
objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
|
// org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate,
|
||||||
LocalDate date = objectMapper.readerFor(LocalDate.class).readValue(jsonDate);
|
// LocalDateTime.class);
|
||||||
System.out.println(date);*/
|
|
||||||
|
|
||||||
//checking if the jsonDate is a LocalDate
|
|
||||||
//LocalDateTime date = org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate, LocalDateTime.class);
|
|
||||||
LocalDate date = org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate, LocalDate.class);
|
LocalDate date = org.gcube.application.geoportal.client.utils.Serialization.read(jsonDate, LocalDate.class);
|
||||||
System.out.println(date);
|
System.out.println(date);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue