Updated Task in background

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99761 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-11 16:35:14 +00:00
parent f2f89d01fe
commit 3c4b5a7748
7 changed files with 198 additions and 79 deletions

View File

@ -14,6 +14,8 @@ public class SessionConstants {
protected static final String OPERATIONS_TASKS_STARTED="OPERATION_TASKS_STARTED"; protected static final String OPERATIONS_TASKS_STARTED="OPERATION_TASKS_STARTED";
protected static final String OPERATIONS_TASKS_IN_BACKGROUND="OPERATION_TASKS_IN_BACKGROUND"; protected static final String OPERATIONS_TASKS_IN_BACKGROUND="OPERATION_TASKS_IN_BACKGROUND";
protected static final String OPERATIONS_TASKS_ABORTED="OPERATION_TASKS_ABORTED";
protected static final String OPERATIONS_TASKS_HIDDEN="OPERATION_TASKS_HIDDEN";
protected static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR"; protected static final String FILE_UPLOAD_MONITOR = "FILE_UPLOAD_MONITOR";
protected static final String TR_TASK_MANAGER = "TR_TASK_MANAGER"; protected static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";

View File

@ -1227,7 +1227,7 @@ public class SessionUtil {
} }
public static TaskWrapper getTaskStarted(HttpSession httpSession, public static TaskWrapper getStartedTask(HttpSession httpSession,
String taskId) { String taskId) {
TaskWrapper taskWrapper = null; TaskWrapper taskWrapper = null;
@ -1252,7 +1252,7 @@ public class SessionUtil {
}; };
public static void removeTaskStarted(HttpSession httpSession, public static void removeStartedTask(HttpSession httpSession,
TaskWrapper taskWrapper) { TaskWrapper taskWrapper) {
if (taskWrapper == null) { if (taskWrapper == null) {
logger.error("TaskWrapper is null"); logger.error("TaskWrapper is null");
@ -1284,7 +1284,7 @@ public class SessionUtil {
} }
public static void setTaskStarted(HttpSession httpSession, public static void setStartedTask(HttpSession httpSession,
TaskWrapper taskWrapper) { TaskWrapper taskWrapper) {
if (taskWrapper == null) { if (taskWrapper == null) {
logger.error("TaskWrapper is null"); logger.error("TaskWrapper is null");
@ -1315,6 +1315,82 @@ public class SessionUtil {
} }
public static HashMap<String,TaskWrapper> getAbortedTaskMap(HttpSession httpSession) {
@SuppressWarnings("unchecked")
HashMap<String, TaskWrapper> tasksAborted = (HashMap<String, TaskWrapper>) httpSession
.getAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED);
return tasksAborted;
};
public static void setAbortedTasks(HttpSession httpSession,
TaskWrapper taskWrapper) {
if (taskWrapper == null) {
logger.error("TaskWrapper is null");
return;
}
if (taskWrapper.getTask().getId() == null
|| taskWrapper.getTask().getId().getValue() == null
|| taskWrapper.getTask().getId().getValue().isEmpty()) {
logger.error("TaskWrapper contains Task with invalid task id");
return;
}
@SuppressWarnings("unchecked")
HashMap<String, TaskWrapper> tasksAborted = ((HashMap<String, TaskWrapper>) httpSession
.getAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED));
if (tasksAborted == null) {
tasksAborted = new HashMap<String, TaskWrapper>();
} else {
httpSession
.removeAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED);
}
tasksAborted.put(taskWrapper.getTask().getId().getValue(), taskWrapper);
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED,
tasksAborted);
}
public static HashMap<String,TaskWrapper> getHiddenTaskMap(HttpSession httpSession) {
@SuppressWarnings("unchecked")
HashMap<String, TaskWrapper> hiddenTasks = (HashMap<String, TaskWrapper>) httpSession
.getAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN);
return hiddenTasks;
};
public static void setHiddenTask(HttpSession httpSession,
TaskWrapper taskWrapper) {
if (taskWrapper == null) {
logger.error("TaskWrapper is null");
return;
}
if (taskWrapper.getTask().getId() == null
|| taskWrapper.getTask().getId().getValue() == null
|| taskWrapper.getTask().getId().getValue().isEmpty()) {
logger.error("TaskWrapper contains Task with invalid task id");
return;
}
@SuppressWarnings("unchecked")
HashMap<String, TaskWrapper> hiddenTasks = ((HashMap<String, TaskWrapper>) httpSession
.getAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN));
if (hiddenTasks == null) {
hiddenTasks = new HashMap<String, TaskWrapper>();
} else {
httpSession
.removeAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN);
}
hiddenTasks.put(taskWrapper.getTask().getId().getValue(), taskWrapper);
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN,
hiddenTasks);
}
public static HashMap<String,TaskWrapper> getTaskInBackgroundMap(HttpSession httpSession) { public static HashMap<String,TaskWrapper> getTaskInBackgroundMap(HttpSession httpSession) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
HashMap<String, TaskWrapper> tasksInBackground = (HashMap<String, TaskWrapper>) httpSession HashMap<String, TaskWrapper> tasksInBackground = (HashMap<String, TaskWrapper>) httpSession
@ -1322,6 +1398,9 @@ public class SessionUtil {
return tasksInBackground; return tasksInBackground;
}; };
public static void setTaskInBackground(HttpSession httpSession, public static void setTaskInBackground(HttpSession httpSession,
TaskWrapper taskWrapper) { TaskWrapper taskWrapper) {
if (taskWrapper == null) { if (taskWrapper == null) {

View File

@ -2468,7 +2468,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SDMXImport, trId); UIOperationsId.SDMXImport, trId);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -2874,7 +2874,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Start Task on service: TaskId " + trTask.getId()); logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.CSVImport, trId); UIOperationsId.CSVImport, trId);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} }
@ -3583,7 +3583,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SDMXExport, trId); UIOperationsId.SDMXExport, trId);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -3658,7 +3658,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.CSVExport, trId); UIOperationsId.CSVExport, trId);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -3718,7 +3718,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeColumnType, changeColumnTypeSession UIOperationsId.ChangeColumnType, changeColumnTypeSession
.getColumnData().getTrId()); .getColumnData().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -3772,7 +3772,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.AddColumn, addColumnSession.getTrId()); UIOperationsId.AddColumn, addColumnSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -3828,7 +3828,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.DeleteColumn, deleteColumnSession.getTrId()); UIOperationsId.DeleteColumn, deleteColumnSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -3898,7 +3898,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.FilterColumn, filterColumnSession UIOperationsId.FilterColumn, filterColumnSession
.getColumn().getTrId()); .getColumn().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -3951,7 +3951,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeColumnLabel, UIOperationsId.ChangeColumnLabel,
labelColumnSession.getTrId()); labelColumnSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -4009,7 +4009,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeTableType, UIOperationsId.ChangeTableType,
changeTableTypeSession.getTrId()); changeTableTypeSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -4180,7 +4180,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.DeleteRow, deleteRowsSession.getTrId()); UIOperationsId.DeleteRow, deleteRowsSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -4267,7 +4267,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.Clone, trIdClone); UIOperationsId.Clone, trIdClone);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -4321,7 +4321,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.DuplicateTuples, duplicatesSession.getTrId()); UIOperationsId.DuplicateTuples, duplicatesSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -4720,7 +4720,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ApplyTemplate, UIOperationsId.ApplyTemplate,
templateApplySession.getTrId()); templateApplySession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -4820,7 +4820,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ReplaceValue, replaceColumnSession UIOperationsId.ReplaceValue, replaceColumnSession
.getColumnData().getTrId()); .getColumnData().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -4884,7 +4884,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ReplaceBatch, UIOperationsId.ReplaceBatch,
replaceBatchColumnSession.getTrId()); replaceBatchColumnSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -5276,7 +5276,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.RollBack, rollBackSession.getTrId()); UIOperationsId.RollBack, rollBackSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -5422,7 +5422,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.EditRow, editRowSession.getTrId()); UIOperationsId.EditRow, editRowSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -5523,7 +5523,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ResubmitTask, taskResubmitSession.getTrId()); UIOperationsId.ResubmitTask, taskResubmitSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -5661,7 +5661,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ResumeTask, taskResumeSession.getTrId()); UIOperationsId.ResumeTask, taskResumeSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
@ -5722,7 +5722,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ExtractCodelist, UIOperationsId.ExtractCodelist,
extractCodelistSession.getTrId()); extractCodelistSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -5781,7 +5781,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SplitColumn, splitColumnSession UIOperationsId.SplitColumn, splitColumnSession
.getColumnData().getTrId()); .getColumnData().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -5842,7 +5842,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.MergeColumn, mergeColumnSession UIOperationsId.MergeColumn, mergeColumnSession
.getColumnDataSource1().getTrId()); .getColumnDataSource1().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -6080,7 +6080,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.CodelistMappingImport, UIOperationsId.CodelistMappingImport,
codelistMappingSession.getTrId()); codelistMappingSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} }
@ -6118,7 +6118,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("GroupBy start on service: TaskId " + trTask.getId()); logger.debug("GroupBy start on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.GroupBy, groupBySession.getTrId()); UIOperationsId.GroupBy, groupBySession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -6174,7 +6174,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.Normalize, normalizationSession.getTrId()); UIOperationsId.Normalize, normalizationSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -6234,7 +6234,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.Denormalize, UIOperationsId.Denormalize,
denormalizationSession.getTrId()); denormalizationSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -6287,7 +6287,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Start Task on service: TaskId " + trTask.getId()); logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask, TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.Union, unionSession.getTrId()); UIOperationsId.Union, unionSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue(); return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -6316,7 +6316,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session); ASLSession aslSession = SessionUtil.getAslSession(session);
TaskWrapper taskWrapper = SessionUtil.getTaskStarted(session, TaskWrapper taskWrapper = SessionUtil.getStartedTask(session,
operationMonitorSession.getTaskId()); operationMonitorSession.getTaskId());
OperationMonitorCreator operationMonitorCreator = new OperationMonitorCreator( OperationMonitorCreator operationMonitorCreator = new OperationMonitorCreator(
@ -6374,8 +6374,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
// TODO
//TODO
@Override @Override
public ArrayList<OperationMonitor> getBackgroundOperationMonitor( public ArrayList<OperationMonitor> getBackgroundOperationMonitor(
BackgroundOperationMonitorSession backgroundOperationMonitorSession) BackgroundOperationMonitorSession backgroundOperationMonitorSession)
@ -6389,31 +6388,36 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HashMap<String, TaskWrapper> taskInBackgroundMap = SessionUtil HashMap<String, TaskWrapper> taskInBackgroundMap = SessionUtil
.getTaskInBackgroundMap(session); .getTaskInBackgroundMap(session);
OperationMonitorSession operationMonitorSession; if (taskInBackgroundMap != null) {
for (Map.Entry<String, TaskWrapper> taskInBackground : taskInBackgroundMap OperationMonitorSession operationMonitorSession;
.entrySet()) { for (Map.Entry<String, TaskWrapper> taskInBackground : taskInBackgroundMap
operationMonitorSession=new OperationMonitorSession(taskInBackground.getKey()); .entrySet()) {
operationMonitorSession.setInBackground(true); operationMonitorSession = new OperationMonitorSession(
if(backgroundOperationMonitorSession!=null){ taskInBackground.getKey());
ArrayList<OperationMonitorSession> operationMonitorSessionList=backgroundOperationMonitorSession.getOperationMonitorSessionList(); operationMonitorSession.setInBackground(true);
for(OperationMonitorSession opMonitorSession:operationMonitorSessionList){ if (backgroundOperationMonitorSession != null) {
if(opMonitorSession.getTaskId().compareTo(taskInBackground.getKey())==0){ ArrayList<OperationMonitorSession> operationMonitorSessionList = backgroundOperationMonitorSession
operationMonitorSession=opMonitorSession; .getOperationMonitorSessionList();
break; for (OperationMonitorSession opMonitorSession : operationMonitorSessionList) {
if (opMonitorSession.getTaskId().compareTo(
taskInBackground.getKey()) == 0) {
operationMonitorSession = opMonitorSession;
break;
}
} }
} }
BackgroundOperationMonitorCreator backgroundOperationMonitorCreator = new BackgroundOperationMonitorCreator(
session, aslSession, taskInBackground.getValue(),
operationMonitorSession);
OperationMonitor operationMonitor = backgroundOperationMonitorCreator
.create();
logger.debug("BackgroundOperationMonitor(): " + operationMonitor);
backgroundOperationMonitorList.add(operationMonitor);
} }
BackgroundOperationMonitorCreator backgroundOperationMonitorCreator = new BackgroundOperationMonitorCreator(
session, aslSession, taskInBackground.getValue(),
operationMonitorSession);
OperationMonitor operationMonitor = backgroundOperationMonitorCreator
.create();
logger.debug("OperationMonitor(): " + operationMonitor);
backgroundOperationMonitorList.add(operationMonitor);
} }
return backgroundOperationMonitorList; return backgroundOperationMonitorList;
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {

View File

@ -64,8 +64,8 @@ public class BackgroundOperationMonitorCreator {
* @param startTRId * @param startTRId
* @param operationMonitorSession * @param operationMonitorSession
*/ */
public BackgroundOperationMonitorCreator(HttpSession session, ASLSession aslSession, public BackgroundOperationMonitorCreator(HttpSession session,
TaskWrapper taskWrapper, ASLSession aslSession, TaskWrapper taskWrapper,
OperationMonitorSession operationMonitorSession) { OperationMonitorSession operationMonitorSession) {
this.session = session; this.session = session;
this.aslSession = aslSession; this.aslSession = aslSession;
@ -102,28 +102,39 @@ public class BackgroundOperationMonitorCreator {
taskS.setState(State.ABORTED); taskS.setState(State.ABORTED);
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
operationMonitor.setAbort(true); operationMonitor.setAbort(true);
SessionUtil.setTaskInBackground(session, taskWrapper); SessionUtil.removeTaskInBackground(session, taskWrapper);
SessionUtil.setAbortedTasks(session, taskWrapper);
postOperation(operationMonitor); postOperation(operationMonitor);
} else { } else {
if (!operationMonitorSession.isInBackground()) { if (operationMonitorSession.isHidden()) {
TaskS taskS = createTaskS(); TaskS taskS = createTaskS();
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
operationMonitor.setInBackground(false); operationMonitor.setHidden(true);
SessionUtil.removeTaskInBackground(session, taskWrapper); SessionUtil.removeTaskInBackground(session, taskWrapper);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setHiddenTask(session, taskWrapper);
postOperation(operationMonitor); postOperation(operationMonitor);
} else { } else {
TaskStatus status = taskWrapper.getTask().getStatus(); if (!operationMonitorSession.isInBackground()) {
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in OperationMonitor Status is null");
} else {
TaskS taskS = createTaskS(); TaskS taskS = createTaskS();
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
operationMonitor.setInBackground(false);
SessionUtil
.removeTaskInBackground(session, taskWrapper);
SessionUtil.setStartedTask(session, taskWrapper);
postOperation(operationMonitor);
} else {
TaskStatus status = taskWrapper.getTask().getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in OperationMonitor Status is null");
} else {
TaskS taskS = createTaskS();
operationMonitor.setTask(taskS);
}
SessionUtil.setTaskInBackground(session, taskWrapper);
postOperation(operationMonitor);
} }
SessionUtil.setTaskInBackground(session, taskWrapper);
postOperation(operationMonitor);
} }
} }

View File

@ -24,6 +24,7 @@ public class OperationMonitor implements Serializable {
private TaskS task; private TaskS task;
private boolean inBackground; private boolean inBackground;
private boolean abort; private boolean abort;
private boolean hidden;
private TRId trId; private TRId trId;
@ -84,12 +85,23 @@ public class OperationMonitor implements Serializable {
this.trId = trId; this.trId = trId;
} }
public boolean isHidden() {
return hidden;
}
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
@Override @Override
public String toString() { public String toString() {
return "OperationMonitor [taskId=" + taskId + ", operationId=" return "OperationMonitor [taskId=" + taskId + ", operationId="
+ operationId + ", task=" + task + ", inBackground=" + operationId + ", task=" + task + ", inBackground="
+ inBackground + ", abort=" + abort + ", trId=" + trId + "]"; + inBackground + ", abort=" + abort + ", hidden=" + hidden
+ ", trId=" + trId + "]";
} }
} }

View File

@ -102,7 +102,7 @@ public class OperationMonitorCreator {
taskS.setState(State.ABORTED); taskS.setState(State.ABORTED);
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
operationMonitor.setAbort(true); operationMonitor.setAbort(true);
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
postOperation(operationMonitor); postOperation(operationMonitor);
} else { } else {
if (operationMonitorSession.isInBackground()) { if (operationMonitorSession.isInBackground()) {
@ -110,7 +110,7 @@ public class OperationMonitorCreator {
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
operationMonitor.setInBackground(true); operationMonitor.setInBackground(true);
SessionUtil.setTaskInBackground(session, taskWrapper); SessionUtil.setTaskInBackground(session, taskWrapper);
SessionUtil.removeTaskStarted(session, taskWrapper); SessionUtil.removeStartedTask(session, taskWrapper);
postOperation(operationMonitor); postOperation(operationMonitor);
} else { } else {
TaskStatus status = taskWrapper.getTask().getStatus(); TaskStatus status = taskWrapper.getTask().getStatus();
@ -122,7 +122,7 @@ public class OperationMonitorCreator {
TaskS taskS = createTaskS(); TaskS taskS = createTaskS();
operationMonitor.setTask(taskS); operationMonitor.setTask(taskS);
} }
SessionUtil.setTaskStarted(session, taskWrapper); SessionUtil.setStartedTask(session, taskWrapper);
postOperation(operationMonitor); postOperation(operationMonitor);
} }
} }

View File

@ -16,6 +16,7 @@ public class OperationMonitorSession implements Serializable {
private String taskId; private String taskId;
private boolean inBackground; private boolean inBackground;
private boolean abort; private boolean abort;
private boolean hidden;
public OperationMonitorSession(){ public OperationMonitorSession(){
@ -56,10 +57,19 @@ public class OperationMonitorSession implements Serializable {
return serialVersionUID; return serialVersionUID;
} }
public boolean isHidden() {
return hidden;
}
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
@Override @Override
public String toString() { public String toString() {
return "OperationMonitorSession [taskId=" + taskId + ", inBackground=" return "OperationMonitorSession [taskId=" + taskId + ", inBackground="
+ inBackground + ", abort=" + abort + "]"; + inBackground + ", abort=" + abort + ", hidden=" + hidden
+ "]";
} }
@ -67,4 +77,5 @@ public class OperationMonitorSession implements Serializable {
} }