Updated EditRow operation

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95729 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-15 16:16:31 +00:00
parent 3e764a8388
commit e923432c44
8 changed files with 827 additions and 331 deletions

View File

@ -52,6 +52,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
@ -587,6 +589,26 @@ public interface TDGWTService extends RemoteService {
throws TDGWTServiceException;
// Rows Operations
/**
* Get Operation Monitor during the Edit Row operation
*
*
* @return
* @throws TDGWTServiceException
*/
public EditRowMonitor getEditRowMonitor()
throws TDGWTServiceException;
/**
* Start edit row or add row
*
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public void startEditRow(EditRowSession editRowSession)
throws TDGWTServiceException;
/**
* Get Operation Monitor during the Delete Rows operation
*

View File

@ -51,6 +51,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabMetadata;
@ -175,6 +177,9 @@ public interface TDGWTServiceAsync {
void startChangeTableType(ChangeTableTypeSession changeTableTypeSession,AsyncCallback<Void> callback);
//Rows Operation
void getEditRowMonitor(AsyncCallback<EditRowMonitor> callback);
void startEditRow(EditRowSession editRowSession,AsyncCallback<Void> callback);
void getDeleteRowsMonitor(AsyncCallback<DeleteRowsMonitor> callback);
void startDeleteRows(DeleteRowsSession deleteRowsSession,AsyncCallback<Void> callback);

View File

@ -0,0 +1,81 @@
package org.gcube.portlets.user.td.gwtservice.server;
public class SessionConstants {
protected static final String CURRENT_TABULAR_RESOURCE = "CURRENT_TABULAR_RESOURCE";
protected static final String CURRENT_TR_ID = "CURRENT_TR_ID";
protected static final String TDOPEN_SESSION = "TDOPEN_SESSION";
protected static final String TABULAR_RESOURCE_LIST = "TABULAR_RESOURCE_LIST";
protected static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";
protected static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE";
protected static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
protected static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
protected static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
protected static final String SDMX_IMPORT_TASK = "SDMX_IMPORT_TASK";
protected static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
protected static final String SDMX_EXPORT_TASK = "SDMX_EXPORT_TASK";
protected static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
protected static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
protected static final String CSV_IMPORT_TASK = "CSV_IMPORT_TASK";
protected static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE";
protected static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
protected static final String CSV_EXPORT_TASK = "CSV_EXPORT_TASK";
protected static final String CSV_EXPORT_END = "CSV_EXPORT_END";
protected static final String CSV_EXPORT_MONITOR = "CSV_EXPORT_MONITOR";
protected static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
protected static final String CHANGE_COLUMN_TYPE_MONITOR = "CHANGE_COLUMN_TYPE_MONITOR";
protected static final String CHANGE_COLUMN_TYPE_TASK = "CHANGE_COLUMN_TYPE_TASK";
protected static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION";
protected static final String DELETE_COLUMN_MONITOR = "DELETE_COLUMN_MONITOR";
protected static final String DELETE_COLUMN_TASK = "DELETE_COLUMN_TASK";
protected static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION";
protected static final String EDIT_ROW_MONITOR = "EDIT_ROW_MONITOR";
protected static final String EDIT_ROW_TASK = "EDIT_ROW_TASK";
protected static final String REPLACE_COLUMN_SESSION = "REPLACE_COLUMN_SESSION";
protected static final String REPLACE_COLUMN_MONITOR = "REPLACE_COLUMN_MONITOR";
protected static final String REPLACE_COLUMN_TASK = "REPLACE_COLUMN_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";
protected static final String REPLACE_BATCH_COLUMN_TASK = "REPLACE_BATCH_COLUMN_TASK";
protected static final String CHANGE_THE_COLUMN_LABEL_SESSION = "CHANGE_THE_COLUMN_LABEL_SESSION";
protected static final String CHANGE_THE_COLUMN_LABEL_MONITOR = "CHANGE_THE_COLUMN_LABEL_MONITOR";
protected static final String CHANGE_THE_COLUMN_LABEL_TASK = "CHANGE_THE_COLUMN_LABEL_TASK";
protected static final String CHANGE_TABLE_TYPE_SESSION = "CHANGE_TABLE_TYPE_SESSION";
protected static final String CHANGE_TABLE_TYPE_MONITOR = "CHANGE_TABLE_TYPE_MONITOR";
protected static final String CHANGE_TABLE_TYPE_TASK = "CHANGE_TABLE_TYPE_TASK";
protected static final String DELETE_ROWS_SESSION = "DELETE_ROWS_SESSION";
protected static final String DELETE_ROWS_MONITOR = "DELETE_ROWS_MONITOR";
protected static final String DELETE_ROWS_TASK = "DELETE_ROWS_TASK";
protected static final String DUPLICATES_ROWS_SESSION = "DUPLICATES_ROWS_SESSION";
protected static final String DUPLICATES_ROWS_MONITOR = "DUPLICATES_ROWS_MONITOR";
protected static final String DUPLICATES_ROWS_TASK = "DUPLICATES_ROWS_TASK";
protected static final String TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION";
protected static final String TEMPLATE_APPLY_MONITOR = "TEMPLATE_APPLY_MONITOR";
protected static final String TEMPLATE_APPLY_TASK = "TEMPLATE_APPLY_TASK";
protected static final String CODELISTS_PAGING_LOADED = "CODELISTS_PAGING_LOADED";
protected static final String CODELISTS_PAGING_LOADED_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY";
protected static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
protected static final String ROLLBACK_SESSION = "ROLLBACK_SESSION";
protected static final String ROLLBACK_MONITOR = "ROLLBACK_MONITOR";
protected static final String ROLLBACK_TASK = "ROLLBACK_TASK";
}

View File

@ -102,6 +102,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitio
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
import org.gcube.portlets.user.td.gwtservice.server.trservice.QueryService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ValueMap;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportMonitor;
@ -168,6 +169,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.Validations;
@ -2482,8 +2485,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
logger.info("configureCSVParser encoding: " + encoding
logger.debug("Session:" + session.getId());
logger.debug("configureCSVParser encoding: " + encoding
+ " headerPresence: " + headerPresence + " delimiter: "
+ delimiter + " comment: " + comment);
@ -2527,7 +2530,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
logger.debug("Session:" + session.getId());
FileUploadSession fileUploadSession = SessionUtil
.getFileUploadSession(session);
if (fileUploadSession == null) {
@ -2556,7 +2559,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
logger.debug("Session:" + session.getId());
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
@ -2564,7 +2567,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the asl session: null");
}
String user = aslSession.getUsername();
logger.info("Session User:" + user);
logger.debug("Session User:" + user);
logger.debug("StartCSVImport: " + csvImportSession.toString());
@ -2793,7 +2796,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
importMonitor.setTrId(trId);
}
logger.info("getImportMonitor(): " + importMonitor);
logger.debug("getImportMonitor(): " + importMonitor);
return importMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -3308,7 +3311,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
logger.debug("Session:" + session.getId());
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
@ -3316,7 +3319,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the asl session: null");
}
String user = aslSession.getUsername();
logger.info("Session User:" + user);
logger.debug("Session User:" + user);
TRId trId = SessionUtil.getTRId(session);
if (trId == null) {
@ -3461,7 +3464,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setSDMXExportTask(session, task);
}
logger.info("getExportMonitor(): " + exportMonitor);
logger.debug("getExportMonitor(): " + exportMonitor);
return exportMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -3488,7 +3491,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"Error retrieving the session: null");
}
logger.info("Session:" + session.getId());
logger.debug("Session:" + session.getId());
ASLSession aslSession = SessionUtil.getAslSession(session);
if (aslSession == null) {
@ -3496,7 +3499,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the asl session: null");
}
String user = aslSession.getUsername();
logger.info("Session User:" + user);
logger.debug("Session User:" + user);
TRId trId = SessionUtil.getTRId(session);
if (trId == null) {
@ -3649,7 +3652,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setCSVExportTask(session, task);
}
logger.info("getExportMonitor(): " + exportMonitor);
logger.debug("getExportMonitor(): " + exportMonitor);
return exportMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -3883,6 +3886,57 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
/**
* Retrieve OperationExecution for change column type
*
* @param replaceColumnSession
* @return
*/
//TODO
protected OperationExecution retrieveOperationExecution(
TabularDataService service,
EditRowSession editRowSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(editRowSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
ValueMap valueMap=new ValueMap();
ArrayList<Map<String,Object>> compositeValue=valueMap.genValueMap(editRowSession);
if (editRowSession.isNewRow()) {
logger.debug("Is a add row");
operationDefinition = OperationDefinitionMap.map(
OperationsId.AddRow.toString(),
capabilities);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
} else {
logger.debug("Is a edit row");
operationDefinition = OperationDefinitionMap.map(
OperationsId.AddRow.toString(),
capabilities);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
}
return invocation;
}
/**
* Retrieve OperationExecution for change column type
@ -4289,7 +4343,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setChangeColumnTypeTask(session, task);
}
logger.info("ChangeColumnTypeMonitor(): " + changeColumnTypeMonitor);
logger.debug("ChangeColumnTypeMonitor(): " + changeColumnTypeMonitor);
return changeColumnTypeMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -4439,7 +4493,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setDeleteColumnTask(session, task);
}
logger.info("DeleteColumnMonitor(): " + deleteColumnMonitor);
logger.debug("DeleteColumnMonitor(): " + deleteColumnMonitor);
return deleteColumnMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -4588,7 +4642,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setLabelColumnTask(session, task);
}
logger.info("LabelColumnMonitor(): " + labelColumnMonitor);
logger.debug("LabelColumnMonitor(): " + labelColumnMonitor);
return labelColumnMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -4742,7 +4796,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setChangeTableTypeTask(session, task);
}
logger.info("ChangeTableTypeMonitor(): " + changeTableTypeMonitor);
logger.debug("ChangeTableTypeMonitor(): " + changeTableTypeMonitor);
return changeTableTypeMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -5002,7 +5056,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setDeleteRowsTask(session, task);
}
logger.info("DeleteRowsMonitor(): " + deleteRowsMonitor);
logger.debug("DeleteRowsMonitor(): " + deleteRowsMonitor);
return deleteRowsMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -5222,7 +5276,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setDuplicatesTask(session, task);
}
logger.info("DuplicatesMonitor(): " + duplicatesMonitor);
logger.debug("DuplicatesMonitor(): " + duplicatesMonitor);
return duplicatesMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -5595,7 +5649,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setTemplateApplyTask(session, task);
}
logger.info("TemplateApplyMonitor(): " + templateApplyMonitor);
logger.debug("TemplateApplyMonitor(): " + templateApplyMonitor);
return templateApplyMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -5785,7 +5839,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setReplaceColumnTask(session, task);
}
logger.info("ReplaceColumnMonitor(): " + replaceColumnMonitor);
logger.debug("ReplaceColumnMonitor(): " + replaceColumnMonitor);
return replaceColumnMonitor;
} catch (TDGWTSessionExpiredException e) {
@ -5949,7 +6003,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setReplaceBatchColumnTask(session, task);
}
logger.info("ReplaceBatchColumnMonitor(): "
logger.debug("ReplaceBatchColumnMonitor(): "
+ replaceBatchColumnMonitor);
return replaceBatchColumnMonitor;
@ -6418,7 +6472,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setRollBackSessionTask(session, task);
}
logger.info("RollBackSessionMonitor(): " + rollBackMonitor);
logger.debug("RollBackSessionMonitor(): " + rollBackMonitor);
return rollBackMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -6493,4 +6547,152 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startEditRow(EditRowSession editRowSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setEditRowSession(session, editRowSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
OperationExecution invocation = retrieveOperationExecution(service,
editRowSession);
if (invocation == null) {
throw new TDGWTServiceException(
"Error in invocation: Operation not supported");
}
Long id;
if(editRowSession.getTrId().isViewTable()){
id=Long.valueOf(editRowSession.getTrId().getReferenceTargetTableId());
} else {
id=Long.valueOf(editRowSession.getTrId().getId());
}
TabularResourceId serviceTR = new TabularResourceId(
id);
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setReplaceColumnTask(session, trTask);
return;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in operation: "
+ e.getLocalizedMessage());
}
}
@Override
public EditRowMonitor getEditRowMonitor() throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
EditRowSession editRowSession = SessionUtil
.getEditRowSession(session);
Task task = SessionUtil.getEditRowTask(session);
EditRowMonitor editRowMonitor = new EditRowMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in EditRowMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in EditRowMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
editRowMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
TRId trId;
TabResource tabResource;
switch (editRowMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
task.getErrorCause().printStackTrace();
editRowMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In EditRowMonitor");
editRowMonitor.setError(new Throwable(
"Error in edit row"));
}
editRowMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
editRowMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(editRowSession.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
editRowMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
editRowMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
editRowMonitor.setProgress(task.getProgress());
break;
case GENERATING_VIEW:
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
editRowMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(editRowSession
.getTrId());
editRowMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setEditRowTask(session, task);
}
logger.debug("EditMonitor(): " + editRowMonitor);
return editRowMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
logger.debug("Error in EditRowMonitor: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -67,8 +67,11 @@ public enum OperationsId {
ChangeTableType("1002"),
CreateDatasetView("1003"),
RemoveColumn("1004"),
AddsAColumn("1005"),
ColumnNameAdd("1006"),
ColumnNameRemove("1007"),
ColumnNameRemove("1007"),
TableNameAdd("1008"),
TableNameRemove("1009"),
ChangeToAnnotationColumn("2000"),
ChangeToAttributeColumn("2001"),
ChangeToMeasureColumn("2002"),
@ -77,20 +80,27 @@ public enum OperationsId {
ChangeToCodeDescription("2005"),
ChangeToDimensionColumn("2006"),
ChangeToTimeDimensionColumn("2007"),
AddRow("3004"),
Denormalize("3005"),
GroupBy("3006"),
RemoveDuplicateTuples("3007"),
ReplaceColumnByExpression("3101"),
ReplaceById("3102"),
FilterByExpression("3201"),
RemoveRowById("3202"),
Union("3004"),
Denormalize("3005"),
Aggregation("3006"),
Union("3208"),
CodelistValidation("5001"),
ColumnTypeCastCheck("5002"),
DuplicateTupleValidation("5003"),
DuplicateValuesInColumnValidator("5004"),
PeriodFormatCheck("5005"),
ExpressionValidation("5006"),
DimensionColumnValidator("5010");
AmbiguousExternalReferenceCheck("5007"),
DimensionColumnValidator("5010"),
ValidateTable("5011"),
ValidateDataSet("5012"),
ValidateGeneric("5013"),
ExtractCodelist("11001");
/**
* @param text

View File

@ -0,0 +1,176 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
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.datatype.value.TDBoolean;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDDate;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDNumeric;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDText;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.i18n.client.DateTimeFormat;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class ValueMap {
protected static Logger logger = LoggerFactory
.getLogger(ValueMap.class);
public ValueMap(){
}
protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
public ArrayList<Map<String,Object>> genValueMap(EditRowSession editRowSession){
ArrayList<Map<String,Object>> composit=new ArrayList<Map<String,Object>>();
if(editRowSession.getMaps()==null){
return composit;
}
TRId trId=editRowSession.getTrId();
TableId tableId;
if(trId.isViewTable()){
tableId=new TableId(new Long(trId.getReferenceTargetTableId()));
} else {
tableId=new TableId(new Long(trId.getTableId()));
}
Map<String,String> parametersValue=editRowSession.getMaps();
Set<String> keys=parametersValue.keySet();
Iterator<String> iterator=keys.iterator();
String key;
while(iterator.hasNext()){
key=iterator.next();
String value=parametersValue.get(key);
for(ColumnData col:editRowSession.getColumns()){
if(col.getColumnId().compareTo(key)==0){
if (col.getTypeCode().compareTo(
ColumnTypeCode.DIMENSION.toString()) == 0
|| col.getTypeCode().compareTo(
ColumnTypeCode.TIMEDIMENSION.toString()) == 0) {
TDInteger tdDim=new TDInteger(new Integer(value));
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdDim);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Boolean.toString()) == 0) {
TDBoolean tdBoolean=new TDBoolean(new Boolean(value));
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdBoolean);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Date.toString()) == 0) {
Date d;
try{
d=sdf.parse(value);
}catch(IllegalArgumentException e){
continue;
}
TDDate tdDate=new TDDate(d);
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdDate);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) {
TDText tdText=new TDText(value);
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdText);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Geometry.toString()) == 0) {
TDText tdGeometry=new TDText(value);
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdGeometry);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Integer.toString()) == 0) {
Integer integ;
try{
integ=new Integer(value);
} catch(NumberFormatException e){
continue;
}
TDInteger tdInteger=new TDInteger(integ);
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdInteger);
composit.add(valueMap);
} else {
if (col.getDataTypeName().compareTo(
ColumnDataType.Numeric.toString()) == 0) {
Float numeric;
try{
numeric=new Float(value);
} catch(NumberFormatException e){
continue;
}
TDNumeric tdNumeric=new TDNumeric(numeric);
ColumnLocalId columnId=new ColumnLocalId(key);
ColumnReference colRef=new ColumnReference(tableId, columnId);
Map<String,Object> valueMap=new HashMap<String,Object>();
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_FIELD,colRef);
valueMap.put(Constants.PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE,tdNumeric);
composit.add(valueMap);
} else {
}
}
}
}
}
}
}
break;
}
}
}
return composit;
}
}

View File

@ -39,6 +39,9 @@ public class Constants {
public static final String PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION="condition";
public static final String PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE="value";
public static final String PARAMETER_ADD_ROW_COMPOSITE_FIELD="field";
public static final String PARAMETER_ADD_ROW_COMPOSITE_TOSETVALUE="toSetValue";
public static final String PARAMETER_ADD_ROW_COMPOSITE="mapping";
public static final String NAME_PARAMETER_ID="NAME_PARAMETER_ID";
public static final String PARAMETER_KEY="key";
@ -49,5 +52,5 @@ public class Constants {
public static final String PARAMETER_TABLE_TYPE="tableType";
public static final String PARAMETER_ROW_ID="rowId";
}