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.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);
|
||||
|
|
|
@ -984,13 +984,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
|
||||
logger.debug("getValidationColumns():[" + trId.toString()
|
||||
+ " columnName: " + columnName + "]");
|
||||
|
||||
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) {
|
||||
logger.error("Column not present on table");
|
||||
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -42,86 +42,23 @@ public class QueryService {
|
|||
TabularDataService service,
|
||||
OccurrencesForReplaceBatchColumnSession occurrencesSession,
|
||||
Direction direction) throws TDGWTServiceException {
|
||||
logger.debug("QueryOccurences");
|
||||
ColumnData column = occurrencesSession.getColumnData();
|
||||
|
||||
try {
|
||||
|
||||
logger.debug("QueryOccurences");
|
||||
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()));
|
||||
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
|
||||
QuerySelect querySelect = null;
|
||||
QueryGroup queryGroup = null;
|
||||
TableId tableId = new TableId(new Long(column.getTrId()
|
||||
.getTableId()));
|
||||
ColumnLocalId columnId = new ColumnLocalId(column.getColumnId());
|
||||
QuerySelect querySelect = null;
|
||||
QueryGroup queryGroup = null;
|
||||
|
||||
ConditionCode conditionCode = occurrencesSession.getConditionCode();
|
||||
if (conditionCode == null) {
|
||||
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());
|
||||
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());
|
||||
}
|
||||
} 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:
|
||||
ConditionCode conditionCode = occurrencesSession.getConditionCode();
|
||||
if (conditionCode == null) {
|
||||
logger.debug("Replace Batch no validations");
|
||||
if (column.isViewColumn()) {
|
||||
ColumnLocalId sourceColumnId = new ColumnLocalId(column
|
||||
.getColumnViewData()
|
||||
|
@ -146,207 +83,242 @@ public class QueryService {
|
|||
logger.debug("Occurences queryGroup:"
|
||||
+ 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 {
|
||||
return occurences;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
logger.debug("Replace Batch from validations");
|
||||
switch (conditionCode) {
|
||||
case AllowedColumnType:
|
||||
break;
|
||||
case AmbigousValueOnExternalReference:
|
||||
if (column.isViewColumn()) {
|
||||
occurence = new Occurrences(
|
||||
currentRow.getString(0),
|
||||
currentRow.getString(1),
|
||||
currentRow.getInt(2));
|
||||
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 {
|
||||
occurence = new Occurrences(
|
||||
currentRow.getString(0),
|
||||
currentRow.getInt(1));
|
||||
querySelect = new QuerySelect(
|
||||
Arrays.asList(new QueryColumn(columnId)));
|
||||
logger.debug("Occurences querySelect:"
|
||||
+ querySelect.toString());
|
||||
}
|
||||
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 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()) {
|
||||
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:
|
||||
break;
|
||||
case MustContainAtLeastOneMeasure:
|
||||
break;
|
||||
case MustHaveDataLocaleMetadataAndAtLeastOneLabel:
|
||||
break;
|
||||
case OnlyOneCodeColumn:
|
||||
break;
|
||||
case OnlyOneCodenameColumn:
|
||||
break;
|
||||
case ValidPeriodFormat:
|
||||
break;
|
||||
case MissingValueOnExternalReference:
|
||||
default:
|
||||
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) {
|
||||
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()) {
|
||||
occurence = new Occurrences(
|
||||
currentRow.getString(0),
|
||||
|
@ -357,26 +329,86 @@ public class QueryService {
|
|||
currentRow.getString(0),
|
||||
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) {
|
||||
|
||||
logger.error("An error occurred while parsing json document\n"
|
||||
+ "At Row " + i + ",Column " + j + "\nRow Content: "
|
||||
+ currentRow + "\nLenght rows " + totalRows, e);
|
||||
} catch (Throwable e) {
|
||||
logger.error("QueryService - error on queryOccurences():"
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(
|
||||
"An error occurred, while reading json of service", e);
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
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 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";
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue