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
This commit is contained in:
Giancarlo Panichi 2015-02-06 08:28:28 +00:00
parent 5541f36f7f
commit df30048e76
3 changed files with 144 additions and 50 deletions

View File

@ -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<PeriodDataType> getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType)
throws TDGWTServiceException;
//ValueDataFormats
/**
* Retrieve ValueDataFormat for all ColumnDataType
*
* @return
* @throws TDGWTServiceException
*/
public HashMap<ColumnDataType, ArrayList<ValueDataFormat>> getValueDataFormats()
throws TDGWTServiceException;
/**
* Retrieve ValueDataFormat for specific ColumnDataType
*
* @param columnDataType
* @return
* @throws TDGWTServiceException
*/
public ArrayList<ValueDataFormat> getValueDataFormatsOfColumnDataType(
ColumnDataType columnDataType) throws TDGWTServiceException;
// TabularResource
/**
* Get current TRId

View File

@ -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<UserInfo> callback);
void pendingTasksRetrieve(AsyncCallback<Integer> callback);
void restoreUISession(AsyncCallback<TRId> callback);
void getUriFromResolver(UriResolverSession uriResolverSession,
AsyncCallback<String> callback);
//PeriodDataType
// PeriodDataType
void getPeriodDataTypes(AsyncCallback<ArrayList<PeriodDataType>> callback);
void getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType, AsyncCallback<ArrayList<PeriodDataType>> callback);
void getHierarchicalRelationshipForPeriodDataTypes(
PeriodDataType periodDataType,
AsyncCallback<ArrayList<PeriodDataType>> callback);
//
void getValueDataFormats(
AsyncCallback<HashMap<ColumnDataType, ArrayList<ValueDataFormat>>> callback);
void getValueDataFormatsOfColumnDataType(ColumnDataType columnDataType,
AsyncCallback<ArrayList<ValueDataFormat>> callback);
// TabularResource
void getCurrentTRId(AsyncCallback<TRId> callback);
@ -123,7 +135,7 @@ public interface TDGWTServiceAsync {
AsyncCallback<Void> callback);
void setTabResourceToFinal(TRId trId, AsyncCallback<Void> callback);
void getTRCreationDate(TRId trId, AsyncCallback<String> callback);
void setTabResource(TabResource tabResource, AsyncCallback<Void> callback);
@ -141,9 +153,10 @@ public interface TDGWTServiceAsync {
AsyncCallback<ArrayList<TabMetadata>> callback);
void getTRMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
void getTimeTableId(PeriodDataType periodDataType, AsyncCallback<Long> callback);
void getTimeTableId(PeriodDataType periodDataType,
AsyncCallback<Long> callback);
void getColumns(AsyncCallback<ArrayList<ColumnData>> callback);
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
@ -317,8 +330,9 @@ public interface TDGWTServiceAsync {
// Replace Operation
void startReplaceColumn(ReplaceColumnSession replaceColumnSession,
AsyncCallback<String> callback);
void startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession,
void startReplaceByExternal(
ReplaceByExternalSession replaceByExternalSession,
AsyncCallback<String> callback);
// Templates
@ -389,7 +403,7 @@ public interface TDGWTServiceAsync {
void removeResource(RemoveResourceSession removeResourceSession,
AsyncCallback<Void> callback);
void saveResource(SaveResourceSession saveResourceSession,
AsyncCallback<Void> callback);
@ -401,8 +415,8 @@ public interface TDGWTServiceAsync {
void startStatisticalOperation(
StatisticalOperationSession statisticalOperationSession,
AsyncCallback<String> callback);
//Chart
// Chart
void startChartTopRating(ChartTopRatingSession chartTopRatingSession,
AsyncCallback<String> callback);
}

View File

@ -329,7 +329,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
ArrayList<PeriodDataType> periodDataTypes = new ArrayList<PeriodDataType>();
for (PeriodType period : PeriodType.values()) {
@ -338,16 +338,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
List<ValueFormat> 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<PeriodDataType> getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType)
throws TDGWTServiceException {
public ArrayList<PeriodDataType> getHierarchicalRelationshipForPeriodDataTypes(
PeriodDataType periodDataType) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
ArrayList<PeriodDataType> hierarchicalPeriodDataTypes = new ArrayList<PeriodDataType>();
PeriodType periodType= PeriodTypeMap.map(periodDataType);
List<PeriodType> hierarchicalList=PeriodType.getHierarchicalRelation().get(periodType);
PeriodType periodType = PeriodTypeMap.map(periodDataType);
List<PeriodType> hierarchicalList = PeriodType
.getHierarchicalRelation().get(periodType);
for (PeriodType period : hierarchicalList) {
ArrayList<ValueDataFormat> valueDataFormats = new ArrayList<ValueDataFormat>();
List<ValueFormat> 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<ValueDataFormat> getValueDataFormats(ColumnDataType columnDataType)
@Override
public HashMap<ColumnDataType, ArrayList<ValueDataFormat>> getValueDataFormats()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
ArrayList<ValueDataFormat> valueDataFormats = new ArrayList<ValueDataFormat>();
Class<? extends DataType> dataType=ColumnDataTypeMap.mapToDataTypeClass(columnDataType);
for (ValueFormat valueF: DataTypeFormats.getFormatsPerDataType(dataType)) {
HashMap<ColumnDataType, ArrayList<ValueDataFormat>> columnDataTypeFormats = new HashMap<ColumnDataType, ArrayList<ValueDataFormat>>();
for (ColumnDataType columnDataType : ColumnDataType.values()) {
ArrayList<ValueDataFormat> valueDataFormats = new ArrayList<ValueDataFormat>();
Class<? extends DataType> 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<ValueDataFormat> getValueDataFormatsOfColumnDataType(
ColumnDataType columnDataType) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getAslSession(session);
ArrayList<ValueDataFormat> valueDataFormats = new ArrayList<ValueDataFormat>();
Class<? extends DataType> 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());
}
}
/**
*