diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index d5570d1..b9d344c 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -22,7 +22,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata; +import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -82,6 +84,17 @@ public interface TDGWTService extends RemoteService { */ public TableData getLastTable(TRId trId) throws TDGWTServiceException; + + /** + * Return Metadata + * + * @param trId + * @return + * @throws TDGWTServiceException + */ + public ArrayList getTableMetadata(TRId trId) throws TDGWTServiceException; + + // Open /** diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index cefd20e..4bbc4f7 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -21,6 +21,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata; + import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -47,6 +49,8 @@ public interface TDGWTServiceAsync { void getLastTable(TRId trId, AsyncCallback callback); + void getTableMetadata(TRId trId, AsyncCallback> callback); + //Open void setTDOpenSession(TDOpenSession tdOpenSession, AsyncCallback callback); 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 f087b3c..e03e946 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 @@ -26,6 +26,8 @@ import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException; import org.gcube.data.analysis.tabulardata.model.column.Column; +import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; +import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.table.TableMetadata; import org.gcube.data.analysis.tabulardata.model.table.Table; import org.gcube.data.analysis.tabulardata.model.table.TableId; @@ -74,6 +76,9 @@ import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadState; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRDescriptionsMetadata; +import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRLocalizedText; +import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1114,4 +1119,48 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements SessionUtil.setFileUploadSession(session, fileUploadSession); } + @Override + public ArrayList getTableMetadata(TRId trId) + throws TDGWTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + + service = TabularDataServiceFactory.getService(aslSession + .getUsername()); + + Table table = service.getTable(new TableId(Long.valueOf(trId.getTableId()))); + Collection cMeta=table.getAllMetadata(); + ArrayList listTRMetadata=new ArrayList(); + + for(TableMetadata tMetadata:cMeta){ + if(tMetadata instanceof TRDescriptionsMetadata){ + TRDescriptionsMetadata trDescriptionsMetadata=new TRDescriptionsMetadata(); + ArrayList listTRLocalizedText=new ArrayList(); + List lLocalizedText=((DescriptionsMetadata) tMetadata).getTexts(); + for(LocalizedText lt:lLocalizedText){ + TRLocalizedText trLocalizedText=new TRLocalizedText(); + trLocalizedText.setValue(lt.getValue()); + trLocalizedText.setLocaleCode(lt.getLocaleCode()); + listTRLocalizedText.add(trLocalizedText); + } + trDescriptionsMetadata.setListTRLocalizedText(listTRLocalizedText); + listTRMetadata.add(trDescriptionsMetadata); + + } else { + + } + } + + + return listTRMetadata; + + } catch (Exception e) { + logger.error("Error in getTableMetadata(): " + e.getLocalizedMessage(), + e); + throw new TDGWTServiceException("Error in getTableMetadata(): " + + e.getLocalizedMessage()); + } + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/metadata/TRDescriptionsMetadata.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/metadata/TRDescriptionsMetadata.java index c2b50b4..3fd8e8a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/metadata/TRDescriptionsMetadata.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/metadata/TRDescriptionsMetadata.java @@ -12,19 +12,19 @@ import java.util.ArrayList; public class TRDescriptionsMetadata implements TRMetadata { private static final long serialVersionUID = -2663624208642658528L; - ArrayList listLocalizedText; + ArrayList listTRLocalizedText; - public ArrayList getListLocalizedText() { - return listLocalizedText; + public ArrayList getListTRLocalizedText() { + return listTRLocalizedText; } - public void setListLocalizedText(ArrayList listLocalizedText) { - this.listLocalizedText = listLocalizedText; + public void setListTRLocalizedText(ArrayList listTRLocalizedText) { + this.listTRLocalizedText = listTRLocalizedText; } @Override public String toString() { - return "TRDescriptionsMetadata [listLocalizedText=" + listLocalizedText + return "TRDescriptionsMetadata [listTRLocalizedText=" + listTRLocalizedText + "]"; }