Added metadata

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@85798 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-20 17:26:49 +00:00
parent 8abac0ccfe
commit 710c8a373c
4 changed files with 72 additions and 6 deletions

View File

@ -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<TRMetadata> getTableMetadata(TRId trId) throws TDGWTServiceException;
// Open
/**

View File

@ -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<TableData> callback);
void getTableMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
//Open
void setTDOpenSession(TDOpenSession tdOpenSession, AsyncCallback<Void> callback);

View File

@ -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<TRMetadata> 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<TableMetadata> cMeta=table.getAllMetadata();
ArrayList<TRMetadata> listTRMetadata=new ArrayList<TRMetadata>();
for(TableMetadata tMetadata:cMeta){
if(tMetadata instanceof TRDescriptionsMetadata){
TRDescriptionsMetadata trDescriptionsMetadata=new TRDescriptionsMetadata();
ArrayList<TRLocalizedText> listTRLocalizedText=new ArrayList<TRLocalizedText>();
List<LocalizedText> 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());
}
}
}

View File

@ -12,19 +12,19 @@ import java.util.ArrayList;
public class TRDescriptionsMetadata implements TRMetadata {
private static final long serialVersionUID = -2663624208642658528L;
ArrayList<TRLocalizedText> listLocalizedText;
ArrayList<TRLocalizedText> listTRLocalizedText;
public ArrayList<TRLocalizedText> getListLocalizedText() {
return listLocalizedText;
public ArrayList<TRLocalizedText> getListTRLocalizedText() {
return listTRLocalizedText;
}
public void setListLocalizedText(ArrayList<TRLocalizedText> listLocalizedText) {
this.listLocalizedText = listLocalizedText;
public void setListTRLocalizedText(ArrayList<TRLocalizedText> listTRLocalizedText) {
this.listTRLocalizedText = listTRLocalizedText;
}
@Override
public String toString() {
return "TRDescriptionsMetadata [listLocalizedText=" + listLocalizedText
return "TRDescriptionsMetadata [listTRLocalizedText=" + listTRLocalizedText
+ "]";
}