geoportal-data-common/src/test/java/org/gcube/application/TestGNACommon.java

144 lines
4.1 KiB
Java

package org.gcube.application;
import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GNADataEntryConfigProfile;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.config.RoleRights;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
public class TestGNACommon {
private static String TOKEN = "";
private static String CONTEXT = "/gcube/devsec/devVRE";
private static String USERNAME = "francesco.mangiacrapa";
//@Before
public void init() {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
}
// @Test
public GNADataViewerConfigProfile getGeoNaDataViewProfile() throws Exception {
System.out.println("getGeoNaDataViewProfile called");
ScopeProvider.instance.set(CONTEXT);
GeoportalCommon gc = new GeoportalCommon();
GNADataViewerConfigProfile profile = gc.readGNADataViewerConfig(null);
System.out.println("Returning profile: " + profile);
return profile;
}
// @Test
public GeoNaItemRef getLinks() throws Exception {
System.out.println("getGeoNaDataViewProfile called");
ScopeProvider.instance.set(CONTEXT);
GeoportalCommon gc = new GeoportalCommon();
GeoNaItemRef item = new GeoNaItemRef("", "concessione");
GeoNaItemRef links = gc.getPublicLinksFor(item, true);
return links;
}
// @Test
// public void queryConcessioniTest() throws Exception {
// try {
//
// ScopeProvider.instance.set(CONTEXT);
// MongoServiceCommon msc = new MongoServiceCommon();
// SearchingFilter filter = new SearchingFilter();
//
// Map<String, Object> searchInto = new HashMap<String, Object>();
// searchInto.put("nome", "san");
// searchInto.put("authors", "silvia");
// // searchInto.put("report.status", "PASSED");
//
// WhereClause where1 = new WhereClause(LOGICAL_OP.OR, searchInto);
//
// Map<String, Object> searchInto2 = new HashMap<String, Object>();
// searchInto2.put("report.status", "PASSED");
// WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
//
// ArrayList<WhereClause> list = new ArrayList<WhereClause>();
// list.add(where1);
// // list.add(where2);
// filter.setConditions(list);
// ResultSetPaginatedData result = msc.queryOnMongo(30, 0, 30, filter, "concessione");
//
// int i = 0;
// for (ConcessioneDV concessione : result.getData()) {
// System.out.println(++i + ") " + concessione);
// }
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// }
// @Test
public void readGNDataEntryConfigsFromIS() throws Exception {
Thread thread = new Thread() {
public void run() {
geoCommon();
}
};
Thread thread2 = new Thread() {
public void run() {
geoCommon();
}
};
thread.run();
thread2.run();
}
private void geoCommon() {
GeoportalCommon r = new GeoportalCommon();
try {
ScopeProvider.instance.set(CONTEXT);
GNADataEntryConfigProfile configurations = r.readGNADataEntryConfig();
System.out.println("Permissions are:");
int i = 0;
for (RoleRights role : configurations.getPermissionsForRole()) {
System.out.println(++i + " " + role);
}
System.out.println("Item Fields are:");
i = 0;
for (ItemField item : configurations.getListItemFields()) {
System.out.println(++i + " " + item);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//@Test
public void readGNDataViewerConfigsFromIS() throws Exception {
GeoportalCommon r = new GeoportalCommon();
try {
ScopeProvider.instance.set(CONTEXT);
GNADataViewerConfigProfile configurations = r.readGNADataViewerConfig(null);
System.out.println("Map layers are:");
System.out.println(configurations.getMapLayers());
System.out.println("Item Fields are:");
int i = 0;
for (ItemField item : configurations.getListItemFields()) {
System.out.println(++i + " " + item);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}