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:
parent
2486c088d9
commit
e0a505c619
|
@ -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
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -99,6 +101,11 @@ public class SessionUtil {
|
|||
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_FILTER = "CODELISTS_PAGING_LOADED_FILTER";
|
||||
|
@ -660,16 +667,17 @@ 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);
|
||||
|
@ -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,15 +743,13 @@ 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(
|
||||
|
@ -808,18 +812,13 @@ 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(
|
||||
|
@ -848,20 +847,16 @@ public class SessionUtil {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /
|
||||
|
||||
public static DeleteRowsSession getDeleteRowsSession(
|
||||
HttpSession httpSession) {
|
||||
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);
|
||||
httpSession.setAttribute(DELETE_ROWS_SESSION, deleteRowsSession);
|
||||
return deleteRowsSession;
|
||||
}
|
||||
}
|
||||
|
@ -873,21 +868,18 @@ public class SessionUtil {
|
|||
if (dr != null) {
|
||||
httpSession.removeAttribute(DELETE_ROWS_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(DELETE_ROWS_SESSION,
|
||||
deleteRowsSession);
|
||||
httpSession.setAttribute(DELETE_ROWS_SESSION, deleteRowsSession);
|
||||
|
||||
}
|
||||
|
||||
public static DeleteRowsMonitor getDeleteRowsMonitor(
|
||||
HttpSession httpSession) {
|
||||
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);
|
||||
httpSession.setAttribute(DELETE_ROWS_MONITOR, deleteRowsMonitor);
|
||||
return deleteRowsMonitor;
|
||||
}
|
||||
}
|
||||
|
@ -899,8 +891,7 @@ public class SessionUtil {
|
|||
if (ctt != null) {
|
||||
httpSession.removeAttribute(DELETE_ROWS_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(DELETE_ROWS_MONITOR,
|
||||
deleteRowsMonitor);
|
||||
httpSession.setAttribute(DELETE_ROWS_MONITOR, deleteRowsMonitor);
|
||||
|
||||
}
|
||||
|
||||
|
@ -912,16 +903,77 @@ public class SessionUtil {
|
|||
return monitor;
|
||||
}
|
||||
|
||||
public static void setDeleteRowsTask(HttpSession httpSession,
|
||||
Task task) {
|
||||
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) {
|
||||
|
@ -955,18 +1007,18 @@ 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
|
||||
.getAttribute(CODELISTS_PAGING_LOADED_FILTER);
|
||||
|
@ -986,8 +1038,4 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(CODELISTS_PAGING_LOADED_FILTER, filter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -2752,8 +2754,57 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -3625,15 +3676,14 @@ 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(
|
||||
|
@ -3646,8 +3696,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
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 trId = new TRId(
|
||||
new Long(cloned.getId().getValue()).toString(), new Long(
|
||||
table.getId().getValue()).toString());
|
||||
trId.setTableType(table.getTableType().getName());
|
||||
|
||||
TabResource tabResource = new TabResource();
|
||||
|
@ -3664,5 +3715,142 @@ 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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue