Added Chart Top Rating
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@101539 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7f456daef7
commit
dd7e16bd7b
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.gwtservice.client.rpc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||
|
@ -1061,4 +1062,15 @@ public interface TDGWTService extends RemoteService {
|
|||
StatisticalOperationSession statisticalOperationSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
// Chart
|
||||
/**
|
||||
* Start Chart Top Rating Creation and invokes the client library
|
||||
*
|
||||
* @param chartTopRatingSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public String startChartTopRating(ChartTopRatingSession chartTopRatingSession)
|
||||
throws TDGWTServiceException;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.gwtservice.client.rpc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||
|
@ -384,5 +385,8 @@ public interface TDGWTServiceAsync {
|
|||
void startStatisticalOperation(
|
||||
StatisticalOperationSession statisticalOperationSession,
|
||||
AsyncCallback<String> callback);
|
||||
|
||||
|
||||
//Chart
|
||||
void startChartTopRating(ChartTopRatingSession chartTopRatingSession,
|
||||
AsyncCallback<String> callback);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class SessionConstants {
|
|||
protected static final String CODELIST_MAPPING_SESSION = "CODELIST_MAPPING_SESSION";
|
||||
protected static final String CODELIST_MAPPING_FILE_UPLOAD_SESSION = "CODELIST_MAPPING_FILE_UPLOAD_SESSION";
|
||||
|
||||
|
||||
protected static final String CHART_TOPRATING_SESSION = "CHART_TOPRATING_SESSION";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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.chart.ChartTopRatingSession;
|
||||
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;
|
||||
|
@ -85,13 +86,13 @@ public class SessionUtil {
|
|||
|
||||
// Remove comment for Test
|
||||
/*
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
|
||||
username); session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username); session.setScope(scope);
|
||||
*/
|
||||
* username = Constants.DEFAULT_USER; String scope =
|
||||
* Constants.DEFAULT_SCOPE;
|
||||
*
|
||||
* httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
|
||||
* username); session = SessionManager.getInstance().getASLSession(
|
||||
* httpSession.getId(), username); session.setScope(scope);
|
||||
*/
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
|
@ -1320,9 +1321,10 @@ public class SessionUtil {
|
|||
groupBySession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static TimeAggregationSession getTimeAggregationSession(HttpSession httpSession) {
|
||||
public static TimeAggregationSession getTimeAggregationSession(
|
||||
HttpSession httpSession) {
|
||||
TimeAggregationSession timeAggregationSession = (TimeAggregationSession) httpSession
|
||||
.getAttribute(SessionConstants.TIME_AGGREGATION_SESSION);
|
||||
if (timeAggregationSession != null) {
|
||||
|
@ -1340,13 +1342,13 @@ public class SessionUtil {
|
|||
TimeAggregationSession timeAggr = (TimeAggregationSession) httpSession
|
||||
.getAttribute(SessionConstants.TIME_AGGREGATION_SESSION);
|
||||
if (timeAggr != null) {
|
||||
httpSession.removeAttribute(SessionConstants.TIME_AGGREGATION_SESSION);
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.TIME_AGGREGATION_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.TIME_AGGREGATION_SESSION,
|
||||
timeAggregationSession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static CodelistMappingSession getCodelistMappingSession(
|
||||
|
@ -1453,16 +1455,18 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(SessionConstants.UNION_SESSION, unionSession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static ReplaceByExternalSession getReplaceByExternalSession(HttpSession httpSession) {
|
||||
public static ReplaceByExternalSession getReplaceByExternalSession(
|
||||
HttpSession httpSession) {
|
||||
ReplaceByExternalSession replaceByExternalSession = (ReplaceByExternalSession) httpSession
|
||||
.getAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
if (replaceByExternalSession != null) {
|
||||
return replaceByExternalSession;
|
||||
} else {
|
||||
replaceByExternalSession = new ReplaceByExternalSession();
|
||||
httpSession.setAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION,
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.REPLACE_BY_EXTERNAL_SESSION,
|
||||
replaceByExternalSession);
|
||||
return replaceByExternalSession;
|
||||
}
|
||||
|
@ -1473,22 +1477,25 @@ public class SessionUtil {
|
|||
ReplaceByExternalSession re = (ReplaceByExternalSession) httpSession
|
||||
.getAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
if (re != null) {
|
||||
httpSession.removeAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION, replaceByExternalSession);
|
||||
httpSession.setAttribute(SessionConstants.REPLACE_BY_EXTERNAL_SESSION,
|
||||
replaceByExternalSession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static StatisticalOperationSession getStatisticalOperationSession(HttpSession httpSession) {
|
||||
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,
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.STATISTICAL_OPERATION_SESSION,
|
||||
statisticalOperationSession);
|
||||
return statisticalOperationSession;
|
||||
}
|
||||
|
@ -1499,9 +1506,12 @@ public class SessionUtil {
|
|||
StatisticalOperationSession so = (StatisticalOperationSession) httpSession
|
||||
.getAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION);
|
||||
if (so != null) {
|
||||
httpSession.removeAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION);
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.STATISTICAL_OPERATION_SESSION, statisticalOperationSession);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.STATISTICAL_OPERATION_SESSION,
|
||||
statisticalOperationSession);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1533,6 +1543,34 @@ public class SessionUtil {
|
|||
|
||||
}
|
||||
|
||||
// /
|
||||
|
||||
public static ChartTopRatingSession getChartTopRatingSession(
|
||||
HttpSession httpSession) {
|
||||
ChartTopRatingSession chartTopRatingSession = (ChartTopRatingSession) httpSession
|
||||
.getAttribute(SessionConstants.CHART_TOPRATING_SESSION);
|
||||
if (chartTopRatingSession != null) {
|
||||
return chartTopRatingSession;
|
||||
} else {
|
||||
chartTopRatingSession = new ChartTopRatingSession();
|
||||
httpSession.setAttribute(SessionConstants.CHART_TOPRATING_SESSION,
|
||||
chartTopRatingSession);
|
||||
return chartTopRatingSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setChartTopRatingSession(HttpSession httpSession,
|
||||
ChartTopRatingSession chartTopRatingSession) {
|
||||
ChartTopRatingSession chart = (ChartTopRatingSession) httpSession
|
||||
.getAttribute(SessionConstants.CHART_TOPRATING_SESSION);
|
||||
if (chart != null) {
|
||||
httpSession.removeAttribute(SessionConstants.CHART_TOPRATING_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.CHART_TOPRATING_SESSION,
|
||||
chartTopRatingSession);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public static TaskWrapper getStartedTask(HttpSession httpSession,
|
||||
|
|
|
@ -111,6 +111,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddC
|
|||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVExport;
|
||||
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.OpExecution4ChartTopRating;
|
||||
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;
|
||||
|
@ -150,6 +151,7 @@ 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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.UIOperationsId;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||
|
@ -8130,4 +8132,61 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String startChartTopRating(ChartTopRatingSession chartTopRatingSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setChartTopRatingSession(session, chartTopRatingSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
checkTRId(chartTopRatingSession.getTrId());
|
||||
|
||||
TabularResourceId tabularResourceId = new TabularResourceId(
|
||||
Long.valueOf(chartTopRatingSession.getTrId().getId()));
|
||||
TabularResource tabularResource = service
|
||||
.getTabularResource(tabularResourceId);
|
||||
|
||||
checkTabularResourceLocked(tabularResource);
|
||||
|
||||
OpExecution4ChartTopRating opEx = new OpExecution4ChartTopRating(service,
|
||||
chartTopRatingSession);
|
||||
OpExecutionDirector director = new OpExecutionDirector();
|
||||
director.setOperationExecutionBuilder(opEx);
|
||||
director.constructOperationExecution();
|
||||
OperationExecution invocation = director.getOperationExecution();
|
||||
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in Top Rating Chart 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.ChartTopRating, chartTopRatingSession.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 creating top rating chart: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
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.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.chart.ChartTopRatingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Operation Execution for Top Rating Chart creation
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OpExecution4ChartTopRating extends OpExecutionBuilder {
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(OpExecution4ChartTopRating.class);
|
||||
|
||||
private TabularDataService service;
|
||||
private ChartTopRatingSession chartTopRatingSession;
|
||||
|
||||
public OpExecution4ChartTopRating(
|
||||
TabularDataService service,
|
||||
ChartTopRatingSession chartTopRatingSession) {
|
||||
this.service = service;
|
||||
this.chartTopRatingSession = chartTopRatingSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws TDGWTServiceException {
|
||||
OperationExecution invocation = null;
|
||||
|
||||
logger.debug(chartTopRatingSession.toString());
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.TopRatingChart.toString(), service);
|
||||
|
||||
|
||||
map.put(Constants.PARAMETER_CHART_TOPRATING_SAMPLESIZE,
|
||||
chartTopRatingSession.getSampleSize());
|
||||
map.put(Constants.PARAMETER_CHART_TOPRATING_VALUEOPERATION,
|
||||
chartTopRatingSession.getValueOperation());
|
||||
|
||||
|
||||
invocation = new OperationExecution(chartTopRatingSession.getColumn().getColumnId(),
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
operationExecutionSpec.setOp(invocation);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -114,4 +114,9 @@ public class Constants {
|
|||
public static final String PARAMETER_GENERATEMAP_METACREDITS = "metaCredits";
|
||||
public static final String PARAMETER_GENERATEMAP_METAKEYWORDS = "metaKeywords";
|
||||
|
||||
public static final String PARAMETER_CHART_TOPRATING_SAMPLESIZE = "sampleSize";
|
||||
public static final String PARAMETER_CHART_TOPRATING_VALUEOPERATION = "valueOperation";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ public enum OperationsId {
|
|||
ValidateTable("5011"),
|
||||
ValidateDataSet("5012"),
|
||||
ValidateGeneric("5013"),
|
||||
TopRatingChart("9000"),
|
||||
StatisticalOperation("10001"),
|
||||
ExportToStatisticalOperation("10002"),
|
||||
ImportFromStatistical("10003"),
|
||||
|
|
|
@ -99,7 +99,8 @@ public enum UIOperationsId {
|
|||
RollBack("Roll Back"),
|
||||
ApplyTemplate("Apply Template"),
|
||||
GenerateMap("Generate Map"),
|
||||
StatisticalOperation("Statistical Operation");
|
||||
StatisticalOperation("Statistical Operation"),
|
||||
ChartTopRating("Top Rating Chart");
|
||||
|
||||
/**
|
||||
* @param text
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gwtservice.shared.chart;
|
||||
|
||||
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 email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ChartTopRatingSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4988917715929182427L;
|
||||
|
||||
private TRId trId;
|
||||
private ColumnData column;
|
||||
private Integer sampleSize;
|
||||
private String valueOperation;
|
||||
|
||||
public ChartTopRatingSession() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param trId
|
||||
* @param column
|
||||
* @param sampleSize
|
||||
* @param valueOperation
|
||||
*/
|
||||
public ChartTopRatingSession(TRId trId, ColumnData column,
|
||||
Integer sampleSize, String valueOperation) {
|
||||
super();
|
||||
this.trId = trId;
|
||||
this.column = column;
|
||||
this.sampleSize = sampleSize;
|
||||
this.valueOperation = valueOperation;
|
||||
}
|
||||
|
||||
|
||||
public TRId getTrId() {
|
||||
return trId;
|
||||
}
|
||||
|
||||
|
||||
public void setTrId(TRId trId) {
|
||||
this.trId = trId;
|
||||
}
|
||||
|
||||
|
||||
public ColumnData getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
|
||||
public void setColumn(ColumnData column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
|
||||
public Integer getSampleSize() {
|
||||
return sampleSize;
|
||||
}
|
||||
|
||||
|
||||
public void setSampleSize(Integer sampleSize) {
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
|
||||
public String getValueOperation() {
|
||||
return valueOperation;
|
||||
}
|
||||
|
||||
|
||||
public void setValueOperation(String valueOperation) {
|
||||
this.valueOperation = valueOperation;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChartTopRatingSession [trId=" + trId + ", column=" + column
|
||||
+ ", sampleSize=" + sampleSize + ", valueOperation="
|
||||
+ valueOperation + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue