Added getColumn
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@90128 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5fe7355674
commit
b48a59d116
|
@ -30,6 +30,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
|
@ -156,7 +157,14 @@ public interface TDGWTService extends RemoteService {
|
|||
*/
|
||||
public ArrayList<ColumnData> getColumns(TRId trId) throws TDGWTServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves information about a specific column
|
||||
*
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
public ColumnData getColumn(TRId trId, String columnName) throws TDGWTServiceException;
|
||||
|
||||
/**
|
||||
* Remove Tabular Resource From Service
|
||||
*
|
||||
|
|
|
@ -64,6 +64,8 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
|
||||
|
||||
void getColumn(TRId trId, String columnName, AsyncCallback<ColumnData> callback);
|
||||
|
||||
void removeTabularResource(TRId trId, AsyncCallback<Void> callback);
|
||||
|
||||
//Open
|
||||
|
|
|
@ -319,10 +319,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
"Error retrieving Columns: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
"Error retrieving Columns: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
@ -388,10 +388,79 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error setting TabResource parameter: "
|
||||
"Error retrieving Columns: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error setting TabResource parameter: "
|
||||
"Error retrieving Columns: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ColumnData getColumn(TRId trId, String columnName) 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())));
|
||||
|
||||
ColumnData cData = new ColumnData();
|
||||
|
||||
Column c = table.getColumnByName(columnName);
|
||||
if (c.getColumnType() instanceof IdColumnType) {
|
||||
cData.setId(Integer.toString(0));
|
||||
cData.setName("Id");
|
||||
cData.setLabel("Id");
|
||||
cData.setTypeCode(c.getColumnType().getCode());
|
||||
cData.setTypeName(c.getColumnType().getName());
|
||||
cData.setTrId(trId);
|
||||
} else {
|
||||
cData.setId(Integer.toString(0));
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
return cData;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"Error retrieving Column: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
throw new TDGWTServiceException(
|
||||
"Error retrieving Column: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue