From 67621940f41a0ceb52e3fc6cace6643420f75dba Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 22 Oct 2014 16:16:53 +0000 Subject: [PATCH] Added Statistical Operation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@100887 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 26 +++ .../client/rpc/TDGWTServiceAsync.java | 76 ++++--- .../gwtservice/server/SessionConstants.java | 2 + .../td/gwtservice/server/SessionUtil.java | 27 +++ .../gwtservice/server/TDGWTServiceImpl.java | 198 ++++++++++++++++-- .../OpExecution4StatisticalOperation.java | 76 +++++++ .../user/td/gwtservice/shared/Constants.java | 7 +- .../td/gwtservice/shared/UIOperationsId.java | 3 +- .../StatisticalOperationSession.java | 113 ++++++++++ 9 files changed, 480 insertions(+), 48 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4StatisticalOperation.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gwtservice/shared/statistical/StatisticalOperationSession.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 91bb58c..d40b973 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 @@ -27,6 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTemplate; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; +import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession; import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata; @@ -454,7 +455,19 @@ public interface TDGWTService extends RemoteService { */ public ArrayList getColumns(TRId trId) throws TDGWTServiceException; + + /** + * Retrieves the list of columns in the table provided by trId + * view columns included + * + * @param trId + * @return + * @throws TDGWTServiceException + */ + public ArrayList getColumnWithViewColumnIncluded(TRId trId) + throws TDGWTServiceException; + /** * Retrieves the list of columns in the table provided by trId only CODE and * CODENAME types @@ -1002,5 +1015,18 @@ public interface TDGWTService extends RemoteService { */ public String startMapCreation(MapCreationSession mapCreationSession) throws TDGWTServiceException; + + + // Statistical + /** + * + * @param statisticalOperationSession + * @return + * @throws TDGWTServiceException + */ + public String startStatisticalOperation(StatisticalOperationSession statisticalOperationSession) + throws TDGWTServiceException; + + } 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 749bb92..04666f2 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 @@ -26,6 +26,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTemplate; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; +import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession; import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata; @@ -85,9 +86,10 @@ public interface TDGWTServiceAsync { void hello(AsyncCallback callback); void restoreUISession(AsyncCallback callback); - - void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback callback); - + + void getUriFromResolver(UriResolverSession uriResolverSession, + AsyncCallback callback); + // TabularResource void getCurrentTRId(AsyncCallback callback); @@ -99,7 +101,7 @@ public interface TDGWTServiceAsync { void isTabularResourceValid(TRId trId, AsyncCallback callback); void getInSessionTabResourceInfo(AsyncCallback callback); - + void getTabResourceInformation(AsyncCallback callback); void getTabResourceInformation(TRId trId, @@ -130,6 +132,9 @@ public interface TDGWTServiceAsync { void getColumns(TRId trId, AsyncCallback> callback); + void getColumnWithViewColumnIncluded(TRId trId, + AsyncCallback> callback); + void getColumnsForDimension(TRId trId, AsyncCallback> callback); @@ -140,16 +145,16 @@ public interface TDGWTServiceAsync { AsyncCallback callback); void getConnection(RefColumn refColumn, AsyncCallback callback); - - + void closeAllTabularResources(AsyncCallback callback); - - void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId, AsyncCallback callback); - + + void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId, + AsyncCallback callback); + void closeTabularResource(TRId closeTRId, AsyncCallback callback); - - void setActiveTabularResource(TRId activeTRId,AsyncCallback callback); - + + void setActiveTabularResource(TRId activeTRId, AsyncCallback callback); + // Task void startTaskResubmit(TaskResubmitSession taskResubmitSession, AsyncCallback callback); @@ -175,10 +180,10 @@ public interface TDGWTServiceAsync { // Share void setShare(ShareTabResource shareInfo, AsyncCallback callback); - - void setShareTemplate(ShareTemplate shareTemplate,AsyncCallback callback); - - + + void setShareTemplate(ShareTemplate shareTemplate, + AsyncCallback callback); + // CodelistPagingLoaded void setCodelistsPagingLoader(AsyncCallback callback); @@ -237,8 +242,8 @@ public interface TDGWTServiceAsync { // Export JSON void startJSONExport(JSONExportSession jsonExportSession, - AsyncCallback callback); - + AsyncCallback callback); + // Table Operation void startChangeTableType(ChangeTableTypeSession changeTableTypeSession, AsyncCallback callback); @@ -305,10 +310,10 @@ public interface TDGWTServiceAsync { // Locales void getLocales(AsyncCallback> callback); - + // Licences void getLicences(AsyncCallback> callback); - + // History void getHistory(AsyncCallback> callback); @@ -345,21 +350,28 @@ public interface TDGWTServiceAsync { // Operation Monitor void getOperationMonitor(OperationMonitorSession operationMonitorSession, AsyncCallback callback); - - void getBackgroundOperationMonitor(BackgroundOperationMonitorSession backgroundOperationMonitorSession, + + void getBackgroundOperationMonitor( + BackgroundOperationMonitorSession backgroundOperationMonitorSession, AsyncCallback> callback); // File Upload Monitor void getFileUploadMonitor(AsyncCallback callback); - - - //ResourceTD - void getResourcesTD(TRId trId,AsyncCallback> callback); - void getResourcesTDByType(TRId trId, ResourceTDType reourceTDType,AsyncCallback> callback); - - - //GIS MAP + + // ResourceTD + void getResourcesTD(TRId trId, + AsyncCallback> callback); + + void getResourcesTDByType(TRId trId, ResourceTDType reourceTDType, + AsyncCallback> callback); + + // GIS MAP void startMapCreation(MapCreationSession mapCreationSession, - AsyncCallback callback); - + AsyncCallback callback); + + // Statistical + void startStatisticalOperation( + StatisticalOperationSession statisticalOperationSession, + AsyncCallback callback); + } 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 a8cd485..205bcac 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 @@ -64,6 +64,8 @@ public class SessionConstants { protected static final String UNION_SESSION = "UNION_SESSION"; + protected static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION"; + protected static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION"; protected static final String DENORMALIZATION_SESSION = "DENORMALIZATION_SESSION"; 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 4460fdd..8cd9c77 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 @@ -29,6 +29,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.map.MapCreationSession; 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.source.SDMXRegistrySource; +import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResubmitSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession; import org.gcube.portlets.user.td.gwtservice.shared.task.TaskWrapper; @@ -1424,6 +1425,32 @@ public class SessionUtil { } + + // + public static StatisticalOperationSession getStatisticalOperationSession(HttpSession httpSession) { + StatisticalOperationSession statisticalOperationSession = (StatisticalOperationSession) httpSession + .getAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION); + if (statisticalOperationSession != null) { + return statisticalOperationSession; + } else { + statisticalOperationSession = new StatisticalOperationSession(); + httpSession.setAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION, + statisticalOperationSession); + return statisticalOperationSession; + } + } + + public static void setStatisticalOperationSession(HttpSession httpSession, + StatisticalOperationSession statisticalOperationSession) { + StatisticalOperationSession so = (StatisticalOperationSession) httpSession + .getAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION); + if (so != null) { + httpSession.removeAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION); + } + httpSession.setAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION, statisticalOperationSession); + + } + // / public static MapCreationSession getMapCreationSession( 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 ec53fe9..a019131 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 @@ -130,6 +130,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Repl import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumn; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumnByExpression; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SplitColumn; +import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4StatisticalOperation; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Union; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecutionDirector; import org.gcube.portlets.user.td.gwtservice.server.resource.ResourceTDCreator; @@ -175,6 +176,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTabResource; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareTemplate; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; import org.gcube.portlets.user.td.gwtservice.shared.source.SourceType; +import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession; import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS; import org.gcube.portlets.user.td.gwtservice.shared.task.JobS; import org.gcube.portlets.user.td.gwtservice.shared.task.State; @@ -877,6 +879,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * * {@inheritDoc} */ + @Override public ArrayList getColumns(TRId trId) throws TDGWTServiceException { try { @@ -988,6 +991,121 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } + /** + * Returns ArrayList other than IdColumnType, + * ValidationColumnType + * + * + * {@inheritDoc} + */ + public ArrayList getColumnWithViewColumnIncluded(TRId trId) + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getAslSession(session); + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername(), aslSession.getScope())); + TabularDataService service = TabularDataServiceFactory.getService(); + + logger.debug("getColumns():" + trId.toString()); + + Table table = service.getTable(new TableId(Long.valueOf(trId + .getTableId()))); + + ArrayList columns = new ArrayList(); + + List cols = table.getColumns(); + int i = 0; + for (Column c : cols) { + if (c.getColumnType() instanceof IdColumnType + || c.getColumnType() instanceof ValidationColumnType) { + + } else { + ColumnData cData = new ColumnData(); + cData.setId(Integer.toString(i)); + cData.setColumnId(c.getLocalId().getValue()); + cData.setName(c.getName()); + cData.setTypeCode(c.getColumnType().getCode()); + cData.setTypeName(c.getColumnType().getName()); + cData.setDataTypeName(c.getDataType().getName()); + ColumnRelationship rel = c.getRelationship(); + if (rel != null) { + RelationshipData relData = new RelationshipData(rel + .getTargetTableId().getValue(), rel + .getTargetColumnId().getValue()); + cData.setRelationship(relData); + + } + NamesMetadata labelsMetadata = null; + try { + labelsMetadata = c.getMetadata(NamesMetadata.class); + } catch (NoSuchMetadataException e) { + logger.debug("labelMetadata: NoSuchMetadataException " + + e.getLocalizedMessage()); + } + + if (labelsMetadata == null) { + cData.setLabel("nolabel"); + logger.debug("LabelsMetadata no labels"); + } else { + LocalizedText cl = null; + cl = labelsMetadata.getTextWithLocale("en"); + if (cl == null) { + cData.setLabel("nolabel"); + logger.debug("ColumnLabel no label in en"); + } else { + if (cl.getValue() == null + || cl.getValue().isEmpty()) { + cData.setLabel("nolabel"); + logger.debug("ColumnLabel no label in en"); + } else { + cData.setLabel(cl.getValue()); + logger.debug("Column Set Label: " + + cl.getValue()); + } + } + } + + DataLocaleMetadata dataLocaleMetadata = null; + try { + dataLocaleMetadata = c + .getMetadata(DataLocaleMetadata.class); + } catch (NoSuchMetadataException e) { + logger.debug("DataLocaleMetadata: NoSuchMetadataException " + + e.getLocalizedMessage()); + } + + if (dataLocaleMetadata == null) { + logger.debug("No DataLocaleMetadata"); + } else { + cData.setLocale(dataLocaleMetadata.getLocale()); + } + + cData.setTrId(trId); + columns.add(cData); + i++; + + } + + } + + return columns; + + } catch (TDGWTServiceException e) { + throw e; + } catch (SecurityException e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Security exception, you haven't rights!"); + } catch (Throwable e) { + logger.error( + "Error retrieving Columns: " + e.getLocalizedMessage(), e); + throw new TDGWTServiceException("Error retrieving Columns: " + + e.getLocalizedMessage()); + } + } + /** * * {@inheritDoc} @@ -3991,7 +4109,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error in CSVExport: Operation not supported for now!"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -4065,7 +4182,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error in JSONExport: Operation not supported for now!"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -4132,7 +4248,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error in ChangeColumnType: Operation not supported for now!"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -4407,7 +4522,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "Error in invocation: Operation not supported"); } - + logger.debug("OperationInvocation: \n" + invocation.toString()); logger.debug("Start Replace on Service:" @@ -4477,7 +4592,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements if (invocations == null) { throw new TDGWTServiceException("Operation not supported"); } - + logger.debug("OperationInvocation: \n" + invocations); Task trTask = service.executeBatch(invocations, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -4720,7 +4835,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error Delete Rows invocation: Operation not supported"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -4785,10 +4899,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "Error in invocation: Operation not supported"); } - - - TabularResource cloneTR = service.createTabularResource(); cloneTR.setAllMetadata(tabularResource.getAllMetadata()); NameMetadata nameMetadata = cloneTR.getMetadata(NameMetadata.class); @@ -4874,7 +4985,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error Delete Rows invocation: Operation not supported"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -5498,7 +5608,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error Replace Column Value invocation: Operation not supported"); } - logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -5565,7 +5674,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements if (invocations == null) { throw new TDGWTServiceException("Operation not supported"); } - + logger.debug("OperationInvocation: \n" + invocations.toString()); Task trTask = service.executeBatch(invocations, tabularResourceId); if (trTask == null) { @@ -6163,7 +6272,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "Error in invocation: Operation not supported"); } - + logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Start Task on service: TaskId " + trTask.getId()); @@ -6483,7 +6592,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "Error in invocation: Operation not supported"); } - + logger.debug("OperationInvocation: \n" + invocation.toString()); Task trTask = service.execute(invocation, tabularResourceId); logger.debug("Extract Codelist on service: TaskId " @@ -7119,6 +7228,67 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } + + /** + * + * {@inheritDoc} + */ + @Override + public String startStatisticalOperation(StatisticalOperationSession statisticalOperationSession) + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + SessionUtil.setStatisticalOperationSession(session, statisticalOperationSession); + ASLSession aslSession = SessionUtil.getAslSession(session); + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername(), aslSession.getScope())); + TabularDataService service = TabularDataServiceFactory.getService(); + + checkTRId(statisticalOperationSession.getTrId()); + + TabularResourceId tabularResourceId = new TabularResourceId( + Long.valueOf(statisticalOperationSession.getTrId().getId())); + TabularResource tabularResource = service + .getTabularResource(tabularResourceId); + + checkTabularResourceLocked(tabularResource); + + OpExecution4StatisticalOperation opEx = new OpExecution4StatisticalOperation(service, aslSession, + statisticalOperationSession); + OpExecutionDirector director = new OpExecutionDirector(); + director.setOperationExecutionBuilder(opEx); + director.constructOperationExecution(); + OperationExecution invocation = director.getOperationExecution(); + + if (invocation == null) { + throw new TDGWTServiceException( + "Error Statistical Operation invocation: Operation not supported"); + } + + logger.debug("OperationInvocation: \n" + invocation.toString()); + Task trTask = service.execute(invocation, tabularResourceId); + logger.debug("Start Task on service: TaskId " + trTask.getId()); + TaskWrapper taskWrapper = new TaskWrapper(trTask, + UIOperationsId.StatisticalOperation, statisticalOperationSession.getTrId()); + 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 statistical operation: " + + e.getLocalizedMessage()); + } + + } + + /** * * {@inheritDoc} diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4StatisticalOperation.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4StatisticalOperation.java new file mode 100644 index 0000000..f616dd3 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4StatisticalOperation.java @@ -0,0 +1,76 @@ +package org.gcube.portlets.user.td.gwtservice.server.opexecution; + +import java.util.HashMap; +import java.util.Map; + +import org.gcube.application.framework.core.session.ASLSession; +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.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.statistical.StatisticalOperationSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Operation Execution for union + * + * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it + * + */ +public class OpExecution4StatisticalOperation extends OpExecutionBuilder { + protected static Logger logger = LoggerFactory + .getLogger(OpExecution4StatisticalOperation.class); + + private TabularDataService service; + private ASLSession aslSession; + private StatisticalOperationSession statisticalOperationSession; + + + public OpExecution4StatisticalOperation( + TabularDataService service,ASLSession aslSession, + StatisticalOperationSession statisticalOperationSession) { + this.service = service; + this.aslSession = aslSession; + this.statisticalOperationSession = statisticalOperationSession; + } + + @Override + public void buildOpEx() throws TDGWTServiceException { + OperationExecution invocation = null; + + logger.debug(statisticalOperationSession.toString()); + OperationDefinition operationDefinition; + Map map = new HashMap(); + + operationDefinition = OperationDefinitionMap.map( + OperationsId.StatisticalOperation.toString(), service); + + map.put(Constants.PARAMETER_STATISTICAL_OPERATION_USER, aslSession.getUsername()); + map.put(Constants.PARAMETER_STATISTICAL_OPERATION_ALGORITHM, statisticalOperationSession.getOperatorId()); + + + Map params = new HashMap(); + Map parameters=statisticalOperationSession.getParameters(); + for (String key : parameters.keySet()) { + params.put(key.toString(), parameters.get(key)); + } + map.put(Constants.PARAMETER_STATISTICAL_OPERATION_PARAMETERS, params); + + map.put(Constants.PARAMETER_STATISTICAL_OPERATION_DESCRIPTION, statisticalOperationSession.getDescription()); + map.put(Constants.PARAMETER_STATISTICAL_OPERATION_TITLE, statisticalOperationSession.getTitle()); + + + 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 f9f3abf..a92577c 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 @@ -46,7 +46,12 @@ public class Constants { public static final String PARAMETER_UNION_COMPOSITE_SOURCE = "source"; public static final String PARAMETER_UNION_COMPOSITE_TARGET = "target"; public static final String PARAMETER_UNION_COMPOSITE = "mappings"; - + + public static final String PARAMETER_STATISTICAL_OPERATION_USER = "user"; + public static final String PARAMETER_STATISTICAL_OPERATION_ALGORITHM = "algorithm"; + public static final String PARAMETER_STATISTICAL_OPERATION_PARAMETERS = "smEntries"; + public static final String PARAMETER_STATISTICAL_OPERATION_DESCRIPTION = "description"; + public static final String PARAMETER_STATISTICAL_OPERATION_TITLE = "title"; public static final String PARAMETER_ADD_ROW_COMPOSITE_FIELD = "field"; public static final String PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE = "toSetValue"; diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/UIOperationsId.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/UIOperationsId.java index f31943f..ba9365a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/UIOperationsId.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/UIOperationsId.java @@ -96,7 +96,8 @@ public enum UIOperationsId { ResubmitTask("ResubmitTask"), RollBack("Roll Back"), ApplyTemplate("Apply Template"), - GenerateMap("Generate Map"); + GenerateMap("Generate Map"), + StatisticalOperation("Statistical Operation"); /** * @param text diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/statistical/StatisticalOperationSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/statistical/StatisticalOperationSession.java new file mode 100644 index 0000000..f598a5e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/statistical/StatisticalOperationSession.java @@ -0,0 +1,113 @@ +/** + * + */ +package org.gcube.portlets.user.td.gwtservice.shared.statistical; + +import java.io.Serializable; +import java.util.Map; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +/** + * + * @author giancarlo email: g.panichi@isti.cnr.it + * + */ +public class StatisticalOperationSession implements Serializable { + + private static final long serialVersionUID = -8968614490778086448L; + private TRId trId; + private Map parameters; + private String description; + private String title; + private String operatorId; + private String operatorName; + private String operatorBriefDescription; + + public StatisticalOperationSession() { + super(); + } + + public StatisticalOperationSession(TRId trId, + Map parameters, String description, String title, + String operatorId, String operatorName, + String operatorBriefDescription) { + super(); + this.trId = trId; + this.parameters = parameters; + this.description = description; + this.title = title; + this.operatorId = operatorId; + this.operatorName = operatorName; + this.operatorBriefDescription = operatorBriefDescription; + } + + public TRId getTrId() { + return trId; + } + + public void setTrId(TRId trId) { + this.trId = trId; + } + + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorName() { + return operatorName; + } + + public void setOperatorName(String operatorName) { + this.operatorName = operatorName; + } + + public String getOperatorBriefDescription() { + return operatorBriefDescription; + } + + public void setOperatorBriefDescription(String operatorBriefDescription) { + this.operatorBriefDescription = operatorBriefDescription; + } + + @Override + public String toString() { + return "StatisticalOperationSession [trId=" + trId + ", parameters=" + + parameters + ", description=" + description + ", title=" + + title + ", operatorId=" + operatorId + ", operatorName=" + + operatorName + ", operatorBriefDescription=" + + operatorBriefDescription + "]"; + } + + + +}