Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95900 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-21 13:40:26 +00:00
parent b6a77d47ae
commit 46b239a3f7
7 changed files with 308 additions and 2 deletions

View File

@ -23,6 +23,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
@ -215,6 +217,26 @@ public interface TDGWTService extends RemoteService {
public ColumnData getConnection(RefColumn refColumn)
throws TDGWTServiceException;
// Task
/**
* Get Operation Monitor during the resubmit task
*
* @return
* @throws TDGWTServiceException
*/
public TaskResubmitMonitor getTaskResubmitMonitor()
throws TDGWTServiceException;
/**
* Resubmit task
*
* @param taskResubmitSession
* @throws TDGWTServiceException
*/
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
throws TDGWTServiceException;
// Validations
/**
* Returns validations contained in the tasks

View File

@ -22,6 +22,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
@ -103,6 +105,10 @@ public interface TDGWTServiceAsync {
void getColumn(String columnLocalId,TRId trId, AsyncCallback<ColumnData> callback);
void getConnection(RefColumn refColumn, AsyncCallback<ColumnData> callback);
//Task
void getTaskResubmitMonitor(AsyncCallback<TaskResubmitMonitor> callback);
void startTaskResubmit(TaskResubmitSession taskResubmitSession,AsyncCallback<Void> callback);
//Validations
void getValidationsTasksMetadata(TRId trId,AsyncCallback<ValidationsTasksMetadata> callback);
void getTableValidationsMetadata(TRId trId,AsyncCallback<TabValidationsMetadata> callback);

View File

@ -42,6 +42,10 @@ public class SessionConstants {
protected static final String EDIT_ROW_MONITOR = "EDIT_ROW_MONITOR";
protected static final String EDIT_ROW_TASK = "EDIT_ROW_TASK";
protected static final String TASK_RESUBMIT_SESSION = "TASK_RESUBMIT_SESSION";
protected static final String TASK_RESUBMIT_MONITOR = "TASK_RESUBMIT_MONITOR";
protected static final String TASK_RESUBMIT_TASK = "TASK_RESUBMIT_TASK";
protected static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION";
protected static final String REPLACE_COLUMN_MONITOR = "REPLACE_COLUMN_MONITOR";
protected static final String REPLACE_COLUMN_TASK = "REPLACE_COLUMN_TASK";

View File

@ -16,7 +16,6 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
@ -25,6 +24,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonit
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
@ -708,6 +709,73 @@ public class SessionUtil {
httpSession.setAttribute(SessionConstants.DELETE_COLUMN_TASK, task);
}
//
public static TaskResubmitSession getTaskResubmitSession(
HttpSession httpSession) {
TaskResubmitSession taskResubmitSession = (TaskResubmitSession) httpSession
.getAttribute(SessionConstants.TASK_RESUBMIT_SESSION);
if (taskResubmitSession != null) {
return taskResubmitSession;
} else {
taskResubmitSession = new TaskResubmitSession();
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_SESSION,
taskResubmitSession);
return taskResubmitSession;
}
}
public static void setTaskResubmitSession(HttpSession httpSession,
TaskResubmitSession taskResubmitSession) {
TaskResubmitSession tr = (TaskResubmitSession) httpSession
.getAttribute(SessionConstants.TASK_RESUBMIT_SESSION);
if (tr != null) {
httpSession.removeAttribute(SessionConstants.TASK_RESUBMIT_SESSION);
}
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_SESSION, taskResubmitSession);
}
public static TaskResubmitMonitor getTaskResubmitMonitor(
HttpSession httpSession) {
TaskResubmitMonitor taskResubmitMonitor = (TaskResubmitMonitor) httpSession
.getAttribute(SessionConstants.TASK_RESUBMIT_MONITOR);
if (taskResubmitMonitor != null) {
return taskResubmitMonitor;
} else {
taskResubmitMonitor = new TaskResubmitMonitor();
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_MONITOR,
taskResubmitMonitor);
return taskResubmitMonitor;
}
}
public static void setTaskResubmitMonitor(HttpSession httpSession,
TaskResubmitMonitor TaskResubmitMonitor) {
TaskResubmitMonitor trm = (TaskResubmitMonitor) httpSession
.getAttribute(SessionConstants.TASK_RESUBMIT_MONITOR);
if (trm != null) {
httpSession.removeAttribute(SessionConstants.TASK_RESUBMIT_MONITOR);
}
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_MONITOR, TaskResubmitMonitor);
}
public static Task getTaskResubmitTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.TASK_RESUBMIT_TASK);
if (monitor == null) {
logger.error("TASK_RESUBMIT_TASK was not acquired");
}
return monitor;
}
public static void setTaskResubmitTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.TASK_RESUBMIT_TASK);
if (monitor != null)
httpSession.removeAttribute(SessionConstants.TASK_RESUBMIT_TASK);
httpSession.setAttribute(SessionConstants.TASK_RESUBMIT_TASK, task);
}
//
public static EditRowSession getEditRowSession(
HttpSession httpSession) {
@ -775,6 +843,7 @@ public class SessionUtil {
}
//
public static ReplaceColumnSession getReplaceColumnSession(

View File

@ -133,6 +133,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS;
import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
@ -6688,7 +6690,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
//TODO Connect
@Override
public ColumnData getConnection(RefColumn refColumn)
throws TDGWTServiceException {
@ -6729,4 +6731,137 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
//TODO
@Override
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setTaskResubmitSession(session, taskResubmitSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
//TabularDataService service = TabularDataServiceFactory.getService();
//TRId trId=taskResubmitSession.getTrId();
//TabularResourceId serviceTR = new TabularResourceId(id);
//Task trTask = service.execute(invocation, serviceTR);
//logger.debug("Start Task on service: TaskId " + trTask.getId());
//SessionUtil.setTaskResubmitTask(session, trTask);
return;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in resubmit task: "
+ e.getLocalizedMessage());
}
}
@Override
public TaskResubmitMonitor getTaskResubmitMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
TaskResubmitSession taskResubmitSession = SessionUtil
.getTaskResubmitSession(session);
Task task = SessionUtil.getTaskResubmitTask(session);
TaskResubmitMonitor taskResubmitMonitor = new TaskResubmitMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in TaskResubmitMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in TaskResubmitMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
taskResubmitMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
TRId trId;
TabResource tabResource;
switch (taskResubmitMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
task.getErrorCause().printStackTrace();
taskResubmitMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In TaskResubmitMonitor");
taskResubmitMonitor.setError(new Throwable(
"Error task resubmit"));
}
taskResubmitMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
taskResubmitMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(taskResubmitSession.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
taskResubmitMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
taskResubmitMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
taskResubmitMonitor.setProgress(task.getProgress());
break;
case GENERATING_VIEW:
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
taskResubmitMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(taskResubmitSession
.getTrId());
taskResubmitMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setTaskResubmitTask(session, task);
}
logger.debug("TaskResubmitMonitor(): " + taskResubmitMonitor);
return taskResubmitMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in TaskResubmitMonitor: " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
}

View File

@ -0,0 +1,18 @@
package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class TaskResubmitMonitor extends OperationMonitor implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1547897501452634298L;
}

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class TaskResubmitSession implements Serializable {
private static final long serialVersionUID = -4503878699159491057L;
protected TRId trId;
protected String taskId;
public TaskResubmitSession(){
}
public TaskResubmitSession(TRId trId, String taskId){
this.trId=trId;
this.taskId=taskId;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
@Override
public String toString() {
return "ResubmitTaskSession [trId=" + trId + ", taskId=" + taskId + "]";
}
}