From a99fc93d5d1fbc8036d4c3176a96c4e3f4b9bea3 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 4 Apr 2014 08:27:24 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94288 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 112 +++++++++++++++++- .../tr/batch/ReplaceBatchColumnSession.java | 11 ++ 2 files changed, 117 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 4f1b8f2..e804a22 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -3358,9 +3358,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements capabilities); Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition(replaceBatchColumnSession,re); + .genReplaceValueParameterCondition( + replaceBatchColumnSession, re); Expression value = ExpressionGenerator - .genReplaceBatchValueParameterValue(replaceBatchColumnSession,re); + .genReplaceBatchValueParameterValue( + replaceBatchColumnSession, re); map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, condition); @@ -3380,9 +3382,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements capabilities); Expression condition = ExpressionGenerator - .genReplaceValueParameterCondition(replaceBatchColumnSession,re); + .genReplaceValueParameterCondition( + replaceBatchColumnSession, re); Expression value = ExpressionGenerator - .genReplaceBatchValueParameterValue(replaceBatchColumnSession,re); + .genReplaceBatchValueParameterValue( + replaceBatchColumnSession, re); map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, condition); @@ -5169,8 +5173,104 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements @Override public ReplaceBatchColumnMonitor getReplaceBatchColumnMonitor() throws TDGWTServiceException { - // TODO Auto-generated method stub - return null; + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ReplaceBatchColumnSession replaceBatchColumnSession = SessionUtil + .getReplaceBatchColumnSession(session); + + Task task = SessionUtil.getReplaceBatchColumnTask(session); + ReplaceBatchColumnMonitor replaceBatchColumnMonitor = new ReplaceBatchColumnMonitor(); + + if (task == null) { + logger.debug("Task null"); + throw new TDGWTServiceException( + "Error in ReplaceBatchColumnMonitor task null"); + } else { + TaskStatus status = task.getStatus(); + if (status == null) { + logger.debug("Services TaskStatus : null"); + throw new TDGWTServiceException( + "Error in ReplaceBatchColumnMonitor Status null"); + } else { + logger.debug("Services TaskStatus: " + task.getStatus()); + + replaceBatchColumnMonitor.setStatus(TaskStateMap.map(task + .getStatus())); + + TRId trId; + TabResource tabResource; + switch (replaceBatchColumnMonitor.getStatus()) { + case FAILED: + if (task.getResult() != null) { + logger.debug("Task exception:" + + task.getErrorCause()); + replaceBatchColumnMonitor.setError(new Throwable(task + .getErrorCause())); + } else { + logger.debug("Task exception: Error In ReplaceBatchColumnMonitor"); + replaceBatchColumnMonitor.setError(new Throwable( + "Error replacing the Column value")); + } + replaceBatchColumnMonitor.setProgress(task.getProgress()); + break; + case SUCCEDED: + logger.debug("Task Result:" + task.getResult()); + replaceBatchColumnMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(replaceBatchColumnSession.getTrId().getId()); + + trId = retrieveTabularResourceBasicData(trId); + + replaceBatchColumnMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case IN_PROGRESS: + replaceBatchColumnMonitor.setProgress(task.getProgress()); + break; + case VALIDATING_RULES: + replaceBatchColumnMonitor.setProgress(task.getProgress()); + break; + case ABORTED: + break; + case STOPPED: + logger.debug("Task Result:" + task.getResult()); + replaceBatchColumnMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(replaceBatchColumnSession.getColumnData() + .getTrId().getId()); + + trId = retrieveTabularResourceBasicData(trId); + + replaceBatchColumnMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case INITIALIZING: + break; + default: + break; + } + } + SessionUtil.setReplaceBatchColumnTask(session, task); + } + + logger.info("ReplaceBatchColumnMonitor(): " + replaceBatchColumnMonitor); + return replaceBatchColumnMonitor; + } catch (Throwable e) { + logger.debug("Error in ReplaceBatchColumnMonitor: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in replace batch: " + + e.getLocalizedMessage()); + + } + } } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/ReplaceBatchColumnSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/ReplaceBatchColumnSession.java index 7aed74a..dbf82fb 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/ReplaceBatchColumnSession.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/ReplaceBatchColumnSession.java @@ -21,6 +21,17 @@ public class ReplaceBatchColumnSession implements Serializable { protected ArrayList replaceEntryList; protected boolean replaceDimension; + public ReplaceBatchColumnSession() { + } + + public ReplaceBatchColumnSession(TRId trId, ColumnData columnData, + ArrayList replaceEntryList, boolean replaceDimension) { + this.trId = trId; + this.columnData = columnData; + this.replaceEntryList = replaceEntryList; + this.replaceDimension = replaceDimension; + } + public TRId getTrId() { return trId; }