Updated Replace Bach with ConditionCode on Validation

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98308 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-02 15:31:01 +00:00
parent 544fe2371b
commit affb2cfd29
18 changed files with 707 additions and 83 deletions

View File

@ -59,6 +59,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnT
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.groupby.GroupByMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
@ -776,28 +778,27 @@ public interface TDGWTService extends RemoteService {
*/
public void startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Split Column operation
*
*
* @return
* @throws TDGWTServiceException
*/
*/
public SplitColumnMonitor getSplitColumnMonitor()
throws TDGWTServiceException;
/**
* Start split column
*
* @param splitColumnSession
* @throws TDGWTServiceException
public void startSplitColumn(SplitColumnSession splitColumnSession)
throws TDGWTServiceException;
*/
*
* public void startSplitColumn(SplitColumnSession
* splitColumnSession) throws TDGWTServiceException;
*/
/**
* Get Operation Monitor during the Merge Column operation
*
@ -813,32 +814,30 @@ public interface TDGWTService extends RemoteService {
*
* @param splitColumnSession
* @throws TDGWTServiceException
public void startMergeColumn(MergeColumnSession mergeColumnSession)
throws TDGWTServiceException;
*/
*
* public void startMergeColumn(MergeColumnSession
* mergeColumnSession) throws TDGWTServiceException;
*/
/**
* Get Operation Monitor during the Group By operation
*
*
* @return
* @throws TDGWTServiceException
*/
public GroupByMonitor getGroupByMonitor()
throws TDGWTServiceException;
*/
public GroupByMonitor getGroupByMonitor() throws TDGWTServiceException;
/**
* Start group by
*
* @param groupBySession
* @throws TDGWTServiceException
public void startGroupBy(GroupBySession groupBySession)
throws TDGWTServiceException;
*/
*
* public void startGroupBy(GroupBySession groupBySession)
* throws TDGWTServiceException;
*/
// BatchReplace Operations
/**
* Retrieves the values in a column grouped by number of occurrences
@ -1007,4 +1006,23 @@ public interface TDGWTService extends RemoteService {
CodelistMappingSession codelistMappingSession)
throws TDGWTServiceException;
// Normalization
/**
* Get Operation Monitor during the Normalization operation
*
* @return
* @throws TDGWTServiceException
*/
public NormalizationMonitor getNormalizationMonitor()
throws TDGWTServiceException;
/**
* Start Normalization and invokes the client library
*
* @param normalizationSession
* @throws TDGWTServiceException
*/
public void startNormalization(NormalizationSession normalizationSession)
throws TDGWTServiceException;
}

View File

@ -58,6 +58,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnT
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.groupby.GroupByMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
@ -261,6 +263,10 @@ public interface TDGWTServiceAsync {
void setCodelistMappingSession(CodelistMappingSession codelistMappingSession, AsyncCallback<Void> callback);
void getFileFromWorkspace(CodelistMappingSession codelistMappingSession, AsyncCallback<Void> callback);
void startCodelistMappingImport(CodelistMappingSession codelistMappingSession, AsyncCallback<Void> callback);
//Normalization
void getNormalizationMonitor(AsyncCallback<NormalizationMonitor> callback);
void startNormalization(NormalizationSession normalizationSession, AsyncCallback<Void> callback);
}

View File

@ -62,6 +62,13 @@ public class SessionConstants {
protected static final String GROUPBY_MONITOR = "GROUPBY_MONITOR";
protected static final String GROUPBY_TASK = "GROUPBY_TASK";
protected static final String NORMALIZATION_SESSION = "NORMALIZATION_SESSION";
protected static final String NORMALIZATION_MONITOR = "NORMALIZATION_MONITOR";
protected static final String NORMALIZATION_TASK = "NORMALIZATION_TASK";
protected static final String DENORMALIZATION_SESSION = "DENORMALIZATION_SESSION";
protected static final String DENORMALIZATION_MONITOR = "DENORMALIZATION_MONITOR";
protected static final String DENORMALIZATION_TASK = "DENORMALIZATION_TASK";
protected static final String REPLACE_BATCH_COLUMN_SESSION = "REPLACE_BATCH_COLUMN_SESSION";
protected static final String REPLACE_BATCH_COLUMN_MONITOR = "REPLACE_BATCH_COLUMN_MONITOR";

View File

@ -56,6 +56,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnT
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.groupby.GroupByMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.groupby.GroupBySession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
@ -329,10 +331,7 @@ public class SessionUtil {
return fileUploadSession;
}
//TODO
public static void setCodelistMappingFileUploadSession(HttpSession httpSession,
CodelistMappingFileUploadSession s) throws TDGWTSessionExpiredException {
@ -1931,6 +1930,71 @@ public class SessionUtil {
httpSession.setAttribute(SessionConstants.CODELIST_MAPPING_TASK, task);
}
//
public static NormalizationSession getNormalizationSession(
HttpSession httpSession) {
NormalizationSession normalizationSession = (NormalizationSession) httpSession
.getAttribute(SessionConstants.NORMALIZATION_SESSION);
if (normalizationSession != null) {
return normalizationSession;
} else {
normalizationSession = new NormalizationSession();
httpSession
.setAttribute(SessionConstants.NORMALIZATION_SESSION, normalizationSession);
return normalizationSession;
}
}
public static void setNormalizationSession(HttpSession httpSession,
NormalizationSession normalizationSession) {
NormalizationSession gb = (NormalizationSession) httpSession
.getAttribute(SessionConstants.NORMALIZATION_SESSION);
if (gb != null) {
httpSession.removeAttribute(SessionConstants.NORMALIZATION_SESSION);
}
httpSession.setAttribute(SessionConstants.NORMALIZATION_SESSION, normalizationSession);
}
public static NormalizationMonitor getNormalizationMonitor(
HttpSession httpSession) {
NormalizationMonitor normalizationMonitor = (NormalizationMonitor) httpSession
.getAttribute(SessionConstants.NORMALIZATION_MONITOR);
if (normalizationMonitor != null) {
return normalizationMonitor;
} else {
normalizationMonitor = new NormalizationMonitor();
httpSession
.setAttribute(SessionConstants.NORMALIZATION_MONITOR, normalizationMonitor);
return normalizationMonitor;
}
}
public static void setNormalizationMonitor(HttpSession httpSession,
NormalizationMonitor normalizationMonitor) {
NormalizationMonitor nm = (NormalizationMonitor) httpSession
.getAttribute(SessionConstants.NORMALIZATION_MONITOR);
if (nm != null) {
httpSession.removeAttribute(SessionConstants.NORMALIZATION_MONITOR);
}
httpSession.setAttribute(SessionConstants.NORMALIZATION_MONITOR, normalizationMonitor);
}
public static Task getNormalizationTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.NORMALIZATION_TASK);
if (monitor == null) {
logger.error("NORMALIZATION_TASK was not acquired");
}
return monitor;
}
public static void setNormalizationTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(SessionConstants.NORMALIZATION_TASK);
if (monitor != null)
httpSession.removeAttribute(SessionConstants.NORMALIZATION_TASK);
httpSession.setAttribute(SessionConstants.NORMALIZATION_TASK, task);
}
}

View File

@ -108,6 +108,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Extr
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4GroupBy;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4LabelColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Normalization;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceBatch;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SplitColumn;
@ -162,6 +163,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCodeMap;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
@ -192,6 +194,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRLocalizedText;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRNameMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRRightsMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadConfig;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
@ -3150,7 +3154,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
// TODO
TabularResource tr = service
.getTabularResource(new TabularResourceId(Long.valueOf(trId
.getId())));
@ -3246,7 +3250,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
int i = 0;
for (Validation v : vals) {
valid = new Validations(String.valueOf(i),
v.getDescription(), v.isValid());
v.getDescription(), v.isValid(), null, null);
vList.add(valid);
i++;
}
@ -6557,11 +6561,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
for (ValidationDescriptor val : job.getValidations()) {
Validations validation = new Validations(
String.valueOf(i), val.getDescription(),
val.isValid());
val.isValid(),
ConditionCodeMap.mapConditionCode(val
.getConditionCode()),
val.getValidationColumn());
validations.add(validation);
i++;
}
// TODO Fix refColumn
InvocationS invocationS = null;
if (job.getInvocation() != null) {
@ -6818,7 +6825,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
// TODO
@Override
public void startTaskResubmit(TaskResubmitSession taskResubmitSession)
throws TDGWTServiceException {
@ -6967,7 +6974,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
// TODO
@Override
public void startTaskResume(TaskResumeSession taskResumeSession)
throws TDGWTServiceException {
@ -7115,7 +7122,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
// TODO
@Override
public void startExtractCodelist(
ExtractCodelistSession extractCodelistSession)
@ -7272,7 +7279,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
// TODO
//TODO
public void startSplitColumn(SplitColumnSession splitColumnSession,
HttpSession session) throws TDGWTServiceException {
try {
@ -8042,4 +8049,159 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startNormalization(NormalizationSession normalizationSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setNormalizationSession(session, normalizationSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (normalizationSession == null) {
logger.error("NormalizationSession is null");
throw new TDGWTServiceException(
"Error in normalization : NormalizationSession is null");
}
logger.debug("StartNormalization: " + normalizationSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
OpExecution4Normalization opEx = new OpExecution4Normalization(service,
normalizationSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
OperationExecution invocation = director.getOperationExecution();
if (invocation == null) {
throw new TDGWTServiceException(
"Error in invocation: Operation not supported");
}
Long id = Long.valueOf(normalizationSession.getTrId().getId());
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());
SessionUtil.setNormalizationTask(session, trTask);
return;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Security exception, you haven't rights!");
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in start normalization: "
+ e.getLocalizedMessage());
}
}
@Override
public NormalizationMonitor getNormalizationMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
NormalizationSession normalizationSession = SessionUtil
.getNormalizationSession(session);
Task task = SessionUtil.getNormalizationTask(session);
NormalizationMonitor normalizationMonitor = new NormalizationMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in NormalizationMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in NormalizationMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
normalizationMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
TRId trId;
TabResource tabResource;
switch (normalizationMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
task.getErrorCause().printStackTrace();
normalizationMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In NormalizationMonitor");
normalizationMonitor.setError(new Throwable(
"Error task resume"));
}
normalizationMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
normalizationMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(normalizationSession.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
normalizationMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
normalizationMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
normalizationMonitor.setProgress(task.getProgress());
break;
case GENERATING_VIEW:
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
normalizationMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(normalizationSession
.getTrId());
normalizationMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setNormalizationTask(session, task);
}
logger.debug("NormalizationMonitor(): " + normalizationMonitor);
return normalizationMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in NormalizationMonitor: " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
}
}
}

View File

@ -58,7 +58,7 @@ public class OpExecution4CodelistMapping extends OpExecutionBuilder {
ColumnLocalId columnId=new ColumnLocalId(columnData.getColumnId());
ColumnReference colRef=new ColumnReference(tableId, columnId);
map.put(Constants.PARAMETER_URL, colRef);
map.put(Constants.PARAMETER_IMPORT_CODELIST_MAPPING_OLDCODES, colRef);
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);

View File

@ -0,0 +1,81 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
import org.gcube.data.analysis.tabulardata.model.column.ColumnReference;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
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.normalization.NormalizationSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Operation Execution for duplicates
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OpExecution4Normalization extends OpExecutionBuilder {
protected static Logger logger = LoggerFactory
.getLogger(OpExecution4Normalization.class);
private TabularDataService service;
private NormalizationSession normalizationSession;
public OpExecution4Normalization(TabularDataService service,
NormalizationSession normalizationSession) {
this.service = service;
this.normalizationSession = normalizationSession;
}
@Override
public void buildOpEx() throws TDGWTServiceException {
OperationExecution invocation = null;
logger.debug(normalizationSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<ColumnData> cols = normalizationSession.getColumns();
logger.debug("Column To Set: " + cols);
ArrayList<ColumnReference> columnReferences = new ArrayList<ColumnReference>();
for (ColumnData col : cols) {
ColumnLocalId cId = new ColumnLocalId(col.getColumnId());
TRId trId = col.getTrId();
logger.debug("trID: " + trId);
long tabId = new Long(trId.getTableId());
TableId tId = new TableId(tabId);
ColumnReference columnReference = new ColumnReference(tId, cId);
columnReferences.add(columnReference);
}
//String name=normalizationSession.getNormalizedColumnName();
//String value=normalizationSession.getValueColumnName();
operationDefinition = OperationDefinitionMap.map(
OperationsId.Normalize.toString(), service);
map.put(Constants.PARAMETER_KEY, columnReferences);
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation);
}
}

View File

@ -18,6 +18,7 @@ import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
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.batch.OccurrencesForReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
@ -211,31 +212,45 @@ public class ExpressionGenerator {
}
public static Expression genReplaceBatchOccurrencesFilter(ColumnData column)
public static Expression genReplaceBatchOccurrencesFilter(
OccurrencesForReplaceBatchColumnSession occurrencesSession)
throws TDGWTServiceException {
try {
ArrayList<String> validationColumnReferences = column
.getValidationColumnReferences();
String validationColumnColumnId = occurrencesSession
.getValidationColumnColumnId();
ColumnData column = occurrencesSession.getColumnData();
TableId tableId = new TableId(Long.valueOf(column.getTrId()
.getTableId()));
ArrayList<Expression> listColumnReference = new ArrayList<Expression>();
for (String columnLocalId : validationColumnReferences) {
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(columnLocalId));
listColumnReference.add(cr);
}
if (listColumnReference.size() <= 0) {
return null;
} else {
if (listColumnReference.size() == 1) {
Not not = new Not(listColumnReference.get(0));
return not;
} else {
And and = new And(listColumnReference);
Not not = new Not(and);
return not;
if (validationColumnColumnId == null
|| validationColumnColumnId.isEmpty()) {
ArrayList<String> validationColumnReferences = column
.getValidationColumnReferences();
ArrayList<Expression> listColumnReference = new ArrayList<Expression>();
for (String columnLocalId : validationColumnReferences) {
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(columnLocalId));
listColumnReference.add(cr);
}
if (listColumnReference.size() <= 0) {
return null;
} else {
if (listColumnReference.size() == 1) {
Not not = new Not(listColumnReference.get(0));
return not;
} else {
And and = new And(listColumnReference);
Not not = new Not(and);
return not;
}
}
} else {
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(validationColumnColumnId));
Not not = new Not(cr);
return not;
}
} catch (Throwable e) {
@ -249,10 +264,11 @@ public class ExpressionGenerator {
}
public static Expression genEditRowParamaterCondition(TabularDataService service,
EditRowSession editRowSession) throws TDGWTServiceException {
public static Expression genEditRowParamaterCondition(
TabularDataService service, EditRowSession editRowSession)
throws TDGWTServiceException {
try {
Expression exp=null;
Expression exp = null;
TRId trId = editRowSession.getTrId();
TableId tableId;
if (trId.isViewTable()) {
@ -261,7 +277,7 @@ public class ExpressionGenerator {
} else {
tableId = new TableId(new Long(trId.getTableId()));
}
Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId())));
@ -280,18 +296,22 @@ public class ExpressionGenerator {
exp = new Equals(cr, new TDInteger(
Integer.parseInt(editRowSession.getRowId())));
} else {
logger.debug("No IdColumnType retrieved for table:"+table.getId().toString());
logger.debug("No IdColumnType retrieved for table:"
+ table.getId().toString());
}
logger.debug("genEditRowParamaterCondition() condition:"+exp);
logger.debug("genEditRowParamaterCondition() condition:" + exp);
return exp;
} catch (Throwable e) {
logger.error("Error in genEditRowParamaterCondition(): "+e.getLocalizedMessage());
logger.error("Error in genEditRowParamaterCondition(): "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error in genEditRowParamaterCondition(): "+e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error in genEditRowParamaterCondition(): "
+ e.getLocalizedMessage());
}
}
}

View File

@ -89,7 +89,7 @@ public class QueryService {
ShowOccurrencesType.ONLYERRORS) == 0) {
if (occurrencesSession.isHasValidationColumns()) {
Expression exp=ExpressionGenerator
.genReplaceBatchOccurrencesFilter(column);
.genReplaceBatchOccurrencesFilter(occurrencesSession);
logger.debug("Expression: "+exp);
if(exp!=null){
queryFilter = new QueryFilter(

View File

@ -3,6 +3,7 @@
*/
package org.gcube.portlets.user.td.gwtservice.shared;
/**
*
* @author "Giancarlo Panichi" <a
@ -72,6 +73,9 @@ public class Constants {
public static final String REQUEST_PROPERTIES_REFCOLUMN = "RefColumn";
public static final String REQUEST_PROPERTIES_COLUMNID = "ColumnId";
public static final String REQUEST_PROPERTIES_TASKID = "TaskId";
public static final String REQUEST_PROPERTIES_CONDITIONCODE = "ConditionCode";
public static final String REQUEST_PROPERTIES_VALIDATIONCOLUMNCOLUMNID = "ValidationColumnColumnId";
public static final String PARAMETER_ADD_COLUMN_COLUMN_TYPE = "columnType";
public static final String PARAMETER_ADD_COLUMN_LABEL = "label";

View File

@ -98,6 +98,7 @@ public enum OperationsId {
Denormalize("3005"),
GroupBy("3006"),
RemoveDuplicateTuples("3007"),
Normalize("3008"),
ReplaceColumnByExpression("3101"),
ReplaceById("3102"),
FilterByExpression("3201"),
@ -114,7 +115,11 @@ public enum OperationsId {
ValidateTable("5011"),
ValidateDataSet("5012"),
ValidateGeneric("5013"),
StatisticalOperation("10001"),
ExportToStatisticalOperation("10002"),
ImportFromStatistical("10003"),
ExtractCodelist("11001"),
GuessCodelist("11002"),
CodelistMappingImport("12001");
/**

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum ConditionCode {
GenericValidity(0),
OnlyOneCodeColumn(1),
OnlyOneCodenameColumn(2),
MaxOneCodenameForDataLocale(3),
AllowedColumnType(4),
MustHaveDataLocaleMetadataAndAtLeastOneLabel(5),
MustContainAtLeastOneDimension(6),
MustContainAtLeastOneMeasure(7),
GenericTupleValidity(100),
DuplicateTupleValidation(101),
DuplicateValueInColumn(102),
AmbigousValueOnExternalReference(103),
MissingValueOnExternalReference(104),
CodeNamePresence(105),
CastValidation(106),
ValidPeriodFormat(105);
/**
* @param int
*/
private ConditionCode(final int id) {
this.id = id;
}
private final int id;
public int value() {
return id;
}
@Override
public String toString(){
return String.valueOf(id);
}
}

View File

@ -0,0 +1,28 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ConditionCodeMap {
/**
*
* @param conditionCode
* @return
*/
public static ConditionCode mapConditionCode(int conditionCode) {
ConditionCode[] conditions=ConditionCode.values();
for(ConditionCode cond:conditions){
if(cond.value()==conditionCode){
return cond;
}
}
return ConditionCode.GenericValidity;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.tr.batch;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode;
/**
*
@ -13,18 +14,25 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
public class OccurrencesForReplaceBatchColumnSession implements Serializable {
private static final long serialVersionUID = -838394991333185029L;
protected ColumnData columnData;
protected ShowOccurrencesType showType;
protected boolean hasValidationColumns;
protected ConditionCode conditionCode;
protected String validationColumnColumnId;
public OccurrencesForReplaceBatchColumnSession() {
}
public OccurrencesForReplaceBatchColumnSession(ColumnData columnData,
ShowOccurrencesType showType, boolean hasValidationColumns) {
ShowOccurrencesType showType, boolean hasValidationColumns,
ConditionCode conditionCode, String validationColumnColumnId) {
this.columnData = columnData;
this.showType = showType;
this.hasValidationColumns = hasValidationColumns;
this.conditionCode=conditionCode;
this.validationColumnColumnId=validationColumnColumnId;
}
public ColumnData getColumnData() {
@ -50,16 +58,32 @@ public class OccurrencesForReplaceBatchColumnSession implements Serializable {
public void setHasValidationColumns(boolean hasValidationColumns) {
this.hasValidationColumns = hasValidationColumns;
}
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 "OccurrencesForReplaceBatchColumnSession [columnData="
+ columnData + ", showType=" + showType
+ ", hasValidationColumns=" + hasValidationColumns + "]";
+ ", hasValidationColumns=" + hasValidationColumns
+ ", conditionCode=" + conditionCode
+ ", validationColumnColumnId=" + validationColumnColumnId
+ "]";
}
}

View File

@ -0,0 +1,18 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.normalization;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class NormalizationMonitor extends OperationMonitor implements
Serializable {
private static final long serialVersionUID = -7021715301225849091L;
}

View File

@ -0,0 +1,92 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.normalization;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class NormalizationSession implements Serializable {
private static final long serialVersionUID = 4139331553059193758L;
public enum DuplicateOp {
VALIDATE, DELETE;
}
protected TRId trId;
protected ArrayList<ColumnData> columns;
protected String normalizedColumnName;
protected String valueColumnName;
public NormalizationSession() {
}
/**
*
* @param trId
* @param columns
* @param normalizedColumnName
* @param valueColumnName
*/
public NormalizationSession(TRId trId, ArrayList<ColumnData> columns,String normalizedColumnName,
String valueColumnName ) {
this.trId = trId;
this.columns = columns;
this.normalizedColumnName=normalizedColumnName;
this.valueColumnName=valueColumnName;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ArrayList<ColumnData> getColumns() {
return columns;
}
public void setColumns(ArrayList<ColumnData> columns) {
this.columns = columns;
}
public String getNormalizedColumnName() {
return normalizedColumnName;
}
public void setNormalizedColumnName(String normalizedColumnName) {
this.normalizedColumnName = normalizedColumnName;
}
public String getValueColumnName() {
return valueColumnName;
}
public void setValueColumnName(String valueColumnName) {
this.valueColumnName = valueColumnName;
}
@Override
public String toString() {
return "NormalizationSession [trId=" + trId + ", columns=" + columns
+ ", normalizedColumnName=" + normalizedColumnName
+ ", valueColumnName=" + valueColumnName + "]";
}
}

View File

@ -2,25 +2,44 @@ package org.gcube.portlets.user.td.gwtservice.shared.tr.table;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode;
/**
*
* @author "Giancarlo Panichi"
*
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class Validations implements Serializable {
private static final long serialVersionUID = 4950002331717895999L;
String id;// Only for grid
String description;
Boolean valid;
protected String id;// Only for grid
protected String description;
protected Boolean valid;
protected ConditionCode conditionCode;
protected String validationColumnColumnId;
/**
*
*/
public Validations() {
}
public Validations(String id, String description, Boolean valid) {
/**
*
* @param id
* @param description
* @param valid
* @param conditionCode
* @param validationColumnColumnId
*/
public Validations(String id, String description, Boolean valid, ConditionCode conditionCode
, String validationColumnColumnId) {
this.id = id;
this.description = description;
this.valid = valid;
this.conditionCode = conditionCode;
this.validationColumnColumnId=validationColumnColumnId;
}
public String getDescription() {
@ -47,10 +66,34 @@ public class Validations implements Serializable {
this.id = id;
}
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 "Validations [id=" + id + ", description=" + description
+ ", valid=" + valid + "]";
+ ", valid=" + valid + ", conditionCode=" + conditionCode
+ ", validationColumnColumnId=" + validationColumnColumnId
+ "]";
}
}