From 3db5a7f068d03789146464e8b8bca46d47e71be6 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 26 Mar 2014 18:08:43 +0000 Subject: [PATCH] Added Replace value git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@93603 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 24 ++ .../client/rpc/TDGWTServiceAsync.java | 6 + .../td/gwtservice/server/SessionUtil.java | 102 +++++++-- .../gwtservice/server/TDGWTServiceImpl.java | 211 ++++++++++++++++-- .../server/trservice/TDTypeValueMap.java | 59 +++++ .../user/td/gwtservice/shared/Constants.java | 3 + .../tr/column/ReplaceColumnMonitor.java | 21 ++ .../tr/column/ReplaceColumnSession.java | 86 +++++++ 8 files changed, 484 insertions(+), 28 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnMonitor.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnSession.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 4d86c4d..1244e13 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 @@ -33,6 +33,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata; @@ -598,7 +600,29 @@ public interface TDGWTService extends RemoteService { public ArrayList getOccurencesForBatchReplace(ColumnData column) throws TDGWTServiceException; + + //Replace Operation + /** + * Get Operation Monitor during the replace the Column Value operation + * + * + * @return + * @throws TDGWTServiceException + */ + public ReplaceColumnMonitor getReplaceColumnMonitor() + throws TDGWTServiceException; + + /** + * Start replace the column value + * + * @param labelColumnSession + * @throws TDGWTServiceException + */ + public void startReplaceColumn(ReplaceColumnSession replaceColumnSession) + throws TDGWTServiceException; + + //Templates /** * Retrieves templates of user 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 af414be..d9e752e 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 @@ -32,6 +32,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata; @@ -187,6 +189,10 @@ public interface TDGWTServiceAsync { //BatchReplace Operation void getOccurencesForBatchReplace(ColumnData column, AsyncCallback> callback); + //Replace Operation + void getReplaceColumnMonitor(AsyncCallback callback); + void startReplaceColumn(ReplaceColumnSession replaceColumnSession,AsyncCallback callback); + //Templates void getTemplates(AsyncCallback> callback); void getTemplateApplyMonitor(AsyncCallback callback); 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 61f0cf1..8876d88 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 @@ -30,6 +30,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession; @@ -91,6 +93,10 @@ public class SessionUtil { protected static final String DELETE_COLUMN_MONITOR = "DELETE_COLUMN_MONITOR"; protected static final String DELETE_COLUMN_TASK = "DELETE_COLUMN_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"; + protected static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION"; protected static final String CHANGE_THE_COLUMN_LABEL_MONITOR = "CHANGE_THE_COLUMN_LABEL_MONITOR"; protected static final String CHANGE_THE_COLUMN_LABEL_TASK = "CHANGE_THE_COLUMN_LABEL_TASK"; @@ -106,11 +112,11 @@ public class SessionUtil { protected static final String DUPLICATES_ROWS_SESSION = "DUPLICATES_ROWS_SESSION"; protected static final String DUPLICATES_ROWS_MONITOR = "DUPLICATES_ROWS_MONITOR"; protected static final String DUPLICATES_ROWS_TASK = "DUPLICATES_ROWS_TASK"; - + protected static final String TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION"; protected static final String TEMPLATE_APPLY_MONITOR = "TEMPLATE_APPLY_MONITOR"; protected static final String TEMPLATE_APPLY_TASK = "TEMPLATE_APPLY_TASK"; - + protected static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED"; protected static final String CODELISTS_PAGING_LOADED_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY"; protected static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER"; @@ -688,7 +694,7 @@ public class SessionUtil { httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_TASK, task); } - // / + // public static DeleteColumnSession getDeleteColumnSession( HttpSession httpSession) { @@ -755,7 +761,74 @@ public class SessionUtil { httpSession.setAttribute(DELETE_COLUMN_TASK, task); } - // / + // + + public static ReplaceColumnSession getReplaceColumnSession( + HttpSession httpSession) { + ReplaceColumnSession replaceColumnSession = (ReplaceColumnSession) httpSession + .getAttribute(REPLACE_COLUMN_SESSION); + if (replaceColumnSession != null) { + return replaceColumnSession; + } else { + replaceColumnSession = new ReplaceColumnSession(); + httpSession.setAttribute(REPLACE_COLUMN_SESSION, + replaceColumnSession); + return replaceColumnSession; + } + } + + public static void setReplaceColumnSession(HttpSession httpSession, + ReplaceColumnSession replaceColumnSession) { + ReplaceColumnSession rc = (ReplaceColumnSession) httpSession + .getAttribute(REPLACE_COLUMN_SESSION); + if (rc != null) { + httpSession.removeAttribute(REPLACE_COLUMN_SESSION); + } + httpSession.setAttribute(REPLACE_COLUMN_SESSION, replaceColumnSession); + + } + + public static ReplaceColumnMonitor getReplaceColumnMonitor( + HttpSession httpSession) { + ReplaceColumnMonitor replaceColumnMonitor = (ReplaceColumnMonitor) httpSession + .getAttribute(REPLACE_COLUMN_MONITOR); + if (replaceColumnMonitor != null) { + return replaceColumnMonitor; + } else { + replaceColumnMonitor = new ReplaceColumnMonitor(); + httpSession.setAttribute(REPLACE_COLUMN_MONITOR, + replaceColumnMonitor); + return replaceColumnMonitor; + } + } + + public static void setReplaceColumnMonitor(HttpSession httpSession, + DeleteColumnMonitor replaceColumnMonitor) { + ReplaceColumnMonitor rc = (ReplaceColumnMonitor) httpSession + .getAttribute(REPLACE_COLUMN_MONITOR); + if (rc != null) { + httpSession.removeAttribute(REPLACE_COLUMN_MONITOR); + } + httpSession.setAttribute(REPLACE_COLUMN_MONITOR, replaceColumnMonitor); + + } + + public static Task getReplaceColumnTask(HttpSession httpSession) { + Task monitor = (Task) httpSession.getAttribute(REPLACE_COLUMN_TASK); + if (monitor == null) { + logger.error("REPLACE_COLUMN_TASK was not acquired"); + } + return monitor; + } + + public static void setReplaceColumnTask(HttpSession httpSession, Task task) { + Task monitor = (Task) httpSession.getAttribute(REPLACE_COLUMN_TASK); + if (monitor != null) + httpSession.removeAttribute(REPLACE_COLUMN_TASK); + httpSession.setAttribute(REPLACE_COLUMN_TASK, task); + } + + // public static ChangeTableTypeSession getChangeTableTypeSession( HttpSession httpSession) { @@ -917,14 +990,16 @@ public class SessionUtil { // - public static TemplateApplySession getTemplateApplySession(HttpSession httpSession) { + public static TemplateApplySession getTemplateApplySession( + HttpSession httpSession) { TemplateApplySession templateApplySession = (TemplateApplySession) httpSession .getAttribute(TEMPLATE_APPLY_SESSION); if (templateApplySession != null) { return templateApplySession; } else { templateApplySession = new TemplateApplySession(); - httpSession.setAttribute(TEMPLATE_APPLY_SESSION, templateApplySession); + httpSession.setAttribute(TEMPLATE_APPLY_SESSION, + templateApplySession); return templateApplySession; } } @@ -940,14 +1015,16 @@ public class SessionUtil { } - public static TemplateApplyMonitor getTemplateApplyMonitor(HttpSession httpSession) { + public static TemplateApplyMonitor getTemplateApplyMonitor( + HttpSession httpSession) { TemplateApplyMonitor templateApplyMonitor = (TemplateApplyMonitor) httpSession .getAttribute(TEMPLATE_APPLY_MONITOR); if (templateApplyMonitor != null) { return templateApplyMonitor; } else { templateApplyMonitor = new TemplateApplyMonitor(); - httpSession.setAttribute(TEMPLATE_APPLY_MONITOR, templateApplyMonitor); + httpSession.setAttribute(TEMPLATE_APPLY_MONITOR, + templateApplyMonitor); return templateApplyMonitor; } } @@ -987,7 +1064,8 @@ public class SessionUtil { return duplicatesSession; } else { duplicatesSession = new DuplicatesSession(); - httpSession.setAttribute(DUPLICATES_ROWS_SESSION, duplicatesSession); + httpSession + .setAttribute(DUPLICATES_ROWS_SESSION, duplicatesSession); return duplicatesSession; } } @@ -1010,7 +1088,8 @@ public class SessionUtil { return duplicatesMonitor; } else { duplicatesMonitor = new DuplicatesMonitor(); - httpSession.setAttribute(DUPLICATES_ROWS_MONITOR, duplicatesMonitor); + httpSession + .setAttribute(DUPLICATES_ROWS_MONITOR, duplicatesMonitor); return duplicatesMonitor; } } @@ -1041,9 +1120,6 @@ public class SessionUtil { httpSession.setAttribute(DUPLICATES_ROWS_TASK, task); } - // - - // public static ArrayList getCodelistsPagingLoaded( 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 4dee06c..42b8058 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 @@ -53,6 +53,7 @@ import org.gcube.data.analysis.tabulardata.model.column.type.DimensionColumnType import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.TimeDimensionColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.ValidationColumnType; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue; import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText; @@ -89,6 +90,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId; import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService; +import org.gcube.portlets.user.td.gwtservice.server.trservice.TDTypeValueMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap; import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList; @@ -124,6 +126,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRAgencyMetadata; @@ -2975,6 +2979,49 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements return invocation; } + + + /** + * Retrieve OperationExecution for change column type + * + * @param replaceColumnSession + * @return + */ + protected OperationExecution retrieveOperationExecution( + TabularDataService service, + ReplaceColumnSession replaceColumnSession) + throws TDGWTServiceException { + + OperationExecution invocation = null; + List capabilities = service.getCapabilities(); + + logger.debug(replaceColumnSession.toString()); + OperationDefinition operationDefinition; + Map map = new HashMap(); + + if(replaceColumnSession.getColumnData().isViewColumn()){ + logger.debug("Is a View Column, not supported for now"); + } else { + operationDefinition = OperationDefinitionMap.map( + OperationsId.ReplaceById.toString(), + capabilities); + + Integer rowId=new Integer(replaceColumnSession.getRowId()); + String dataTypeName=replaceColumnSession.getColumnData().getDataTypeName(); + String replaceValue=replaceColumnSession.getReplaceValue(); + + TDTypeValue tdValue=TDTypeValueMap.map(dataTypeName, replaceValue); + map.put(Constants.PARAMETER_REPLACE_COLUMN_VALUE, tdValue); + map.put(Constants.PARAMETER_REPLACE_COLUMN_ID, rowId); + + invocation = new OperationExecution(replaceColumnSession + .getColumnData().getColumnId(), + operationDefinition.getOperationId(), map); + } + + return invocation; + } + /** * @@ -3541,7 +3588,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements labelColumnMonitor.setStatus(TaskStateMap.map(task .getStatus())); - Table table; + TRId trId; TabResource tabResource; switch (labelColumnMonitor.getStatus()) { @@ -3561,16 +3608,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements case SUCCEDED: logger.debug("Task Result:" + task.getResult()); labelColumnMonitor.setProgress(task.getProgress()); - table = task.getResult().getPrimaryTable(); - logger.debug("Table retrived: " + table.toString()); trId = new TRId(); trId.setId(labelColumnSession.getColumnData().getTrId() .getId()); - /* - * trId.setTableId(String - * .valueOf(table.getId().getValue())); - * trId.setTableType(table.getTableType().getName()); - */ retrieveTabularResourceBasicData(trId); labelColumnMonitor.setTrId(trId); @@ -3590,16 +3630,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements case STOPPED: logger.debug("Task Result:" + task.getResult()); labelColumnMonitor.setProgress(task.getProgress()); - table = task.getResult().getPrimaryTable(); - logger.debug("Table retrived: " + table.toString()); trId = new TRId(); trId.setId(labelColumnSession.getColumnData().getTrId() .getId()); - /* - * trId.setTableId(String - * .valueOf(table.getId().getValue())); - * trId.setTableType(table.getTableType().getName()); - */ retrieveTabularResourceBasicData(trId); labelColumnMonitor.setTrId(trId); @@ -4590,4 +4623,152 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } + /** + * + * {@inheritDoc} + */ + @Override + public void startReplaceColumn(ReplaceColumnSession replaceColumnSession) + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + SessionUtil.setReplaceColumnSession(session, replaceColumnSession); + ASLSession aslSession = SessionUtil.getAslSession(session); + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername())); + TabularDataService service = TabularDataServiceFactory.getService(); + + OperationExecution invocation = retrieveOperationExecution(service, + replaceColumnSession); + if (invocation == null) { + throw new TDGWTServiceException( + "Error Replace Column Value invocation: Operation not supported"); + } + + TabularResourceId serviceTR = new TabularResourceId( + Long.valueOf(replaceColumnSession.getTrId().getId())); + logger.debug("OperationInvocation: \n" + invocation.toString()); + Task trTask = service.execute(invocation, serviceTR); + logger.debug("Start Task on service: TaskId " + trTask.getId()); + SessionUtil.setReplaceColumnTask(session, trTask); + return; + } catch (Throwable e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in operation for replace column value: " + + e.getLocalizedMessage()); + } + + + } + + /** + * + * {@inheritDoc} + */ + @Override + public ReplaceColumnMonitor getReplaceColumnMonitor() + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ReplaceColumnSession replaceColumnSession = SessionUtil + .getReplaceColumnSession(session); + + Task task = SessionUtil.getReplaceColumnTask(session); + ReplaceColumnMonitor replaceColumnMonitor = new ReplaceColumnMonitor(); + + if (task == null) { + logger.debug("Task null"); + throw new TDGWTServiceException( + "Error in ReplaceColumnMonitor task null"); + } else { + TaskStatus status = task.getStatus(); + if (status == null) { + logger.debug("Services TaskStatus : null"); + throw new TDGWTServiceException( + "Error in ReplaceColumnMonitor Status null"); + } else { + logger.debug("Services TaskStatus: " + task.getStatus()); + + replaceColumnMonitor.setStatus(TaskStateMap.map(task + .getStatus())); + + TRId trId; + TabResource tabResource; + switch (replaceColumnMonitor.getStatus()) { + case FAILED: + if (task.getResult() != null) { + logger.debug("Task exception:" + + task.getErrorCause()); + replaceColumnMonitor.setError(new Throwable(task + .getErrorCause())); + } else { + logger.debug("Task exception: Error In ReplaceColumnMonitor"); + replaceColumnMonitor.setError(new Throwable( + "Error replacing the Column value")); + } + replaceColumnMonitor.setProgress(task.getProgress()); + break; + case SUCCEDED: + logger.debug("Task Result:" + task.getResult()); + replaceColumnMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(replaceColumnSession.getTrId() + .getId()); + + retrieveTabularResourceBasicData(trId); + + replaceColumnMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case IN_PROGRESS: + replaceColumnMonitor.setProgress(task.getProgress()); + break; + case VALIDATING_RULES: + replaceColumnMonitor.setProgress(task.getProgress()); + break; + case ABORTED: + break; + case STOPPED: + logger.debug("Task Result:" + task.getResult()); + replaceColumnMonitor.setProgress(task.getProgress()); + trId = new TRId(); + trId.setId(replaceColumnSession.getColumnData().getTrId() + .getId()); + + retrieveTabularResourceBasicData(trId); + + replaceColumnMonitor.setTrId(trId); + tabResource = SessionUtil.getTabResource(session); + tabResource.setTrId(trId); + SessionUtil.setTabResource(session, tabResource); + SessionUtil.setTRId(session, trId); + break; + case INITIALIZING: + break; + default: + break; + } + } + SessionUtil.setReplaceColumnTask(session, task); + } + + logger.info("ReplaceColumnMonitor(): " + replaceColumnMonitor); + return replaceColumnMonitor; + } catch (Throwable e) { + logger.debug("Error in replace column monitor ReplaceColumnMonitor: " + + e.getLocalizedMessage()); + e.printStackTrace(); + throw new TDGWTServiceException( + "Error in replace column monitor ReplaceColumnMonitor: " + + e.getLocalizedMessage()); + + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java new file mode 100644 index 0000000..1d31afa --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java @@ -0,0 +1,59 @@ +package org.gcube.portlets.user.td.gwtservice.server.trservice; + +import java.util.Date; + +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDBoolean; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDDate; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDNumeric; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDText; +import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TDTypeValueMap { + protected static Logger logger = LoggerFactory + .getLogger(TDTypeValueMap.class); + + public static TDTypeValue map(String dataTypeName, String value) + throws TDGWTServiceException { + TDTypeValue tdTypeValue = null; + try { + switch (dataTypeName) { + case "Boolean": + Boolean b = new Boolean(value); + tdTypeValue = new TDBoolean(b); + break; + case "Date": + Long d = new Long(value); + Date date = new Date(d); + tdTypeValue = new TDDate(date); + break; + case "Geometry": + tdTypeValue = new TDText(value); + break; + case "Integer": + Integer in = new Integer(value); + tdTypeValue = new TDInteger(in); + break; + case "Numeric": + Float fl = new Float(value); + tdTypeValue = new TDNumeric(fl); + break; + case "Text": + tdTypeValue = new TDText(value); + break; + default: + break; + } + + } catch (Throwable e) { + logger.debug("Error in TDTypeValueMap: "+e.getLocalizedMessage()); + e.printStackTrace(); + throw new TDGWTServiceException("Error in TDTypeValueMap: " + + e.getLocalizedMessage()); + } + return tdTypeValue; + } +} 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 f1129cc..962ca16 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 @@ -30,6 +30,9 @@ public class Constants { public static final String PARAMETER_DATA_TYPE="dataType"; public static final String PARAMETER_TARGET_DATA_TYPE="targetDataType"; + public static final String PARAMETER_REPLACE_COLUMN_VALUE="value"; + public static final String PARAMETER_REPLACE_COLUMN_ID="id"; + public static final String NAME_PARAMETER_ID="NAME_PARAMETER_ID"; public static final String PARAMETER_KEY="key"; public static final String PARAMETER_REFERENCE_COLUMN="refColumn"; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnMonitor.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnMonitor.java new file mode 100644 index 0000000..a01f8ca --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnMonitor.java @@ -0,0 +1,21 @@ +/** + * + */ +package org.gcube.portlets.user.td.gwtservice.shared.tr.column; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class ReplaceColumnMonitor extends OperationMonitor implements Serializable { + + + private static final long serialVersionUID = -7694151843138161474L; + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnSession.java new file mode 100644 index 0000000..e6bd05c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/column/ReplaceColumnSession.java @@ -0,0 +1,86 @@ +package org.gcube.portlets.user.td.gwtservice.shared.tr.column; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class ReplaceColumnSession implements Serializable { + + private static final long serialVersionUID = -1896235499708614266L; + + protected String value; + protected String replaceValue; + protected TRId trId; + protected ColumnData columnData; + protected String rowId; + + public ReplaceColumnSession(){ + + } + + public ReplaceColumnSession(String value,String replaceValue, TRId trId, ColumnData columnData, String rowId){ + this.value=value; + this.replaceValue=replaceValue; + this.trId=trId; + this.columnData=columnData; + this.rowId=rowId; + } + + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getReplaceValue() { + return replaceValue; + } + + public void setReplaceValue(String replaceValue) { + this.replaceValue = replaceValue; + } + + public TRId getTrId() { + return trId; + } + + public void setTrId(TRId trId) { + this.trId = trId; + } + + public ColumnData getColumnData() { + return columnData; + } + + public void setColumnData(ColumnData columnData) { + this.columnData = columnData; + } + + public String getRowId() { + return rowId; + } + + public void setRowId(String rowId) { + this.rowId = rowId; + } + + @Override + public String toString() { + return "ReplaceColumnSession [value=" + value + ", replaceValue=" + + replaceValue + ", trId=" + trId + ", columnData=" + + columnData + ", rowId=" + rowId + "]"; + } + + + +}