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 64ba20f..cb857e4 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 @@ -17,6 +17,7 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; 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.trservice.TRTasksManager; +import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; @@ -78,10 +79,10 @@ public class SessionUtil { ASLSession session; if (username == null) { logger.warn("no user found in session, using test one"); - throw new TDGWTSessionExpiredException("Session Expired!"); + /*throw new TDGWTSessionExpiredException("Session Expired!");*/ // Remove comment for Test - /* + username = Constants.DEFAULT_USER; String scope = Constants.DEFAULT_SCOPE; @@ -89,7 +90,7 @@ public class SessionUtil { session = SessionManager.getInstance().getASLSession( httpSession.getId(), username); session.setScope(scope); - */ + } else { session = SessionManager.getInstance().getASLSession( httpSession.getId(), username); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4MapCreation.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4MapCreation.java index 0540ac7..1203162 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4MapCreation.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4MapCreation.java @@ -1,16 +1,21 @@ package org.gcube.portlets.user.td.gwtservice.server.opexecution; +import java.util.ArrayList; 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.column.ColumnLocalId; +import org.gcube.data.analysis.tabulardata.model.column.ColumnReference; +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.map.MapCreationSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,28 +33,49 @@ public class OpExecution4MapCreation extends OpExecutionBuilder { private TabularDataService service; private MapCreationSession mapCreationSession; - public OpExecution4MapCreation(TabularDataService service, MapCreationSession mapCreationSession) { this.service = service; - this.mapCreationSession = mapCreationSession; + this.mapCreationSession = mapCreationSession; } @Override public void buildOpEx() throws TDGWTServiceException { - logger.debug(mapCreationSession.toString()); - + logger.debug(mapCreationSession.toString()); + OperationDefinition operationDefinition; operationDefinition = OperationDefinitionMap.map( OperationsId.GenerateMap.toString(), service); Map map = new HashMap(); - + + ArrayList fut = mapCreationSession.getFeature(); + ArrayList futures = new ArrayList(); + + String tableIdS = null; + if (mapCreationSession.getTrId().isViewTable()) { + tableIdS = mapCreationSession.getTrId().getReferenceTargetTableId(); + } else { + tableIdS = mapCreationSession.getTrId().getTableId(); + } + TableId tableId = new TableId(Long.valueOf(tableIdS)); + + for (ColumnData c : fut) { + ColumnLocalId columnId = new ColumnLocalId(c.getColumnId()); + ColumnReference columnRef = new ColumnReference(tableId, columnId); + futures.add(columnRef); + } + + ColumnLocalId columnGeometryId = new ColumnLocalId(mapCreationSession + .getGeometry().getColumnId()); + ColumnReference columnGeometryRef = new ColumnReference(tableId, + columnGeometryId); + map.put(Constants.PARAMETER_GENERATEMAP_MAPNAME, mapCreationSession.getName()); - map.put(Constants.PARAMETER_GENERATEMAP_FEATURE, - mapCreationSession.getFeature()); - map.put(Constants.PARAMETER_GENERATEMAP_USEVIEW, - mapCreationSession.isUseView()); + map.put(Constants.PARAMETER_GENERATEMAP_FEATURE, futures); + map.put(Constants.PARAMETER_GENERATEMAP_GEOM, columnGeometryRef); + map.put(Constants.PARAMETER_GENERATEMAP_USEVIEW, new Boolean( + mapCreationSession.isUseView())); map.put(Constants.PARAMETER_GENERATEMAP_METAABSTRACT, mapCreationSession.getMetaAbstract()); map.put(Constants.PARAMETER_GENERATEMAP_METAPURPOSE, @@ -60,11 +86,10 @@ public class OpExecution4MapCreation extends OpExecutionBuilder { mapCreationSession.getMetaCredits()); map.put(Constants.PARAMETER_GENERATEMAP_METAKEYWORDS, mapCreationSession.getMetaKeywords()); - - + 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 5572411..f9f3abf 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 @@ -101,6 +101,7 @@ public class Constants { public static final String PARAMETER_GENERATEMAP_MAPNAME = "mapName"; public static final String PARAMETER_GENERATEMAP_FEATURE = "feature"; + public static final String PARAMETER_GENERATEMAP_GEOM = "geom"; public static final String PARAMETER_GENERATEMAP_USEVIEW = "useView"; public static final String PARAMETER_GENERATEMAP_METAABSTRACT = "metaAbstract"; public static final String PARAMETER_GENERATEMAP_METAPURPOSE = "metaPurpose";