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 eefb4c2..b1869a6 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 @@ -412,11 +412,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setLabel("nolabel"); logger.debug("ColumnLabel no label in en"); } else { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " - + cl.getValue()); + 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; + try { + 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()); + } + cData.setTrId(trId); columns.add(cData); i++; @@ -495,11 +517,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setLabel("nolabel"); logger.debug("ColumnLabel no label in en"); } else { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " - + cl.getValue()); + 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; + try { + 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()); + } + cData.setTrId(trId); columns.add(cData); i++; @@ -517,8 +561,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } - - + /** * * {@inheritDoc} @@ -533,10 +576,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - Table table = service.getTable(new TableId(Long.valueOf(trId.getTableId()))); + Table table = service.getTable(new TableId(Long.valueOf(trId + .getTableId()))); ColumnData cData = new ColumnData(); - ColumnLocalId columnId=new ColumnLocalId(columnLocalId); + ColumnLocalId columnId = new ColumnLocalId(columnLocalId); Column c = table.getColumnById(columnId); if (c.getColumnType() instanceof IdColumnType) { @@ -588,10 +632,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setLabel("nolabel"); logger.debug("ColumnLabel no label in en"); } else { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " + cl.getValue()); + 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; + try { + 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()); + } + cData.setTrId(trId); } @@ -676,10 +743,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setLabel("nolabel"); logger.debug("ColumnLabel no label in en"); } else { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " + cl.getValue()); + 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; + try { + 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()); + } + cData.setTrId(trId); } @@ -3412,7 +3502,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements operationDefinition.getOperationId(), map); break; case CODENAME: - DataLocaleMetadata locale=new DataLocaleMetadata(changeColumnTypeSession.getLocale()); + DataLocaleMetadata locale = new DataLocaleMetadata( + changeColumnTypeSession.getLocale()); map.put(Constants.PARAMETER_ADDITIONAL_META, locale); operationDefinition = OperationDefinitionMap.map( OperationsId.ChangeToCodeName.toString(), capabilities); @@ -4438,11 +4529,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements cData.setLabel("nolabel"); logger.debug("ColumnLabel no label in en"); } else { - cData.setLabel(cl.getValue()); - logger.debug("Column Set Label: " - + cl.getValue()); + 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; + try { + 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()); + } + cData.setTrId(trId); columns.add(cData); i++; @@ -4950,13 +5063,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements try { HttpSession session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); - logger.debug("GetOccurencesForBatchReplace: " + occurrencesForReplaceBatchColumnSession.toString()); + logger.debug("GetOccurencesForBatchReplace: " + + occurrencesForReplaceBatchColumnSession.toString()); AuthorizationProvider.instance.set(new AuthorizationToken( aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); ArrayList occurences = QueryService.queryOccurences( - service, occurrencesForReplaceBatchColumnSession, Direction.ASC); + service, occurrencesForReplaceBatchColumnSession, + Direction.ASC); logger.debug("Retrieved Occurences"); return occurences; @@ -5502,37 +5617,32 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } - /** * * {@inheritDoc} */ @Override - public ArrayList getLocales() - throws TDGWTServiceException { + public ArrayList getLocales() throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); @SuppressWarnings("unused") ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("getLocales()"); - List listLocales=Arrays.asList(Locales.ALLOWED_LOCALES); - ArrayList locales=new ArrayList(); - locales.addAll(listLocales); - - logger.debug("locales :"+locales); - return locales; - - + List listLocales = Arrays.asList(Locales.ALLOWED_LOCALES); + ArrayList locales = new ArrayList(); + locales.addAll(listLocales); + + logger.debug("locales :" + locales); + return locales; + } catch (Throwable e) { - logger.debug("getLocales(): "+e.getLocalizedMessage()); + logger.debug("getLocales(): " + e.getLocalizedMessage()); e.printStackTrace(); - throw new TDGWTServiceException( - "Error retrieving locales: " - + e.getLocalizedMessage()); + throw new TDGWTServiceException("Error retrieving locales: " + + e.getLocalizedMessage()); } } - - + } 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 42d5f72..47a0ddb 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,6 +22,8 @@ public class ColumnData implements Serializable { protected String typeCode; protected String dataTypeName; protected String label; + protected String locale; + protected TRId trId; protected boolean viewColumn; protected ColumnViewData columnViewData; @@ -133,22 +135,31 @@ public class ColumnData implements Serializable { public ArrayList getValidationColumnReferences() { return validationColumnReferences; } - + public void setValidationColumnReferences( ArrayList validationColumnReferences) { this.validationColumnReferences = validationColumnReferences; } + + public String getLocale() { + return locale; + } + + public void setLocale(String locale) { + this.locale = locale; + } @Override public String toString() { return "ColumnData [id=" + id + ", columnId=" + columnId + ", name=" + name + ", typeName=" + typeName + ", typeCode=" + typeCode + ", dataTypeName=" + dataTypeName + ", label=" + label - + ", trId=" + trId + ", viewColumn=" + viewColumn - + ", columnViewData=" + columnViewData + + ", locale=" + locale + ", trId=" + trId + ", viewColumn=" + + viewColumn + ", columnViewData=" + columnViewData + ", validationColumnReferences=" + validationColumnReferences + ", validationColumn=" + validationColumn + ", validatedColumns=" + validatedColumns + "]"; } + }