Updated Client Library

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86325 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-28 14:58:07 +00:00
parent d68ba422e0
commit c5bf5a1d4f
7 changed files with 87 additions and 7 deletions

View File

@ -942,14 +942,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
protected void importCSVFileOnService(String user,
FileUploadSession fileUploadSession,
CSVImportSession csvImportSession) throws TDGWTServiceException {
logger.debug("File Storage Access");
FilesStorage filesStorage = new FilesStorage();
String fileUrlOnStorage = filesStorage.storageCSVTempFile(user,
fileUploadSession.getCsvFile());
logger.debug("File Url On Storage:"+fileUrlOnStorage);
Map<String, Object> parameterInstance = csvImportFileParameter(
fileUrlOnStorage, fileUploadSession, csvImportSession);
logger.debug("Tabular Data Service");
service = TabularDataServiceFactory
.getService(aslSession.getUsername());
List<OperationDescriptor> capabilities = service.getCapabilities();

View File

@ -12,7 +12,7 @@ package org.gcube.portlets.user.td.gwtservice.shared;
*/
public class Constants {
public final static String VERSION = "1.0.0";
public final static String VERSION = "2.0.0";
public final static String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devsec";

View File

@ -30,7 +30,7 @@ import org.junit.Test;
*/
public class TestService {
protected Map<String, Object> getParameterInvocation() {
protected Map<String, Object> getParameterInvocationSDMX() {
Map<String, Object> parameterInstances = new HashMap<String, Object>();
parameterInstances
.put("registryBaseUrl",
@ -42,7 +42,7 @@ public class TestService {
}
@Test
public void create() throws Exception {
public void createSDMX() throws Exception {
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
TabularDataService service = TabularDataServiceFactory
@ -77,7 +77,7 @@ public class TestService {
InvocationCreator ic = InvocationCreator.getCreator(csvop);
OperationInvocation opInvocation = ic.setParameters(
getParameterInvocation()).create();
getParameterInvocationSDMX()).create();
//
System.out.println("------------Execute------------");
@ -111,7 +111,83 @@ public class TestService {
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(){
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(SEPARATOR, ",");
parameterInstances.put(ENCODING, "UTF-8");
parameterInstances.put(HASHEADER, true);
return parameterInstances;
}
@Test
public void createCSV() throws Exception{
try{
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
TabularDataService service = TabularDataServiceFactory.getService(Constants.DEFAULT_USER);
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());
TabularResourceId resourceId = resource.getId();
List<OperationDescriptor> ops =service.getCapabilities();
OperationDescriptor csvop = null;
for (OperationDescriptor op : ops ){
System.out.println(op.getName());
if (op.getName().equals("CSV Import"))
csvop = op;
}
OperationInvocation invocation = InvocationCreator.getCreator(csvop)
.setParameters(getParameterInvocationCSV())
.create();
Task task = service.execute(invocation, resource.getId());
while (task.getStatus()!= TaskStatus.FAILED && task.getStatus()!= TaskStatus.SUCCEDED){
System.out.println(task.getStatus()+" "+task.getStartTime().getTime());
Thread.sleep(3000);
}
System.out.println(task.getStatus());
if (task.getStatus()== TaskStatus.FAILED)
task.getErrorCause().printStackTrace();
Assert.assertEquals(TaskStatus.SUCCEDED, task.getStatus());
System.out.println(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());
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) {
e.printStackTrace();
}
}
@Test
public void listTR() throws Exception {
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
@ -124,5 +200,4 @@ public class TestService {
System.out.println("TabularResource:" + tr.getId());
}
}
}