From f6da612b29d014c0e3b42385d06d1da1bf659ccc Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 16 Jul 2014 17:51:16 +0000 Subject: [PATCH] Updated Curation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98707 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../td/gwtservice/server/SessionUtil.java | 4 +- .../gwtservice/server/TDGWTServiceImpl.java | 87 +++++++++++++------ .../server/trservice/QueryService.java | 21 +++-- .../shared/task/TaskResumeSession.java | 31 ++++++- 4 files changed, 103 insertions(+), 40 deletions(-) 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 1eaef3c..b7dab90 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 @@ -95,9 +95,9 @@ public class SessionUtil { if (username == null) { logger.warn("no user found in session, using test one"); throw new TDGWTSessionExpiredException("Session Expired!"); - /* - //Remove comment for Test + //Remove comment for Test + /* username = Constants.DEFAULT_USER; String scope = Constants.DEFAULT_SCOPE; 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 1cf9cb0..d81cef5 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.Locales; import org.gcube.data.analysis.tabulardata.model.metadata.column.DataLocaleMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.column.ValidationReferencesMetadata; @@ -119,6 +120,7 @@ import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage; import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; 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.OperationsId; @@ -7026,31 +7028,69 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements Map map = new HashMap(); ArrayList columnMapping = taskResumeSession .getColumnMapping(); - + Task trTask; if (columnMapping != null && columnMapping.size() > 0) { - HashMap mapping = new HashMap(); + HashMap mapping = new HashMap(); + logger.debug("New Mapping"); for (ColumnMappingData columnMappingData : columnMapping) { if (columnMappingData.getSourceArg() != null && columnMappingData.getTargetArg() != null) { DimensionRow source = columnMappingData.getSourceArg(); DimensionRow target = columnMappingData.getTargetArg(); - mapping.put(new Long(source.getRowId()), new Long( - target.getRowId())); + + TDTypeValue tdValue = TDTypeValueMap + .map(taskResumeSession.getColumn() + .getDataTypeName(), source.getValue()); + logger.debug("Key = " + tdValue + " - " + + new Long(target.getRowId())); + mapping.put(tdValue, new Long(target.getRowId())); } } + /* + InvocationS invocationS = taskResumeSession.getInvocationS(); + + if (invocationS != null) { + HashMap mapParameters = invocationS + .getParameters(); + if (mapParameters != null) { + logger.debug("Map Class: "+mapParameters + .get(Constants.PARAMETER_COLUMN_MAPPING).getClass()); + @SuppressWarnings("unchecked") + Map mappingPrevious = (Map) mapParameters + .get(Constants.PARAMETER_COLUMN_MAPPING); + logger.debug("Previous Mapping"); + if (mappingPrevious != null) { + for (TDTypeValue key : mappingPrevious.keySet()) { + logger.debug("Key = " + key + " - " + + mappingPrevious.get(key)); + mapping.put(key, mappingPrevious.get(key)); + } + } else { + logger.debug("Previous Mapping is null"); + } + + } else { + logger.debug("Parameters is null"); + } + } else { + logger.debug("InvocationS is null"); + } + */ + map.put(Constants.PARAMETER_COLUMN_MAPPING, mapping); - trTask = service.resume(taskId,map); - logger.debug("Resume Task on service: [TaskId:" + trTask.getId()+", Map:"+map+"]"); + trTask = service.resume(taskId, map); + logger.debug("Resume Task on service: [TaskId:" + + trTask.getId() + ", Map:" + map + "]"); } else { trTask = service.resume(taskId); - logger.debug("Resume Task on service: [TaskId:" + trTask.getId()+"]"); + logger.debug("Resume Task on service: [TaskId:" + + trTask.getId() + "]"); } - SessionUtil.setTaskResumeTask(session, trTask); return; @@ -8410,8 +8450,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } - - + /** * * {@inheritDoc} @@ -8428,8 +8467,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements aslSession.getUsername(), aslSession.getScope())); TabularDataService service = TabularDataServiceFactory.getService(); - OpExecution4Union opEx = new OpExecution4Union( - service, unionSession); + OpExecution4Union opEx = new OpExecution4Union(service, + unionSession); OpExecutionDirector director = new OpExecutionDirector(); director.setOperationExecutionBuilder(opEx); director.constructOperationExecution(); @@ -8456,9 +8495,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Security exception, you haven't rights!"); } catch (Throwable e) { e.printStackTrace(); - throw new TDGWTServiceException( - "Error in union: " - + e.getLocalizedMessage()); + throw new TDGWTServiceException("Error in union: " + + e.getLocalizedMessage()); } } @@ -8468,12 +8506,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * {@inheritDoc} */ @Override - public UnionMonitor getUnionMonitor() - throws TDGWTServiceException { + public UnionMonitor getUnionMonitor() throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); - UnionSession unionSession = SessionUtil - .getUnionSession(session); + UnionSession unionSession = SessionUtil.getUnionSession(session); Task task = SessionUtil.getUnionTask(session); UnionMonitor unionMonitor = new UnionMonitor(); @@ -8491,8 +8527,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } else { logger.debug("Services TaskStatus: " + task.getStatus()); - unionMonitor.setStatus(TaskStateMap.map(task - .getStatus())); + unionMonitor.setStatus(TaskStateMap.map(task.getStatus())); TRId trId; TabResource tabResource; @@ -8563,17 +8598,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } catch (TDGWTSessionExpiredException e) { throw e; } catch (Throwable e) { - logger.debug("Error in UnionMonitor: " - + e.getLocalizedMessage()); + logger.debug("Error in UnionMonitor: " + e.getLocalizedMessage()); e.printStackTrace(); - throw new TDGWTServiceException( - "Error in union monitor: " - + e.getLocalizedMessage()); + throw new TDGWTServiceException("Error in union monitor: " + + e.getLocalizedMessage()); } } - - } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java index e96814f..9c08b76 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java @@ -105,17 +105,24 @@ public class QueryService { querySelect = new QuerySelect(Arrays.asList( new QueryColumn(columnId), new QueryColumn( - sourceColumnId))); + sourceColumnId),new QueryColumn(columnId, + Function.COUNT))); logger.debug("Occurences querySelect:" + querySelect.toString()); + queryGroup = new QueryGroup(Arrays.asList(columnId, sourceColumnId)); + logger.debug("Occurences queryGroup:" + + queryGroup.toString()); } else { - ColumnLocalId idColumn = retrieveColumnLocalIdOFIdColumnType( - column.getTrId(), service); + //ColumnLocalId idColumn = retrieveColumnLocalIdOFIdColumnType( + // column.getTrId(), service); querySelect = new QuerySelect(Arrays.asList( - new QueryColumn(columnId), new QueryColumn( - idColumn))); + new QueryColumn(columnId),new QueryColumn(columnId, + Function.COUNT))); logger.debug("Occurences querySelect:" + querySelect.toString()); + queryGroup = new QueryGroup(Arrays.asList(columnId)); + logger.debug("Occurences queryGroup:" + + queryGroup.toString()); } break; case CastValidation: @@ -350,11 +357,11 @@ public class QueryService { if (column.isViewColumn()) { occurence = new Occurrences( currentRow.getString(0), - currentRow.getString(1), 1); + currentRow.getString(1), currentRow.getInt(2)); } else { occurence = new Occurrences( currentRow.getString(0), - currentRow.getString(1), 1); + "1", currentRow.getInt(1)); } break; case CastValidation: diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/TaskResumeSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/TaskResumeSession.java index 9688f26..62b0328 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/TaskResumeSession.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/task/TaskResumeSession.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.task; import java.io.Serializable; import java.util.ArrayList; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.mapping.ColumnMappingData; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; @@ -18,8 +19,10 @@ public class TaskResumeSession implements Serializable { protected TRId trId; protected String taskId; + protected ColumnData column; protected ArrayList columnMapping; - + protected InvocationS invocationS; + public TaskResumeSession() { } @@ -31,10 +34,12 @@ public class TaskResumeSession implements Serializable { } public TaskResumeSession(TRId trId, String taskId, - ArrayList columnMapping) { + ArrayList columnMapping, ColumnData column, InvocationS invocationS) { this.trId = trId; this.taskId = taskId; this.columnMapping = columnMapping; + this.column=column; + this.invocationS=invocationS; } public TRId getTrId() { @@ -61,12 +66,32 @@ public class TaskResumeSession implements Serializable { this.columnMapping = columnMapping; } + public ColumnData getColumn() { + return column; + } + + public void setColumn(ColumnData column) { + this.column = column; + } + + public InvocationS getInvocationS() { + return invocationS; + } + + public void setInvocationS(InvocationS invocationS) { + this.invocationS = invocationS; + } + @Override public String toString() { return "TaskResumeSession [trId=" + trId + ", taskId=" + taskId - + ", columnMapping=" + columnMapping + "]"; + + ", column=" + column + ", columnMapping=" + columnMapping + + ", invocationS=" + invocationS + "]"; } + + + }