Added getColumns
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@90119 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4f43bd52d5
commit
5fe7355674
|
@ -148,6 +148,15 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public ArrayList<ColumnData> getColumns() throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Retrieves the list of columns in the table provided by trId
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ArrayList<ColumnData> getColumns(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Remove Tabular Resource From Service
|
||||
*
|
||||
|
|
|
@ -62,6 +62,8 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void getColumns(AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void removeTabularResource(TRId trId, AsyncCallback<Void> callback);
|
||||
|
||||
//Open
|
||||
|
|
|
@ -327,6 +327,75 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ArrayList<ColumnData> getColumns(TRId trId) throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
Table table = service.getTable(new TableId(Long
|
||||
.valueOf(trId.getTableId())));
|
||||
|
||||
ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
|
||||
|
||||
List<Column> cols = table.getColumns();
|
||||
int i = 0;
|
||||
for (Column c : cols) {
|
||||
if (c.getColumnType() instanceof IdColumnType) {
|
||||
|
||||
} else {
|
||||
ColumnData cData = new ColumnData();
|
||||
cData.setId(Integer.toString(i));
|
||||
cData.setName(c.getName());
|
||||
cData.setTypeCode(c.getColumnType().getCode());
|
||||
cData.setTypeName(c.getColumnType().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++;
|
||||
}
|
||||
}
|
||||
|
||||
return columns;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
|
Loading…
Reference in New Issue