Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96228 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
60b4f62ab6
commit
08a5e58b45
|
@ -86,4 +86,8 @@ public class SessionConstants {
|
|||
protected static final String ROLLBACK_MONITOR = "ROLLBACK_MONITOR";
|
||||
protected static final String ROLLBACK_TASK = "ROLLBACK_TASK";
|
||||
|
||||
protected static final String EXTRACT_CODELIST_SESSION = "EXTRACT_CODELIST_SESSION";
|
||||
protected static final String EXTRACT_CODELIST_MONITOR = "EXTRACT_CODELIST_MONITOR";
|
||||
protected static final String EXTRACT_CODELIST_TASK = "EXTRACT_CODELIST_TASK";
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ 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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSessionMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
|
@ -816,13 +818,13 @@ public class SessionUtil {
|
|||
}
|
||||
|
||||
public static void setTaskResumeMonitor(HttpSession httpSession,
|
||||
TaskResumeMonitor TaskResumeMonitor) {
|
||||
TaskResumeMonitor taskResumeMonitor) {
|
||||
TaskResumeMonitor trm = (TaskResumeMonitor) httpSession
|
||||
.getAttribute(SessionConstants.TASK_RESUME_MONITOR);
|
||||
if (trm != null) {
|
||||
httpSession.removeAttribute(SessionConstants.TASK_RESUME_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_MONITOR, TaskResumeMonitor);
|
||||
httpSession.setAttribute(SessionConstants.TASK_RESUME_MONITOR, taskResumeMonitor);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1471,6 +1473,73 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(SessionConstants.ROLLBACK_TASK, task);
|
||||
}
|
||||
|
||||
//
|
||||
public static ExtractCodelistSession getExtractCodelistSession(
|
||||
HttpSession httpSession) {
|
||||
ExtractCodelistSession extractCodelistSession = (ExtractCodelistSession) httpSession
|
||||
.getAttribute(SessionConstants.EXTRACT_CODELIST_SESSION);
|
||||
if (extractCodelistSession != null) {
|
||||
return extractCodelistSession;
|
||||
} else {
|
||||
extractCodelistSession = new ExtractCodelistSession();
|
||||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_SESSION,
|
||||
extractCodelistSession);
|
||||
return extractCodelistSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setExtractCodelistSession(HttpSession httpSession,
|
||||
ExtractCodelistSession extractCodelistSession) {
|
||||
ExtractCodelistSession ec = (ExtractCodelistSession) httpSession
|
||||
.getAttribute(SessionConstants.EXTRACT_CODELIST_SESSION);
|
||||
if (ec != null) {
|
||||
httpSession.removeAttribute(SessionConstants.EXTRACT_CODELIST_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_SESSION, extractCodelistSession);
|
||||
|
||||
}
|
||||
|
||||
public static ExtractCodelistMonitor getExtractCodelistMonitor(
|
||||
HttpSession httpSession) {
|
||||
ExtractCodelistMonitor extractCodelistMonitor = (ExtractCodelistMonitor) httpSession
|
||||
.getAttribute(SessionConstants.EXTRACT_CODELIST_MONITOR);
|
||||
if (extractCodelistMonitor != null) {
|
||||
return extractCodelistMonitor;
|
||||
} else {
|
||||
extractCodelistMonitor = new ExtractCodelistMonitor();
|
||||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_MONITOR,
|
||||
extractCodelistMonitor);
|
||||
return extractCodelistMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setExtractCodelistMonitor(HttpSession httpSession,
|
||||
ExtractCodelistMonitor extractCodelistMonitor) {
|
||||
ExtractCodelistMonitor ecm = (ExtractCodelistMonitor) httpSession
|
||||
.getAttribute(SessionConstants.EXTRACT_CODELIST_MONITOR);
|
||||
if (ecm != null) {
|
||||
httpSession.removeAttribute(SessionConstants.EXTRACT_CODELIST_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_MONITOR, extractCodelistMonitor);
|
||||
|
||||
}
|
||||
|
||||
public static Task getExtractCodelistTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.EXTRACT_CODELIST_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("EXTRACT_CODELIST_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setExtractCodelistTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.EXTRACT_CODELIST_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(SessionConstants.EXTRACT_CODELIST_TASK);
|
||||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3935,7 +3935,26 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve OperationExecution for change column type
|
||||
*
|
||||
* @param replaceColumnSession
|
||||
* @return
|
||||
*/
|
||||
//TODO
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service, ExtractCodelistSession extractCodelistSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
OperationExecution invocation = null;
|
||||
|
||||
logger.debug(extractCodelistSession.toString());
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve OperationExecution for change column type
|
||||
*
|
||||
|
@ -7096,20 +7115,156 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtractCodelistMonitor getExtractCodelistMonitor()
|
||||
throws TDGWTServiceException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public void startExtractCodelist(
|
||||
ExtractCodelistSession extractCodelistSession)
|
||||
throws TDGWTServiceException {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setExtractCodelistSession(session, extractCodelistSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("StartExtractCodelist: " + extractCodelistSession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
if (extractCodelistSession == null) {
|
||||
logger.error("ExtractCodelistSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in extract codelist: ExtractCodelistSession is null");
|
||||
}
|
||||
if (extractCodelistSession.getTabResource() == null) {
|
||||
logger.error("TabResource is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in extract codelist, TabResource is null");
|
||||
}
|
||||
|
||||
OperationExecution invocation = retrieveOperationExecution(service,
|
||||
extractCodelistSession);
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
}
|
||||
Long id= Long.valueOf(extractCodelistSession.getTrId().getTableId());
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(id);
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, serviceTR);
|
||||
logger.debug("Extract Codelist on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setExtractCodelistTask(session, trTask);
|
||||
return;
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in extract codelist: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtractCodelistMonitor getExtractCodelistMonitor()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ExtractCodelistSession extractCodelistSession = SessionUtil
|
||||
.getExtractCodelistSession(session);
|
||||
|
||||
Task task = SessionUtil.getExtractCodelistTask(session);
|
||||
ExtractCodelistMonitor extractCodelistMonitor = new ExtractCodelistMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ExtractCodelistMonitor task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in ExtractCodelistMonitor Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
extractCodelistMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
|
||||
TRId trId;
|
||||
TabResource tabResource;
|
||||
switch (extractCodelistMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
task.getErrorCause().printStackTrace();
|
||||
extractCodelistMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In ExtractCodelistMonitor");
|
||||
extractCodelistMonitor.setError(new Throwable(
|
||||
"Error task resume"));
|
||||
}
|
||||
extractCodelistMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
extractCodelistMonitor.setProgress(task.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(extractCodelistSession.getTrId().getId());
|
||||
trId = retrieveTabularResourceBasicData(trId);
|
||||
extractCodelistMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
extractCodelistMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
extractCodelistMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case GENERATING_VIEW:
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
extractCodelistMonitor.setProgress(task.getProgress());
|
||||
|
||||
trId = retrieveTabularResourceBasicData(extractCodelistSession
|
||||
.getTrId());
|
||||
|
||||
extractCodelistMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SessionUtil.setExtractCodelistTask(session, task);
|
||||
}
|
||||
|
||||
logger.debug("ExtractCodelistMonitor(): " + extractCodelistMonitor);
|
||||
return extractCodelistMonitor;
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in ExtractCodelistMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,6 +20,7 @@ public class ExtractCodelistSession implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = -2537172740573310646L;
|
||||
|
||||
protected TRId trId;
|
||||
protected TabResource tabResource;
|
||||
protected ArrayList<ColumnData> sourceColumns;
|
||||
protected ArrayList<ExtractCodelistTargetColumn> targetColumns;
|
||||
|
@ -26,8 +28,9 @@ public class ExtractCodelistSession implements Serializable {
|
|||
public ExtractCodelistSession() {
|
||||
}
|
||||
|
||||
public ExtractCodelistSession(TabResource tabResource,ArrayList<ColumnData> sourceColumns,
|
||||
public ExtractCodelistSession(TRId trId, TabResource tabResource,ArrayList<ColumnData> sourceColumns,
|
||||
ArrayList<ExtractCodelistTargetColumn> targetColumns) {
|
||||
this.trId=trId;
|
||||
this.tabResource= tabResource;
|
||||
this.sourceColumns = sourceColumns;
|
||||
this.targetColumns = targetColumns;
|
||||
|
@ -57,13 +60,22 @@ public class ExtractCodelistSession implements Serializable {
|
|||
public void setTabResource(TabResource tabResource) {
|
||||
this.tabResource = tabResource;
|
||||
}
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExtractCodelistSession [tabResource=" + tabResource
|
||||
+ ", sourceColumns=" + sourceColumns + ", targetColumns="
|
||||
+ targetColumns + "]";
|
||||
return "ExtractCodelistSession [trId=" + trId + ", tabResource="
|
||||
+ tabResource + ", sourceColumns=" + sourceColumns
|
||||
+ ", targetColumns=" + targetColumns + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue