From 0dc3ddff6a5c5560090924e8e77488989f46b8d6 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 5 Aug 2014 16:15:56 +0000 Subject: [PATCH] Updated Clone git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99220 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 14 +- .../client/rpc/TDGWTServiceAsync.java | 4 +- .../gwtservice/server/SessionConstants.java | 8 +- .../td/gwtservice/server/SessionUtil.java | 41 ++++ .../gwtservice/server/TDGWTServiceImpl.java | 181 +++++++++++++----- .../td/gwtservice/server/TDLogsServlet.java | 103 ++++++++++ .../server/opexecution/OpExecution4Clone.java | 70 +++++++ .../user/td/gwtservice/shared/Constants.java | 1 + .../td/gwtservice/shared/OperationsId.java | 1 + .../shared/monitor/CloneMonitor.java | 14 ++ src/main/webapp/WEB-INF/web.xml | 42 ++-- 11 files changed, 408 insertions(+), 71 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDLogsServlet.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4Clone.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/CloneMonitor.java diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index 7b1a9e6..f7c56e5 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -20,6 +20,7 @@ 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.monitor.AddColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.ChangeTableTypeMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.monitor.CloneMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.CodelistMappingMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteRowsMonitor; @@ -377,10 +378,19 @@ public interface TDGWTService extends RemoteService { * @param labelColumnSession * @throws TDGWTServiceException */ - public TRId startCloneTabularResource( + public void startCloneTabularResource( CloneTabularResourceSession cloneTabularResourceSession) throws TDGWTServiceException; - + + /** + * Get Operation Monitor during the Clone operation + * + * @return + * @throws TDGWTServiceException + */ + public CloneMonitor getCloneMonitor() throws TDGWTServiceException; + + // /** * Initialize Codelists Paging Loader diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index 188e702..f9b17c4 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -19,6 +19,7 @@ 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.monitor.AddColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.ChangeTableTypeMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.monitor.CloneMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.CodelistMappingMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteRowsMonitor; @@ -155,7 +156,8 @@ public interface TDGWTServiceAsync { void startTDOpen(TDOpenSession tdOpenSession, AsyncCallback callback); //Clone - void startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession,AsyncCallback callback); + void getCloneMonitor(AsyncCallback callback); + void startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession, AsyncCallback callback); //SDMX diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java index 6899284..3dd8fb9 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java @@ -10,8 +10,7 @@ public class SessionConstants { protected static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE"; - protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION"; - + protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT"; protected static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT"; protected static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE"; @@ -29,7 +28,12 @@ public class SessionConstants { protected static final String CSV_EXPORT_TASK = "CSV_EXPORT_TASK"; protected static final String CSV_EXPORT_END = "CSV_EXPORT_END"; protected static final String CSV_EXPORT_MONITOR = "CSV_EXPORT_MONITOR"; + + protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION"; + protected static final String CLONE_TABULAR_RESOURCE_MONITOR = "CLONE_TABULAR_RESOURCE_MONITOR"; + protected static final String CLONE_TABULAR_RESOURCE_TASK = "CLONE_TABULAR_RESOURCE_TASK"; + protected static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION"; protected static final String CHANGE_COLUMN_TYPE_MONITOR = "CHANGE_COLUMN_TYPE_MONITOR"; protected static final String CHANGE_COLUMN_TYPE_TASK = "CHANGE_COLUMN_TYPE_TASK"; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index f4c7fad..cd68d06 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -26,6 +26,7 @@ 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.monitor.AddColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.ChangeTableTypeMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.monitor.CloneMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.CodelistMappingMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteRowsMonitor; @@ -1281,6 +1282,46 @@ public class SessionUtil { cloneTabularResourceSession); } + + public static CloneMonitor getCloneMonitor(HttpSession httpSession) { + CloneMonitor cloneMonitor = (CloneMonitor) httpSession + .getAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_MONITOR); + if (cloneMonitor != null) { + return cloneMonitor; + } else { + cloneMonitor = new CloneMonitor(); + httpSession.setAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_MONITOR, cloneMonitor); + return cloneMonitor; + } + } + + public static void setCloneMonitor(HttpSession httpSession, + DeleteRowsMonitor cloneMonitor) { + CloneMonitor cm = (CloneMonitor) httpSession + .getAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_MONITOR); + if (cm != null) { + httpSession.removeAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_MONITOR); + } + httpSession.setAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_MONITOR, cloneMonitor); + + } + + public static Task getCloneTask(HttpSession httpSession) { + Task monitor = (Task) httpSession.getAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_TASK); + if (monitor == null) { + logger.error("CLONE_TABULAR_RESOURCE_TASK was not acquired"); + } + return monitor; + } + + public static void setCloneTask(HttpSession httpSession, Task task) { + Task monitor = (Task) httpSession.getAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_TASK); + if (monitor != null) + httpSession.removeAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_TASK); + httpSession.setAttribute(SessionConstants.CLONE_TABULAR_RESOURCE_TASK, task); + } + + // / diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 89f7eee..1dbe18d 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -100,6 +100,7 @@ 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.OpExecution4ChangeColumnType; 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.OpExecution4CodelistMapping; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4DeleteColumn; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4DeleteRows; @@ -143,6 +144,7 @@ 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.monitor.AddColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.ChangeTableTypeMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.monitor.CloneMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.CodelistMappingMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteRowsMonitor; @@ -4493,8 +4495,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements logger.debug("Task exception:" + task.getErrorCause()); task.getErrorCause().printStackTrace(); - labelColumnMonitor.setError(new Throwable(task - .getErrorCause())); + labelColumnMonitor.setError(task + .getErrorCause()); } else { logger.debug("Task exception: Error In LabelColumnMonitor"); labelColumnMonitor.setError(new Throwable( @@ -5005,7 +5007,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * {@inheritDoc} */ @Override - public TRId startCloneTabularResource( + public void startCloneTabularResource( CloneTabularResourceSession cloneTabularResourceSession) throws TDGWTServiceException { try { @@ -5021,57 +5023,26 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TabularDataService service = TabularDataServiceFactory.getService(); - TabularResourceId serviceTR = new TabularResourceId( - Long.valueOf(cloneTabularResourceSession.getTrId().getId())); + + OpExecution4Clone opEx = new OpExecution4Clone(service, + cloneTabularResourceSession); + OpExecutionDirector director = new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); - TabularResource cloned = service.cloneTabularResource(serviceTR); - logger.debug("Clone: " + cloned.toString()); - Table table = service.getLastTable(cloned.getId()); - - if (table == null) { - String report = "This tabular resource has not valid last table! (TR id=" - + cloned.getId() + ")"; - logger.error(report); - throw new TDGWTServiceException(report); + if (invocation == null) { + throw new TDGWTServiceException( + "Error in invocation: Operation not supported"); } + Long id = Long.valueOf(cloneTabularResourceSession.getTrId().getId()); - logger.debug("Last Table: " + table.toString()); - Table viewTable = null; - - if (table.contains(DatasetViewTableMetadata.class)) { - DatasetViewTableMetadata dwm = table - .getMetadata(DatasetViewTableMetadata.class); - try { - viewTable = service.getTable(dwm - .getTargetDatasetViewTableId()); - } catch (Exception e) { - logger.error("view table not found"); - } - } else { - logger.debug("No DatasetViewTableMeatadata found"); - } - - TRId trId; - if (viewTable == null) { - trId = new TRId(new Long(cloned.getId().getValue()).toString(), - cloned.getTableType(), new Long(table.getId() - .getValue()).toString(), table.getTableType() - .getName()); - - } else { - trId = new TRId(new Long(cloned.getId().getValue()).toString(), - cloned.getTableType(), String.valueOf(viewTable.getId() - .getValue()), viewTable.getTableType() - .getName(), String.valueOf(table.getId() - .getValue()), true); - } - - TabResource tabResource = new TabResource(); - tabResource.setTrId(trId); - SessionUtil.setTabResource(session, tabResource); - SessionUtil.setTRId(session, trId); - - return trId; + TabularResourceId serviceTR = new TabularResourceId(id); + logger.debug("OperationInvocation: \n" + invocation.toString()); + Task trTask = service.execute(invocation, serviceTR); + logger.debug("Start Task on service: TaskId " + trTask.getId()); + SessionUtil.setCloneTask(session, trTask); + } catch (TDGWTSessionExpiredException e) { throw e; } catch (SecurityException e) { @@ -5086,6 +5057,114 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } + + /** + * + * {@inheritDoc} + */ + @Override + public CloneMonitor getCloneMonitor() + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + CloneTabularResourceSession cloneTabularResourceSession = SessionUtil + .getCloneTabularResourceSession(session); + + Task task = SessionUtil.getCloneTask(session); + CloneMonitor cloneMonitor = new CloneMonitor(); + + if (task == null) { + logger.debug("Task null"); + throw new TDGWTServiceException( + "Error in CloneMonitor task null"); + } else { + TaskStatus status = task.getStatus(); + if (status == null) { + logger.debug("Services TaskStatus : null"); + throw new TDGWTServiceException( + "Error in CloneMonitor Status null"); + } else { + logger.debug("Services TaskStatus: " + task.getStatus()); + + cloneMonitor.setStatus(TaskStateMap.map(task + .getStatus())); + // Table table; + TRId trId; + TabResource tabResource; + switch (cloneMonitor.getStatus()) { + case FAILED: + if (task.getResult() != null) { + logger.debug("Task exception: " + + task.getErrorCause()); + task.getErrorCause().printStackTrace(); + cloneMonitor.setError(new Throwable(task + .getErrorCause())); + } else { + logger.debug("Task exception: Error In CloneMonitor"); + cloneMonitor.setError(new Throwable( + "Error cloning tabular resource")); + } + cloneMonitor.setProgress(task.getProgress()); + break; + case SUCCEDED: + logger.debug("Task Result:" + task.getResult()); + cloneMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(cloneTabularResourceSession.getTrId().getId()); + + trId = retrieveTabularResourceBasicData(trId); + + cloneMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case IN_PROGRESS: + cloneMonitor.setProgress(task.getProgress()); + break; + case VALIDATING_RULES: + cloneMonitor.setProgress(task.getProgress()); + break; + case GENERATING_VIEW: + break; + case ABORTED: + break; + case STOPPED: + logger.debug("Task Result:" + task.getResult()); + cloneMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(cloneTabularResourceSession.getTrId().getId()); + trId = retrieveTabularResourceBasicData(trId); + + cloneMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case INITIALIZING: + break; + default: + break; + } + } + SessionUtil.setCloneTask(session, task); + } + + logger.debug("CloneMonitor(): " + cloneMonitor); + return cloneMonitor; + } catch (TDGWTSessionExpiredException e) { + throw e; + } catch (Throwable e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in monitor CloneMonitor: " + + e.getLocalizedMessage()); + + } + } + /** * * {@inheritDoc} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDLogsServlet.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDLogsServlet.java new file mode 100644 index 0000000..b6b600b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDLogsServlet.java @@ -0,0 +1,103 @@ +/** + * + */ +package org.gcube.portlets.user.td.gwtservice.server; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class TDLogsServlet extends HttpServlet { + + private static final long serialVersionUID = -737451890907300011L; + protected static Logger logger = LoggerFactory + .getLogger(TDLogsServlet.class); + + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + handleRequest(req, resp); + } + + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + handleRequest(req, resp); + } + + protected void handleRequest(HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + + logger.debug("TDLogsServlet"); + long startTime = System.currentTimeMillis(); + + HttpSession session = request.getSession(); + + if (session == null) { + logger.error("Error getting the upload session, no session valid found: " + + session); + response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT, + "ERROR-Error getting the user session, no session found" + + session); + return; + } + + logger.debug("TDLogsServlet import session id: " + session.getId()); + + ByteArrayInputStream in = null; + ByteArrayOutputStream out = null; + try { + response.setContentType("text/html; charset=utf-8"); + String relativeWebPath = "/logs/TabularDataManagerLogBack.log"; + out = new ByteArrayOutputStream(); + + String absoluteDiskPath = getServletContext().getRealPath( + relativeWebPath); + File file = new File(absoluteDiskPath); + + in = new ByteArrayInputStream(FileUtils.readFileToByteArray(file)); + + IOUtils.copy(in, out); + + response.getOutputStream().write(out.toByteArray()); + + response.setStatus(HttpServletResponse.SC_OK); + + } catch (FileNotFoundException e) { + logger.error("File not found: " + e.getLocalizedMessage()); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, + e.getLocalizedMessage()); + + } catch (IOException e) { + logger.error("IO error: " + e.getLocalizedMessage()); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, + e.getLocalizedMessage()); + } finally { + if (in != null) { + in.close(); + } + if (out != null) { + out.close(); + } + } + + logger.debug("Response in " + (System.currentTimeMillis() - startTime)); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4Clone.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4Clone.java new file mode 100644 index 0000000..b32f4a4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4Clone.java @@ -0,0 +1,70 @@ +package org.gcube.portlets.user.td.gwtservice.server.opexecution; + +import java.util.HashMap; +import java.util.Map; + +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.model.table.TableId; +import org.gcube.data.analysis.tabulardata.service.TabularDataService; +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.tr.clone.CloneTabularResourceSession; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Operation Execution for delete column + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class OpExecution4Clone extends OpExecutionBuilder { + protected static Logger logger = LoggerFactory + .getLogger(OpExecution4Clone.class); + + private TabularDataService service; + private CloneTabularResourceSession cloneTabularResourceSession; + + public OpExecution4Clone(TabularDataService service, + CloneTabularResourceSession cloneTabularResourceSession) { + this.service = service; + this.cloneTabularResourceSession = cloneTabularResourceSession; + } + + @Override + public void buildOpEx() throws TDGWTServiceException { + logger.debug(cloneTabularResourceSession.toString()); + + if(cloneTabularResourceSession.getTrId()==null){ + logger.error("TRId is null"); + new TDGWTServiceException("No valid tabular resource id present"); + } + + TRId trId=cloneTabularResourceSession.getTrId(); + TableId tableId; + if(trId.isViewTable()){ + tableId=new TableId(Long.valueOf(trId.getReferenceTargetTableId())); + } else { + tableId=new TableId(Long.valueOf(trId.getTableId())); + } + + + OperationDefinition operationDefinition; + operationDefinition = OperationDefinitionMap.map( + OperationsId.CLONE.toString(), service); + Map map = new HashMap(); + + map.put(Constants.PARAMETER_CLONE_TABLE, tableId); + + OperationExecution invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + + operationExecutionSpec.setOp(invocation); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java index b0655b6..41b5fcc 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java @@ -95,5 +95,6 @@ public class Constants { public static final String PARAMETER_DENORMALIZATION_VALUE_COLUMN = "value_column"; public static final String PARAMETER_DENORMALIZATION_ATTRIBUTE_COLUMN = "attribute_column"; + public static final String PARAMETER_CLONE_TABLE = "table"; } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/OperationsId.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/OperationsId.java index 9471eb0..03eab25 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/OperationsId.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/OperationsId.java @@ -67,6 +67,7 @@ package org.gcube.portlets.user.td.gwtservice.shared; public enum OperationsId { CSVImport("100"), CSVExport("101"), + CLONE("102"), SDMXCodelistImport("200"), SDMXCodelistExport("201"), SDMXDatasetImport("202"), diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/CloneMonitor.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/CloneMonitor.java new file mode 100644 index 0000000..26f35fb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/CloneMonitor.java @@ -0,0 +1,14 @@ +package org.gcube.portlets.user.td.gwtservice.shared.monitor; + +import java.io.Serializable; + + +public class CloneMonitor extends OperationMonitor implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8626668361737808483L; + + +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 163cef8..47c5d9d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -5,64 +5,76 @@ - + TDGWTService org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl - + CSVImportFileServlet org.gcube.portlets.user.td.gwtservice.server.CSVImportFileServlet - + LocalUploadServlet org.gcube.portlets.user.td.gwtservice.server.LocalUploadServlet - + CodelistMappingUploadServlet org.gcube.portlets.user.td.gwtservice.server.CodelistMappingUploadServlet - + + + TDLogsServlet + org.gcube.portlets.user.td.gwtservice.server.TDLogsServlet + + jUnitHostImpl com.google.gwt.junit.server.JUnitHostImpl - + TDGWTService /tdgwtservice/TDGWTService - + CSVImportFileServlet /tdgwtservice/CSVImportFileServlet - + LocalUploadServlet /tdgwtservice/LocalUploadServlet - + CodelistMappingUploadServlet /tdgwtservice/CodelistMappingUploadServlet - + jUnitHostImpl TDServiceManagerWidgets/junithost/* - - - - TDGWTService.html - + + TDLogsServlet + /tdgwtservice/TDLogsServlet + + + + + + + + TDGWTService.html +