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 7de1a4f..ca65b88 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 @@ -46,8 +46,11 @@ import org.gcube.data.analysis.tabulardata.model.column.ColumnReference; import org.gcube.data.analysis.tabulardata.model.column.ColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.CodeColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.CodeNameColumnType; +import org.gcube.data.analysis.tabulardata.model.column.type.DimensionColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType; +import org.gcube.data.analysis.tabulardata.model.column.type.TimeDimensionColumnType; import org.gcube.data.analysis.tabulardata.model.column.type.ValidationColumnType; +import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText; @@ -103,6 +106,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.share.Contacts; import org.gcube.portlets.user.td.gwtservice.shared.share.ShareInfo; import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData; 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.batch.Occurences; @@ -225,10 +229,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "CURRENT_TABULAR_RESOURCE is null"); } logger.debug("GetTabResourceInformation():" + currentTR.toString()); - - TRId trId=retrieveTabularResourceType(currentTR.getTrId()); + + TRId trId = retrieveTabularResourceType(currentTR.getTrId()); currentTR.setTrId(trId); - + ArrayList trMetadatas = getTRMetadata(currentTR .getTrId()); updateTabResourceInformation(currentTR, trMetadatas); @@ -261,7 +265,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements // ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("GetTabResourceInformation(TRId):" + trId.toString()); TabResource currentTR = new TabResource(); - trId=retrieveTabularResourceType(trId); + trId = retrieveTabularResourceType(trId); currentTR.setTrId(trId); ArrayList trMetadatas = getTRMetadata(currentTR .getTrId()); @@ -317,6 +321,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } /** + * Returns ArrayList other than IdColumnType, + * ValidationColumnType, DimensionColumnType and TimeDimensionColumnType * * {@inheritDoc} */ @@ -345,10 +351,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List cols = table.getColumns(); int i = 0; for (Column c : cols) { - if (c.getColumnType() instanceof IdColumnType) { + if (c.getColumnType() instanceof IdColumnType + || c.getColumnType() instanceof ValidationColumnType + || c.getColumnType() instanceof DimensionColumnType + || c.getColumnType() instanceof TimeDimensionColumnType) { } else { - if (c.getColumnType() instanceof ValidationColumnType) { + if (c.contains(ViewColumnMetadata.class)) { } else { ColumnData cData = new ColumnData(); @@ -399,6 +408,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } /** + * Returns ArrayList other than IdColumnType, + * ValidationColumnType, DimensionColumnType and TimeDimensionColumnType + * * * {@inheritDoc} */ @@ -422,10 +434,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements List cols = table.getColumns(); int i = 0; for (Column c : cols) { - if (c.getColumnType() instanceof IdColumnType) { + if (c.getColumnType() instanceof IdColumnType + || c.getColumnType() instanceof ValidationColumnType + || c.getColumnType() instanceof DimensionColumnType + || c.getColumnType() instanceof TimeDimensionColumnType) { } else { - if (c.getColumnType() instanceof ValidationColumnType) { + if (c.contains(ViewColumnMetadata.class)) { } else { ColumnData cData = new ColumnData(); @@ -502,9 +517,32 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setId(Integer.toString(0)); cData.setColumnId(c.getLocalId().getValue()); cData.setName(c.getName()); + + if (c.contains(ViewColumnMetadata.class)) { + ViewColumnMetadata viewMetadata = c + .getMetadata(ViewColumnMetadata.class); + logger.debug("ViewColumnMetadata: " + + viewMetadata.toString()); + + String sourceTableDimensionColumnId = viewMetadata + .getSourceTableDimensionColumnId().getValue(); + String targetTableColumnId = viewMetadata + .getTargetTableColumnId().getValue(); + long targetTableId = viewMetadata.getTargetTableId() + .getValue(); + ColumnViewData columnViewData = new ColumnViewData( + sourceTableDimensionColumnId, targetTableColumnId, + targetTableId); + cData.setColumnViewData(columnViewData); + cData.setViewColumn(true); + + } else { + cData.setViewColumn(false); + } cData.setTypeCode(c.getColumnType().getCode()); cData.setTypeName(c.getColumnType().getName()); cData.setDataTypeName(c.getDataType().getName()); + NamesMetadata labelsMetadata = null; try { labelsMetadata = c.getMetadata(NamesMetadata.class); @@ -1353,7 +1391,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } /** - * Retrieve and set Tabular Resource Type + * Retrieve and set Tabular Resource Type * * @param trId * @return @@ -1372,7 +1410,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements new Long(trId.getId())); TabularResource tr = service.getTabularResource(tabularResourceId); trId.setTableType(tr.getTableType()); - logger.debug("Retrieved TRId type:"+ trId.toString()); + logger.debug("Retrieved TRId type:" + trId.toString()); return trId; } catch (Throwable e) { @@ -1425,7 +1463,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + sdmxImportTabResource.setTrId(trId); SessionUtil.setSDMXImportTabResource(session, sdmxImportTabResource); @@ -1454,7 +1492,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + sdmxImportTabResource.setTrId(trId); SessionUtil.setSDMXImportTabResource(session, sdmxImportTabResource); @@ -1842,7 +1880,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + csvImportTabResource.setTrId(trId); SessionUtil.setCSVImportTabResource(session, csvImportTabResource); @@ -3089,7 +3127,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + changeColumnTypeMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3114,7 +3152,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + changeColumnTypeMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3237,7 +3275,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + deleteColumnMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3264,7 +3302,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + deleteColumnMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3388,7 +3426,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + labelColumnMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3415,7 +3453,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + labelColumnMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3540,7 +3578,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + changeTableTypeMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3566,7 +3604,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + changeTableTypeMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3619,41 +3657,56 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements int i = 0; for (Column c : cols) { ColumnType ctype = c.getColumnType(); - if (ctype instanceof CodeColumnType - || ctype instanceof CodeNameColumnType) { + if (c.getColumnType() instanceof IdColumnType + || c.getColumnType() instanceof ValidationColumnType + || c.getColumnType() instanceof DimensionColumnType + || c.getColumnType() instanceof TimeDimensionColumnType) { - 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()); - NamesMetadata labelsMetadata = null; - try { - labelsMetadata = c.getMetadata(NamesMetadata.class); - } catch (NoSuchMetadataException e) { - logger.debug("labelMetadata: NoSuchMetadataException " - + e.getLocalizedMessage()); - } + } else { + if (c.contains(ViewColumnMetadata.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 { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " + cl.getValue()); + + if (ctype instanceof CodeColumnType + || ctype instanceof CodeNameColumnType) { + + 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()); + NamesMetadata labelsMetadata = null; + try { + 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"); + } else { + LocalizedText cl = null; + cl = labelsMetadata.getTextWithLocale("en"); + if (cl == null) { + cData.setLabel("nolabel"); + logger.debug("ColumnLabel no label in en"); + } else { + cData.setLabel(cl.getValue()); + logger.debug("Column Set Label: " + + cl.getValue()); + } + } + cData.setTrId(trId); + columns.add(cData); + i++; } } - cData.setTrId(trId); - columns.add(cData); - i++; + } } return columns; @@ -3693,41 +3746,54 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements int i = 0; for (Column c : cols) { ColumnType ctype = c.getColumnType(); - if (ctype instanceof CodeColumnType - || ctype instanceof CodeNameColumnType) { + if (c.getColumnType() instanceof IdColumnType + || c.getColumnType() instanceof ValidationColumnType + || c.getColumnType() instanceof DimensionColumnType + || c.getColumnType() instanceof TimeDimensionColumnType) { - 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()); - NamesMetadata labelsMetadata = null; - try { - labelsMetadata = c.getMetadata(NamesMetadata.class); - } catch (NoSuchMetadataException e) { - logger.debug("labelMetadata: NoSuchMetadataException " - + e.getLocalizedMessage()); - } + } else { + if (c.contains(ViewColumnMetadata.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 { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " + cl.getValue()); + if (ctype instanceof CodeColumnType + || ctype instanceof CodeNameColumnType) { + + 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()); + NamesMetadata labelsMetadata = null; + try { + 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"); + } else { + LocalizedText cl = null; + cl = labelsMetadata.getTextWithLocale("en"); + if (cl == null) { + cData.setLabel("nolabel"); + logger.debug("ColumnLabel no label in en"); + } else { + cData.setLabel(cl.getValue()); + logger.debug("Column Set Label: " + + cl.getValue()); + } + } + cData.setTrId(trId); + columns.add(cData); + i++; } } - cData.setTrId(trId); - columns.add(cData); - i++; } } return columns; @@ -3837,7 +3903,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + deleteRowsMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -3863,7 +3929,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + deleteRowsMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -4030,7 +4096,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + duplicatesMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); @@ -4056,7 +4122,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .valueOf(table.getId().getValue())); trId.setTableType(table.getTableType().getName()); retrieveTabularResourceType(trId); - + duplicatesMonitor.setTrId(trId); tabResource = SessionUtil.getTabResource(session); tabResource.setTrId(trId); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnData.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnData.java index a1f0567..7e3658a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnData.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnData.java @@ -22,7 +22,8 @@ public class ColumnData implements Serializable { protected String dataTypeName; protected String label; protected TRId trId; - protected ColumnViewData columnView; + protected boolean viewColumn; + protected ColumnViewData columnViewData; public String getColumnId() { return columnId; @@ -87,13 +88,21 @@ public class ColumnData implements Serializable { public void setLabel(String label) { this.label = label; } - - public ColumnViewData getColumnView() { - return columnView; + + public ColumnViewData getColumnViewData() { + return columnViewData; } - public void setColumnView(ColumnViewData columnView) { - this.columnView = columnView; + public void setColumnViewData(ColumnViewData columnViewData) { + this.columnViewData = columnViewData; + } + + public boolean isViewColumn() { + return viewColumn; + } + + public void setViewColumn(boolean viewColumn) { + this.viewColumn = viewColumn; } @Override @@ -101,10 +110,13 @@ public class ColumnData implements Serializable { return "ColumnData [id=" + id + ", columnId=" + columnId + ", name=" + name + ", typeName=" + typeName + ", typeCode=" + typeCode + ", dataTypeName=" + dataTypeName + ", label=" + label - + ", trId=" + trId + ", columnView=" + columnView + "]"; + + ", trId=" + trId + ", viewColumn=" + viewColumn + + ", columnViewData=" + columnViewData + "]"; } + + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnViewData.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnViewData.java index 4c6eb95..6a9160d 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnViewData.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/ColumnViewData.java @@ -4,25 +4,27 @@ import java.io.Serializable; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * */ public class ColumnViewData implements Serializable { private static final long serialVersionUID = 6727733264842637144L; - protected boolean viewColumn; protected String sourceTableDimensionColumnId; protected String targetTableColumnId; protected long targetTableId; - public boolean isViewColumn() { - return viewColumn; + public ColumnViewData() { + } - public void setViewColumn(boolean viewColumn) { - this.viewColumn = viewColumn; + public ColumnViewData(String sourceTableDimensionColumnId, + String targetTableColumnId, long targetTableId) { + this.sourceTableDimensionColumnId = sourceTableDimensionColumnId; + this.targetTableColumnId = targetTableColumnId; + this.targetTableId = targetTableId; } public String getSourceTableDimensionColumnId() { @@ -52,13 +54,10 @@ public class ColumnViewData implements Serializable { @Override public String toString() { - return "ColumnViewData [viewColumn=" + viewColumn - + ", sourceTableDimensionColumnId=" + return "ColumnViewData [sourceTableDimensionColumnId=" + sourceTableDimensionColumnId + ", targetTableColumnId=" + targetTableColumnId + ", targetTableId=" + targetTableId + "]"; } - - }