diff --git a/pom.xml b/pom.xml
index 0b4a507..27b1fb4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,13 @@
sources
test
-
+
+
+ org.json
+ json
+ 20090211
+
+
org.gcube.data.publishing
sdmx-registry-client-gcube
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 f5086c6..cb34da6 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
@@ -47,7 +47,6 @@ 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;
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 6952177..40c3f35 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
@@ -3491,6 +3491,72 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
+ public ArrayList getColumnsForDimension(TRId trId,
+ ASLSession aslSession) throws TDGWTServiceException {
+ try {
+ AuthorizationProvider.instance.set(new AuthorizationToken(
+ aslSession.getUsername()));
+ TabularDataService service = TabularDataServiceFactory.getService();
+
+ logger.debug("getColumnsForDimension():" + trId.toString());
+
+ Table table = service.getTable(new TableId(Long.valueOf(trId
+ .getTableId())));
+
+ ArrayList columns = new ArrayList();
+
+ List cols = table.getColumns();
+ int i = 0;
+ for (Column c : cols) {
+ ColumnType ctype = c.getColumnType();
+ if (ctype instanceof CodeColumnType
+ || ctype instanceof CodeNameColumnType) {
+
+ ColumnData cData = new ColumnData();
+ cData.setId(Integer.toString(i));
+ cData.setColumnId(c.getLocalId().getValue());
+ cData.setName(c.getName());
+ cData.setTypeCode(c.getColumnType().getCode());
+ cData.setTypeName(c.getColumnType().getName());
+ cData.setDataTypeName(c.getDataType().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 in getColumnsForDimension() retrieving Columns: "
+ + e.getLocalizedMessage(), e);
+ throw new TDGWTServiceException("Error retrieving Columns: "
+ + e.getLocalizedMessage());
+ }
+ }
+
/**
*
* {@inheritDoc}
@@ -3992,8 +4058,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
@Override
- public ArrayList getOccurencesForBatchReplace(
- ColumnData column)
+ public ArrayList getOccurencesForBatchReplace(ColumnData column)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
@@ -4003,8 +4068,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
- ArrayList occurences=QueryService.queryOccurences(service,column, Direction.ASC);
-
+ ArrayList occurences = QueryService.queryOccurences(
+ service, column, Direction.ASC);
+
+ logger.debug("Retrieved Occurences");
return occurences;
} catch (Exception e) {
logger.debug("Error in GetOccurencesForBatchReplace: "
@@ -4016,7 +4083,5 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
-
-
}
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java
index d19557a..5095dcb 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/QueryService.java
@@ -13,12 +13,10 @@ import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn;
import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn.Function;
import org.gcube.data.analysis.tabulardata.query.parameters.select.QuerySelect;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
-import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTableException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
@@ -32,16 +30,18 @@ public class QueryService {
public static ArrayList queryOccurences(
TabularDataService service, ColumnData column, Direction direction)
throws TDGWTServiceException {
+ logger.debug("QueryOccurences");
ArrayList occurences = new ArrayList();
TableId tableId = new TableId(new Long(column.getTrId().getTableId()));
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
-
+
QuerySelect querySelect = new QuerySelect(Arrays.asList(
new QueryColumn(columnId), new QueryColumn(columnId,
Function.COUNT)));
+ logger.debug("Occurences querySelect:"+querySelect.toString());
QueryGroup queryGroup = new QueryGroup(Arrays.asList(columnId));
-
+ logger.debug("Occurences queryGroup:"+querySelect.toString());
QueryOrder queryOrder = null;
switch (direction) {
case ASC:
@@ -55,8 +55,10 @@ public class QueryService {
break;
}
+
QueryPage queryPage = null;// All occurences
-
+ logger.debug("Occurences queryPage all");
+
String serviceJson = null;
try {
if (queryOrder == null) {
@@ -67,7 +69,7 @@ public class QueryService {
serviceJson = service.queryAsJson(tableId, queryPage,
queryOrder, querySelect, queryGroup);
}
- } catch (NoSuchTableException e) {
+ } catch (Throwable e) {
logger.debug("Error by running the query on the server:"+e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(
@@ -75,10 +77,14 @@ public class QueryService {
}
logger.debug("Created serviceJson");
+ logger.debug(serviceJson);
+
JSONArray currentRow = null;
int i = -1;
int j = -1;
int totalRows = -1;
+
+
try {
org.json.JSONObject obj = new org.json.JSONObject(serviceJson);
org.json.JSONArray rows = obj.getJSONArray("rows");
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/Occurences.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/Occurences.java
index a95d45a..8c61845 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/Occurences.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/batch/Occurences.java
@@ -10,8 +10,8 @@ import java.io.Serializable;
*/
public class Occurences implements Serializable {
- private static final long serialVersionUID = -5933329146218505850L;
-
+ private static final long serialVersionUID = -5521905443482827219L;
+
protected String value;
protected int number;