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:
parent
f2f89d01fe
commit
3c4b5a7748
|
@ -14,6 +14,8 @@ public class SessionConstants {
|
|||
|
||||
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_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 TR_TASK_MANAGER = "TR_TASK_MANAGER";
|
||||
|
|
|
@ -1227,7 +1227,7 @@ public class SessionUtil {
|
|||
|
||||
}
|
||||
|
||||
public static TaskWrapper getTaskStarted(HttpSession httpSession,
|
||||
public static TaskWrapper getStartedTask(HttpSession httpSession,
|
||||
String taskId) {
|
||||
TaskWrapper taskWrapper = null;
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ public class SessionUtil {
|
|||
};
|
||||
|
||||
|
||||
public static void removeTaskStarted(HttpSession httpSession,
|
||||
public static void removeStartedTask(HttpSession httpSession,
|
||||
TaskWrapper taskWrapper) {
|
||||
if (taskWrapper == 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) {
|
||||
if (taskWrapper == 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) {
|
||||
@SuppressWarnings("unchecked")
|
||||
HashMap<String, TaskWrapper> tasksInBackground = (HashMap<String, TaskWrapper>) httpSession
|
||||
|
@ -1322,6 +1398,9 @@ public class SessionUtil {
|
|||
return tasksInBackground;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
public static void setTaskInBackground(HttpSession httpSession,
|
||||
TaskWrapper taskWrapper) {
|
||||
if (taskWrapper == null) {
|
||||
|
|
|
@ -2468,7 +2468,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.SDMXImport, trId);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -2874,7 +2874,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.CSVImport, trId);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
}
|
||||
|
@ -3583,7 +3583,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.SDMXExport, trId);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -3658,7 +3658,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.CSVExport, trId);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -3718,7 +3718,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ChangeColumnType, changeColumnTypeSession
|
||||
.getColumnData().getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -3772,7 +3772,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.AddColumn, addColumnSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -3828,7 +3828,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.DeleteColumn, deleteColumnSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -3898,7 +3898,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.FilterColumn, filterColumnSession
|
||||
.getColumn().getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -3951,7 +3951,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ChangeColumnLabel,
|
||||
labelColumnSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -4009,7 +4009,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ChangeTableType,
|
||||
changeTableTypeSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -4180,7 +4180,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.DeleteRow, deleteRowsSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -4267,7 +4267,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.Clone, trIdClone);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -4321,7 +4321,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.DuplicateTuples, duplicatesSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -4720,7 +4720,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ApplyTemplate,
|
||||
templateApplySession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -4820,7 +4820,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ReplaceValue, replaceColumnSession
|
||||
.getColumnData().getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -4884,7 +4884,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ReplaceBatch,
|
||||
replaceBatchColumnSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -5276,7 +5276,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.RollBack, rollBackSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -5422,7 +5422,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.EditRow, editRowSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -5523,7 +5523,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ResubmitTask, taskResubmitSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -5661,7 +5661,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ResumeTask, taskResumeSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
|
||||
return trTask.getId().getValue();
|
||||
|
||||
|
@ -5722,7 +5722,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.ExtractCodelist,
|
||||
extractCodelistSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -5781,7 +5781,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.SplitColumn, splitColumnSession
|
||||
.getColumnData().getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -5842,7 +5842,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.MergeColumn, mergeColumnSession
|
||||
.getColumnDataSource1().getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -6080,7 +6080,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.CodelistMappingImport,
|
||||
codelistMappingSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
}
|
||||
|
@ -6118,7 +6118,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("GroupBy start on service: TaskId " + trTask.getId());
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.GroupBy, groupBySession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -6174,7 +6174,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.Normalize, normalizationSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -6234,7 +6234,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.Denormalize,
|
||||
denormalizationSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -6287,7 +6287,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||
UIOperationsId.Union, unionSession.getTrId());
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
return trTask.getId().getValue();
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
@ -6316,7 +6316,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
TaskWrapper taskWrapper = SessionUtil.getTaskStarted(session,
|
||||
TaskWrapper taskWrapper = SessionUtil.getStartedTask(session,
|
||||
operationMonitorSession.getTaskId());
|
||||
|
||||
OperationMonitorCreator operationMonitorCreator = new OperationMonitorCreator(
|
||||
|
@ -6374,8 +6374,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
// TODO
|
||||
@Override
|
||||
public ArrayList<OperationMonitor> getBackgroundOperationMonitor(
|
||||
BackgroundOperationMonitorSession backgroundOperationMonitorSession)
|
||||
|
@ -6388,32 +6387,37 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
HashMap<String, TaskWrapper> taskInBackgroundMap = SessionUtil
|
||||
.getTaskInBackgroundMap(session);
|
||||
|
||||
OperationMonitorSession operationMonitorSession;
|
||||
for (Map.Entry<String, TaskWrapper> taskInBackground : taskInBackgroundMap
|
||||
.entrySet()) {
|
||||
operationMonitorSession=new OperationMonitorSession(taskInBackground.getKey());
|
||||
operationMonitorSession.setInBackground(true);
|
||||
if(backgroundOperationMonitorSession!=null){
|
||||
ArrayList<OperationMonitorSession> operationMonitorSessionList=backgroundOperationMonitorSession.getOperationMonitorSessionList();
|
||||
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("OperationMonitor(): " + operationMonitor);
|
||||
backgroundOperationMonitorList.add(operationMonitor);
|
||||
}
|
||||
|
||||
if (taskInBackgroundMap != null) {
|
||||
OperationMonitorSession operationMonitorSession;
|
||||
for (Map.Entry<String, TaskWrapper> taskInBackground : taskInBackgroundMap
|
||||
.entrySet()) {
|
||||
operationMonitorSession = new OperationMonitorSession(
|
||||
taskInBackground.getKey());
|
||||
operationMonitorSession.setInBackground(true);
|
||||
if (backgroundOperationMonitorSession != null) {
|
||||
ArrayList<OperationMonitorSession> operationMonitorSessionList = backgroundOperationMonitorSession
|
||||
.getOperationMonitorSessionList();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
return backgroundOperationMonitorList;
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
|
|
|
@ -64,8 +64,8 @@ public class BackgroundOperationMonitorCreator {
|
|||
* @param startTRId
|
||||
* @param operationMonitorSession
|
||||
*/
|
||||
public BackgroundOperationMonitorCreator(HttpSession session, ASLSession aslSession,
|
||||
TaskWrapper taskWrapper,
|
||||
public BackgroundOperationMonitorCreator(HttpSession session,
|
||||
ASLSession aslSession, TaskWrapper taskWrapper,
|
||||
OperationMonitorSession operationMonitorSession) {
|
||||
this.session = session;
|
||||
this.aslSession = aslSession;
|
||||
|
@ -102,31 +102,42 @@ public class BackgroundOperationMonitorCreator {
|
|||
taskS.setState(State.ABORTED);
|
||||
operationMonitor.setTask(taskS);
|
||||
operationMonitor.setAbort(true);
|
||||
SessionUtil.setTaskInBackground(session, taskWrapper);
|
||||
SessionUtil.removeTaskInBackground(session, taskWrapper);
|
||||
SessionUtil.setAbortedTasks(session, taskWrapper);
|
||||
postOperation(operationMonitor);
|
||||
} else {
|
||||
if (!operationMonitorSession.isInBackground()) {
|
||||
if (operationMonitorSession.isHidden()) {
|
||||
TaskS taskS = createTaskS();
|
||||
operationMonitor.setTask(taskS);
|
||||
operationMonitor.setInBackground(false);
|
||||
operationMonitor.setHidden(true);
|
||||
SessionUtil.removeTaskInBackground(session, taskWrapper);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setHiddenTask(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 {
|
||||
if (!operationMonitorSession.isInBackground()) {
|
||||
TaskS taskS = createTaskS();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return operationMonitor;
|
||||
|
|
|
@ -24,6 +24,7 @@ public class OperationMonitor implements Serializable {
|
|||
private TaskS task;
|
||||
private boolean inBackground;
|
||||
private boolean abort;
|
||||
private boolean hidden;
|
||||
private TRId trId;
|
||||
|
||||
|
||||
|
@ -83,13 +84,24 @@ public class OperationMonitor implements Serializable {
|
|||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OperationMonitor [taskId=" + taskId + ", operationId="
|
||||
+ operationId + ", task=" + task + ", inBackground="
|
||||
+ inBackground + ", abort=" + abort + ", trId=" + trId + "]";
|
||||
+ inBackground + ", abort=" + abort + ", hidden=" + hidden
|
||||
+ ", trId=" + trId + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class OperationMonitorCreator {
|
|||
taskS.setState(State.ABORTED);
|
||||
operationMonitor.setTask(taskS);
|
||||
operationMonitor.setAbort(true);
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
postOperation(operationMonitor);
|
||||
} else {
|
||||
if (operationMonitorSession.isInBackground()) {
|
||||
|
@ -110,7 +110,7 @@ public class OperationMonitorCreator {
|
|||
operationMonitor.setTask(taskS);
|
||||
operationMonitor.setInBackground(true);
|
||||
SessionUtil.setTaskInBackground(session, taskWrapper);
|
||||
SessionUtil.removeTaskStarted(session, taskWrapper);
|
||||
SessionUtil.removeStartedTask(session, taskWrapper);
|
||||
postOperation(operationMonitor);
|
||||
} else {
|
||||
TaskStatus status = taskWrapper.getTask().getStatus();
|
||||
|
@ -122,7 +122,7 @@ public class OperationMonitorCreator {
|
|||
TaskS taskS = createTaskS();
|
||||
operationMonitor.setTask(taskS);
|
||||
}
|
||||
SessionUtil.setTaskStarted(session, taskWrapper);
|
||||
SessionUtil.setStartedTask(session, taskWrapper);
|
||||
postOperation(operationMonitor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ public class OperationMonitorSession implements Serializable {
|
|||
private String taskId;
|
||||
private boolean inBackground;
|
||||
private boolean abort;
|
||||
private boolean hidden;
|
||||
|
||||
public OperationMonitorSession(){
|
||||
|
||||
|
@ -55,11 +56,20 @@ public class OperationMonitorSession implements Serializable {
|
|||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OperationMonitorSession [taskId=" + taskId + ", inBackground="
|
||||
+ inBackground + ", abort=" + abort + "]";
|
||||
+ inBackground + ", abort=" + abort + ", hidden=" + hidden
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,4 +77,5 @@ public class OperationMonitorSession implements Serializable {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue