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.CodelistMappingFileUploadSession;
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.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
@ -93,8 +92,8 @@ public class SessionUtil {
ASLSession session;
if (username == null) {
logger.warn("no user found in session, using test one");
/*throw new TDGWTSessionExpiredException("Session Expired!");*/
throw new TDGWTSessionExpiredException("Session Expired!");
/*
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
@ -102,7 +101,7 @@ public class SessionUtil {
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
session.setScope(scope);
*/
} else {
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);

View File

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

View File

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

View File

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

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.ArrayList;
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;
/**
@ -21,6 +22,9 @@ public class ReplaceBatchColumnSession implements Serializable {
protected ArrayList<ReplaceEntry> replaceEntryList;
protected boolean replaceDimension;
protected ConditionCode conditionCode;
protected String validationColumnColumnId;
public ReplaceBatchColumnSession() {
}
@ -32,6 +36,17 @@ public class ReplaceBatchColumnSession implements Serializable {
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() {
return trId;
}
@ -64,11 +79,31 @@ public class ReplaceBatchColumnSession implements Serializable {
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
public String toString() {
return "ReplaceBatchColumnSession [trId=" + trId + ", columnData="
+ columnData + ", replaceEntryList=" + replaceEntryList
+ ", replaceDimension=" + replaceDimension + "]";
+ ", replaceDimension=" + replaceDimension + ", conditionCode="
+ conditionCode + ", validationColumnColumnId="
+ validationColumnColumnId + "]";
}
}