From df30048e76d657e23747fe90c8778447412f3117 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 6 Feb 2015 08:28:28 +0000 Subject: [PATCH] Added ValueDataFormat git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@111753 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 25 ++++ .../client/rpc/TDGWTServiceAsync.java | 42 ++++-- .../gwtservice/server/TDGWTServiceImpl.java | 127 +++++++++++++----- 3 files changed, 144 insertions(+), 50 deletions(-) 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 1b3fc85..8429bd3 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 @@ -4,6 +4,7 @@ package org.gcube.portlets.user.td.gwtservice.client.rpc; import java.util.ArrayList; +import java.util.HashMap; import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; @@ -40,6 +41,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.PeriodDataType; import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ValueDataFormat; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession; @@ -73,6 +75,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession; import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -151,6 +154,28 @@ public interface TDGWTService extends RemoteService { public ArrayList getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType) throws TDGWTServiceException; + + //ValueDataFormats + /** + * Retrieve ValueDataFormat for all ColumnDataType + * + * @return + * @throws TDGWTServiceException + */ + public HashMap> getValueDataFormats() + throws TDGWTServiceException; + + + /** + * Retrieve ValueDataFormat for specific ColumnDataType + * + * @param columnDataType + * @return + * @throws TDGWTServiceException + */ + public ArrayList getValueDataFormatsOfColumnDataType( + ColumnDataType columnDataType) throws TDGWTServiceException; + // TabularResource /** * Get current TRId 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 47bfd3b..bb654c0 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 @@ -4,6 +4,7 @@ package org.gcube.portlets.user.td.gwtservice.client.rpc; import java.util.ArrayList; +import java.util.HashMap; import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; @@ -39,6 +40,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.PeriodDataType; import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ValueDataFormat; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession; @@ -72,6 +74,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.union.UnionSession; import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession; import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -91,17 +94,26 @@ public interface TDGWTServiceAsync { void hello(AsyncCallback callback); void pendingTasksRetrieve(AsyncCallback callback); - + void restoreUISession(AsyncCallback callback); void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback callback); - //PeriodDataType + // PeriodDataType void getPeriodDataTypes(AsyncCallback> callback); - - void getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType, AsyncCallback> callback); - + + void getHierarchicalRelationshipForPeriodDataTypes( + PeriodDataType periodDataType, + AsyncCallback> callback); + + // + void getValueDataFormats( + AsyncCallback>> callback); + + void getValueDataFormatsOfColumnDataType(ColumnDataType columnDataType, + AsyncCallback> callback); + // TabularResource void getCurrentTRId(AsyncCallback callback); @@ -123,7 +135,7 @@ public interface TDGWTServiceAsync { AsyncCallback callback); void setTabResourceToFinal(TRId trId, AsyncCallback callback); - + void getTRCreationDate(TRId trId, AsyncCallback callback); void setTabResource(TabResource tabResource, AsyncCallback callback); @@ -141,9 +153,10 @@ public interface TDGWTServiceAsync { AsyncCallback> callback); void getTRMetadata(TRId trId, AsyncCallback> callback); - - void getTimeTableId(PeriodDataType periodDataType, AsyncCallback callback); - + + void getTimeTableId(PeriodDataType periodDataType, + AsyncCallback callback); + void getColumns(AsyncCallback> callback); void getColumns(TRId trId, AsyncCallback> callback); @@ -317,8 +330,9 @@ public interface TDGWTServiceAsync { // Replace Operation void startReplaceColumn(ReplaceColumnSession replaceColumnSession, AsyncCallback callback); - - void startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession, + + void startReplaceByExternal( + ReplaceByExternalSession replaceByExternalSession, AsyncCallback callback); // Templates @@ -389,7 +403,7 @@ public interface TDGWTServiceAsync { void removeResource(RemoveResourceSession removeResourceSession, AsyncCallback callback); - + void saveResource(SaveResourceSession saveResourceSession, AsyncCallback callback); @@ -401,8 +415,8 @@ public interface TDGWTServiceAsync { void startStatisticalOperation( StatisticalOperationSession statisticalOperationSession, AsyncCallback callback); - - //Chart + + // Chart void startChartTopRating(ChartTopRatingSession chartTopRatingSession, AsyncCallback callback); } 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 8061162..88c9355 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 @@ -329,7 +329,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements try { HttpSession session = this.getThreadLocalRequest().getSession(); SessionUtil.getAslSession(session); - + ArrayList periodDataTypes = new ArrayList(); for (PeriodType period : PeriodType.values()) { @@ -338,16 +338,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List listValueFormat = period.getAcceptedFormats(); for (ValueFormat valueF : listValueFormat) { ValueDataFormat valueDataFormat = new ValueDataFormat( - valueF.getId(), valueF.getExample(), valueF.getRegExpr()); + valueF.getId(), valueF.getExample(), + valueF.getRegExpr()); valueDataFormats.add(valueDataFormat); } - + PeriodDataType periodDataType = new PeriodDataType( period.name(), period.getName(), valueDataFormats); periodDataTypes.add(periodDataType); } - logger.debug("PeriodDataTypes: "+periodDataTypes); + logger.debug("PeriodDataTypes: " + periodDataTypes); return periodDataTypes; } catch (TDGWTServiceException e) { @@ -361,40 +362,41 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } - - + /** * * {@inheritDoc} */ @Override - public ArrayList getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType) - throws TDGWTServiceException { + public ArrayList getHierarchicalRelationshipForPeriodDataTypes( + PeriodDataType periodDataType) throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); SessionUtil.getAslSession(session); - + ArrayList hierarchicalPeriodDataTypes = new ArrayList(); - PeriodType periodType= PeriodTypeMap.map(periodDataType); - - List hierarchicalList=PeriodType.getHierarchicalRelation().get(periodType); - + PeriodType periodType = PeriodTypeMap.map(periodDataType); + + List hierarchicalList = PeriodType + .getHierarchicalRelation().get(periodType); for (PeriodType period : hierarchicalList) { ArrayList valueDataFormats = new ArrayList(); List listValueFormat = period.getAcceptedFormats(); for (ValueFormat valueF : listValueFormat) { ValueDataFormat valueDataFormat = new ValueDataFormat( - valueF.getId(), valueF.getExample(), valueF.getRegExpr()); + valueF.getId(), valueF.getExample(), + valueF.getRegExpr()); valueDataFormats.add(valueDataFormat); } - PeriodDataType periodDT = new PeriodDataType( - period.name(), period.getName(), valueDataFormats); + PeriodDataType periodDT = new PeriodDataType(period.name(), + period.getName(), valueDataFormats); hierarchicalPeriodDataTypes.add(periodDT); } - - logger.debug("hierarchicalPeriodDataTypes: "+hierarchicalPeriodDataTypes); + + logger.debug("hierarchicalPeriodDataTypes: " + + hierarchicalPeriodDataTypes); return hierarchicalPeriodDataTypes; } catch (TDGWTServiceException e) { @@ -404,36 +406,48 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS); } catch (Throwable e) { logger.error("getPeriodDataTypes(): " + e.getLocalizedMessage(), e); - throw new TDGWTServiceException("Error retrieving hierarchical list of period types: " - + e.getLocalizedMessage()); + throw new TDGWTServiceException( + "Error retrieving hierarchical list of period types: " + + e.getLocalizedMessage()); } } - + /** * * @param columnDataType * @return * @throws TDGWTServiceException */ - public ArrayList getValueDataFormats(ColumnDataType columnDataType) + @Override + public HashMap> getValueDataFormats() throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); SessionUtil.getAslSession(session); - - ArrayList valueDataFormats = new ArrayList(); - Class dataType=ColumnDataTypeMap.mapToDataTypeClass(columnDataType); - - for (ValueFormat valueF: DataTypeFormats.getFormatsPerDataType(dataType)) { + HashMap> columnDataTypeFormats = new HashMap>(); + + for (ColumnDataType columnDataType : ColumnDataType.values()) { + + ArrayList valueDataFormats = new ArrayList(); + + Class dataType = ColumnDataTypeMap + .mapToDataTypeClass(columnDataType); + + for (ValueFormat valueF : DataTypeFormats + .getFormatsPerDataType(dataType)) { ValueDataFormat valueDataFormat = new ValueDataFormat( - valueF.getId(), valueF.getExample(), valueF.getRegExpr()); + valueF.getId(), valueF.getExample(), + valueF.getRegExpr()); valueDataFormats.add(valueDataFormat); - } + } - - logger.debug("ValueDataFormats: "+valueDataFormats); - return valueDataFormats; + columnDataTypeFormats.put(columnDataType, valueDataFormats); + + } + + logger.debug("getValueDataFormats(): " + columnDataTypeFormats); + return columnDataTypeFormats; } catch (TDGWTServiceException e) { throw e; @@ -442,12 +456,53 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS); } catch (Throwable e) { logger.error("getValueDataFormats(): " + e.getLocalizedMessage(), e); - throw new TDGWTServiceException("Error retrieving value data formats: " - + e.getLocalizedMessage()); + throw new TDGWTServiceException( + "Error retrieving value data formats: " + + e.getLocalizedMessage()); + } + } + + /** + * + * @param columnDataType + * @return + * @throws TDGWTServiceException + */ + @Override + public ArrayList getValueDataFormatsOfColumnDataType( + ColumnDataType columnDataType) throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + SessionUtil.getAslSession(session); + + ArrayList valueDataFormats = new ArrayList(); + + Class dataType = ColumnDataTypeMap + .mapToDataTypeClass(columnDataType); + + for (ValueFormat valueF : DataTypeFormats + .getFormatsPerDataType(dataType)) { + ValueDataFormat valueDataFormat = new ValueDataFormat( + valueF.getId(), valueF.getExample(), + valueF.getRegExpr()); + valueDataFormats.add(valueDataFormat); + } + + logger.debug("getValueDataFormatsOfColumnDataType(): ["+columnDataType+", "+ valueDataFormats+"]"); + return valueDataFormats; + + } catch (TDGWTServiceException e) { + throw e; + } catch (SecurityException e) { + e.printStackTrace(); + throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS); + } catch (Throwable e) { + logger.error("getValueDataFormatsOfColumnDataType(): " + e.getLocalizedMessage(), e); + throw new TDGWTServiceException( + "Error retrieving value data formats: " + + e.getLocalizedMessage()); } } - - /** *