Added getColumns

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86348 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-29 10:07:31 +00:00
parent 1f4f39c122
commit e1a265e9c0
3 changed files with 67 additions and 1 deletions

View File

@ -17,6 +17,7 @@ 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.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
@ -26,6 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -114,6 +116,14 @@ public interface TDGWTService extends RemoteService {
*/
public void setTDOpenSession(TDOpenSession tdOpenSession) throws TDGWTServiceException;
/**
* Retrieves the list of columns in the current table
*
* @return
* @throws TDGWTServiceException
*/
public ArrayList<ColumnData> getColumns() throws TDGWTServiceException;
// Import SDMX
/**

View File

@ -16,6 +16,7 @@ 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.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
@ -53,6 +54,8 @@ public interface TDGWTServiceAsync {
void getTableMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
void getColumns(AsyncCallback<List<ColumnData>> callback);
//Open
void setTDOpenSession(TDOpenSession tdOpenSession, AsyncCallback<Void> callback);
@ -82,7 +85,7 @@ public interface TDGWTServiceAsync {
void configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment, AsyncCallback<ArrayList<String>> callback);
void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError> > callback);
void checkCSV(long errorsLimit, AsyncCallback<ArrayList<CSVRowError>> callback);
void startCSVImport(CSVImportSession csvImportSession, AsyncCallback<Void> callback);

View File

@ -148,6 +148,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
@ -175,6 +176,58 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<ColumnData> getColumns() throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
TabResource currentTR = SessionUtil.getTabResource(session);
if (currentTR == null) {
logger.error("CURRENT_TABULAR_RESOURCE is null");
throw new TDGWTServiceException(
"CURRENT_TABULAR_RESOURCE is null");
}
TRId trId=currentTR.getTrId();
service = TabularDataServiceFactory.getService(aslSession
.getUsername());
Table table = service.getLastTable(new TabularResourceId(Long
.valueOf(trId.getId())));
ArrayList<ColumnData> columns=new ArrayList<ColumnData>();
List<Column> cols=table.getColumns();
for(Column c: cols){
ColumnData cData=new ColumnData();
cData.setName(c.getName());
cData.setTypeCode(c.getColumnType().getCode());
cData.setTypeName(c.getColumnType().getName());
cData.setTrId(trId);
}
return columns;
} catch (Exception e) {
logger.error(
"Error setting TabResource parameter: "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error setting TabResource parameter: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public TableData getLastTable(TRId trId) throws TDGWTServiceException {
try {