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;
@ -100,7 +103,16 @@ public interface TDGWTServiceAsync {
// 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);
@ -142,7 +154,8 @@ public interface TDGWTServiceAsync {
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);
@ -318,7 +331,8 @@ public interface TDGWTServiceAsync {
void startReplaceColumn(ReplaceColumnSession replaceColumnSession,
AsyncCallback<String> callback);
void startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession,
void startReplaceByExternal(
ReplaceByExternalSession replaceByExternalSession,
AsyncCallback<String> callback);
// Templates

View File

@ -338,7 +338,8 @@ 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);
}
@ -362,14 +363,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@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);
@ -378,23 +378,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
PeriodType periodType = PeriodTypeMap.map(periodDataType);
List<PeriodType> hierarchicalList=PeriodType.getHierarchicalRelation().get(periodType);
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,7 +406,8 @@ 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: "
throw new TDGWTServiceException(
"Error retrieving hierarchical list of period types: "
+ e.getLocalizedMessage());
}
}
@ -415,25 +418,36 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* @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);
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);
Class<? extends DataType> dataType = ColumnDataTypeMap
.mapToDataTypeClass(columnDataType);
for (ValueFormat valueF: DataTypeFormats.getFormatsPerDataType(dataType)) {
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);
}
columnDataTypeFormats.put(columnDataType, valueDataFormats);
logger.debug("ValueDataFormats: "+valueDataFormats);
return 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: "
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());
}
}
/**
*