Updated to service impl 2.0.0
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86136 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
560bf36210
commit
3e6d59a895
2
pom.xml
2
pom.xml
|
@ -151,7 +151,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>service-client-impl</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -36,15 +36,17 @@ import org.gcube.data.analysis.tabulardata.model.metadata.table.TableMetadata;
|
|||
import org.gcube.data.analysis.tabulardata.model.metadata.table.VersionMetadata;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.TableId;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.InvocationCreator;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.OperationInvocation;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.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.TabularResourceInterface;
|
||||
|
@ -546,10 +548,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
OperationInterface oService = service;
|
||||
TabularResourceInterface trService = service;
|
||||
|
||||
List<EligibleOperation> capabilities = service.getCapabilities();
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
|
||||
// Import SDMX Codelist takes id 200
|
||||
EligibleOperation importSDMXCodelistOperation = getEligibleOperationWithId(
|
||||
OperationDescriptor importSDMXCodelistOperation = getOperationDescriptorWithId(
|
||||
OperationsId.SDMXCodelistImport.toString(), capabilities);
|
||||
|
||||
TabResource importSDMXTabResource = sdmxImportSession
|
||||
|
@ -564,10 +566,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
SessionUtil
|
||||
.setSDMXImportTabResource(session, importSDMXTabResource);
|
||||
|
||||
Map<String, Object> parameterInstances = retrieveOperationParameters(sdmxImportSession);
|
||||
Map<String, Object> parameterInstance = retrieveOperationParameters(sdmxImportSession);
|
||||
|
||||
OperationInvocation invocation = importSDMXCodelistOperation
|
||||
.createOperationInvocation(parameterInstances);
|
||||
InvocationCreator ic=InvocationCreator.getCreator(importSDMXCodelistOperation);
|
||||
OperationInvocation invocation = ic.setParameters(parameterInstance).create();
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = oService.execute(invocation, serviceTR.getId());
|
||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
|
@ -587,17 +590,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected EligibleOperation getEligibleOperationWithId(String op,
|
||||
List<EligibleOperation> capabilities) throws TDGWTServiceException {
|
||||
for (EligibleOperation operation : capabilities) {
|
||||
if (Long.valueOf(op) == operation.getOperationDescriptor()
|
||||
.getOperationId().getValue()) {
|
||||
protected OperationDescriptor getOperationDescriptorWithId(String op,
|
||||
List<OperationDescriptor> capabilities) throws TDGWTServiceException {
|
||||
for (OperationDescriptor operation : capabilities) {
|
||||
if (Long.valueOf(op) == operation.getOperationId().getValue()) {
|
||||
return operation;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
throw new TDGWTServiceException("ElegibleOperation not found");
|
||||
throw new TDGWTServiceException("OperationDescriptor not found");
|
||||
|
||||
}
|
||||
|
||||
|
@ -625,7 +627,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"Error in importSDMX task null");
|
||||
} else {
|
||||
logger.debug("Service task: " + task.toString());
|
||||
ActivityStatus status = task.getStatus();
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in importSDMX Status null");
|
||||
|
@ -637,8 +639,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
case SUCCEDED:
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
logger.debug("Task Result: " + task.getResult());
|
||||
trId.setTableId(String.valueOf(task.getResult()
|
||||
.getOutput().getId().getValue()));
|
||||
trId.setTableId(String.valueOf(task.getResult().getPrimaryTable().getId().getValue()));
|
||||
sdmxImportTabResource.setTrId(trId);
|
||||
SessionUtil.setSDMXImportTabResource(session,
|
||||
sdmxImportTabResource);
|
||||
|
@ -650,11 +651,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getResult().getException());
|
||||
+ task.getErrorMessage());
|
||||
importMonitor
|
||||
.setError(new Throwable(task
|
||||
.getResult().getException()
|
||||
.toString()));
|
||||
.setError(new Throwable(task.getErrorMessage()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In Import");
|
||||
importMonitor.setError(new Throwable(
|
||||
|
@ -930,15 +929,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
service = TabularDataServiceFactory
|
||||
.getService(aslSession.getUsername());
|
||||
List<EligibleOperation> capabilities = service.getCapabilities();
|
||||
List<OperationDescriptor> capabilities = service.getCapabilities();
|
||||
|
||||
// Import CSV file
|
||||
EligibleOperation importCSVFileOperation = getEligibleOperationWithId(
|
||||
|
||||
OperationDescriptor importCSVFileOperation = getOperationDescriptorWithId(
|
||||
OperationsId.CSVImport.toString(), capabilities);
|
||||
|
||||
OperationInvocation oi = importCSVFileOperation
|
||||
.createOperationInvocation(parameterInstance);
|
||||
logger.debug("OperationInvocation: \n" + oi.toString());
|
||||
InvocationCreator ic=InvocationCreator.getCreator(importCSVFileOperation);
|
||||
OperationInvocation invocation = ic.setParameters(parameterInstance).create();
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
TabularResource tabularResource = service.createTabularResource();
|
||||
TabResource csvImportTabResource = csvImportSession.getTabResource();
|
||||
syncTRMetaData(tabularResource, csvImportTabResource);
|
||||
|
@ -947,7 +948,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
SessionUtil.setCSVImportTabResource(session, csvImportTabResource);
|
||||
Task trTask;
|
||||
try {
|
||||
trTask = service.execute(oi, tabularResource.getId());
|
||||
trTask = service.execute(invocation, tabularResource.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
|
@ -983,7 +984,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException(
|
||||
"Error in importCSV task null");
|
||||
} else {
|
||||
ActivityStatus status = task.getStatus();
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in importCSV Status null");
|
||||
|
@ -994,11 +995,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getResult().getException());
|
||||
+ task.getErrorMessage());
|
||||
importMonitor
|
||||
.setError(new Throwable(task
|
||||
.getResult().getException()
|
||||
.toString()));
|
||||
.setError(new Throwable(task.getErrorMessage()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In Import");
|
||||
importMonitor.setError(new Throwable(
|
||||
|
@ -1009,7 +1008,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
importMonitor.setProgress(task.getProgress());
|
||||
Table table = task.getResult().getOutput();
|
||||
Table table = task.getResult().getPrimaryTable();
|
||||
|
||||
logger.debug("Table retrived: " + table.toString());
|
||||
trId.setTableId(String.valueOf(table.getId()
|
||||
|
@ -1155,7 +1154,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TRLocalizedText trLocalizedText=new TRLocalizedText();
|
||||
trLocalizedText.setId(i);
|
||||
trLocalizedText.setValue(lt.getValue());
|
||||
trLocalizedText.setLocaleCode(lt.getLocaleCode());
|
||||
trLocalizedText.setLocaleCode(lt.getLocale());
|
||||
listTRLocalizedText.add(trLocalizedText);
|
||||
i++;
|
||||
}
|
||||
|
@ -1172,7 +1171,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TRLocalizedText trLocalizedText=new TRLocalizedText();
|
||||
trLocalizedText.setId(i);
|
||||
trLocalizedText.setValue(lt.getValue());
|
||||
trLocalizedText.setLocaleCode(lt.getLocaleCode());
|
||||
trLocalizedText.setLocaleCode(lt.getLocale());
|
||||
listTRLocalizedText.add(trLocalizedText);
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,15 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.model.table.Table;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.InvocationCreator;
|
||||
import org.gcube.data.analysis.tabulardata.operation.invocation.OperationInvocation;
|
||||
|
||||
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.service.operation.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;
|
||||
|
@ -49,21 +51,24 @@ public class TestService {
|
|||
System.out.println("tabular data id: " + resource.getId().getValue());
|
||||
TabularResourceId resourceId = resource.getId();
|
||||
|
||||
List<EligibleOperation> ops = service.getCapabilities();
|
||||
EligibleOperation csvop = null;
|
||||
for (EligibleOperation op : ops) {
|
||||
System.out.println(op.getOperationDescriptor().getName());
|
||||
if (op.getOperationDescriptor().getName().equals("SDMX Codelist import"))
|
||||
List<OperationDescriptor> ops = service.getCapabilities();
|
||||
OperationDescriptor csvop = null;
|
||||
for (OperationDescriptor op : ops) {
|
||||
System.out.println(op.getName());
|
||||
if (op.getName().equals("SDMX Codelist import"))
|
||||
csvop = op;
|
||||
}
|
||||
|
||||
OperationInvocation opInvocation = csvop
|
||||
.createOperationInvocation(getParameterInvocation());
|
||||
InvocationCreator ic=InvocationCreator.getCreator(csvop);
|
||||
|
||||
|
||||
OperationInvocation opInvocation = ic.setParameters(getParameterInvocation()).create();
|
||||
|
||||
|
||||
Task task = service.execute(opInvocation, resource.getId());
|
||||
|
||||
while (task.getStatus() != ActivityStatus.FAILED
|
||||
&& task.getStatus() != ActivityStatus.SUCCEDED) {
|
||||
while (task.getStatus() != TaskStatus.FAILED
|
||||
&& task.getStatus() != TaskStatus.SUCCEDED) {
|
||||
System.out.println(task.getStatus() + " "
|
||||
+ task.getStartTime().getTime());
|
||||
|
||||
|
@ -74,10 +79,10 @@ public class TestService {
|
|||
+ task.getStartTime().getTime() + " "
|
||||
+ task.getEndTime().getTime());
|
||||
|
||||
System.out.println("Task Progress:"+task.getProgress());
|
||||
System.out.println("Task Progress:" + task.getProgress());
|
||||
Assert.assertNotNull(task.getResult());
|
||||
System.out.println("Task getResult: "+task.getResult());
|
||||
Table resultTable = task.getResult().getOutput();
|
||||
System.out.println("Task getResult: " + task.getResult());
|
||||
Table resultTable = task.getResult().getPrimaryTable();
|
||||
|
||||
System.out.println("resultTable :" + resultTable);
|
||||
|
||||
|
@ -89,6 +94,4 @@ public class TestService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ 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.operation.worker.EligibleOperation;
|
||||
import org.gcube.data.analysis.tabulardata.operation.OperationDescriptor;
|
||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
|
||||
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException;
|
||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
|
@ -20,11 +18,11 @@ public class TestServiceOperations {
|
|||
ScopeProvider.instance.set(Constants.DEFAULT_SCOPE);
|
||||
TabularDataService service = TabularDataServiceFactory
|
||||
.getService(Constants.DEFAULT_USER);
|
||||
List<EligibleOperation> trOperations = service.getCapabilities();
|
||||
List<OperationDescriptor> trOperations = service.getCapabilities();
|
||||
Assert.assertTrue(trOperations.size() > 0);
|
||||
System.out
|
||||
.println("------------Tabular Resource Operation--------------");
|
||||
for (EligibleOperation operation : trOperations) {
|
||||
for (OperationDescriptor operation : trOperations) {
|
||||
System.out.println(operation.toString());
|
||||
}
|
||||
|
||||
|
@ -37,26 +35,7 @@ public class TestServiceOperations {
|
|||
System.out.println("TabularResource:"+tr.getId());
|
||||
}
|
||||
|
||||
List<EligibleOperation> tableOperations = null;
|
||||
try {
|
||||
tableOperations = service.getCapabilities(trs.get(0).getId());
|
||||
} catch (NoSuchTabularResourceException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail("No Tabular Resource on Service: "
|
||||
+ e.getLocalizedMessage());
|
||||
} catch (InvalidTabularResourceException e) {
|
||||
e.printStackTrace();
|
||||
Assert.fail("Invalid Tabular Resource on Service: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
Assert.assertTrue("No operations present",
|
||||
tableOperations.size() > 0);
|
||||
|
||||
System.out.println("------------Table Operation--------------");
|
||||
for (EligibleOperation operation : tableOperations) {
|
||||
System.out.println(operation.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue