Added the management of ambiguity

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98538 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-09 16:44:11 +00:00
parent 6b5731733d
commit 4f5a725a59
6 changed files with 362 additions and 294 deletions

View File

@ -17,7 +17,6 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager; import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
@ -93,8 +92,8 @@ public class SessionUtil {
ASLSession session; ASLSession session;
if (username == null) { if (username == null) {
logger.warn("no user found in session, using test one"); logger.warn("no user found in session, using test one");
/*throw new TDGWTSessionExpiredException("Session Expired!");*/ throw new TDGWTSessionExpiredException("Session Expired!");
/*
username = Constants.DEFAULT_USER; username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE; String scope = Constants.DEFAULT_SCOPE;
@ -102,7 +101,7 @@ public class SessionUtil {
session = SessionManager.getInstance().getASLSession( session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); httpSession.getId(), username);
session.setScope(scope); session.setScope(scope);
*/
} else { } else {
session = SessionManager.getInstance().getASLSession( session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); httpSession.getId(), username);

View File

@ -990,6 +990,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Table table = service.getTable(new TableId(Long.valueOf(trId Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId()))); .getTableId())));
logger.debug("getValidationColumns() on Table: "+table.toString());
Column columnSource = table.getColumnByName(columnName); Column columnSource = table.getColumnByName(columnName);
if (columnSource == null) { if (columnSource == null) {
@ -1007,7 +1008,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 0; int i = 0;
for (Column c : cols) { for (Column c : cols) {
if (c.getColumnType() instanceof ValidationColumnType) { if (c.getColumnType() instanceof ValidationColumnType) {
logger.debug("ValidationColumn present: " + c.getLocalId()); logger.debug("ValidationColumn present: [" +c.getColumnType()+" "+c.getLocalId()+"]");
if (c.contains(ValidationReferencesMetadata.class)) { if (c.contains(ValidationReferencesMetadata.class)) {
logger.debug("ValidationReferencesMetadata present"); logger.debug("ValidationReferencesMetadata present");
ValidationReferencesMetadata validationReferenceMetadata = c ValidationReferencesMetadata validationReferenceMetadata = c

View File

@ -259,7 +259,7 @@ public class ExpressionGenerator {
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.debug("Error in genReplaceBatchOccurrencesFilter: " logger.error("Error in genReplaceBatchOccurrencesFilter: "
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new TDGWTServiceException( throw new TDGWTServiceException(

View File

@ -42,12 +42,16 @@ public class QueryService {
TabularDataService service, TabularDataService service,
OccurrencesForReplaceBatchColumnSession occurrencesSession, OccurrencesForReplaceBatchColumnSession occurrencesSession,
Direction direction) throws TDGWTServiceException { Direction direction) throws TDGWTServiceException {
try {
logger.debug("QueryOccurences"); logger.debug("QueryOccurences");
ColumnData column = occurrencesSession.getColumnData(); ColumnData column = occurrencesSession.getColumnData();
ArrayList<Occurrences> occurences = new ArrayList<Occurrences>(); ArrayList<Occurrences> occurences = new ArrayList<Occurrences>();
TableId tableId = new TableId(new Long(column.getTrId().getTableId())); TableId tableId = new TableId(new Long(column.getTrId()
.getTableId()));
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId()); ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
QuerySelect querySelect = null; QuerySelect querySelect = null;
QueryGroup queryGroup = null; QueryGroup queryGroup = null;
@ -57,20 +61,27 @@ public class QueryService {
logger.debug("Replace Batch no validations"); logger.debug("Replace Batch no validations");
if (column.isViewColumn()) { if (column.isViewColumn()) {
ColumnLocalId sourceColumnId = new ColumnLocalId(column ColumnLocalId sourceColumnId = new ColumnLocalId(column
.getColumnViewData().getSourceTableDimensionColumnId()); .getColumnViewData()
querySelect = new QuerySelect(Arrays.asList(new QueryColumn( .getSourceTableDimensionColumnId());
columnId), new QueryColumn(sourceColumnId), querySelect = new QuerySelect(Arrays.asList(
new QueryColumn(columnId, Function.COUNT))); new QueryColumn(columnId), new QueryColumn(
logger.debug("Occurences querySelect:" + querySelect.toString()); sourceColumnId), new QueryColumn(columnId,
Function.COUNT)));
logger.debug("Occurences querySelect:"
+ querySelect.toString());
queryGroup = new QueryGroup(Arrays.asList(columnId, queryGroup = new QueryGroup(Arrays.asList(columnId,
sourceColumnId)); sourceColumnId));
logger.debug("Occurences queryGroup:" + queryGroup.toString()); logger.debug("Occurences queryGroup:"
+ queryGroup.toString());
} else { } else {
querySelect = new QuerySelect(Arrays.asList(new QueryColumn( querySelect = new QuerySelect(Arrays.asList(
columnId), new QueryColumn(columnId, Function.COUNT))); new QueryColumn(columnId), new QueryColumn(
logger.debug("Occurences querySelect:" + querySelect.toString()); columnId, Function.COUNT)));
logger.debug("Occurences querySelect:"
+ querySelect.toString());
queryGroup = new QueryGroup(Arrays.asList(columnId)); queryGroup = new QueryGroup(Arrays.asList(columnId));
logger.debug("Occurences queryGroup:" + queryGroup.toString()); logger.debug("Occurences queryGroup:"
+ queryGroup.toString());
} }
} else { } else {
logger.debug("Replace Batch from validations"); logger.debug("Replace Batch from validations");
@ -128,8 +139,8 @@ public class QueryService {
.getSourceTableDimensionColumnId()); .getSourceTableDimensionColumnId());
querySelect = new QuerySelect(Arrays.asList( querySelect = new QuerySelect(Arrays.asList(
new QueryColumn(columnId), new QueryColumn( new QueryColumn(columnId), new QueryColumn(
sourceColumnId), new QueryColumn(columnId, sourceColumnId), new QueryColumn(
Function.COUNT))); columnId, Function.COUNT)));
logger.debug("Occurences querySelect:" logger.debug("Occurences querySelect:"
+ querySelect.toString()); + querySelect.toString());
queryGroup = new QueryGroup(Arrays.asList(columnId, queryGroup = new QueryGroup(Arrays.asList(columnId,
@ -153,7 +164,8 @@ public class QueryService {
QueryOrder queryOrder = null; QueryOrder queryOrder = null;
switch (direction) { switch (direction) {
case ASC: case ASC:
queryOrder = new QueryOrder(columnId, QueryOrderDirection.ASCENDING); queryOrder = new QueryOrder(columnId,
QueryOrderDirection.ASCENDING);
break; break;
case DESC: case DESC:
queryOrder = new QueryOrder(columnId, queryOrder = new QueryOrder(columnId,
@ -170,22 +182,28 @@ public class QueryService {
QueryFilter queryFilter = null; QueryFilter queryFilter = null;
if (occurrencesSession.getShowType().compareTo( if (occurrencesSession.getShowType().compareTo(
ShowOccurrencesType.ONLYERRORS) == 0) { ShowOccurrencesType.ONLYERRORS) == 0) {
logger.debug("Filter on error");
if (occurrencesSession.isHasValidationColumns()) { if (occurrencesSession.isHasValidationColumns()) {
Expression exp = ExpressionGenerator Expression exp = ExpressionGenerator
.genReplaceBatchOccurrencesFilter(occurrencesSession); .genReplaceBatchOccurrencesFilter(occurrencesSession);
logger.debug("Expression: " + exp); logger.debug("Expression: " + exp);
if (exp != null) { if (exp != null) {
queryFilter = new QueryFilter(exp); queryFilter = new QueryFilter(exp);
} else {
logger.debug("Expression generated is null");
} }
} else { } else {
logger.debug("No validation columns");
return occurences; return occurences;
} }
} else {
logger.debug("No Filter on error");
} }
logger.debug("Query on " + tableId.toString() + " queryPage:" logger.debug("Query on " + tableId.toString() + " queryPage:"
+ queryPage + ", queryFilter:" + queryFilter + ", querySelect:" + queryPage + ", queryFilter:" + queryFilter
+ querySelect + ", queryGroup:" + queryGroup + ", queryOrder:" + ", querySelect:" + querySelect + ", queryGroup:"
+ queryOrder); + queryGroup + ", queryOrder:" + queryOrder);
if (querySelect != null) { if (querySelect != null) {
logger.debug("Query Select Columns:" + querySelect.getColumns()); logger.debug("Query Select Columns:" + querySelect.getColumns());
@ -201,69 +219,77 @@ public class QueryService {
if (queryFilter == null) { if (queryFilter == null) {
if (queryGroup == null) { if (queryGroup == null) {
logger.debug("1-QueryAsJson-->tableId:" + tableId logger.debug("1-QueryAsJson-->tableId:" + tableId
+ ", queryPage:" + queryPage + ", querySelect:" + ", queryPage:" + queryPage
+ querySelect); + ", querySelect:" + querySelect);
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
querySelect); queryPage, querySelect);
} else { } else {
logger.debug("2-QueryAsJson-->tableId:" + tableId logger.debug("2-QueryAsJson-->tableId:" + tableId
+ ", queryPage:" + queryPage + ", querySelect:" + ", queryPage:" + queryPage
+ querySelect + ", queryGroup:" + queryGroup); + ", querySelect:" + querySelect
serviceJson = service.queryAsJson(tableId, queryPage, + ", queryGroup:" + queryGroup);
querySelect, queryGroup); serviceJson = service.queryAsJson(tableId,
queryPage, querySelect, queryGroup);
} }
} else { } else {
if (queryGroup == null) { if (queryGroup == null) {
logger.debug("3-QueryAsJson-->[tableId:" + tableId logger.debug("3-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryFilter:" + ", queryPage:" + queryPage
+ queryFilter + ", querySelect:" + querySelect + ", queryFilter:" + queryFilter
+ "]"); + ", querySelect:" + querySelect + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryFilter, querySelect); queryPage, queryFilter, querySelect);
} else { } else {
logger.debug("4-QueryAsJson-->[tableId:" + tableId logger.debug("4-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryFilter:" + ", queryPage:" + queryPage
+ queryFilter + ", querySelect:" + querySelect + ", queryFilter:" + queryFilter
+ ", querySelect:" + querySelect
+ ", queryGroup:" + queryGroup + "]"); + ", queryGroup:" + queryGroup + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryFilter, querySelect, queryGroup); queryPage, queryFilter, querySelect,
queryGroup);
} }
} }
} else { } else {
if (queryFilter == null) { if (queryFilter == null) {
if (queryGroup == null) { if (queryGroup == null) {
logger.debug("5-QueryAsJson-->[tableId:" + tableId logger.debug("5-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryOrder:" + ", queryPage:" + queryPage
+ queryOrder + ", querySelect:" + querySelect + ", queryOrder:" + queryOrder
+ "]"); + ", querySelect:" + querySelect + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryOrder, querySelect); queryPage, queryOrder, querySelect);
} else { } else {
logger.debug("6-QueryAsJson-->[tableId:" + tableId logger.debug("6-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryOrder:" + ", queryPage:" + queryPage
+ queryOrder + ", querySelect:" + querySelect + ", queryOrder:" + queryOrder
+ ", querySelect:" + querySelect
+ ", queryGroup:" + queryGroup + "]"); + ", queryGroup:" + queryGroup + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryOrder, querySelect, queryGroup); queryPage, queryOrder, querySelect,
queryGroup);
} }
} else { } else {
if (queryGroup == null) { if (queryGroup == null) {
logger.debug("7-QueryAsJson-->[tableId:" + tableId logger.debug("7-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryFilter:" + ", queryPage:" + queryPage
+ queryFilter + ", queryOrder:" + queryOrder + ", queryFilter:" + queryFilter
+ ", queryOrder:" + queryOrder
+ ", querySelect:" + querySelect + "]"); + ", querySelect:" + querySelect + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryFilter, queryOrder, querySelect); queryPage, queryFilter, queryOrder,
querySelect);
} else { } else {
logger.debug("8-QueryAsJson-->[tableId:" + tableId logger.debug("8-QueryAsJson-->[tableId:" + tableId
+ ", queryPage:" + queryPage + ", queryFilter:" + ", queryPage:" + queryPage
+ queryFilter + ", queryOrder:" + queryOrder + ", queryFilter:" + queryFilter
+ ", queryOrder:" + queryOrder
+ ", querySelect:" + querySelect + ", querySelect:" + querySelect
+ ", queryGroup:" + queryGroup + "]"); + ", queryGroup:" + queryGroup + "]");
serviceJson = service.queryAsJson(tableId, queryPage, serviceJson = service.queryAsJson(tableId,
queryFilter, queryOrder, querySelect, queryPage, queryFilter, queryOrder,
queryGroup); querySelect, queryGroup);
} }
} }
} }
@ -303,7 +329,6 @@ public class QueryService {
currentRow.getString(0), currentRow.getString(0),
currentRow.getInt(1)); currentRow.getInt(1));
} }
break;
} else { } else {
switch (conditionCode) { switch (conditionCode) {
case AllowedColumnType: case AllowedColumnType:
@ -378,6 +403,13 @@ public class QueryService {
logger.debug("Retieved occurences: size " + occurences.size()); logger.debug("Retieved occurences: size " + occurences.size());
return occurences; return occurences;
} catch (Throwable e) {
logger.error("QueryService - error on queryOccurences():"
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
}
} }
} }

View File

@ -12,7 +12,7 @@ package org.gcube.portlets.user.td.gwtservice.shared;
*/ */
public class Constants { public class Constants {
public final static String VERSION = "2.1.0"; public final static String VERSION = "2.3.0";
public final static String DEFAULT_USER = "test.user"; public final static String DEFAULT_USER = "test.user";
public final static String DEFAULT_SCOPE = "/gcube/devsec"; public final static String DEFAULT_SCOPE = "/gcube/devsec";
@ -70,6 +70,7 @@ public class Constants {
public static final String PARAMETER_ROW_ID = "rowId"; public static final String PARAMETER_ROW_ID = "rowId";
public static final String REQUEST_PROPERTIES_INVOCATIONS = "InvocationS";
public static final String REQUEST_PROPERTIES_REFCOLUMN = "RefColumn"; public static final String REQUEST_PROPERTIES_REFCOLUMN = "RefColumn";
public static final String REQUEST_PROPERTIES_COLUMNID = "ColumnId"; public static final String REQUEST_PROPERTIES_COLUMNID = "ColumnId";
public static final String REQUEST_PROPERTIES_TASKID = "TaskId"; public static final String REQUEST_PROPERTIES_TASKID = "TaskId";

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/** /**
@ -21,6 +22,9 @@ public class ReplaceBatchColumnSession implements Serializable {
protected ArrayList<ReplaceEntry> replaceEntryList; protected ArrayList<ReplaceEntry> replaceEntryList;
protected boolean replaceDimension; protected boolean replaceDimension;
protected ConditionCode conditionCode;
protected String validationColumnColumnId;
public ReplaceBatchColumnSession() { public ReplaceBatchColumnSession() {
} }
@ -32,6 +36,17 @@ public class ReplaceBatchColumnSession implements Serializable {
this.replaceDimension = replaceDimension; this.replaceDimension = replaceDimension;
} }
public ReplaceBatchColumnSession(TRId trId, ColumnData columnData,
ArrayList<ReplaceEntry> replaceEntryList, boolean replaceDimension,
ConditionCode conditionCode, String validationColumnColumnId) {
this.trId = trId;
this.columnData = columnData;
this.replaceEntryList = replaceEntryList;
this.replaceDimension = replaceDimension;
this.conditionCode = conditionCode;
this.validationColumnColumnId = validationColumnColumnId;
}
public TRId getTrId() { public TRId getTrId() {
return trId; return trId;
} }
@ -64,11 +79,31 @@ public class ReplaceBatchColumnSession implements Serializable {
this.replaceDimension = replaceDimension; this.replaceDimension = replaceDimension;
} }
public ConditionCode getConditionCode() {
return conditionCode;
}
public void setConditionCode(ConditionCode conditionCode) {
this.conditionCode = conditionCode;
}
public String getValidationColumnColumnId() {
return validationColumnColumnId;
}
public void setValidationColumnColumnId(String validationColumnColumnId) {
this.validationColumnColumnId = validationColumnColumnId;
}
@Override @Override
public String toString() { public String toString() {
return "ReplaceBatchColumnSession [trId=" + trId + ", columnData=" return "ReplaceBatchColumnSession [trId=" + trId + ", columnData="
+ columnData + ", replaceEntryList=" + replaceEntryList + columnData + ", replaceEntryList=" + replaceEntryList
+ ", replaceDimension=" + replaceDimension + "]"; + ", replaceDimension=" + replaceDimension + ", conditionCode="
+ conditionCode + ", validationColumnColumnId="
+ validationColumnColumnId + "]";
} }
} }