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:
parent
6b5731733d
commit
4f5a725a59
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -42,86 +42,23 @@ public class QueryService {
|
||||||
TabularDataService service,
|
TabularDataService service,
|
||||||
OccurrencesForReplaceBatchColumnSession occurrencesSession,
|
OccurrencesForReplaceBatchColumnSession occurrencesSession,
|
||||||
Direction direction) throws TDGWTServiceException {
|
Direction direction) throws TDGWTServiceException {
|
||||||
logger.debug("QueryOccurences");
|
|
||||||
ColumnData column = occurrencesSession.getColumnData();
|
|
||||||
|
|
||||||
ArrayList<Occurrences> occurences = new ArrayList<Occurrences>();
|
try {
|
||||||
|
|
||||||
TableId tableId = new TableId(new Long(column.getTrId().getTableId()));
|
logger.debug("QueryOccurences");
|
||||||
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
|
ColumnData column = occurrencesSession.getColumnData();
|
||||||
QuerySelect querySelect = null;
|
|
||||||
QueryGroup queryGroup = null;
|
|
||||||
|
|
||||||
ConditionCode conditionCode = occurrencesSession.getConditionCode();
|
ArrayList<Occurrences> occurences = new ArrayList<Occurrences>();
|
||||||
if (conditionCode == null) {
|
|
||||||
logger.debug("Replace Batch no validations");
|
TableId tableId = new TableId(new Long(column.getTrId()
|
||||||
if (column.isViewColumn()) {
|
.getTableId()));
|
||||||
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
|
||||||
.getColumnViewData().getSourceTableDimensionColumnId());
|
QuerySelect querySelect = null;
|
||||||
querySelect = new QuerySelect(Arrays.asList(new QueryColumn(
|
QueryGroup queryGroup = null;
|
||||||
columnId), new QueryColumn(sourceColumnId),
|
|
||||||
new QueryColumn(columnId, Function.COUNT)));
|
ConditionCode conditionCode = occurrencesSession.getConditionCode();
|
||||||
logger.debug("Occurences querySelect:" + querySelect.toString());
|
if (conditionCode == null) {
|
||||||
queryGroup = new QueryGroup(Arrays.asList(columnId,
|
logger.debug("Replace Batch no validations");
|
||||||
sourceColumnId));
|
|
||||||
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());
|
|
||||||
queryGroup = new QueryGroup(Arrays.asList(columnId));
|
|
||||||
logger.debug("Occurences queryGroup:" + queryGroup.toString());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.debug("Replace Batch from validations");
|
|
||||||
switch (conditionCode) {
|
|
||||||
case AllowedColumnType:
|
|
||||||
break;
|
|
||||||
case AmbigousValueOnExternalReference:
|
|
||||||
if (column.isViewColumn()) {
|
|
||||||
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
|
||||||
.getColumnViewData()
|
|
||||||
.getSourceTableDimensionColumnId());
|
|
||||||
querySelect = new QuerySelect(Arrays.asList(
|
|
||||||
new QueryColumn(columnId), new QueryColumn(
|
|
||||||
sourceColumnId)));
|
|
||||||
logger.debug("Occurences querySelect:"
|
|
||||||
+ querySelect.toString());
|
|
||||||
} else {
|
|
||||||
querySelect = new QuerySelect(
|
|
||||||
Arrays.asList(new QueryColumn(columnId)));
|
|
||||||
logger.debug("Occurences querySelect:"
|
|
||||||
+ querySelect.toString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CastValidation:
|
|
||||||
break;
|
|
||||||
case CodeNamePresence:
|
|
||||||
break;
|
|
||||||
case DuplicateTupleValidation:
|
|
||||||
break;
|
|
||||||
case DuplicateValueInColumn:
|
|
||||||
break;
|
|
||||||
case GenericTupleValidity:
|
|
||||||
break;
|
|
||||||
case GenericValidity:
|
|
||||||
break;
|
|
||||||
case MaxOneCodenameForDataLocale:
|
|
||||||
break;
|
|
||||||
case MustContainAtLeastOneDimension:
|
|
||||||
break;
|
|
||||||
case MustContainAtLeastOneMeasure:
|
|
||||||
break;
|
|
||||||
case MustHaveDataLocaleMetadataAndAtLeastOneLabel:
|
|
||||||
break;
|
|
||||||
case OnlyOneCodeColumn:
|
|
||||||
break;
|
|
||||||
case OnlyOneCodenameColumn:
|
|
||||||
break;
|
|
||||||
case ValidPeriodFormat:
|
|
||||||
break;
|
|
||||||
case MissingValueOnExternalReference:
|
|
||||||
default:
|
|
||||||
if (column.isViewColumn()) {
|
if (column.isViewColumn()) {
|
||||||
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
||||||
.getColumnViewData()
|
.getColumnViewData()
|
||||||
|
@ -146,207 +83,242 @@ public class QueryService {
|
||||||
logger.debug("Occurences queryGroup:"
|
logger.debug("Occurences queryGroup:"
|
||||||
+ queryGroup.toString());
|
+ queryGroup.toString());
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryOrder queryOrder = null;
|
|
||||||
switch (direction) {
|
|
||||||
case ASC:
|
|
||||||
queryOrder = new QueryOrder(columnId, QueryOrderDirection.ASCENDING);
|
|
||||||
break;
|
|
||||||
case DESC:
|
|
||||||
queryOrder = new QueryOrder(columnId,
|
|
||||||
QueryOrderDirection.DESCENDING);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryPage queryPage = null;// All occurences
|
|
||||||
logger.debug("Occurences queryPage all");
|
|
||||||
|
|
||||||
QueryFilter queryFilter = null;
|
|
||||||
if (occurrencesSession.getShowType().compareTo(
|
|
||||||
ShowOccurrencesType.ONLYERRORS) == 0) {
|
|
||||||
if (occurrencesSession.isHasValidationColumns()) {
|
|
||||||
Expression exp = ExpressionGenerator
|
|
||||||
.genReplaceBatchOccurrencesFilter(occurrencesSession);
|
|
||||||
logger.debug("Expression: " + exp);
|
|
||||||
if (exp != null) {
|
|
||||||
queryFilter = new QueryFilter(exp);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return occurences;
|
logger.debug("Replace Batch from validations");
|
||||||
}
|
switch (conditionCode) {
|
||||||
}
|
case AllowedColumnType:
|
||||||
|
break;
|
||||||
logger.debug("Query on " + tableId.toString() + " queryPage:"
|
case AmbigousValueOnExternalReference:
|
||||||
+ queryPage + ", queryFilter:" + queryFilter + ", querySelect:"
|
|
||||||
+ querySelect + ", queryGroup:" + queryGroup + ", queryOrder:"
|
|
||||||
+ queryOrder);
|
|
||||||
|
|
||||||
if (querySelect != null) {
|
|
||||||
logger.debug("Query Select Columns:" + querySelect.getColumns());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queryGroup != null) {
|
|
||||||
logger.debug("Query Group Columns: " + queryGroup.getColumns());
|
|
||||||
}
|
|
||||||
|
|
||||||
String serviceJson = null;
|
|
||||||
try {
|
|
||||||
if (queryOrder == null) {
|
|
||||||
if (queryFilter == null) {
|
|
||||||
if (queryGroup == null) {
|
|
||||||
logger.debug("1-QueryAsJson-->tableId:" + tableId
|
|
||||||
+ ", 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);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (queryGroup == null) {
|
|
||||||
logger.debug("3-QueryAsJson-->[tableId:" + tableId
|
|
||||||
+ ", 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
|
|
||||||
+ ", queryGroup:" + 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);
|
|
||||||
} else {
|
|
||||||
logger.debug("6-QueryAsJson-->[tableId:" + tableId
|
|
||||||
+ ", queryPage:" + queryPage + ", queryOrder:"
|
|
||||||
+ queryOrder + ", querySelect:" + querySelect
|
|
||||||
+ ", queryGroup:" + 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
|
|
||||||
+ ", querySelect:" + querySelect + "]");
|
|
||||||
serviceJson = service.queryAsJson(tableId, queryPage,
|
|
||||||
queryFilter, queryOrder, querySelect);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
logger.debug("8-QueryAsJson-->[tableId:" + tableId
|
|
||||||
+ ", queryPage:" + queryPage + ", queryFilter:"
|
|
||||||
+ queryFilter + ", queryOrder:" + queryOrder
|
|
||||||
+ ", querySelect:" + querySelect
|
|
||||||
+ ", queryGroup:" + queryGroup + "]");
|
|
||||||
serviceJson = service.queryAsJson(tableId, queryPage,
|
|
||||||
queryFilter, queryOrder, querySelect,
|
|
||||||
queryGroup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
logger.debug("Error by running the query on the server:"
|
|
||||||
+ e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new TDGWTServiceException(
|
|
||||||
"An error occurred while running query on service", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
totalRows = rows.length();
|
|
||||||
logger.debug("Reading rows from json");
|
|
||||||
Occurrences occurence = null;
|
|
||||||
for (i = 0; i < totalRows; i++) {
|
|
||||||
currentRow = rows.getJSONArray(i);
|
|
||||||
if (conditionCode == null) {
|
|
||||||
if (column.isViewColumn()) {
|
if (column.isViewColumn()) {
|
||||||
occurence = new Occurrences(
|
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
||||||
currentRow.getString(0),
|
.getColumnViewData()
|
||||||
currentRow.getString(1),
|
.getSourceTableDimensionColumnId());
|
||||||
currentRow.getInt(2));
|
querySelect = new QuerySelect(Arrays.asList(
|
||||||
|
new QueryColumn(columnId), new QueryColumn(
|
||||||
|
sourceColumnId)));
|
||||||
|
logger.debug("Occurences querySelect:"
|
||||||
|
+ querySelect.toString());
|
||||||
} else {
|
} else {
|
||||||
occurence = new Occurrences(
|
querySelect = new QuerySelect(
|
||||||
currentRow.getString(0),
|
Arrays.asList(new QueryColumn(columnId)));
|
||||||
currentRow.getInt(1));
|
logger.debug("Occurences querySelect:"
|
||||||
|
+ querySelect.toString());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
case CastValidation:
|
||||||
switch (conditionCode) {
|
break;
|
||||||
case AllowedColumnType:
|
case CodeNamePresence:
|
||||||
break;
|
break;
|
||||||
case AmbigousValueOnExternalReference:
|
case DuplicateTupleValidation:
|
||||||
if (column.isViewColumn()) {
|
break;
|
||||||
occurence = new Occurrences(
|
case DuplicateValueInColumn:
|
||||||
currentRow.getString(0),
|
break;
|
||||||
currentRow.getString(1), 1);
|
case GenericTupleValidity:
|
||||||
} else {
|
break;
|
||||||
occurence = new Occurrences(
|
case GenericValidity:
|
||||||
currentRow.getString(0), 1);
|
break;
|
||||||
}
|
case MaxOneCodenameForDataLocale:
|
||||||
break;
|
break;
|
||||||
case CastValidation:
|
case MustContainAtLeastOneDimension:
|
||||||
break;
|
break;
|
||||||
case CodeNamePresence:
|
case MustContainAtLeastOneMeasure:
|
||||||
break;
|
break;
|
||||||
case DuplicateTupleValidation:
|
case MustHaveDataLocaleMetadataAndAtLeastOneLabel:
|
||||||
break;
|
break;
|
||||||
case DuplicateValueInColumn:
|
case OnlyOneCodeColumn:
|
||||||
break;
|
break;
|
||||||
case GenericTupleValidity:
|
case OnlyOneCodenameColumn:
|
||||||
break;
|
break;
|
||||||
case GenericValidity:
|
case ValidPeriodFormat:
|
||||||
break;
|
break;
|
||||||
case MaxOneCodenameForDataLocale:
|
case MissingValueOnExternalReference:
|
||||||
break;
|
default:
|
||||||
|
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());
|
||||||
|
queryGroup = new QueryGroup(Arrays.asList(columnId,
|
||||||
|
sourceColumnId));
|
||||||
|
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());
|
||||||
|
queryGroup = new QueryGroup(Arrays.asList(columnId));
|
||||||
|
logger.debug("Occurences queryGroup:"
|
||||||
|
+ queryGroup.toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case MustContainAtLeastOneDimension:
|
QueryOrder queryOrder = null;
|
||||||
break;
|
switch (direction) {
|
||||||
case MustContainAtLeastOneMeasure:
|
case ASC:
|
||||||
break;
|
queryOrder = new QueryOrder(columnId,
|
||||||
case MustHaveDataLocaleMetadataAndAtLeastOneLabel:
|
QueryOrderDirection.ASCENDING);
|
||||||
break;
|
break;
|
||||||
case OnlyOneCodeColumn:
|
case DESC:
|
||||||
break;
|
queryOrder = new QueryOrder(columnId,
|
||||||
case OnlyOneCodenameColumn:
|
QueryOrderDirection.DESCENDING);
|
||||||
break;
|
break;
|
||||||
case ValidPeriodFormat:
|
default:
|
||||||
break;
|
break;
|
||||||
case MissingValueOnExternalReference:
|
|
||||||
default:
|
}
|
||||||
|
|
||||||
|
QueryPage queryPage = null;// All occurences
|
||||||
|
logger.debug("Occurences queryPage all");
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (querySelect != null) {
|
||||||
|
logger.debug("Query Select Columns:" + querySelect.getColumns());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queryGroup != null) {
|
||||||
|
logger.debug("Query Group Columns: " + queryGroup.getColumns());
|
||||||
|
}
|
||||||
|
|
||||||
|
String serviceJson = null;
|
||||||
|
try {
|
||||||
|
if (queryOrder == null) {
|
||||||
|
if (queryFilter == null) {
|
||||||
|
if (queryGroup == null) {
|
||||||
|
logger.debug("1-QueryAsJson-->tableId:" + tableId
|
||||||
|
+ ", 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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (queryGroup == null) {
|
||||||
|
logger.debug("3-QueryAsJson-->[tableId:" + tableId
|
||||||
|
+ ", 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
|
||||||
|
+ ", queryGroup:" + 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);
|
||||||
|
} else {
|
||||||
|
logger.debug("6-QueryAsJson-->[tableId:" + tableId
|
||||||
|
+ ", queryPage:" + queryPage
|
||||||
|
+ ", queryOrder:" + queryOrder
|
||||||
|
+ ", querySelect:" + querySelect
|
||||||
|
+ ", queryGroup:" + 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
|
||||||
|
+ ", querySelect:" + querySelect + "]");
|
||||||
|
serviceJson = service.queryAsJson(tableId,
|
||||||
|
queryPage, queryFilter, queryOrder,
|
||||||
|
querySelect);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.debug("8-QueryAsJson-->[tableId:" + tableId
|
||||||
|
+ ", queryPage:" + queryPage
|
||||||
|
+ ", queryFilter:" + queryFilter
|
||||||
|
+ ", queryOrder:" + queryOrder
|
||||||
|
+ ", querySelect:" + querySelect
|
||||||
|
+ ", queryGroup:" + queryGroup + "]");
|
||||||
|
serviceJson = service.queryAsJson(tableId,
|
||||||
|
queryPage, queryFilter, queryOrder,
|
||||||
|
querySelect, queryGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.debug("Error by running the query on the server:"
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"An error occurred while running query on service", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
totalRows = rows.length();
|
||||||
|
logger.debug("Reading rows from json");
|
||||||
|
Occurrences occurence = null;
|
||||||
|
for (i = 0; i < totalRows; i++) {
|
||||||
|
currentRow = rows.getJSONArray(i);
|
||||||
|
if (conditionCode == null) {
|
||||||
if (column.isViewColumn()) {
|
if (column.isViewColumn()) {
|
||||||
occurence = new Occurrences(
|
occurence = new Occurrences(
|
||||||
currentRow.getString(0),
|
currentRow.getString(0),
|
||||||
|
@ -357,26 +329,86 @@ public class QueryService {
|
||||||
currentRow.getString(0),
|
currentRow.getString(0),
|
||||||
currentRow.getInt(1));
|
currentRow.getInt(1));
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
switch (conditionCode) {
|
||||||
|
case AllowedColumnType:
|
||||||
|
break;
|
||||||
|
case AmbigousValueOnExternalReference:
|
||||||
|
if (column.isViewColumn()) {
|
||||||
|
occurence = new Occurrences(
|
||||||
|
currentRow.getString(0),
|
||||||
|
currentRow.getString(1), 1);
|
||||||
|
} else {
|
||||||
|
occurence = new Occurrences(
|
||||||
|
currentRow.getString(0), 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CastValidation:
|
||||||
|
break;
|
||||||
|
case CodeNamePresence:
|
||||||
|
break;
|
||||||
|
case DuplicateTupleValidation:
|
||||||
|
break;
|
||||||
|
case DuplicateValueInColumn:
|
||||||
|
break;
|
||||||
|
case GenericTupleValidity:
|
||||||
|
break;
|
||||||
|
case GenericValidity:
|
||||||
|
break;
|
||||||
|
case MaxOneCodenameForDataLocale:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MustContainAtLeastOneDimension:
|
||||||
|
break;
|
||||||
|
case MustContainAtLeastOneMeasure:
|
||||||
|
break;
|
||||||
|
case MustHaveDataLocaleMetadataAndAtLeastOneLabel:
|
||||||
|
break;
|
||||||
|
case OnlyOneCodeColumn:
|
||||||
|
break;
|
||||||
|
case OnlyOneCodenameColumn:
|
||||||
|
break;
|
||||||
|
case ValidPeriodFormat:
|
||||||
|
break;
|
||||||
|
case MissingValueOnExternalReference:
|
||||||
|
default:
|
||||||
|
if (column.isViewColumn()) {
|
||||||
|
occurence = new Occurrences(
|
||||||
|
currentRow.getString(0),
|
||||||
|
currentRow.getString(1),
|
||||||
|
currentRow.getInt(2));
|
||||||
|
} else {
|
||||||
|
occurence = new Occurrences(
|
||||||
|
currentRow.getString(0),
|
||||||
|
currentRow.getInt(1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// logger.debug(occurence.toString());
|
||||||
|
occurences.add(occurence);
|
||||||
|
|
||||||
}
|
}
|
||||||
// logger.debug(occurence.toString());
|
|
||||||
occurences.add(occurence);
|
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
|
||||||
|
logger.error("An error occurred while parsing json document\n"
|
||||||
|
+ "At Row " + i + ",Column " + j + "\nRow Content: "
|
||||||
|
+ currentRow + "\nLenght rows " + totalRows, e);
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"An error occurred, while reading json of service", e);
|
||||||
}
|
}
|
||||||
|
logger.debug("Retieved occurences: size " + occurences.size());
|
||||||
|
return occurences;
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (Throwable e) {
|
||||||
|
logger.error("QueryService - error on queryOccurences():"
|
||||||
logger.error("An error occurred while parsing json document\n"
|
+ e.getLocalizedMessage());
|
||||||
+ "At Row " + i + ",Column " + j + "\nRow Content: "
|
|
||||||
+ currentRow + "\nLenght rows " + totalRows, e);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TDGWTServiceException(
|
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||||
"An error occurred, while reading json of service", e);
|
|
||||||
}
|
}
|
||||||
logger.debug("Retieved occurences: size " + occurences.size());
|
|
||||||
return occurences;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -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 + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue