127 lines
4.7 KiB
Java
127 lines
4.7 KiB
Java
package org.gcube.application;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.application.geoportal.common.model.document.Project;
|
|
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
|
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
|
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.LifecycleInformationDV;
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ProjectDV;
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
public class Project_Tests {
|
|
|
|
private ProjectsCaller client = null;
|
|
// private static String CONTEXT = "/pred4s/preprod/preVRE";
|
|
// private static String TOKEN = ""; //preVRE
|
|
|
|
private static String CONTEXT = "/gcube/devsec/devVRE";
|
|
private static String TOKEN = ""; // devVRE
|
|
private static String PROFILE_ID = "profiledConcessioni";
|
|
private static String PROJECT_ID = "6226220daf515916fdb54e08";
|
|
|
|
@Before
|
|
public void getClient() {
|
|
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
SecurityTokenProvider.instance.set(TOKEN);
|
|
client = GeoportalClientCaller.projects();
|
|
}
|
|
|
|
//@Test
|
|
public void getList() throws Exception {
|
|
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
|
|
|
int i = 0;
|
|
for (Project project : listOfProjects) {
|
|
System.out.println(++i + ") " + project);
|
|
}
|
|
}
|
|
|
|
//@Test
|
|
public void getByID() throws Exception {
|
|
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
|
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
|
System.out.println(projectDV);
|
|
}
|
|
|
|
//@Test
|
|
public void getListProjectsDV() throws Exception {
|
|
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
|
int i = 0;
|
|
for (Project project : listOfProjects) {
|
|
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
|
System.out.println(++i + ") " + projectDV);
|
|
}
|
|
|
|
}
|
|
|
|
@Test
|
|
public void getListProjectsDVFiltered() throws Exception {
|
|
//List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
|
|
|
SearchingFilter filter = new SearchingFilter();
|
|
|
|
|
|
//Where Clause
|
|
List<WhereClause> conditions = new ArrayList<WhereClause>();
|
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
|
//searchInto.put("_id", "61f0299baf51592c36795f52");
|
|
//searchInto.put("_theDocument.nome", "Test progetto con clustering di fileset");
|
|
WhereClause whereClause = new WhereClause(LOGICAL_OP.AND, searchInto);
|
|
conditions.add(whereClause);
|
|
filter.setConditions(conditions);
|
|
|
|
Map<String, Object> projection = new HashMap<String, Object>();
|
|
//default
|
|
projection.put("_profileID", 1);
|
|
projection.put("_profileVersion", 1);
|
|
projection.put("_version", 1);
|
|
projection.put("_theDocument", 1);
|
|
|
|
projection.put("_theDocument.paroleChiaveLibere", 1);
|
|
projection.put("_theDocument.editore", 1);
|
|
projection.put("_theDocument.paroleChiaveICCD", 1);
|
|
projection.put("_theDocument.nome", 1);
|
|
projection.put("_theDocument.responsabile", 1);
|
|
projection.put("_theDocument.authors", 1);
|
|
|
|
projection.put("_theDocument.nome", 1);
|
|
projection.put("_theDocument.introduzione", 1);
|
|
projection.put("_theDocument.authors", 1);
|
|
filter.setProjection(projection);
|
|
|
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
|
ResultSetPaginatedData results = client.queryOnMongo(PROFILE_ID, 300, 0, 10, filter, projectBuilder);
|
|
int i = 0;
|
|
for (ProjectDV projectDV : results.getData()) {
|
|
System.out.println(++i + ") " + projectDV);
|
|
}
|
|
|
|
}
|
|
|
|
//@Test
|
|
public void getLifecycleForProjectId() throws Exception {
|
|
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
|
LifecycleInformation lci = project.getLifecycleInformation();
|
|
LifecycleInformationDV liDV = ConvertToDataValueObjectModel.toLifecycleInformationDV(lci);
|
|
System.out.println(liDV);
|
|
//
|
|
}
|
|
}
|