Added JSON Export
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@100380 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bbb0a965af
commit
180e295d2e
|
@ -16,6 +16,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
||||||
|
@ -541,6 +542,17 @@ public interface TDGWTService extends RemoteService {
|
||||||
public String startSDMXExport(SDMXExportSession exportSession)
|
public String startSDMXExport(SDMXExportSession exportSession)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
// Export JSON
|
||||||
|
/**
|
||||||
|
* Start JSON Export and invokes the client library
|
||||||
|
*
|
||||||
|
* @param jsonExportSession
|
||||||
|
* @return
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
|
public String startJSONExport(JSONExportSession jsonExportSession)
|
||||||
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
// Table Operations
|
// Table Operations
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -864,7 +876,6 @@ public interface TDGWTService extends RemoteService {
|
||||||
OperationMonitorSession operationMonitorSession)
|
OperationMonitorSession operationMonitorSession)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get List of Background Operation Monitor
|
* Get List of Background Operation Monitor
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
||||||
|
@ -212,6 +213,10 @@ public interface TDGWTServiceAsync {
|
||||||
void startSDMXExport(SDMXExportSession exportSession,
|
void startSDMXExport(SDMXExportSession exportSession,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<String> callback);
|
||||||
|
|
||||||
|
// Export JSON
|
||||||
|
void startJSONExport(JSONExportSession jsonExportSession,
|
||||||
|
AsyncCallback<String> callback);
|
||||||
|
|
||||||
// Table Operation
|
// Table Operation
|
||||||
void startChangeTableType(ChangeTableTypeSession changeTableTypeSession,
|
void startChangeTableType(ChangeTableTypeSession changeTableTypeSession,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<String> callback);
|
||||||
|
|
|
@ -35,6 +35,9 @@ public class SessionConstants {
|
||||||
protected static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
|
protected static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
|
||||||
protected static final String CSV_EXPORT_END = "CSV_EXPORT_END";
|
protected static final String CSV_EXPORT_END = "CSV_EXPORT_END";
|
||||||
|
|
||||||
|
protected static final String JSON_EXPORT_SESSION = "JSON_EXPORT_SESSION";
|
||||||
|
protected static final String JSON_EXPORT_END = "JSON_EXPORT_END";
|
||||||
|
|
||||||
protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
|
protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
|
||||||
|
|
||||||
protected static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
|
protected static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpire
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
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.sdmx.SDMXImportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
|
||||||
|
@ -308,6 +309,29 @@ public class SessionUtil {
|
||||||
return exportSession;
|
return exportSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public static void setJSONExportSession(HttpSession httpSession,
|
||||||
|
JSONExportSession s) throws TDGWTSessionExpiredException {
|
||||||
|
|
||||||
|
JSONExportSession session = (JSONExportSession) httpSession
|
||||||
|
.getAttribute(SessionConstants.JSON_EXPORT_SESSION);
|
||||||
|
if (session != null)
|
||||||
|
httpSession.removeAttribute(SessionConstants.JSON_EXPORT_SESSION);
|
||||||
|
httpSession.setAttribute(SessionConstants.JSON_EXPORT_SESSION, s);
|
||||||
|
ASLSession aslSession = getAslSession(httpSession);
|
||||||
|
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONExportSession getJSONExportSession(HttpSession httpSession) {
|
||||||
|
JSONExportSession exportSession = (JSONExportSession) httpSession
|
||||||
|
.getAttribute(SessionConstants.JSON_EXPORT_SESSION);
|
||||||
|
if (exportSession == null) {
|
||||||
|
logger.error("JSONExportSession was not acquired");
|
||||||
|
}
|
||||||
|
return exportSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
public static void setCSVFileUploadSession(HttpSession httpSession,
|
public static void setCSVFileUploadSession(HttpSession httpSession,
|
||||||
CSVFileUploadSession s) throws TDGWTSessionExpiredException {
|
CSVFileUploadSession s) throws TDGWTSessionExpiredException {
|
||||||
|
|
||||||
|
@ -447,6 +471,7 @@ public class SessionUtil {
|
||||||
return sdmxClient;
|
return sdmxClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
public static void setCSVExportEnd(HttpSession httpSession, Boolean end) {
|
public static void setCSVExportEnd(HttpSession httpSession, Boolean end) {
|
||||||
Boolean fin = (Boolean) httpSession
|
Boolean fin = (Boolean) httpSession
|
||||||
.getAttribute(SessionConstants.CSV_EXPORT_END);
|
.getAttribute(SessionConstants.CSV_EXPORT_END);
|
||||||
|
@ -466,6 +491,27 @@ public class SessionUtil {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
public static void setJSONExportEnd(HttpSession httpSession, Boolean end) {
|
||||||
|
Boolean fin = (Boolean) httpSession
|
||||||
|
.getAttribute(SessionConstants.JSON_EXPORT_END);
|
||||||
|
if (fin != null)
|
||||||
|
httpSession.removeAttribute(SessionConstants.JSON_EXPORT_END);
|
||||||
|
httpSession.setAttribute(SessionConstants.JSON_EXPORT_END, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean getJSONExportEnd(HttpSession httpSession) {
|
||||||
|
Boolean end = (Boolean) httpSession
|
||||||
|
.getAttribute(SessionConstants.JSON_EXPORT_END);
|
||||||
|
logger.debug("getJSONExportEnd(): " + end);
|
||||||
|
if (end == null) {
|
||||||
|
logger.error("JSON_EXPORT_END was not acquired");
|
||||||
|
end = false;
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
public static TRTasksManager getTRTasksManager(HttpSession httpSession) {
|
public static TRTasksManager getTRTasksManager(HttpSession httpSession) {
|
||||||
TRTasksManager tasksManager = (TRTasksManager) httpSession
|
TRTasksManager tasksManager = (TRTasksManager) httpSession
|
||||||
.getAttribute(SessionConstants.TR_TASK_MANAGER);
|
.getAttribute(SessionConstants.TR_TASK_MANAGER);
|
||||||
|
@ -643,20 +689,24 @@ public class SessionUtil {
|
||||||
return replaceColumnByExpressionSession;
|
return replaceColumnByExpressionSession;
|
||||||
} else {
|
} else {
|
||||||
replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession();
|
replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession();
|
||||||
httpSession.setAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
httpSession.setAttribute(
|
||||||
|
SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||||
replaceColumnByExpressionSession);
|
replaceColumnByExpressionSession);
|
||||||
return replaceColumnByExpressionSession;
|
return replaceColumnByExpressionSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setReplaceColumnByExpressionSession(HttpSession httpSession,
|
public static void setReplaceColumnByExpressionSession(
|
||||||
|
HttpSession httpSession,
|
||||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
||||||
ReplaceColumnByExpressionSession rce = (ReplaceColumnByExpressionSession) httpSession
|
ReplaceColumnByExpressionSession rce = (ReplaceColumnByExpressionSession) httpSession
|
||||||
.getAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
.getAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
||||||
if (rce != null) {
|
if (rce != null) {
|
||||||
httpSession.removeAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
httpSession
|
||||||
|
.removeAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
||||||
}
|
}
|
||||||
httpSession.setAttribute(SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
httpSession.setAttribute(
|
||||||
|
SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||||
replaceColumnByExpressionSession);
|
replaceColumnByExpressionSession);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1279,7 +1329,6 @@ public class SessionUtil {
|
||||||
return taskWrapper;
|
return taskWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static void removeStartedTask(HttpSession httpSession,
|
public static void removeStartedTask(HttpSession httpSession,
|
||||||
TaskWrapper taskWrapper) {
|
TaskWrapper taskWrapper) {
|
||||||
if (taskWrapper == null) {
|
if (taskWrapper == null) {
|
||||||
|
@ -1304,14 +1353,12 @@ public class SessionUtil {
|
||||||
.removeAttribute(SessionConstants.OPERATIONS_TASKS_STARTED);
|
.removeAttribute(SessionConstants.OPERATIONS_TASKS_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasksStarted.remove(taskWrapper.getTask().getId().getValue());
|
tasksStarted.remove(taskWrapper.getTask().getId().getValue());
|
||||||
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_STARTED,
|
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_STARTED,
|
||||||
tasksStarted);
|
tasksStarted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setStartedTask(HttpSession httpSession,
|
public static void setStartedTask(HttpSession httpSession,
|
||||||
TaskWrapper taskWrapper) {
|
TaskWrapper taskWrapper) {
|
||||||
if (taskWrapper == null) {
|
if (taskWrapper == null) {
|
||||||
|
@ -1336,21 +1383,20 @@ public class SessionUtil {
|
||||||
.removeAttribute(SessionConstants.OPERATIONS_TASKS_STARTED);
|
.removeAttribute(SessionConstants.OPERATIONS_TASKS_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasksStarted.put(taskWrapper.getTask().getId().getValue(), taskWrapper);
|
tasksStarted.put(taskWrapper.getTask().getId().getValue(), taskWrapper);
|
||||||
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_STARTED,
|
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_STARTED,
|
||||||
tasksStarted);
|
tasksStarted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String,TaskWrapper> getAbortedTaskMap(HttpSession httpSession) {
|
public static HashMap<String, TaskWrapper> getAbortedTaskMap(
|
||||||
|
HttpSession httpSession) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashMap<String, TaskWrapper> tasksAborted = (HashMap<String, TaskWrapper>) httpSession
|
HashMap<String, TaskWrapper> tasksAborted = (HashMap<String, TaskWrapper>) httpSession
|
||||||
.getAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED);
|
.getAttribute(SessionConstants.OPERATIONS_TASKS_ABORTED);
|
||||||
return tasksAborted;
|
return tasksAborted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static void setAbortedTasks(HttpSession httpSession,
|
public static void setAbortedTasks(HttpSession httpSession,
|
||||||
TaskWrapper taskWrapper) {
|
TaskWrapper taskWrapper) {
|
||||||
if (taskWrapper == null) {
|
if (taskWrapper == null) {
|
||||||
|
@ -1380,15 +1426,14 @@ public class SessionUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, TaskWrapper> getHiddenTaskMap(
|
||||||
public static HashMap<String,TaskWrapper> getHiddenTaskMap(HttpSession httpSession) {
|
HttpSession httpSession) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashMap<String, TaskWrapper> hiddenTasks = (HashMap<String, TaskWrapper>) httpSession
|
HashMap<String, TaskWrapper> hiddenTasks = (HashMap<String, TaskWrapper>) httpSession
|
||||||
.getAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN);
|
.getAttribute(SessionConstants.OPERATIONS_TASKS_HIDDEN);
|
||||||
return hiddenTasks;
|
return hiddenTasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static void setHiddenTask(HttpSession httpSession,
|
public static void setHiddenTask(HttpSession httpSession,
|
||||||
TaskWrapper taskWrapper) {
|
TaskWrapper taskWrapper) {
|
||||||
if (taskWrapper == null) {
|
if (taskWrapper == null) {
|
||||||
|
@ -1418,17 +1463,14 @@ public class SessionUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, TaskWrapper> getTaskInBackgroundMap(
|
||||||
public static HashMap<String,TaskWrapper> getTaskInBackgroundMap(HttpSession httpSession) {
|
HttpSession httpSession) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashMap<String, TaskWrapper> tasksInBackground = (HashMap<String, TaskWrapper>) httpSession
|
HashMap<String, TaskWrapper> tasksInBackground = (HashMap<String, TaskWrapper>) httpSession
|
||||||
.getAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
.getAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
||||||
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) {
|
||||||
|
@ -1452,8 +1494,10 @@ public class SessionUtil {
|
||||||
httpSession
|
httpSession
|
||||||
.removeAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
.removeAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
||||||
}
|
}
|
||||||
tasksInBackground.put(taskWrapper.getTask().getId().getValue(), taskWrapper);
|
tasksInBackground.put(taskWrapper.getTask().getId().getValue(),
|
||||||
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND,
|
taskWrapper);
|
||||||
|
httpSession.setAttribute(
|
||||||
|
SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND,
|
||||||
tasksInBackground);
|
tasksInBackground);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1482,12 +1526,12 @@ public class SessionUtil {
|
||||||
.removeAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
.removeAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND);
|
||||||
}
|
}
|
||||||
tasksInBackground.remove(taskWrapper.getTask().getId().getValue());
|
tasksInBackground.remove(taskWrapper.getTask().getId().getValue());
|
||||||
httpSession.setAttribute(SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND,
|
httpSession.setAttribute(
|
||||||
|
SessionConstants.OPERATIONS_TASKS_IN_BACKGROUND,
|
||||||
tasksInBackground);
|
tasksInBackground);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
||||||
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
||||||
|
|
|
@ -106,6 +106,7 @@ import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
|
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
|
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddColumn;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddColumn;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVExport;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeColumnType;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeColumnType;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeTableType;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeTableType;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Clone;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Clone;
|
||||||
|
@ -118,6 +119,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Edit
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExtractCodelist;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExtractCodelist;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4FilterColumn;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4FilterColumn;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4GroupBy;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4GroupBy;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4JSONExport;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4LabelColumn;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4LabelColumn;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Normalization;
|
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Normalization;
|
||||||
|
@ -153,6 +155,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorCreator;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorCreator;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitorSession;
|
||||||
|
@ -3417,25 +3420,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param exportSession
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
protected Map<String, Object> csvExportFileParameter(
|
|
||||||
CSVExportSession exportSession) {
|
|
||||||
Map<String, Object> parameterInstances = new HashMap<String, Object>();
|
|
||||||
parameterInstances.put(Constants.PARAMETER_ENCODING,
|
|
||||||
exportSession.getEncoding());
|
|
||||||
parameterInstances.put(Constants.PARAMETER_SEPARATOR,
|
|
||||||
exportSession.getSeparator());
|
|
||||||
parameterInstances.put(Constants.PARAMETER_VIEW_COLUMNS,
|
|
||||||
exportSession.isExportViewColumns());
|
|
||||||
parameterInstances.put(Constants.PARAMETER_COLUMNS,
|
|
||||||
exportSession.getColumnsAsString());
|
|
||||||
return parameterInstances;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param exportSession
|
* @param exportSession
|
||||||
|
@ -3644,26 +3628,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String startCSVExport(CSVExportSession exportSession)
|
public String startCSVExport(CSVExportSession exportSession)
|
||||||
throws TDGWTServiceException {
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
logger.debug("Start CSV Export");
|
logger.debug("Start CSV Export");
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
if (session == null) {
|
|
||||||
throw new TDGWTServiceException(
|
|
||||||
"Error retrieving the session: null");
|
|
||||||
}
|
|
||||||
logger.debug("Session:" + session.getId());
|
|
||||||
|
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
logger.debug("Session User:" + aslSession.getUsername());
|
|
||||||
|
|
||||||
TRId trId = SessionUtil.getTRId(session);
|
TRId trId = SessionUtil.getTRId(session);
|
||||||
if (trId == null) {
|
if (trId == null) {
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(
|
||||||
|
@ -3677,28 +3656,28 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
SessionUtil.setCSVExportSession(session, exportSession);
|
SessionUtil.setCSVExportSession(session, exportSession);
|
||||||
|
|
||||||
Map<String, Object> parameterInstance = csvExportFileParameter(exportSession);
|
|
||||||
|
|
||||||
logger.debug("Tabular Data Service");
|
|
||||||
|
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername(), aslSession.getScope()));
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
checkTabularResourceLocked(service, trId);
|
checkTabularResourceLocked(service, trId);
|
||||||
|
|
||||||
// Export CSV file
|
OpExecution4CSVExport opEx = new OpExecution4CSVExport(
|
||||||
OperationDefinition exportCSVFileOperation = OperationDefinitionMap
|
session, service, exportSession);
|
||||||
.map(OperationsId.CSVExport.toString(), service);
|
OpExecutionDirector director = new OpExecutionDirector();
|
||||||
|
director.setOperationExecutionBuilder(opEx);
|
||||||
|
director.constructOperationExecution();
|
||||||
|
OperationExecution invocation = director.getOperationExecution();
|
||||||
|
|
||||||
OperationExecution invocation = new OperationExecution(
|
if (invocation == null) {
|
||||||
exportCSVFileOperation.getOperationId(), parameterInstance);
|
throw new TDGWTServiceException(
|
||||||
|
"Error in CSVExport: Operation not supported for now!");
|
||||||
|
}
|
||||||
|
|
||||||
|
TabularResourceId serviceTR = new TabularResourceId(
|
||||||
|
Long.valueOf(trId.getId()));
|
||||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||||
Task trTask = service.execute(invocation, new TabularResourceId(
|
Task trTask = service.execute(invocation, serviceTR);
|
||||||
Long.valueOf(trId.getId())));
|
|
||||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||||
SessionUtil.setCSVExportEnd(session, false);
|
|
||||||
|
|
||||||
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||||
UIOperationsId.CSVExport, trId);
|
UIOperationsId.CSVExport, trId);
|
||||||
SessionUtil.setStartedTask(session, taskWrapper);
|
SessionUtil.setStartedTask(session, taskWrapper);
|
||||||
|
@ -3713,12 +3692,84 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
"Security exception, you haven't rights!");
|
"Security exception, you haven't rights!");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TDGWTServiceException("Error in CSVExport: "
|
throw new TDGWTServiceException("Error in JSON Export: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String startJSONExport(JSONExportSession exportSession)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
try {
|
||||||
|
|
||||||
|
logger.debug("Start JSON Export");
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
TRId trId = SessionUtil.getTRId(session);
|
||||||
|
if (trId == null) {
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Error no tabular resource in session");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trId.getTableId() == null) {
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Error no table present in session");
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionUtil.setJSONExportSession(session, exportSession);
|
||||||
|
|
||||||
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
checkTabularResourceLocked(service, trId);
|
||||||
|
|
||||||
|
OpExecution4JSONExport opEx = new OpExecution4JSONExport(
|
||||||
|
session, service, exportSession);
|
||||||
|
OpExecutionDirector director = new OpExecutionDirector();
|
||||||
|
director.setOperationExecutionBuilder(opEx);
|
||||||
|
director.constructOperationExecution();
|
||||||
|
OperationExecution invocation = director.getOperationExecution();
|
||||||
|
|
||||||
|
if (invocation == null) {
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Error in JSONExport: Operation not supported for now!");
|
||||||
|
}
|
||||||
|
|
||||||
|
TabularResourceId serviceTR = new TabularResourceId(
|
||||||
|
Long.valueOf(trId.getId()));
|
||||||
|
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||||
|
Task trTask = service.execute(invocation, serviceTR);
|
||||||
|
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||||
|
TaskWrapper taskWrapper = new TaskWrapper(trTask,
|
||||||
|
UIOperationsId.JSONExport, trId);
|
||||||
|
SessionUtil.setStartedTask(session, taskWrapper);
|
||||||
|
|
||||||
|
return trTask.getId().getValue();
|
||||||
|
|
||||||
|
} catch (TDGWTServiceException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Security exception, you haven't rights!");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException("Error in JSON Export: "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO UpThis Monitor not updated
|
// TODO UpThis Monitor not updated
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3730,9 +3781,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
throws TDGWTServiceException {
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
SessionUtil.setChangeColumnTypeSession(session,
|
SessionUtil.setChangeColumnTypeSession(session,
|
||||||
changeColumnTypeSession);
|
changeColumnTypeSession);
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
|
||||||
|
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername(), aslSession.getScope()));
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||||
|
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation Execution for CSV Export
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OpExecution4CSVExport extends OpExecutionBuilder {
|
||||||
|
protected static Logger logger = LoggerFactory
|
||||||
|
.getLogger(OpExecution4CSVExport.class);
|
||||||
|
|
||||||
|
private HttpSession session;
|
||||||
|
private TabularDataService service;
|
||||||
|
private CSVExportSession csvExportSession;
|
||||||
|
|
||||||
|
|
||||||
|
public OpExecution4CSVExport(HttpSession session, TabularDataService service,
|
||||||
|
CSVExportSession csvExportSession) {
|
||||||
|
this.service = service;
|
||||||
|
this.csvExportSession = csvExportSession;
|
||||||
|
this.session=session;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildOpEx() throws TDGWTServiceException {
|
||||||
|
logger.debug(csvExportSession.toString());
|
||||||
|
|
||||||
|
SessionUtil.setCSVExportEnd(session, false);
|
||||||
|
|
||||||
|
OperationDefinition operationDefinition;
|
||||||
|
operationDefinition = OperationDefinitionMap.map(
|
||||||
|
OperationsId.CSVExport.toString(), service);
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
map.put(Constants.PARAMETER_ENCODING,
|
||||||
|
csvExportSession.getEncoding());
|
||||||
|
map.put(Constants.PARAMETER_SEPARATOR,
|
||||||
|
csvExportSession.getSeparator());
|
||||||
|
map.put(Constants.PARAMETER_VIEW_COLUMNS,
|
||||||
|
csvExportSession.isExportViewColumns());
|
||||||
|
map.put(Constants.PARAMETER_COLUMNS,
|
||||||
|
csvExportSession.getColumnsAsString());
|
||||||
|
|
||||||
|
OperationExecution invocation = new OperationExecution(
|
||||||
|
operationDefinition.getOperationId(), map);
|
||||||
|
|
||||||
|
operationExecutionSpec.setOp(invocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||||
|
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation Execution for JSON Export
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OpExecution4JSONExport extends OpExecutionBuilder {
|
||||||
|
protected static Logger logger = LoggerFactory
|
||||||
|
.getLogger(OpExecution4JSONExport.class);
|
||||||
|
|
||||||
|
private HttpSession session;
|
||||||
|
private TabularDataService service;
|
||||||
|
private JSONExportSession jsonExportSession;
|
||||||
|
|
||||||
|
|
||||||
|
public OpExecution4JSONExport(HttpSession session, TabularDataService service,
|
||||||
|
JSONExportSession jsonExportSession) {
|
||||||
|
this.service = service;
|
||||||
|
this.jsonExportSession = jsonExportSession;
|
||||||
|
this.session=session;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildOpEx() throws TDGWTServiceException {
|
||||||
|
logger.debug(jsonExportSession.toString());
|
||||||
|
|
||||||
|
SessionUtil.setJSONExportEnd(session, false);
|
||||||
|
|
||||||
|
OperationDefinition operationDefinition;
|
||||||
|
operationDefinition = OperationDefinitionMap.map(
|
||||||
|
OperationsId.JSONExport.toString(), service);
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
map.put(Constants.PARAMETER_VIEW_COLUMNS,
|
||||||
|
jsonExportSession.isExportViewColumns());
|
||||||
|
map.put(Constants.PARAMETER_COLUMNS,
|
||||||
|
jsonExportSession.getColumnsAsString());
|
||||||
|
|
||||||
|
OperationExecution invocation = new OperationExecution(
|
||||||
|
operationDefinition.getOperationId(), map);
|
||||||
|
|
||||||
|
operationExecutionSpec.setOp(invocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.gwtservice.shared.json;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.destination.Destination;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JSONExportSession implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 407790340509190329L;
|
||||||
|
|
||||||
|
protected String id;
|
||||||
|
protected Destination destination;
|
||||||
|
protected String itemId;
|
||||||
|
protected String fileName;
|
||||||
|
protected String fileDescription;
|
||||||
|
protected ArrayList<ColumnData> columns;
|
||||||
|
protected boolean exportViewColumns;
|
||||||
|
|
||||||
|
public JSONExportSession() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ColumnData> getColumns() {
|
||||||
|
return columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColumns(ArrayList<ColumnData> columns) {
|
||||||
|
this.columns = columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getColumnsAsString() {
|
||||||
|
ArrayList<String> columnsAsString = new ArrayList<String>();
|
||||||
|
for (ColumnData cData : columns) {
|
||||||
|
columnsAsString.add(cData.getColumnId());
|
||||||
|
}
|
||||||
|
return columnsAsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getColumnsAsArrayOfString() {
|
||||||
|
ArrayList<String> columnsAsString = new ArrayList<String>();
|
||||||
|
for (ColumnData cData : columns) {
|
||||||
|
columnsAsString.add(cData.getColumnId());
|
||||||
|
}
|
||||||
|
return columnsAsString.toArray(new String[columnsAsString.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Destination getDestination() {
|
||||||
|
return destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDestination(Destination destination) {
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(String itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileDescription() {
|
||||||
|
return fileDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileDescription(String fileDescription) {
|
||||||
|
this.fileDescription = fileDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExportViewColumns() {
|
||||||
|
return exportViewColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExportViewColumns(boolean exportViewColumns) {
|
||||||
|
this.exportViewColumns = exportViewColumns;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "JSONExportSession [id=" + id + ", destination=" + destination
|
||||||
|
+ ", itemId=" + itemId + ", fileName=" + fileName
|
||||||
|
+ ", fileDescription=" + fileDescription + ", columns="
|
||||||
|
+ columns + ", exportViewColumns=" + exportViewColumns + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.WorkerStateMap;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.json.JSONExportSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
|
import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
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.TaskS;
|
||||||
|
@ -230,6 +231,7 @@ public class OperationMonitorCreator {
|
||||||
TRId trId;
|
TRId trId;
|
||||||
TabResource tabResource;
|
TabResource tabResource;
|
||||||
Table table;
|
Table table;
|
||||||
|
TabExportMetadata trExportMetadata;
|
||||||
ExportMetadata exportMetadata;
|
ExportMetadata exportMetadata;
|
||||||
|
|
||||||
switch (taskWrapper.getOperationId()) {
|
switch (taskWrapper.getOperationId()) {
|
||||||
|
@ -241,7 +243,6 @@ public class OperationMonitorCreator {
|
||||||
|
|
||||||
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
||||||
|
|
||||||
TabExportMetadata trExportMetadata;
|
|
||||||
trExportMetadata = new TabExportMetadata();
|
trExportMetadata = new TabExportMetadata();
|
||||||
trExportMetadata.setUrl(exportMetadata.getUri());
|
trExportMetadata.setUrl(exportMetadata.getUri());
|
||||||
trExportMetadata.setDestinationType(exportMetadata
|
trExportMetadata.setDestinationType(exportMetadata
|
||||||
|
@ -258,6 +259,23 @@ public class OperationMonitorCreator {
|
||||||
logger.debug("ExportMetadata: " + exportMetadata);
|
logger.debug("ExportMetadata: " + exportMetadata);
|
||||||
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
||||||
break;
|
break;
|
||||||
|
case JSONExport:
|
||||||
|
table = taskWrapper.getTask().getResult().getPrimaryTable();
|
||||||
|
logger.debug("Table retrived: " + table.toString());
|
||||||
|
exportMetadata = table.getMetadata(ExportMetadata.class);
|
||||||
|
logger.debug("ExportMetadata: " + exportMetadata);
|
||||||
|
|
||||||
|
operationMonitor.setTrId(SessionUtil.getTRId(session));
|
||||||
|
|
||||||
|
trExportMetadata = new TabExportMetadata();
|
||||||
|
trExportMetadata.setUrl(exportMetadata.getUri());
|
||||||
|
trExportMetadata.setDestinationType(exportMetadata
|
||||||
|
.getDestinationType());
|
||||||
|
trExportMetadata.setExportDate(sdf.format(exportMetadata
|
||||||
|
.getExportDate()));
|
||||||
|
|
||||||
|
saveJSONExportInDestination(exportMetadata);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
trId = new TRId();
|
trId = new TRId();
|
||||||
trId.setId(taskWrapper.getTrId().getId());
|
trId.setId(taskWrapper.getTrId().getId());
|
||||||
|
@ -349,7 +367,7 @@ public class OperationMonitorCreator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save export data on Workspace
|
* Save export csv data on Workspace
|
||||||
*
|
*
|
||||||
* @param session
|
* @param session
|
||||||
* @param user
|
* @param user
|
||||||
|
@ -390,7 +408,54 @@ public class OperationMonitorCreator {
|
||||||
} else {
|
} else {
|
||||||
logger.error("Destination No Present");
|
logger.error("Destination No Present");
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(
|
||||||
"Error in exportCSV CSVExportMonitor: no destination present");
|
"Error in export csv: no destination present");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save export json data on Workspace
|
||||||
|
*
|
||||||
|
* @param session
|
||||||
|
* @param user
|
||||||
|
* @param exportMetadata
|
||||||
|
* @param exportSession
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
|
protected void saveJSONExportInDestination(ExportMetadata exportMetadata)
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
JSONExportSession exportSession = SessionUtil
|
||||||
|
.getJSONExportSession(session);
|
||||||
|
String user = aslSession.getUsername();
|
||||||
|
|
||||||
|
logger.debug("Save Export In Destination");
|
||||||
|
logger.debug("Destination: " + exportSession.getDestination().getId());
|
||||||
|
|
||||||
|
if (exportSession.getDestination().getId().compareTo("Workspace") == 0) {
|
||||||
|
logger.debug("Save on Workspace");
|
||||||
|
boolean end = SessionUtil.getJSONExportEnd(session);
|
||||||
|
if (end == false) {
|
||||||
|
SessionUtil.setJSONExportEnd(session, true);
|
||||||
|
FilesStorage storage = new FilesStorage();
|
||||||
|
logger.debug("Create Item On Workspace: [ uri: "
|
||||||
|
+ exportMetadata.getUri() + " ,user: " + user
|
||||||
|
+ " ,fileName: " + exportSession.getFileName()
|
||||||
|
+ " ,fileDescription: "
|
||||||
|
+ exportSession.getFileDescription()
|
||||||
|
+ " ,mimetype: application/json" + " ,folder: "
|
||||||
|
+ exportSession.getItemId() + "]");
|
||||||
|
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
|
||||||
|
exportSession.getFileName(),
|
||||||
|
exportSession.getFileDescription(), "application/json",
|
||||||
|
exportSession.getItemId());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.debug("getJSONExportEnd(): true");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("Destination No Present");
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"Error in export json: no destination present");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
date="Next">
|
date="Next">
|
||||||
<Change>Updated Discard</Change>
|
<Change>Updated Discard</Change>
|
||||||
<Change>Updated CSVExportSession</Change>
|
<Change>Updated CSVExportSession</Change>
|
||||||
|
<Change>Added JSON Export</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="${groupId}.${artifactId}.2-4-0"
|
<Changeset component="${groupId}.${artifactId}.2-4-0"
|
||||||
date="2014-09-12">
|
date="2014-09-12">
|
||||||
|
|
Loading…
Reference in New Issue