Updated Ambiguous

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98558 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-10 16:14:32 +00:00
parent 4f5a725a59
commit d5b5e7088c
7 changed files with 166 additions and 90 deletions

View File

@ -17,6 +17,7 @@ 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,6 +94,8 @@ public class SessionUtil {
if (username == null) {
logger.warn("no user found in session, using test one");
throw new TDGWTSessionExpiredException("Session Expired!");
//Remove comment for Test
/*
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;

View File

@ -984,14 +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());
logger.debug("getValidationColumns() on Table: " + table.toString());
Column columnSource = table.getColumnByName(columnName);
if (columnSource == null) {
logger.error("Column not present on table");
@ -1008,7 +1008,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 0;
for (Column c : cols) {
if (c.getColumnType() instanceof ValidationColumnType) {
logger.debug("ValidationColumn present: [" +c.getColumnType()+" "+c.getLocalId()+"]");
logger.debug("ValidationColumn present: ["
+ c.getColumnType() + " " + c.getLocalId() + "]");
if (c.contains(ValidationReferencesMetadata.class)) {
logger.debug("ValidationReferencesMetadata present");
ValidationReferencesMetadata validationReferenceMetadata = c
@ -3158,7 +3159,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResource tr = service
.getTabularResource(new TabularResourceId(Long.valueOf(trId
.getId())));
@ -4999,7 +5000,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResource cloned = service.cloneTabularResource(serviceTR);
logger.debug("Clone: " + cloned.toString());
Table table = service.getLastTable(cloned.getId());
if (table == null) {
String report = "This tabular resource has not valid last table! (TR id="
+ cloned.getId() + ")";
logger.error(report);
throw new TDGWTServiceException(report);
}
logger.debug("Last Table: " + table.toString());
Table viewTable = null;
if (table.contains(DatasetViewTableMetadata.class)) {
@ -5011,6 +5020,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} catch (Exception e) {
logger.error("view table not found");
}
} else {
logger.debug("No DatasetViewTableMeatadata found");
}
TRId trId;
@ -6568,11 +6579,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
val.isValid(),
ConditionCodeMap.mapConditionCode(val
.getConditionCode()),
val.getValidationColumn());
val.getValidationColumn());
validations.add(validation);
i++;
}
InvocationS invocationS = null;
if (job.getInvocation() != null) {
@ -6656,7 +6666,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error in invocation: Operation not supported");
}
Long id = Long.valueOf(editRowSession.getTrId().getId());
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
@ -6823,7 +6833,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
throws TDGWTServiceException {
@ -6972,7 +6981,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startTaskResume(TaskResumeSession taskResumeSession)
throws TDGWTServiceException {
@ -7120,7 +7128,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startExtractCodelist(
ExtractCodelistSession extractCodelistSession)
@ -7277,7 +7284,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
//TODO
// TODO
public void startSplitColumn(SplitColumnSession splitColumnSession,
HttpSession session) throws TDGWTServiceException {
try {
@ -7703,15 +7710,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
if (session == null) {
throw new TDGWTServiceException(
"Session is null");
throw new TDGWTServiceException("Session is null");
}
logger.debug("Session:" + session.getId());
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
throw new TDGWTServiceException(
"ASLSession is null");
throw new TDGWTServiceException("ASLSession is null");
}
String user = aslSession.getUsername();
logger.debug("Session User:" + user);
@ -7720,12 +7725,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"CodelistMappingSession is null");
}
logger.debug("StartCodelistMappingImport: "
+ codelistMappingSession.toString());
SessionUtil.setCodelistMappingSession(session,codelistMappingSession);
SessionUtil.setCodelistMappingSession(session,
codelistMappingSession);
importCodelistMappingFileOnService(session, aslSession, user,
codelistMappingSession);
} catch (TDGWTSessionExpiredException e) {
@ -8054,13 +8060,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startNormalization(NormalizationSession normalizationSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setNormalizationSession(session, normalizationSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (normalizationSession == null) {
@ -8074,8 +8078,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
OpExecution4Normalization opEx = new OpExecution4Normalization(service,
normalizationSession);
OpExecution4Normalization opEx = new OpExecution4Normalization(
service, normalizationSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -8090,7 +8094,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Normalization start on service: TaskId " + trTask.getId());
logger.debug("Normalization start on service: TaskId "
+ trTask.getId());
SessionUtil.setNormalizationTask(session, trTask);
return;
@ -8105,10 +8110,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Error in start normalization: "
+ e.getLocalizedMessage());
}
}
@Override
public NormalizationMonitor getNormalizationMonitor()
throws TDGWTServiceException {
@ -8133,8 +8137,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
normalizationMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
normalizationMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
TRId trId;
TabResource tabResource;
@ -8202,20 +8206,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in NormalizationMonitor: " + e.getLocalizedMessage());
logger.debug("Error in NormalizationMonitor: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
@Override
public void startDenormalization(DenormalizationSession denormalizationSession)
public void startDenormalization(
DenormalizationSession denormalizationSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setDenormalizationSession(session, denormalizationSession);
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setDenormalizationSession(session,
denormalizationSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (denormalizationSession == null) {
logger.error("DenormalizationSession is null");
@ -8228,8 +8234,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
OpExecution4Denormalization opEx = new OpExecution4Denormalization(service,
denormalizationSession);
OpExecution4Denormalization opEx = new OpExecution4Denormalization(
service, denormalizationSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -8244,7 +8250,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Denormalization start on service: TaskId " + trTask.getId());
logger.debug("Denormalization start on service: TaskId "
+ trTask.getId());
SessionUtil.setDenormalizationTask(session, trTask);
return;
@ -8259,10 +8266,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Error in start denormalization: "
+ e.getLocalizedMessage());
}
}
@Override
public DenormalizationMonitor getDenormalizationMonitor()
throws TDGWTServiceException {
@ -8287,8 +8293,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
denormalizationMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
denormalizationMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
TRId trId;
TabResource tabResource;
@ -8356,15 +8362,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in DenormalizationMonitor: " + e.getLocalizedMessage());
logger.debug("Error in DenormalizationMonitor: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
}

View File

@ -2,9 +2,13 @@ package org.gcube.portlets.user.td.gwtservice.server.trservice;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.query.parameters.QueryFilter;
import org.gcube.data.analysis.tabulardata.query.parameters.QueryOrder;
@ -15,6 +19,7 @@ import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn;
import org.gcube.data.analysis.tabulardata.query.parameters.select.QueryColumn.Function;
import org.gcube.data.analysis.tabulardata.query.parameters.select.QuerySelect;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTableException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode;
@ -22,6 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ShowOccurrencesType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
@ -42,9 +48,9 @@ public class QueryService {
TabularDataService service,
OccurrencesForReplaceBatchColumnSession occurrencesSession,
Direction direction) throws TDGWTServiceException {
try {
logger.debug("QueryOccurences");
ColumnData column = occurrencesSession.getColumnData();
@ -88,19 +94,22 @@ public class QueryService {
switch (conditionCode) {
case AllowedColumnType:
break;
case AmbigousValueOnExternalReference:
case AmbiguousValueOnExternalReference:
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 {
ColumnLocalId idColumn=retrieveColumnLocalIdOFIdColumnType(column.getTrId(),
service);
querySelect = new QuerySelect(
Arrays.asList(new QueryColumn(columnId)));
Arrays.asList(new QueryColumn(columnId),new QueryColumn(idColumn)));
logger.debug("Occurences querySelect:"
+ querySelect.toString());
}
@ -333,14 +342,14 @@ public class QueryService {
switch (conditionCode) {
case AllowedColumnType:
break;
case AmbigousValueOnExternalReference:
case AmbiguousValueOnExternalReference:
if (column.isViewColumn()) {
occurence = new Occurrences(
currentRow.getString(0),
currentRow.getString(1), 1);
} else {
occurence = new Occurrences(
currentRow.getString(0), 1);
currentRow.getString(0),currentRow.getString(1), 1);
}
break;
case CastValidation:
@ -386,7 +395,7 @@ public class QueryService {
}
}
// logger.debug(occurence.toString());
logger.debug("Occurence: " + occurence.toString());
occurences.add(occurence);
}
@ -411,5 +420,51 @@ public class QueryService {
}
}
/**
* Retrieve ColumnLocalId value of IdColumnType
*
* @param trId
* @param service
* @return
* @throws TDGWTServiceException
*/
public static ColumnLocalId retrieveColumnLocalIdOFIdColumnType(TRId trId,
TabularDataService service) throws TDGWTServiceException {
try {
ColumnLocalId columnLocalId = null;
Table table;
table = service.getTable(new TableId(
Long.valueOf(trId.getTableId())));
List<Column> cols = table.getColumns();
for (Column c : cols) {
if (c.getColumnType() instanceof IdColumnType) {
columnLocalId=c.getLocalId();
break;
}
}
return columnLocalId;
} catch (NumberFormatException e) {
logger.error("QueryService - retrieveColumnLocalIdOFIdColumn: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
} catch (NoSuchTableException e) {
logger.error("QueryService - retrieveColumnLocalIdOFIdColumn: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
} catch (Throwable e){
logger.error("QueryService - retrieveColumnLocalIdOFIdColumn: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
}
}
}

View File

@ -19,7 +19,7 @@ public enum ConditionCode {
GenericTupleValidity(100),
DuplicateTupleValidation(101),
DuplicateValueInColumn(102),
AmbigousValueOnExternalReference(103),
AmbiguousValueOnExternalReference(103),
MissingValueOnExternalReference(104),
CodeNamePresence(105),
CastValidation(106),

View File

@ -14,7 +14,13 @@ public class Occurrences implements Serializable {
protected String value;
protected int number;
protected String rowId;//For view column, contains the value of the associated dimension column
//For view column,
//contains the value of the associated dimension column
//for example: [value=atricaudus, number=1, rowId=10]
protected String rowId;
public Occurrences(){

View File

@ -4,7 +4,6 @@ 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,32 +20,24 @@ public class ReplaceBatchColumnSession implements Serializable {
protected ColumnData columnData;
protected ArrayList<ReplaceEntry> replaceEntryList;
protected boolean replaceDimension;
protected ColumnData connection;
protected ConditionCode conditionCode;
protected String validationColumnColumnId;
public ReplaceBatchColumnSession() {
}
public ReplaceBatchColumnSession(TRId trId, ColumnData columnData,
ArrayList<ReplaceEntry> replaceEntryList, boolean replaceDimension) {
this.trId = trId;
this.columnData = columnData;
this.replaceEntryList = replaceEntryList;
this.replaceDimension = replaceDimension;
}
public ReplaceBatchColumnSession(TRId trId, ColumnData columnData,
ArrayList<ReplaceEntry> replaceEntryList, boolean replaceDimension,
ConditionCode conditionCode, String validationColumnColumnId) {
ColumnData connection) {
this.trId = trId;
this.columnData = columnData;
this.replaceEntryList = replaceEntryList;
this.replaceDimension = replaceDimension;
this.conditionCode = conditionCode;
this.validationColumnColumnId = validationColumnColumnId;
this.connection=connection;
}
public TRId getTrId() {
return trId;
}
@ -78,32 +69,26 @@ public class ReplaceBatchColumnSession implements Serializable {
public void setReplaceDimension(boolean replaceDimension) {
this.replaceDimension = replaceDimension;
}
public ConditionCode getConditionCode() {
return conditionCode;
public ColumnData getConnection() {
return connection;
}
public void setConditionCode(ConditionCode conditionCode) {
this.conditionCode = conditionCode;
}
public String getValidationColumnColumnId() {
return validationColumnColumnId;
}
public void setValidationColumnColumnId(String validationColumnColumnId) {
this.validationColumnColumnId = validationColumnColumnId;
public void setConnection(ColumnData connection) {
this.connection = connection;
}
@Override
public String toString() {
return "ReplaceBatchColumnSession [trId=" + trId + ", columnData="
+ columnData + ", replaceEntryList=" + replaceEntryList
+ ", replaceDimension=" + replaceDimension + ", conditionCode="
+ conditionCode + ", validationColumnColumnId="
+ validationColumnColumnId + "]";
+ ", replaceDimension=" + replaceDimension + ", connection="
+ connection + "]";
}
}

View File

@ -24,6 +24,30 @@ public class ChangeColumnTypeSession implements Serializable {
protected ColumnMappingList columnMappingList;
public ChangeColumnTypeSession(){
}
/*
* For change to Dimension with mapping
*/
public ChangeColumnTypeSession(ColumnData columnData,
ColumnTypeCode columnTypeCode,
ColumnDataType columnDataType,
ColumnTypeCode columnTypeCodeTarget,
ColumnDataType columnDataTypeTarget,
ColumnData codelistColumnReference,
ColumnMappingList columnMappingList){
this.columnData=columnData;
this.columnTypeCode=columnTypeCode;
this.columnDataType=columnDataType;
this.columnTypeCodeTarget=columnTypeCodeTarget;
this.columnDataTypeTarget=columnDataTypeTarget;
this.codelistColumnReference=codelistColumnReference;
this.columnMappingList=columnMappingList;
}
public ColumnTypeCode getColumnTypeCode() {
return columnTypeCode;