Fixed SDMX Import

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@85120 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-06 17:12:15 +00:00
parent a57979b278
commit 23355f90de
1 changed files with 88 additions and 78 deletions

View File

@ -20,7 +20,6 @@ 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.JobResult;
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
@ -63,7 +62,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
@ -257,14 +255,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TableId tableId = null;
if (table == null) {
logger.info("Tabular resource "+tr.getId()+" has no table.");
logger.info("Tabular resource " + tr.getId() + " has no table.");
} else {
tableId = table.getId();
}
TRId trId = null;
if (tableId == null) {
logger.info("Tabular Resource "+tr.getId()+" has last table with id null.");
logger.info("Tabular Resource " + tr.getId()
+ " has last table with id null.");
} else {
trId = new TRId(String.valueOf(tr.getId().getValue()),
String.valueOf(tableId.getValue()));
@ -445,12 +444,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
map.put("agency", codelist.getAgencyId());
map.put("id", codelist.getId());
map.put("version", codelist.getVersion());
//TODO-GP: Get registry url from client
// TODO-GP: Get registry url from client
SDMXRegistryDescriptor descriptor = new GCubeSDMXRegistryDescriptor();
map.put("registryBaseUrl", descriptor.getUrl(SDMXRegistryInterfaceType.RESTV2_1));
map.put("registryBaseUrl",
descriptor.getUrl(SDMXRegistryInterfaceType.RESTV2_1));
return map;
@ -495,9 +494,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationInvocation invocation = importSDMXCodelistOperation
.createOperationInvocation(parameterInstances);
logger.debug("OperationInvocation: \n"+invocation.toString());
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = oService.execute(invocation, serviceTR.getId());
logger.debug("Start Task on service: TaskId "+trTask.getId());
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setSDMXImportTask(session, trTask);
return;
} catch (Exception e) {
@ -551,54 +550,59 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error in importSDMX task null");
} else {
logger.debug("Service task: " + task.toString());
ActivityStatus status = task.getStatus();
if (status == null) {
throw new TDGWTServiceException(
"Error in importSDMX Status null");
} else {
logger.debug("Service Task.getStatus(): "+task.getStatus());
importMonitor.setStatus(task.getStatus().ordinal());
importMonitor.setProgress(task.getProgress());
JobResult result = task.getResult();
if (result == null) {
logger.info("Task Result: Waiting");
} else {
importMonitor.setError(task.getResult()
.getException());
if (task.getResult().getOutput() == null) {
logger.info("Task Result Output: "
+ task.getResult().getOutput());
switch (importMonitor.getStatus()) {
case SUCCEDED:
importMonitor.setProgress(task.getProgress());
logger.debug("Task Result: "+task.getResult());
trId.setTableId(String.valueOf(task
.getResult().getOutput().getId()
.getValue()));
sdmxImportTabResource.setTrId(trId);
SessionUtil.setSDMXImportTabResource(
session, sdmxImportTabResource);
SessionUtil.setTabResource(session,
sdmxImportTabResource);
SessionUtil.setTRId(session, trId);
break;
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"+task.getResult().getException());
importMonitor.setError(new Throwable(task.getResult()
.getException().toString()));
} else {
if (task.getResult().getOutput().getId() == null) {
logger.info("Task Result Output Id: "
+ task.getResult().getOutput()
.getId());
} else {
logger.info("Task TableId: "
+ task.getResult().getOutput()
.getId().getValue());
trId.setTableId(String.valueOf(task
.getResult().getOutput().getId()
.getValue()));
sdmxImportTabResource.setTrId(trId);
SessionUtil.setSDMXImportTabResource(
session, sdmxImportTabResource);
SessionUtil.setTabResource(session,
sdmxImportTabResource);
SessionUtil.setTRId(session, trId);
}
importMonitor.setError(new Throwable(
"Error In Import"));
}
importMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case WAITING:
break;
case IN_PROGRESS:
importMonitor.setProgress(task.getProgress());
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setSDMXImportTask(session, task);
}
importMonitor.setTrId(trId);
}
logger.info("getImportMonitor(): " + importMonitor);
logger.debug("getSDMXImportMonitor(): " + importMonitor);
return importMonitor;
} catch (Exception e) {
e.printStackTrace();
@ -856,7 +860,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationInvocation oi = importCSVFileOperation
.createOperationInvocation(parameterInstance);
logger.debug("OperationInvocation: \n"+oi.toString());
logger.debug("OperationInvocation: \n" + oi.toString());
TabularResource tabularResource = service.createTabularResource();
TabResource csvImportTabResource = csvImportSession.getTabResource();
syncTRMetaData(tabularResource, csvImportTabResource);
@ -873,7 +877,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
logger.debug("Start Task on service: TaskId "+trTask.getId());
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setCSVImportFileTask(session, trTask);
}
@ -897,6 +901,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error in importCSV TabularResource Id null");
} else {
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in importCSV task null");
} else {
@ -905,42 +910,47 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error in importCSV Status null");
} else {
logger.debug("Status: "+task.getStatus());
importMonitor.setStatus(task.getStatus().ordinal());
importMonitor.setProgress(task.getProgress());
JobResult result = task.getResult();
if (result == null) {
logger.info("Task Result: " + task.getResult());
} else {
importMonitor.setError(task.getResult()
.getException());
if (task.getResult().getOutput() == null) {
logger.info("Task Result Output: "
+ task.getResult().getOutput());
switch (importMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"+task.getResult().getException());
importMonitor.setError(new Throwable(task.getResult()
.getException().toString()));
} else {
if (task.getResult().getOutput().getId() == null) {
logger.info("Task Result Output Id: "
+ task.getResult().getOutput()
.getId());
} else {
logger.info("Task TableId: "
+ task.getResult().getOutput()
.getId().getValue());
trId.setTableId(String.valueOf(task
.getResult().getOutput().getId()
.getValue()));
csvImportTabResource.setTrId(trId);
SessionUtil.setCSVImportTabResource(
session, csvImportTabResource);
SessionUtil.setTabResource(session,
csvImportTabResource);
SessionUtil.setTRId(session, trId);
}
importMonitor.setError(new Throwable(
"Error In Import"));
}
importMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:"+task.getResult());
importMonitor.setProgress(task.getProgress());
Table table = task.getResult().getOutput();
logger.debug("Table retrived: " + table.toString());
trId.setTableId(String.valueOf(table.getId()
.getValue()));
csvImportTabResource.setTrId(trId);
SessionUtil.setCSVImportTabResource(session,
csvImportTabResource);
SessionUtil.setTabResource(session,
csvImportTabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
importMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case INITIALIZING:
break;
case WAITING:
break;
default:
break;
}
}
SessionUtil.setCSVImportFileTask(session, task);
}