Added PeriodType

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@101080 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-28 14:47:07 +00:00
parent 64bd8edf11
commit d1c2cdc7a4
5 changed files with 460 additions and 151 deletions

View File

@ -468,6 +468,17 @@ public interface TDGWTService extends RemoteService {
throws TDGWTServiceException;
/**
* Retrieves the list of columns in the table provided by trId
* for statistical
*
* @param trId
* @return
* @throws TDGWTServiceException
*/
public ArrayList<ColumnData> getColumnsForStatistical(TRId trId)
throws TDGWTServiceException;
/**
* Retrieves the list of columns in the table provided by trId only CODE and
* CODENAME types

View File

@ -134,6 +134,9 @@ public interface TDGWTServiceAsync {
void getColumnWithViewColumnIncluded(TRId trId,
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnsForStatistical(TRId trId,
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnsForDimension(TRId trId,
AsyncCallback<ArrayList<ColumnData>> callback);

View File

@ -63,6 +63,7 @@ import org.gcube.data.analysis.tabulardata.model.column.type.ValidationColumnTyp
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
import org.gcube.data.analysis.tabulardata.model.metadata.Locales;
import org.gcube.data.analysis.tabulardata.model.metadata.column.DataLocaleMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.column.PeriodTypeMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.column.ValidationReferencesMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata;
@ -82,6 +83,7 @@ import org.gcube.data.analysis.tabulardata.model.resources.ResourceType;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.model.table.type.CodelistTableType;
import org.gcube.data.analysis.tabulardata.model.time.PeriodType;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTemplateException;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
@ -138,6 +140,7 @@ import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExtractReferences;
import org.gcube.portlets.user.td.gwtservice.server.trservice.LicenceMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.PeriodTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TDTypeValueMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TabularResourceTypeMap;
@ -619,8 +622,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
currentTR.setContacts(retrieveShareInfo(tr));
SessionUtil.setTabResource(session, currentTR);
logger.debug("GetTabResourceInformation() updated information:"
+ currentTR.toString());
@ -682,8 +684,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
currentTR.setContacts(retrieveShareInfo(tr));
logger.debug("GetTabResourceInformation() updated information:"
+ currentTR);
return currentTR;
@ -807,14 +808,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setRelationship(relData);
}
NamesMetadata labelsMetadata = null;
try {
if (c.contains(NamesMetadata.class)) {
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");
@ -838,20 +837,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
DataLocaleMetadata dataLocaleMetadata = null;
try {
if (c.contains(DataLocaleMetadata.class)) {
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());
}
}
PeriodTypeMetadata periodTypeMetadata= null;
if (c.contains(PeriodTypeMetadata.class)) {
periodTypeMetadata = c
.getMetadata(PeriodTypeMetadata.class);
PeriodType periodType=periodTypeMetadata.getType();
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
}
cData.setTrId(trId);
columns.add(cData);
i++;
@ -925,14 +925,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setRelationship(relData);
}
NamesMetadata labelsMetadata = null;
try {
if (c.contains(NamesMetadata.class)) {
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");
@ -956,19 +954,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
DataLocaleMetadata dataLocaleMetadata = null;
try {
if (c.contains(DataLocaleMetadata.class)) {
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());
}
}
PeriodTypeMetadata periodTypeMetadata= null;
if (c.contains(PeriodTypeMetadata.class)) {
periodTypeMetadata = c
.getMetadata(PeriodTypeMetadata.class);
PeriodType periodType=periodTypeMetadata.getType();
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
}
cData.setTrId(trId);
columns.add(cData);
@ -1040,14 +1038,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setRelationship(relData);
}
NamesMetadata labelsMetadata = null;
try {
labelsMetadata = c.getMetadata(NamesMetadata.class);
} catch (NoSuchMetadataException e) {
logger.debug("labelMetadata: NoSuchMetadataException "
+ e.getLocalizedMessage());
}
NamesMetadata labelsMetadata = null;
if (c.contains(NamesMetadata.class)) {
labelsMetadata = c.getMetadata(NamesMetadata.class);
}
if (labelsMetadata == null) {
cData.setLabel("nolabel");
logger.debug("LabelsMetadata no labels");
@ -1071,18 +1067,37 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
DataLocaleMetadata dataLocaleMetadata = null;
try {
if (c.contains(DataLocaleMetadata.class)) {
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());
}
PeriodTypeMetadata periodTypeMetadata= null;
if (c.contains(PeriodTypeMetadata.class)) {
periodTypeMetadata = c
.getMetadata(PeriodTypeMetadata.class);
PeriodType periodType=periodTypeMetadata.getType();
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
}
ViewColumnMetadata viewColumnMetadata = null;
if (c.contains(ViewColumnMetadata.class)) {
viewColumnMetadata = c
.getMetadata(ViewColumnMetadata.class);
ColumnViewData columnViewData = new ColumnViewData(
viewColumnMetadata
.getSourceTableDimensionColumnId()
.getValue(), viewColumnMetadata
.getTargetTableColumnId().getValue(),
viewColumnMetadata.getTargetTableId()
.getValue());
cData.setViewColumn(true);
cData.setColumnViewData(columnViewData);
} else {
cData.setViewColumn(false);
}
cData.setTrId(trId);
@ -1109,6 +1124,170 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
* Returns ArrayList<ColumnData> other than IdColumnType,
* ValidationColumnType, DimensionColumnType, TimeDimensionColumnType and
* only View Columns related
*
*
* {@inheritDoc}
*/
public ArrayList<ColumnData> getColumnsForStatistical(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<ColumnData> columns = new ArrayList<ColumnData>();
ArrayList<ColumnData> columnsDimension = new ArrayList<ColumnData>();
List<Column> 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;
if (c.contains(NamesMetadata.class)) {
labelsMetadata = c.getMetadata(NamesMetadata.class);
}
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;
if (c.contains(DataLocaleMetadata.class)) {
dataLocaleMetadata = c
.getMetadata(DataLocaleMetadata.class);
cData.setLocale(dataLocaleMetadata.getLocale());
}
PeriodTypeMetadata periodTypeMetadata= null;
if (c.contains(PeriodTypeMetadata.class)) {
periodTypeMetadata = c
.getMetadata(PeriodTypeMetadata.class);
PeriodType periodType=periodTypeMetadata.getType();
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
}
ViewColumnMetadata viewColumnMetadata = null;
if (c.contains(ViewColumnMetadata.class)) {
viewColumnMetadata = c
.getMetadata(ViewColumnMetadata.class);
ColumnViewData columnViewData = new ColumnViewData(
viewColumnMetadata
.getSourceTableDimensionColumnId()
.getValue(), viewColumnMetadata
.getTargetTableColumnId().getValue(),
viewColumnMetadata.getTargetTableId()
.getValue());
cData.setViewColumn(true);
cData.setColumnViewData(columnViewData);
} else {
cData.setViewColumn(false);
}
cData.setTrId(trId);
if (c.getColumnType() instanceof DimensionColumnType
|| c.getColumnType() instanceof TimeDimensionColumnType) {
columnsDimension.add(cData);
} else {
columns.add(cData);
}
i++;
}
}
for (ColumnData colDimension : columnsDimension) {
RelationshipData rel = colDimension.getRelationship();
if (rel != null) {
String cId = rel.getTargetColumnId();
if (cId != null) {
for (int j = 0; j < columns.size(); j++) {
ColumnData col = columns.get(j);
if (col.getColumnId() != null && !col.getColumnId().isEmpty()
&& col.isViewColumn()
&& col.getColumnId().compareTo(cId) != 0
&& col.getColumnViewData()
.getSourceTableDimensionColumnId()
.compareTo(
colDimension
.getColumnId()) == 0) {
columns.remove(col);
break;
}
}
}
}
}
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}
@ -1956,7 +2135,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
try {
TabResource t = new TabResource();
TRId trId = new TRId(String.valueOf(tr.getId().getValue()));
trId.setTabResourceType(TabularResourceTypeMap.map(tr.getTabularResourceType()));
trId.setTabResourceType(TabularResourceTypeMap.map(tr
.getTabularResourceType()));
trId.setTableTypeName(tr.getTableType());
t.setId(String.valueOf(i));
t.setTrId(trId);
@ -1965,7 +2145,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
t.setLocked(tr.isLocked());
Contacts owner = new Contacts("", tr.getOwner(), false);
t.setOwner(owner);
if (tr.contains(NameMetadata.class)) {
NameMetadata nameMeta = tr.getMetadata(NameMetadata.class);
if (nameMeta != null && nameMeta.getValue() != null) {
@ -2093,13 +2273,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (viewTable == null) {
trId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(tableId
.getValue()), table.getTableType()
TabularResourceTypeMap.map(tr
.getTabularResourceType()),
tr.getTableType(), String.valueOf(tableId
.getValue()), table.getTableType()
.getName());
} else {
trId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
TabularResourceTypeMap.map(tr
.getTabularResourceType()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
.getName(), String.valueOf(tableId
.getValue()), true);
@ -2626,12 +2810,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTRId(trId);
TabularResourceId tabResourceId = new TabularResourceId(Long.valueOf(trId
.getId()));
TabularResource tabularResource = service.getTabularResource(tabResourceId);
TabularResourceId tabResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabResourceId);
checkTabularResourceLocked(tabularResource);
String owner = tabularResource.getOwner();
if (owner != null && owner.compareTo(aslSession.getUsername()) == 0) {
service.removeTabularResource(tabResourceId);
@ -2683,8 +2868,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
syncTRMetaData(serviceTR, tabResource);
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()),
TabularResourceTypeMap.map(serviceTR.getTabularResourceType()), serviceTR.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
TabularResourceTypeMap.map(serviceTR
.getTabularResourceType()),
serviceTR.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
tabResource.setTrId(trId);
return tabResource;
@ -2760,7 +2947,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
* {@inheritDoc}
*/
@ -2778,10 +2964,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularDataService service = TabularDataServiceFactory.getService();
TabularResource serviceTR = service.createTabularResource();
TabResource sdmxImportTabResource = sdmxImportSession
.getTabResource();
syncTRMetaData(serviceTR, sdmxImportTabResource);
TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()));
@ -2790,9 +2976,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil
.setSDMXImportTabResource(session, sdmxImportTabResource);
OpExecution4SDMXCodelistImport opEx = new OpExecution4SDMXCodelistImport(service,
sdmxImportSession);
OpExecution4SDMXCodelistImport opEx = new OpExecution4SDMXCodelistImport(
service, sdmxImportSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -2801,12 +2987,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (invocation == null) {
throw new TDGWTServiceException(
"Error SDMX Codelist Import: Operation not supported!");
}
}
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR.getId());
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SDMXImport, trId);
SessionUtil.setStartedTask(session, taskWrapper);
@ -2862,14 +3048,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TRId newTRId;
if (viewTable == null) {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
newTRId = new TRId(
String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
} else {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
newTRId = new TRId(
String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
.getName(), String.valueOf(table.getId()
.getValue()), true);
@ -3901,7 +4091,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return parameterInstances;
}
/**
*
* @param trId
@ -3942,7 +4131,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(e.getLocalizedMessage());
}
}
/**
*
@ -3968,8 +4156,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param service
@ -3980,9 +4167,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException {
try {
if (tabularResource.getTabularResourceType().compareTo(TabularResourceType.FLOW)==0) {
if (tabularResource.getTabularResourceType().compareTo(
TabularResourceType.FLOW) == 0) {
logger.error("Operation not allowed on a tabular resource of type flow");
throw new TDGWTIsFlowException("Operation not allowed on a tabular resource of type flow");
throw new TDGWTIsFlowException(
"Operation not allowed on a tabular resource of type flow");
}
} catch (TDGWTServiceException e) {
throw e;
@ -3993,7 +4182,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(e.getLocalizedMessage());
}
}
/**
*
@ -4043,10 +4231,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
// Export SDMX Codelist
OperationDefinition exportSDMXOperation = OperationDefinitionMap
.map(OperationsId.SDMXCodelistExport.toString(), service);
@ -4116,7 +4304,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
@ -4190,7 +4378,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
@ -4229,8 +4417,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
@ -4257,7 +4443,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4380,7 +4566,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(deleteColumnSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4457,7 +4643,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4535,7 +4721,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4607,7 +4793,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(labelColumnSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4671,7 +4857,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(changeTableTypeSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -4760,15 +4946,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setTypeCode(c.getColumnType().getCode());
cData.setTypeName(c.getColumnType().getName());
cData.setDataTypeName(c.getDataType().getName());
NamesMetadata labelsMetadata = null;
try {
labelsMetadata = c
.getMetadata(NamesMetadata.class);
} catch (NoSuchMetadataException e) {
logger.debug("labelMetadata: NoSuchMetadataException "
+ e.getLocalizedMessage());
}
if (c.contains(NamesMetadata.class)) {
labelsMetadata = c.getMetadata(NamesMetadata.class);
}
if (labelsMetadata == null) {
cData.setLabel("nolabel");
logger.debug("LabelsMetadata no labels");
@ -4792,19 +4975,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
DataLocaleMetadata dataLocaleMetadata = null;
try {
if (c.contains(DataLocaleMetadata.class)) {
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());
}
}
PeriodTypeMetadata periodTypeMetadata= null;
if (c.contains(PeriodTypeMetadata.class)) {
periodTypeMetadata = c
.getMetadata(PeriodTypeMetadata.class);
PeriodType periodType=periodTypeMetadata.getType();
cData.setPeriodDataType(PeriodTypeMap.map(periodType));
}
cData.setTrId(trId);
columns.add(cData);
@ -4851,7 +5035,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(deleteRowsSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -5002,7 +5186,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(duplicatesSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -5263,8 +5447,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(tabResource.getTrId().getId()));
TabularResource tr = service.getTabularResource(tabularResourceId);
checkTabularResourceLocked(tr);
checkTabularResourceIsFinal(tr);
@ -5627,7 +5810,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(replaceColumnSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -5694,7 +5877,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(replaceBatchColumnSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6036,7 +6219,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6144,7 +6327,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(rollBackSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6296,7 +6479,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(editRowSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6410,7 +6593,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(taskResubmitSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6470,7 +6653,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(taskResumeSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6620,7 +6803,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(extractCodelistSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
@ -6685,7 +6868,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6752,7 +6935,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -6999,7 +7182,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(codelistMappingSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -7047,7 +7230,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(groupBySession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -7109,7 +7292,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(normalizationSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -7176,7 +7359,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(denormalizationSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -7239,7 +7422,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(unionSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
@ -7278,17 +7461,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
public String startStatisticalOperation(StatisticalOperationSession statisticalOperationSession)
public String startStatisticalOperation(
StatisticalOperationSession statisticalOperationSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setStatisticalOperationSession(session, statisticalOperationSession);
SessionUtil.setStatisticalOperationSession(session,
statisticalOperationSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
@ -7301,12 +7485,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Long.valueOf(statisticalOperationSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
OpExecution4StatisticalOperation opEx = new OpExecution4StatisticalOperation(service, aslSession,
statisticalOperationSession);
OpExecution4StatisticalOperation opEx = new OpExecution4StatisticalOperation(
service, aslSession, statisticalOperationSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -7321,7 +7505,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Task trTask = service.execute(invocation, tabularResourceId);
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.StatisticalOperation, statisticalOperationSession.getTrId());
UIOperationsId.StatisticalOperation,
statisticalOperationSession.getTrId());
SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue();
@ -7339,7 +7524,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
import org.gcube.data.analysis.tabulardata.model.time.PeriodType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.PeriodDataType;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class PeriodTypeMap {
public static PeriodType map(PeriodDataType periodDataType){
if(periodDataType.compareTo(PeriodDataType.DAY)==0){
return PeriodType.DAY;
} else {
if(periodDataType.compareTo(PeriodDataType.MONTH)==0){
return PeriodType.MONTH;
} else {
if(periodDataType.compareTo(PeriodDataType.QUARTER)==0){
return PeriodType.QUARTER;
} else {
if(periodDataType.compareTo(PeriodDataType.YEAR)==0){
return PeriodType.YEAR;
} else {
return null;
}
}
}
}
}
public static PeriodDataType map(PeriodType periodType){
if(periodType.compareTo(PeriodType.DAY)==0){
return PeriodDataType.DAY;
} else {
if(periodType.compareTo(PeriodType.MONTH)==0){
return PeriodDataType.MONTH;
} else {
if(periodType.compareTo(PeriodType.QUARTER)==0){
return PeriodDataType.QUARTER;
} else {
if(periodType.compareTo(PeriodType.YEAR)==0){
return PeriodDataType.YEAR;
} else {
return null;
}
}
}
}
}
}

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.PeriodDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.RelationshipData;
/**
@ -26,9 +27,12 @@ public class ColumnData implements Serializable {
protected String locale;
protected TRId trId;
protected boolean viewColumn;
protected ColumnViewData columnViewData;
protected PeriodDataType periodDataType;
// Relationship for Dimension and Timedimension columns
protected RelationshipData relationship;
@ -45,7 +49,51 @@ public class ColumnData implements Serializable {
}
/**
*
* @param id
* @param columnId
* @param name
* @param typeName
* @param typeCode
* @param dataTypeName
* @param label
* @param locale
* @param trId
* @param viewColumn
* @param columnViewData
* @param periodDataType
* @param relationship
* @param validationColumnReferences
* @param validationColumn
* @param validatedColumns
*/
public ColumnData(String id, String columnId, String name, String typeName,
String typeCode, String dataTypeName, String label, String locale,
TRId trId, boolean viewColumn, ColumnViewData columnViewData,
PeriodDataType periodDataType, RelationshipData relationship,
ArrayList<String> validationColumnReferences,
boolean validationColumn, ArrayList<String> validatedColumns) {
super();
this.id = id;
this.columnId = columnId;
this.name = name;
this.typeName = typeName;
this.typeCode = typeCode;
this.dataTypeName = dataTypeName;
this.label = label;
this.locale = locale;
this.trId = trId;
this.viewColumn = viewColumn;
this.columnViewData = columnViewData;
this.periodDataType = periodDataType;
this.relationship = relationship;
this.validationColumnReferences = validationColumnReferences;
this.validationColumn = validationColumn;
this.validatedColumns = validatedColumns;
}
public String getColumnId() {
return columnId;
}
@ -166,6 +214,15 @@ public class ColumnData implements Serializable {
public void setRelationship(RelationshipData relationship) {
this.relationship = relationship;
}
public PeriodDataType getPeriodDataType() {
return periodDataType;
}
public void setPeriodDataType(PeriodDataType periodDataType) {
this.periodDataType = periodDataType;
}
@Override
public String toString() {
@ -174,12 +231,12 @@ public class ColumnData implements Serializable {
+ ", dataTypeName=" + dataTypeName + ", label=" + label
+ ", locale=" + locale + ", trId=" + trId + ", viewColumn="
+ viewColumn + ", columnViewData=" + columnViewData
+ ", relationship=" + relationship
+ ", validationColumnReferences=" + validationColumnReferences
+ ", validationColumn=" + validationColumn
+ ", validatedColumns=" + validatedColumns + "]";
+ ", periodDataType=" + periodDataType + ", relationship="
+ relationship + ", validationColumnReferences="
+ validationColumnReferences + ", validationColumn="
+ validationColumn + ", validatedColumns=" + validatedColumns
+ "]";
}
}