Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@93389 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-20 15:40:08 +00:00
parent 18198f4a3b
commit 40661ff7b9
3 changed files with 181 additions and 104 deletions

View File

@ -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.ColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.CodeColumnType; 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.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.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.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.DescriptionsMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText;
import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText; 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.share.ShareInfo;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; 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.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.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
@ -226,7 +230,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
logger.debug("GetTabResourceInformation():" + currentTR.toString()); logger.debug("GetTabResourceInformation():" + currentTR.toString());
TRId trId=retrieveTabularResourceType(currentTR.getTrId()); TRId trId = retrieveTabularResourceType(currentTR.getTrId());
currentTR.setTrId(trId); currentTR.setTrId(trId);
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
@ -261,7 +265,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
// ASLSession aslSession = SessionUtil.getAslSession(session); // ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("GetTabResourceInformation(TRId):" + trId.toString()); logger.debug("GetTabResourceInformation(TRId):" + trId.toString());
TabResource currentTR = new TabResource(); TabResource currentTR = new TabResource();
trId=retrieveTabularResourceType(trId); trId = retrieveTabularResourceType(trId);
currentTR.setTrId(trId); currentTR.setTrId(trId);
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
.getTrId()); .getTrId());
@ -317,6 +321,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
/** /**
* Returns ArrayList<ColumnData> other than IdColumnType,
* ValidationColumnType, DimensionColumnType and TimeDimensionColumnType
* *
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -345,10 +351,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
List<Column> cols = table.getColumns(); List<Column> cols = table.getColumns();
int i = 0; int i = 0;
for (Column c : cols) { 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 { } else {
if (c.getColumnType() instanceof ValidationColumnType) { if (c.contains(ViewColumnMetadata.class)) {
} else { } else {
ColumnData cData = new ColumnData(); ColumnData cData = new ColumnData();
@ -399,6 +408,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
/** /**
* Returns ArrayList<ColumnData> other than IdColumnType,
* ValidationColumnType, DimensionColumnType and TimeDimensionColumnType
*
* *
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -422,10 +434,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
List<Column> cols = table.getColumns(); List<Column> cols = table.getColumns();
int i = 0; int i = 0;
for (Column c : cols) { 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 { } else {
if (c.getColumnType() instanceof ValidationColumnType) { if (c.contains(ViewColumnMetadata.class)) {
} else { } else {
ColumnData cData = new ColumnData(); ColumnData cData = new ColumnData();
@ -502,9 +517,32 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setId(Integer.toString(0)); cData.setId(Integer.toString(0));
cData.setColumnId(c.getLocalId().getValue()); cData.setColumnId(c.getLocalId().getValue());
cData.setName(c.getName()); 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.setTypeCode(c.getColumnType().getCode());
cData.setTypeName(c.getColumnType().getName()); cData.setTypeName(c.getColumnType().getName());
cData.setDataTypeName(c.getDataType().getName()); cData.setDataTypeName(c.getDataType().getName());
NamesMetadata labelsMetadata = null; NamesMetadata labelsMetadata = null;
try { try {
labelsMetadata = c.getMetadata(NamesMetadata.class); labelsMetadata = c.getMetadata(NamesMetadata.class);
@ -1372,7 +1410,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
new Long(trId.getId())); new Long(trId.getId()));
TabularResource tr = service.getTabularResource(tabularResourceId); TabularResource tr = service.getTabularResource(tabularResourceId);
trId.setTableType(tr.getTableType()); trId.setTableType(tr.getTableType());
logger.debug("Retrieved TRId type:"+ trId.toString()); logger.debug("Retrieved TRId type:" + trId.toString());
return trId; return trId;
} catch (Throwable e) { } catch (Throwable e) {
@ -3619,41 +3657,56 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 0; int i = 0;
for (Column c : cols) { for (Column c : cols) {
ColumnType ctype = c.getColumnType(); ColumnType ctype = c.getColumnType();
if (ctype instanceof CodeColumnType if (c.getColumnType() instanceof IdColumnType
|| ctype instanceof CodeNameColumnType) { || c.getColumnType() instanceof ValidationColumnType
|| c.getColumnType() instanceof DimensionColumnType
|| c.getColumnType() instanceof TimeDimensionColumnType) {
ColumnData cData = new ColumnData(); } else {
cData.setId(Integer.toString(i)); if (c.contains(ViewColumnMetadata.class)) {
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 { } else {
LocalizedText cl = null;
cl = labelsMetadata.getTextWithLocale("en"); if (ctype instanceof CodeColumnType
if (cl == null) { || ctype instanceof CodeNameColumnType) {
cData.setLabel("nolabel");
logger.debug("ColumnLabel no label in en"); ColumnData cData = new ColumnData();
} else { cData.setId(Integer.toString(i));
cData.setLabel(cl.getValue()); cData.setColumnId(c.getLocalId().getValue());
logger.debug("Column Set Label: " + cl.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; return columns;
@ -3693,41 +3746,54 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 0; int i = 0;
for (Column c : cols) { for (Column c : cols) {
ColumnType ctype = c.getColumnType(); ColumnType ctype = c.getColumnType();
if (ctype instanceof CodeColumnType if (c.getColumnType() instanceof IdColumnType
|| ctype instanceof CodeNameColumnType) { || c.getColumnType() instanceof ValidationColumnType
|| c.getColumnType() instanceof DimensionColumnType
|| c.getColumnType() instanceof TimeDimensionColumnType) {
ColumnData cData = new ColumnData(); } else {
cData.setId(Integer.toString(i)); if (c.contains(ViewColumnMetadata.class)) {
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 { } else {
LocalizedText cl = null; if (ctype instanceof CodeColumnType
cl = labelsMetadata.getTextWithLocale("en"); || ctype instanceof CodeNameColumnType) {
if (cl == null) {
cData.setLabel("nolabel"); ColumnData cData = new ColumnData();
logger.debug("ColumnLabel no label in en"); cData.setId(Integer.toString(i));
} else { cData.setColumnId(c.getLocalId().getValue());
cData.setLabel(cl.getValue()); cData.setName(c.getName());
logger.debug("Column Set Label: " + cl.getValue()); 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; return columns;

View File

@ -22,7 +22,8 @@ public class ColumnData implements Serializable {
protected String dataTypeName; protected String dataTypeName;
protected String label; protected String label;
protected TRId trId; protected TRId trId;
protected ColumnViewData columnView; protected boolean viewColumn;
protected ColumnViewData columnViewData;
public String getColumnId() { public String getColumnId() {
return columnId; return columnId;
@ -88,12 +89,20 @@ public class ColumnData implements Serializable {
this.label = label; this.label = label;
} }
public ColumnViewData getColumnView() { public ColumnViewData getColumnViewData() {
return columnView; return columnViewData;
} }
public void setColumnView(ColumnViewData columnView) { public void setColumnViewData(ColumnViewData columnViewData) {
this.columnView = columnView; this.columnViewData = columnViewData;
}
public boolean isViewColumn() {
return viewColumn;
}
public void setViewColumn(boolean viewColumn) {
this.viewColumn = viewColumn;
} }
@Override @Override
@ -101,10 +110,13 @@ public class ColumnData implements Serializable {
return "ColumnData [id=" + id + ", columnId=" + columnId + ", name=" return "ColumnData [id=" + id + ", columnId=" + columnId + ", name="
+ name + ", typeName=" + typeName + ", typeCode=" + typeCode + name + ", typeName=" + typeName + ", typeCode=" + typeCode
+ ", dataTypeName=" + dataTypeName + ", label=" + label + ", dataTypeName=" + dataTypeName + ", label=" + label
+ ", trId=" + trId + ", columnView=" + columnView + "]"; + ", trId=" + trId + ", viewColumn=" + viewColumn
+ ", columnViewData=" + columnViewData + "]";
} }
} }

View File

@ -4,25 +4,27 @@ import java.io.Serializable;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ColumnViewData implements Serializable { public class ColumnViewData implements Serializable {
private static final long serialVersionUID = 6727733264842637144L; private static final long serialVersionUID = 6727733264842637144L;
protected boolean viewColumn;
protected String sourceTableDimensionColumnId; protected String sourceTableDimensionColumnId;
protected String targetTableColumnId; protected String targetTableColumnId;
protected long targetTableId; protected long targetTableId;
public boolean isViewColumn() { public ColumnViewData() {
return viewColumn;
} }
public void setViewColumn(boolean viewColumn) { public ColumnViewData(String sourceTableDimensionColumnId,
this.viewColumn = viewColumn; String targetTableColumnId, long targetTableId) {
this.sourceTableDimensionColumnId = sourceTableDimensionColumnId;
this.targetTableColumnId = targetTableColumnId;
this.targetTableId = targetTableId;
} }
public String getSourceTableDimensionColumnId() { public String getSourceTableDimensionColumnId() {
@ -52,13 +54,10 @@ public class ColumnViewData implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "ColumnViewData [viewColumn=" + viewColumn return "ColumnViewData [sourceTableDimensionColumnId="
+ ", sourceTableDimensionColumnId="
+ sourceTableDimensionColumnId + ", targetTableColumnId=" + sourceTableDimensionColumnId + ", targetTableColumnId="
+ targetTableColumnId + ", targetTableId=" + targetTableId + targetTableColumnId + ", targetTableId=" + targetTableId
+ "]"; + "]";
} }
} }