Updated to new PortalContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@141691 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-01-20 18:19:17 +00:00
parent 4e708d1686
commit f164942f85
8 changed files with 246 additions and 238 deletions

View File

@ -8,8 +8,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
import com.google.gwt.core.client.GWT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
@ -22,6 +24,8 @@ import com.google.gwt.user.client.rpc.ServiceDefTarget;
*/
public class GwtTestTDGWTService extends GWTTestCase {
private static Logger logger = LoggerFactory.getLogger(GwtTestTDGWTService.class);
// protected static final Logger logger=
// LoggerFactory.getLogger(GwtTestTDGWTService.class);
/**
@ -36,12 +40,12 @@ public class GwtTestTDGWTService extends GWTTestCase {
* This test will send a request to the server
*/
public void testListTabularResource() {
System.out.println("---------TEST List Tabular Resource--------");
logger.debug("---------TEST List Tabular Resource--------");
// Create the service that we will test.
TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class);
ServiceDefTarget target = (ServiceDefTarget) tdGWTService;
System.out.println(GWT.getModuleBaseURL() + "TDGWTService");
logger.debug(GWT.getModuleBaseURL() + "TDGWTService");
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGWTService");
// Since RPC calls are asynchronous, we will need to wait for a response
@ -62,12 +66,12 @@ public class GwtTestTDGWTService extends GWTTestCase {
public void onSuccess(ArrayList<TabResource> result) {
assertTrue(result != null);
System.out.println("");
logger.debug("");
if (result.size() <= 0) {
System.out.println("----------------->No tabular Resources for this user.");
logger.debug("----------------->No tabular Resources for this user.");
} else {
for (TabResource tr : result) {
System.out.println("--------------->TR: " + tr);
logger.debug("--------------->TR: " + tr);
}
}
finishTest();

View File

@ -0,0 +1,28 @@
package org.gcube.portlets.user.td.gwtservice.client;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TDService {
private static Logger logger = LoggerFactory.getLogger(TDService.class);
public TabularDataService getService() {
logger.debug("DEFAULT: " + Constants.DEFAULT_USER + ", "
+ Constants.DEFAULT_SCOPE + ", " + Constants.DEFAULT_TOKEN);
//AuthorizationToken authToken = new AuthorizationToken(
// Constants.DEFAULT_USER);
SecurityTokenProvider.instance.set(Constants.DEFAULT_TOKEN);
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
//AuthorizationProvider.instance.set(authToken);
TabularDataService service = TabularDataServiceFactory.getService();
return service;
}
}

View File

@ -1,22 +1,16 @@
package org.gcube.portlets.user.td.gwtservice.client;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.TabularResourceMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRAgencyMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRDescriptionMetadata;
@ -25,6 +19,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRNameMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRRightsMetadata;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@ -34,16 +30,16 @@ import org.junit.Test;
*/
public class TestMetadata {
protected static SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm");
private static Logger logger = LoggerFactory.getLogger(TestMetadata.class);
//private static SimpleDateFormat sdf = new SimpleDateFormat(
// "yyyy-MM-dd HH:mm");
@Test
public void listTR() throws Exception {
System.out.println("################ List TR ####################");
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(
Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
logger.debug("################ List TR ####################");
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
List<TabularResource> trs = service.getTabularResources();
Assert.assertTrue(trs.size() > 0);
@ -51,27 +47,27 @@ public class TestMetadata {
for (TabularResource tr : trs) {
lastTable = service.getLastTable(tr.getId());
if (lastTable != null) {
System.out.println("TabularResource: [" + tr.getId()
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTableId: " + lastTable.getId().getValue()
+ ", lastTableType: "
+ lastTable.getTableType().getName() + "]");
System.out.println("--------Column:");
logger.debug("--------Column:");
List<Column> cols = lastTable.getColumns();
for (Column c : cols) {
System.out.println(c.toString());
logger.debug(c.toString());
}
} else {
System.out.println("TabularResource: [" + tr.getId()
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTable: " + lastTable + "]");
}
System.out.println("---------Metadata:");
logger.debug("---------Metadata:");
ArrayList<TRMetadata> metas = showMetadata(tr);
for (TRMetadata meta : metas) {
System.out.println(meta.toString());
logger.debug(meta.toString());
}
System.out
.println("############################################################");
@ -81,43 +77,44 @@ public class TestMetadata {
// TabularResource tr=service.createTabularResource();
// Date date = Calendar.getInstance().getTime();
// System.out.println("New TR [id="+tr.getId().getValue()+" date:"+sdf.format(tr.getCreationDate().getTime())+"]");
// logger.debug("New TR [id="+tr.getId().getValue()+" date:"+sdf.format(tr.getCreationDate().getTime())+"]");
// tr.setMetadata(new NameMetadata("Sinatra"));
// tr.setMetadata(new DescriptionMetadata("Sinatra Collection"));
// tr.setMetadata(new RightsMetadata("Sinatra free"));
// TabResource tabResource=new TabResource();
// updateTabResourceInformation(tabResource,metas);
// System.out.println("------");
// System.out.println(tabResource.toString());
// logger.debug("------");
// logger.debug(tabResource.toString());
// showMoreInformation(service);
}
protected void showMoreInformation(TabularDataService service)
@SuppressWarnings("unused")
private void showMoreInformation(TabularDataService service)
throws Exception {
List<TabularResource> trs = service.getTabularResources();
Assert.assertTrue(trs.size() > 0);
System.out.println("-----More Informations-----");
logger.debug("-----More Informations-----");
Table lastTable = null;
for (TabularResource tr : trs) {
lastTable = service.getLastTable(tr.getId());
if (lastTable != null) {
System.out.println("TabularResource: [" + tr.getId()
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTableId: " + lastTable.getId().getValue()
+ " lastTableType:"
+ lastTable.getTableType().getName() + "]");
} else {
System.out.println("TabularResource: [" + tr.getId()
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTable: " + lastTable + "]");
}
System.out.println("-----------");
logger.debug("-----------");
}
}
protected ArrayList<TRMetadata> showMetadata(TabularResource tr) {
private ArrayList<TRMetadata> showMetadata(TabularResource tr) {
Collection<TabularResourceMetadata<?>> trMetas = tr.getAllMetadata();
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
@ -158,11 +155,12 @@ public class TestMetadata {
}
}
System.out.println("TR Metadata: " + listTRMetadata.toString());
logger.debug("TR Metadata: " + listTRMetadata.toString());
return listTRMetadata;
}
protected void updateTabResourceInformation(TabResource tabResource,
@SuppressWarnings("unused")
private void updateTabResourceInformation(TabResource tabResource,
ArrayList<TRMetadata> trMetadatas) {
for (TRMetadata trMetadata : trMetadatas) {
if (trMetadata instanceof TRDescriptionMetadata) {

View File

@ -5,33 +5,33 @@ import java.util.List;
import java.util.Map;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.query.parameters.QueryPage;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.operation.Task;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TestService {
protected Map<String, Object> getParameterInvocationSDMX() {
private static Logger logger = LoggerFactory.getLogger(TestService.class);
private Map<String, Object> getParameterInvocationSDMX() {
Map<String, Object> parameterInstances = new HashMap<String, Object>();
parameterInstances
.put("registryBaseUrl",
@ -44,189 +44,193 @@ public class TestService {
@Test
public void createSDMX() throws Exception {
System.out.println("------------Create SDMX TR--------------");
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
logger.debug("------------Create SDMX TR--------------");
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
TabularResource resource = service.createTabularResource();
System.out.println("after createTabResource "
+ ScopeProvider.instance.get());
System.out.println("name: "
logger.debug("after createTabResource " + ScopeProvider.instance.get());
logger.debug("name: "
+ ((NameMetadata) resource.getMetadata(NameMetadata.class))
.getValue());
System.out.println("tabular data id: " + resource.getId().getValue());
logger.debug("tabular data id: " + resource.getId().getValue());
TabularResourceId resourceId = resource.getId();
System.out.println("------------List Operations------------");
logger.debug("------------List Operations------------");
List<OperationDefinition> ops = service.getCapabilities();
OperationDefinition csvop = null;
for (OperationDefinition op : ops) {
System.out.println(op.getName());
if (op.getName().compareTo("SDMX Codelist import")==0)
{
System.out.println("----Takes");
logger.debug(op.getName());
if (op.getName().compareTo("SDMX Codelist import") == 0) {
logger.debug("----Takes");
csvop = op;
}
}
//
System.out.println("------------Invocation------------");
OperationExecution invocation = new OperationExecution(csvop.getOperationId(), getParameterInvocationSDMX());
logger.debug("------------Invocation------------");
OperationExecution invocation = new OperationExecution(
csvop.getOperationId(), getParameterInvocationSDMX());
//
System.out.println("------------Execute------------");
logger.debug("------------Execute------------");
Task task = service.execute(invocation, resource.getId());
System.out.println("------------Check Task------------");
logger.debug("------------Check Task------------");
while (task.getStatus() != TaskStatus.FAILED
&& task.getStatus() != TaskStatus.SUCCEDED) {
System.out.println(task.getStatus() + " "
+ task.getStartTime().getTime());
logger.debug(task.getStatus() + " " + task.getStartTime().getTime());
Thread.sleep(3000);
}
System.out.println("------------Show Task------------");
System.out.println(task.getStatus() + " "
+ task.getStartTime().getTime() + " "
+ task.getEndTime().getTime());
System.out.println("Task Progress:" + task.getProgress());
logger.debug("------------Show Task------------");
logger.debug(task.getStatus() + " " + task.getStartTime().getTime()
+ " " + task.getEndTime().getTime());
logger.debug("Task Progress:" + task.getProgress());
Assert.assertNotNull(task.getResult());
System.out.println("Task getResult: " + task.getResult());
logger.debug("Task getResult: " + task.getResult());
Table resultTable = task.getResult().getPrimaryTable();
System.out.println("resultTable :" + resultTable);
logger.debug("resultTable :" + resultTable);
System.out.println(service.getLastTable(resourceId).getName());
logger.debug(service.getLastTable(resourceId).getName());
System.out.println(service.getQueryLenght(resultTable.getId(), null));
System.out.println(service.queryAsJson(resultTable.getId(),
new QueryPage(0, 200)));
logger.debug("QueryLenght: "
+ service.getQueryLenght(resultTable.getId(), null));
logger.debug(service.queryAsJson(resultTable.getId(), new QueryPage(0,
200)));
}
public static final String ENCODING = "encoding";
public static final String HASHEADER = "hasHeader";
public static final String SEPARATOR = "separator";
public static final String URL = "url";
private Map<String, Object> getParameterInvocationCSV(){
private Map<String, Object> getParameterInvocationCSV() {
Map<String, Object> parameterInstances = new HashMap<String, Object>();
parameterInstances.put(URL, "smp://importCSV/import.csv?5ezvFfBOLqZDktisNW+YdntfYeiRwwsx6mcSk7QrncHxpcgkYS6DSZuEmrrVwjNcQni7q/eoILP1k7BwnoPjFNqJykZW71mI7F/ELBV1lV8qTh/bosrhjOzQb50+GI/1aaspqr2Xc3LqUp9Q101dAT29nbhl9SyJqgEi0BgUQmMaZs/n4coLNw==");
parameterInstances
.put(URL,
"smp://importCSV/import.csv?5ezvFfBOLqZDktisNW+YdntfYeiRwwsx6mcSk7QrncHxpcgkYS6DSZuEmrrVwjNcQni7q/eoILP1k7BwnoPjFNqJykZW71mI7F/ELBV1lV8qTh/bosrhjOzQb50+GI/1aaspqr2Xc3LqUp9Q101dAT29nbhl9SyJqgEi0BgUQmMaZs/n4coLNw==");
parameterInstances.put(SEPARATOR, ",");
parameterInstances.put(ENCODING, "UTF-8");
parameterInstances.put(HASHEADER, true);
return parameterInstances;
}
@Test
public void createCSV() throws Exception{
System.out.println("------------Create CSV TR--------------");
try{
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResource resource = service.createTabularResource();
System.out.println("after createTabResource "+ScopeProvider.instance.get());
System.out.println("name: "+((NameMetadata)resource.getMetadata(NameMetadata.class)).getValue());
System.out.println("tabular data id: "+resource.getId().getValue());
public void createCSV() throws Exception {
logger.debug("------------Create CSV TR--------------");
try {
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
TabularResource resource = service.createTabularResource();
logger.debug("after createTabResource "
+ ScopeProvider.instance.get());
logger.debug("name: "
+ ((NameMetadata) resource.getMetadata(NameMetadata.class))
.getValue());
logger.debug("tabular data id: " + resource.getId().getValue());
TabularResourceId resourceId = resource.getId();
List<OperationDefinition> ops =service.getCapabilities();
OperationDefinition csvop = null;
for (OperationDefinition op : ops ){
System.out.println(op.getName());
List<OperationDefinition> ops = service.getCapabilities();
OperationDefinition csvop = null;
for (OperationDefinition op : ops) {
logger.debug(op.getName());
if (op.getName().equals("CSV Import"))
csvop = op;
}
OperationExecution invocation = new OperationExecution(csvop.getOperationId(), getParameterInvocationCSV());
OperationExecution invocation = new OperationExecution(
csvop.getOperationId(), getParameterInvocationCSV());
Task task = service.execute(invocation, resource.getId());
while (task.getStatus()!= TaskStatus.FAILED && task.getStatus()!= TaskStatus.SUCCEDED){
System.out.println(task.getStatus()+" "+task.getStartTime().getTime());
while (task.getStatus() != TaskStatus.FAILED
&& task.getStatus() != TaskStatus.SUCCEDED) {
logger.debug(task.getStatus() + " "
+ task.getStartTime().getTime());
Thread.sleep(3000);
}
System.out.println(task.getStatus());
if (task.getStatus()== TaskStatus.FAILED)
System.out.println("Failed: "+task.getErrorCause());
logger.debug("Task Status: " + task.getStatus());
if (task.getStatus() == TaskStatus.FAILED)
logger.debug("Failed: " + task.getErrorCause());
Assert.assertEquals(TaskStatus.SUCCEDED, task.getStatus());
System.out.println(task.getStartTime().getTime()+" "+task.getEndTime().getTime());
logger.debug(task.getStartTime().getTime() + " "
+ task.getEndTime().getTime());
Assert.assertNotNull(task.getResult());
Table resultTable = task.getResult().getPrimaryTable();
System.out.println("resultTable :"+task.getResult().getPrimaryTable());
System.out.println(service.getLastTable(resourceId).getName());
logger.debug("resultTable :" + task.getResult().getPrimaryTable());
logger.debug(service.getLastTable(resourceId).getName());
Assert.assertNotNull(service);
System.out.println(service.queryAsJson(resultTable.getId(), new QueryPage(0, 200)));
System.out.println(service.getQueryLenght(resultTable.getId(), null));
}catch (Exception e) {
logger.debug(service.queryAsJson(resultTable.getId(),
new QueryPage(0, 200)));
System.out
.println(service.getQueryLenght(resultTable.getId(), null));
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void listTR() throws Exception {
System.out.println("------------List TR--------------");
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
logger.debug("------------List TR--------------");
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
List<TabularResource> trs = service.getTabularResources();
Assert.assertTrue(trs.size() > 0);
System.out.println("---Tabular Resource---");
Table lastTable=null;
logger.debug("---Tabular Resource---");
Table lastTable = null;
for (TabularResource tr : trs) {
lastTable=service.getLastTable(tr.getId());
if(lastTable!=null){
System.out.println("TabularResource: [" + tr.getId()+", lastTable: "+lastTable.getTableType().getName()+"]");
lastTable = service.getLastTable(tr.getId());
if (lastTable != null) {
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTable: " + lastTable.getTableType().getName()
+ "]");
} else {
System.out.println("TabularResource: [" + tr.getId()+", lastTable: "+lastTable+"]");
logger.debug("TabularResource: [" + tr.getId()
+ ", lastTable: " + lastTable + "]");
}
}
if(lastTable!=null){
System.out.println("---Test Column---");
System.out.println("Table "+lastTable.getId()+" "+lastTable.getName());
for(Column col:lastTable.getColumns()){
System.out.println("Column: [name:" + col.getName()+", localId:"+col.getLocalId()+", dataType:"+col.getDataType()+"]");
if (lastTable != null) {
logger.debug("---Test Column---");
logger.debug("Table " + lastTable.getId() + " "
+ lastTable.getName());
for (Column col : lastTable.getColumns()) {
logger.debug("Column: [name:" + col.getName() + ", localId:"
+ col.getLocalId() + ", dataType:" + col.getDataType()
+ "]");
}
}
}
}

View File

@ -1,18 +1,15 @@
package org.gcube.portlets.user.td.gwtservice.client;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTableException;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTabularResourceException;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@ -21,18 +18,16 @@ import org.junit.Test;
*
*/
public class TestServiceColumn {
private static Logger logger = LoggerFactory.getLogger(TestServiceColumn.class);
private final static long trId = 225;
private final String columnLocalId="a5aedc5b-b843-451b-9659-afd672656276";
@Test
public void TestTROperation() {
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(
Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
TabularResourceId tabularResourceId = new TabularResourceId(trId);
@ -40,20 +35,20 @@ public class TestServiceColumn {
try {
lastTable = service.getLastTable(tabularResourceId);
} catch (NoSuchTabularResourceException e) {
System.out.println("No such tabular resource with id: " + trId);
logger.debug("No such tabular resource with id: " + trId);
e.printStackTrace();
return;
} catch (NoSuchTableException e) {
System.out.println("No such last table for: " + trId);
logger.debug("No such last table for: " + trId);
e.printStackTrace();
return;
}
System.out.println(lastTable.toString());
logger.debug(lastTable.toString());
ColumnLocalId clId=new ColumnLocalId(columnLocalId);
Column column=lastTable.getColumnById(clId);
System.out.println(column.toString());
logger.debug(column.toString());
}

View File

@ -4,33 +4,29 @@ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.TabularResourceMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestServiceListTR {
private static Logger logger = LoggerFactory.getLogger(TestServiceListTR.class);
private static SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm z");
@Test
public void listTR() throws Exception {
System.out
.println("------------List of Tabular Resources--------------");
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(
Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
logger.debug("------------List of Tabular Resources--------------");
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
List<TabularResource> trs = service.getTabularResources();
Assert.assertTrue(trs.size() > 0);
@ -40,33 +36,32 @@ public class TestServiceListTR {
Collection<TabularResourceMetadata<?>> metas = tr.getAllMetadata();
if (lastTable != null) {
System.out
.println("TabularResource: [ id="
logger.debug("TabularResource: [ id="
+ tr.getId().getValue() + ", type="
+ tr.getTabularResourceType() + ", date="
+ sdf.format(tr.getCreationDate().getTime())
+ ", lastTable=[ id="
+ lastTable.getId().getValue() + ", type="
+ lastTable.getTableType().getName() + "]]");
System.out.println("Last table id=" + lastTable.getId()
logger.debug("Last table id=" + lastTable.getId()
+ ", name=" + lastTable.getName());
for (Column col : lastTable.getColumns()) {
System.out.println("Column: [name:" + col.getName()
logger.debug("Column: [name:" + col.getName()
+ ", localId:" + col.getLocalId() + ", dataType:"
+ col.getDataType() + "]");
}
} else {
System.out.println("TabularResource: [ id="
logger.debug("TabularResource: [ id="
+ tr.getId().getValue() + ", lastTable= " + lastTable
+ "]");
}
for (TabularResourceMetadata<?> meta : metas) {
System.out.println("Meta: " + meta);
logger.debug("Meta: " + meta);
}
System.out.println("---------------------------------");
logger.debug("---------------------------------");
}
}

View File

@ -2,42 +2,39 @@ package org.gcube.portlets.user.td.gwtservice.client;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TestServiceOperations {
private static Logger logger = LoggerFactory.getLogger(TestServiceOperations.class);
@Test
public void TestTROperation() {
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
AuthorizationProvider.instance.set(new AuthorizationToken(Constants.DEFAULT_USER));
TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> trOperations = service.getCapabilities();
Assert.assertTrue("No operations exists",trOperations.size() > 0);
System.out
.println("------------Tabular Resource Operation--------------");
for (OperationDefinition operation : trOperations) {
System.out.println("Name: "+operation.getName());
//System.out.println("Scope: "+operation.getScope());
System.out.println("Desc: "+operation.toString());
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
System.out.println("-----------------------------------");
}
List<OperationDefinition> trOperations = service.getCapabilities();
Assert.assertTrue("No operations exists", trOperations.size() > 0);
logger.debug("------------Tabular Resource Operation--------------");
for (OperationDefinition operation : trOperations) {
logger.debug("Name: " + operation.getName());
// logger.debug("Scope: "+operation.getScope());
logger.debug("Desc: " + operation.toString());
logger.debug("-----------------------------------");
}
}
}

View File

@ -1,16 +1,11 @@
package org.gcube.portlets.user.td.gwtservice.client;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTableException;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTabularResourceException;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.junit.Test;
/**
@ -22,17 +17,12 @@ import org.junit.Test;
public class TestServiceTable {
private final static long trId = 157;
private final static long searchTableId=1951;
private String user=Constants.DEFAULT_USER;
private String scope=Constants.DEFAULT_SCOPE;
@Test
public void TestLastTable() {
ScopeProvider.instance.set(scope);
AuthorizationProvider.instance.set(new AuthorizationToken(
user));
TabularDataService service = TabularDataServiceFactory.getService();
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
TabularResourceId tabularResourceId = new TabularResourceId(trId);
@ -56,11 +46,8 @@ public class TestServiceTable {
@Test
public void TestTable() {
ScopeProvider.instance.set(scope);
AuthorizationProvider.instance.set(new AuthorizationToken(
user));
TabularDataService service = TabularDataServiceFactory.getService();
TDService tdService=new TDService();
TabularDataService service = tdService.getService();
Table searchTable;