Added Duplicates

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@92832 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-07 16:19:35 +00:00
parent 2486c088d9
commit e0a505c619
7 changed files with 471 additions and 131 deletions

View File

@ -35,6 +35,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoad
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
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.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;
@ -43,6 +45,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -461,6 +464,27 @@ public interface TDGWTService extends RemoteService {
throws TDGWTServiceException;
/**
* Get Operation Monitor during the operation on duplicates
*
*
* @return
* @throws TDGWTServiceException
*/
public DuplicatesMonitor getDuplicatesMonitor()
throws TDGWTServiceException;
/**
* Start operation on duplicates
*
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public void startDuplicates(
DuplicatesSession duplicatesSession)
throws TDGWTServiceException;
// Column Operation
/**

View File

@ -34,6 +34,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoad
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.CodelistPagingLoadResult;
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.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;
@ -155,6 +157,9 @@ public interface TDGWTServiceAsync {
void getDeleteRowsMonitor(AsyncCallback<DeleteRowsMonitor> callback);
void startDeleteRows(DeleteRowsSession deleteRowsSession,AsyncCallback<Void> callback);
void getDuplicateMonitor(AsyncCallback<DuplicatesMonitor> callback);
void startDuplicate(DuplicatesSession duplicatesSession,AsyncCallback<Void> callback);
//Column Operation
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);

View File

@ -33,6 +33,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnT
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;
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.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
@ -56,11 +58,11 @@ public class SessionUtil {
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";
@ -86,7 +88,7 @@ public class SessionUtil {
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 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";
@ -94,15 +96,20 @@ public class SessionUtil {
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 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_FILTERED_COPY = "CODELISTS_PAGING_LOADED_FILTERED_COPY";
protected static final String CODELISTS_PAGING_LOADED_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
public static ASLSession getAslSession(HttpSession httpSession) {
@ -535,7 +542,7 @@ public class SessionUtil {
httpSession.setAttribute(TR_TASK_MANAGER, trTasksManager);
}
//
public static ChangeColumnTypeSession getChangeColumnTypeSession(
HttpSession httpSession) {
@ -604,8 +611,8 @@ public class SessionUtil {
httpSession.removeAttribute(CHANGE_COLUMN_TYPE_TASK);
httpSession.setAttribute(CHANGE_COLUMN_TYPE_TASK, task);
}
///
// /
public static LabelColumnSession getLabelColumnSession(
HttpSession httpSession) {
@ -660,22 +667,23 @@ public class SessionUtil {
}
public static Task getLabelColumnTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
Task monitor = (Task) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
if (monitor == null) {
logger.error("CHANGE_THE_COLUMN_LABEL_TASK was not acquired");
}
return monitor;
}
public static void setLabelColumnTask(HttpSession httpSession,
Task task) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
public static void setLabelColumnTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession
.getAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
if (monitor != null)
httpSession.removeAttribute(CHANGE_THE_COLUMN_LABEL_TASK);
httpSession.setAttribute(CHANGE_THE_COLUMN_LABEL_TASK, task);
}
///
// /
public static DeleteColumnSession getDeleteColumnSession(
HttpSession httpSession) {
@ -685,8 +693,8 @@ public class SessionUtil {
return deleteColumnSession;
} else {
deleteColumnSession = new DeleteColumnSession();
httpSession.setAttribute(DELETE_COLUMN_SESSION,
deleteColumnSession);
httpSession
.setAttribute(DELETE_COLUMN_SESSION, deleteColumnSession);
return deleteColumnSession;
}
}
@ -698,8 +706,7 @@ public class SessionUtil {
if (dc != null) {
httpSession.removeAttribute(DELETE_COLUMN_SESSION);
}
httpSession.setAttribute(DELETE_COLUMN_SESSION,
deleteColumnSession);
httpSession.setAttribute(DELETE_COLUMN_SESSION, deleteColumnSession);
}
@ -711,8 +718,8 @@ public class SessionUtil {
return deleteColumnMonitor;
} else {
deleteColumnMonitor = new DeleteColumnMonitor();
httpSession.setAttribute(DELETE_COLUMN_MONITOR,
deleteColumnMonitor);
httpSession
.setAttribute(DELETE_COLUMN_MONITOR, deleteColumnMonitor);
return deleteColumnMonitor;
}
}
@ -724,8 +731,7 @@ public class SessionUtil {
if (cm != null) {
httpSession.removeAttribute(DELETE_COLUMN_MONITOR);
}
httpSession.setAttribute(DELETE_COLUMN_MONITOR,
deleteColumnMonitor);
httpSession.setAttribute(DELETE_COLUMN_MONITOR, deleteColumnMonitor);
}
@ -737,16 +743,14 @@ public class SessionUtil {
return monitor;
}
public static void setDeleteColumnTask(HttpSession httpSession,
Task task) {
public static void setDeleteColumnTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(DELETE_COLUMN_TASK);
if (monitor != null)
httpSession.removeAttribute(DELETE_COLUMN_TASK);
httpSession.setAttribute(DELETE_COLUMN_TASK, task);
}
///
// /
public static ChangeTableTypeSession getChangeTableTypeSession(
HttpSession httpSession) {
@ -808,20 +812,15 @@ public class SessionUtil {
return monitor;
}
public static void setChangeTableTypeTask(HttpSession httpSession,
Task task) {
public static void setChangeTableTypeTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(CHANGE_TABLE_TYPE_TASK);
if (monitor != null)
httpSession.removeAttribute(CHANGE_TABLE_TYPE_TASK);
httpSession.setAttribute(CHANGE_TABLE_TYPE_TASK, task);
}
///
// /
public static CloneTabularResourceSession getCloneTabularResourceSession(
HttpSession httpSession) {
CloneTabularResourceSession cloneTabularResourceSession = (CloneTabularResourceSession) httpSession
@ -848,81 +847,134 @@ public class SessionUtil {
}
///
public static DeleteRowsSession getDeleteRowsSession(
HttpSession httpSession) {
DeleteRowsSession deleteRowsSession = (DeleteRowsSession) httpSession
.getAttribute(DELETE_ROWS_SESSION);
if (deleteRowsSession != null) {
return deleteRowsSession;
} else {
deleteRowsSession = new DeleteRowsSession();
httpSession.setAttribute(DELETE_ROWS_SESSION,
deleteRowsSession);
return deleteRowsSession;
}
// /
public static DeleteRowsSession getDeleteRowsSession(HttpSession httpSession) {
DeleteRowsSession deleteRowsSession = (DeleteRowsSession) httpSession
.getAttribute(DELETE_ROWS_SESSION);
if (deleteRowsSession != null) {
return deleteRowsSession;
} else {
deleteRowsSession = new DeleteRowsSession();
httpSession.setAttribute(DELETE_ROWS_SESSION, deleteRowsSession);
return deleteRowsSession;
}
}
public static void setDeleteRowsSession(HttpSession httpSession,
DeleteRowsSession deleteRowsSession) {
DeleteRowsSession dr = (DeleteRowsSession) httpSession
.getAttribute(DELETE_ROWS_SESSION);
if (dr != null) {
httpSession.removeAttribute(DELETE_ROWS_SESSION);
}
httpSession.setAttribute(DELETE_ROWS_SESSION,
deleteRowsSession);
public static void setDeleteRowsSession(HttpSession httpSession,
DeleteRowsSession deleteRowsSession) {
DeleteRowsSession dr = (DeleteRowsSession) httpSession
.getAttribute(DELETE_ROWS_SESSION);
if (dr != null) {
httpSession.removeAttribute(DELETE_ROWS_SESSION);
}
httpSession.setAttribute(DELETE_ROWS_SESSION, deleteRowsSession);
public static DeleteRowsMonitor getDeleteRowsMonitor(
HttpSession httpSession) {
DeleteRowsMonitor deleteRowsMonitor = (DeleteRowsMonitor) httpSession
.getAttribute(DELETE_ROWS_MONITOR);
if (deleteRowsMonitor != null) {
return deleteRowsMonitor;
} else {
deleteRowsMonitor = new DeleteRowsMonitor();
httpSession.setAttribute(DELETE_ROWS_MONITOR,
deleteRowsMonitor);
return deleteRowsMonitor;
}
}
public static DeleteRowsMonitor getDeleteRowsMonitor(HttpSession httpSession) {
DeleteRowsMonitor deleteRowsMonitor = (DeleteRowsMonitor) httpSession
.getAttribute(DELETE_ROWS_MONITOR);
if (deleteRowsMonitor != null) {
return deleteRowsMonitor;
} else {
deleteRowsMonitor = new DeleteRowsMonitor();
httpSession.setAttribute(DELETE_ROWS_MONITOR, deleteRowsMonitor);
return deleteRowsMonitor;
}
}
public static void setDeleteRowsMonitor(HttpSession httpSession,
DeleteRowsMonitor deleteRowsMonitor) {
DeleteRowsMonitor ctt = (DeleteRowsMonitor) httpSession
.getAttribute(DELETE_ROWS_MONITOR);
if (ctt != null) {
httpSession.removeAttribute(DELETE_ROWS_MONITOR);
}
httpSession.setAttribute(DELETE_ROWS_MONITOR,
deleteRowsMonitor);
public static void setDeleteRowsMonitor(HttpSession httpSession,
DeleteRowsMonitor deleteRowsMonitor) {
DeleteRowsMonitor ctt = (DeleteRowsMonitor) httpSession
.getAttribute(DELETE_ROWS_MONITOR);
if (ctt != null) {
httpSession.removeAttribute(DELETE_ROWS_MONITOR);
}
httpSession.setAttribute(DELETE_ROWS_MONITOR, deleteRowsMonitor);
public static Task getDeleteRowsTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(DELETE_ROWS_TASK);
if (monitor == null) {
logger.error("DELETE_ROWS_TASK was not acquired");
}
return monitor;
}
}
public static void setDeleteRowsTask(HttpSession httpSession,
Task task) {
Task monitor = (Task) httpSession.getAttribute(DELETE_ROWS_TASK);
if (monitor != null)
httpSession.removeAttribute(DELETE_ROWS_TASK);
httpSession.setAttribute(DELETE_ROWS_TASK, task);
public static Task getDeleteRowsTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(DELETE_ROWS_TASK);
if (monitor == null) {
logger.error("DELETE_ROWS_TASK was not acquired");
}
///
return monitor;
}
public static void setDeleteRowsTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(DELETE_ROWS_TASK);
if (monitor != null)
httpSession.removeAttribute(DELETE_ROWS_TASK);
httpSession.setAttribute(DELETE_ROWS_TASK, task);
}
//
public static DuplicatesSession getDuplicatesSession(HttpSession httpSession) {
DuplicatesSession duplicatesSession = (DuplicatesSession) httpSession
.getAttribute(DUPLICATES_ROWS_SESSION);
if (duplicatesSession != null) {
return duplicatesSession;
} else {
duplicatesSession = new DuplicatesSession();
httpSession.setAttribute(DUPLICATES_ROWS_SESSION, duplicatesSession);
return duplicatesSession;
}
}
public static void setDuplicatesSession(HttpSession httpSession,
DuplicatesSession duplicatesSession) {
DuplicatesSession dr = (DuplicatesSession) httpSession
.getAttribute(DUPLICATES_ROWS_SESSION);
if (dr != null) {
httpSession.removeAttribute(DUPLICATES_ROWS_SESSION);
}
httpSession.setAttribute(DUPLICATES_ROWS_SESSION, duplicatesSession);
}
public static DuplicatesMonitor getDuplicatesMonitor(HttpSession httpSession) {
DuplicatesMonitor duplicatesMonitor = (DuplicatesMonitor) httpSession
.getAttribute(DUPLICATES_ROWS_MONITOR);
if (duplicatesMonitor != null) {
return duplicatesMonitor;
} else {
duplicatesMonitor = new DuplicatesMonitor();
httpSession.setAttribute(DUPLICATES_ROWS_MONITOR, duplicatesMonitor);
return duplicatesMonitor;
}
}
public static void setDuplicatesMonitor(HttpSession httpSession,
DuplicatesMonitor duplicateMonitor) {
DuplicatesMonitor d = (DuplicatesMonitor) httpSession
.getAttribute(DUPLICATES_ROWS_MONITOR);
if (d != null) {
httpSession.removeAttribute(DUPLICATES_ROWS_MONITOR);
}
httpSession.setAttribute(DUPLICATES_ROWS_MONITOR, duplicateMonitor);
}
public static Task getDuplicatesTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(DUPLICATES_ROWS_TASK);
if (monitor == null) {
logger.error("DUPLICATES_ROWS_TASK was not acquired");
}
return monitor;
}
public static void setDuplicatesTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(DUPLICATES_ROWS_TASK);
if (monitor != null)
httpSession.removeAttribute(DUPLICATES_ROWS_TASK);
httpSession.setAttribute(DUPLICATES_ROWS_TASK, task);
}
//
public static ArrayList<TabResource> getCodelistsPagingLoaded(
HttpSession httpSession) {
@SuppressWarnings("unchecked")
@ -955,17 +1007,17 @@ public class SessionUtil {
return ltrFilteredCopy;
}
public static void setCodelistsPagingLoadedFilteredCopy(HttpSession httpSession,
public static void setCodelistsPagingLoadedFilteredCopy(
HttpSession httpSession,
ArrayList<TabResource> listCodelistsFilteredCopy) {
@SuppressWarnings("unchecked")
ArrayList<TabResource> ltrFilteredCopy = ((ArrayList<TabResource>) httpSession
.getAttribute(CODELISTS_PAGING_LOADED_FILTERED_COPY));
if (ltrFilteredCopy != null)
httpSession.removeAttribute(CODELISTS_PAGING_LOADED_FILTERED_COPY);
httpSession.setAttribute(CODELISTS_PAGING_LOADED_FILTERED_COPY, listCodelistsFilteredCopy);
}
httpSession.setAttribute(CODELISTS_PAGING_LOADED_FILTERED_COPY,
listCodelistsFilteredCopy);
}
public static String getCodelistsPagingLoadedFilter(HttpSession httpSession) {
String filter = (String) httpSession
@ -985,9 +1037,5 @@ public class SessionUtil {
httpSession.removeAttribute(CODELISTS_PAGING_LOADED_FILTER);
httpSession.setAttribute(CODELISTS_PAGING_LOADED_FILTER, filter);
}
}

View File

@ -121,6 +121,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.Direction;
import org.gcube.portlets.user.td.gwtservice.shared.tr.paging.OrderInfo;
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.table.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.metadata.TabDescriptionsMetadata;
@ -2750,11 +2752,60 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
protected OperationExecution retrieveOperationExecution(
TabularDataService service, DuplicatesSession duplicatesSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(duplicatesSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<ColumnData> cols = duplicatesSession.getColumns();
logger.debug("ReferenceColumn 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);
}
switch (duplicatesSession.getDuplicateOp()) {
case VALIDATE:
operationDefinition = OperationDefinitionMap.map(
OperationsId.DuplicateTupleValidation.toString(), capabilities);
map.put(Constants.PARAMETER_KEY, columnReferences);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
break;
case DELETE:
operationDefinition = OperationDefinitionMap.map(
OperationsId.RemoveDuplicateTuples.toString(), capabilities);
map.put(Constants.PARAMETER_KEY, columnReferences);
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
break;
default:
break;
}
return invocation;
}
protected OperationExecution retrieveOperationExecution(
TabularDataService service, LabelColumnSession labelColumnSession)
throws TDGWTServiceException {
@ -3625,36 +3676,36 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public TRId startCloneTabularResource(
CloneTabularResourceSession cloneTabularResourceSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setCloneTabularResourceSession(session, cloneTabularResourceSession);
SessionUtil.setCloneTabularResourceSession(session,
cloneTabularResourceSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(cloneTabularResourceSession.getTrId().getId()));
TabularResource cloned=service.cloneTabularResource(serviceTR);
Table table=service.getLastTable(serviceTR);
TRId trId = new TRId(new Long(cloned.getId().getValue()).toString(),
new Long(table.getId().getValue()).toString());
TabularResource cloned = service.cloneTabularResource(serviceTR);
Table table = service.getLastTable(serviceTR);
TRId trId = new TRId(
new Long(cloned.getId().getValue()).toString(), new Long(
table.getId().getValue()).toString());
trId.setTableType(table.getTableType().getName());
TabResource tabResource = new TabResource();
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
return trId;
} catch (Exception e) {
e.printStackTrace();
@ -3663,6 +3714,143 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startDuplicates(DuplicatesSession duplicatesSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setDuplicatesSession(session, duplicatesSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
OperationExecution invocation = retrieveOperationExecution(service,
duplicatesSession);
if (invocation == null) {
throw new TDGWTServiceException(
"Error Delete Rows invocation: Operation not supported");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(duplicatesSession.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setDuplicatesTask(session, trTask);
return;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in operation for duplicates: "
+ e.getLocalizedMessage());
}
}
@Override
public DuplicatesMonitor getDuplicatesMonitor()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
DuplicatesSession duplicatesSession = SessionUtil
.getDuplicatesSession(session);
Task task = SessionUtil.getDeleteRowsTask(session);
DuplicatesMonitor duplicatesMonitor = new DuplicatesMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in DuplicatesMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in DuplicatesMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
duplicatesMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
Table table;
TRId trId;
TabResource tabResource;
switch (duplicatesMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
duplicatesMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In DuplicatesMonitor");
duplicatesMonitor.setError(new Throwable(
"Error in operation for duplicates"));
}
duplicatesMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
duplicatesMonitor.setProgress(task.getProgress());
table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
trId = new TRId();
trId.setId(duplicatesSession.getTrId().getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());
duplicatesMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
duplicatesMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
duplicatesMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
duplicatesMonitor.setProgress(task.getProgress());
table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
trId = new TRId();
trId.setId(duplicatesSession.getTrId().getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());
duplicatesMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setDuplicatesTask(session, task);
}
logger.info("DuplicatesMonitor(): " + duplicatesMonitor);
return duplicatesMonitor;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in monitor DuplicatesMonitor: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -30,7 +30,7 @@ public class Constants {
public static final String PARAMETER_DATA_TYPE="dataType";
public static final String PARAMETER_TARGET_DATA_TYPE="targetDataType";
public static final String PARAMETER_KEY="key";
public static final String PARAMETER_REFERENCE_COLUMN="refColumn";
public static final String PARAMETER_PERIOD_FORMAT="periodFormat";
public static final String PARAMETER_EXPRESSION="expression";

View File

@ -0,0 +1,12 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.rows;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
public class DuplicatesMonitor extends OperationMonitor implements Serializable {
private static final long serialVersionUID = 2329951047629617335L;
}

View File

@ -0,0 +1,63 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.rows;
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;
public class DuplicatesSession implements Serializable {
private static final long serialVersionUID = -4503878699159491057L;
public enum DuplicateOp {
VALIDATE, DELETE;
}
protected TRId trId;
protected ArrayList<ColumnData> columns;
protected DuplicateOp duplicateOp;
public DuplicatesSession() {
}
public DuplicatesSession(TRId trId, ArrayList<ColumnData> columns,DuplicateOp duplicateOp) {
this.trId = trId;
this.columns = columns;
this.duplicateOp=duplicateOp;
}
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 DuplicateOp getDuplicateOp() {
return duplicateOp;
}
public void setDuplicateOp(DuplicateOp duplicateOp) {
this.duplicateOp = duplicateOp;
}
@Override
public String toString() {
return "DuplicateSession [trId=" + trId + ", columns=" + columns
+ ", duplicateOp=" + duplicateOp + "]";
}
}