Added Clone

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@92819 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-07 14:26:39 +00:00
parent 22872c5ba5
commit 3bf30a2420
5 changed files with 186 additions and 59 deletions

View File

@ -22,6 +22,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
@ -42,7 +43,6 @@ 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;
@ -167,6 +167,18 @@ public interface TDGWTService extends RemoteService {
public ArrayList<TabResource> getTabularResources()
throws TDGWTServiceException;
//Clone
/**
* Start clone tabular resource
*
* @param labelColumnSession
* @throws TDGWTServiceException
*/
public TRId startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession)
throws TDGWTServiceException;
//
/**
* Initialize Codelists Paging Loader
*

View File

@ -21,6 +21,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
@ -59,6 +60,7 @@ public interface TDGWTServiceAsync {
void hello(AsyncCallback<String> callback);
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
void getTabResourceInformation(AsyncCallback<TabResource> callback);
@ -99,6 +101,10 @@ public interface TDGWTServiceAsync {
//Open
void startTDOpen(TDOpenSession tdOpenSession, AsyncCallback<Void> callback);
//Clone
void startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession,AsyncCallback<TRId> callback);
//SDMX
void getCodelists(AsyncCallback<ArrayList<Codelist>> callback);

View File

@ -23,6 +23,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
@ -55,9 +56,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";
@ -819,74 +822,104 @@ public class SessionUtil {
///
public static DeleteRowsSession getDeleteRowsSession(
public static CloneTabularResourceSession getCloneTabularResourceSession(
HttpSession httpSession) {
DeleteRowsSession deleteRowsSession = (DeleteRowsSession) httpSession
.getAttribute(DELETE_ROWS_SESSION);
if (deleteRowsSession != null) {
return deleteRowsSession;
CloneTabularResourceSession cloneTabularResourceSession = (CloneTabularResourceSession) httpSession
.getAttribute(CLONE_TABULAR_RESOURCE_SESSION);
if (cloneTabularResourceSession != null) {
return cloneTabularResourceSession;
} else {
deleteRowsSession = new DeleteRowsSession();
cloneTabularResourceSession = new CloneTabularResourceSession();
httpSession.setAttribute(CLONE_TABULAR_RESOURCE_SESSION,
cloneTabularResourceSession);
return cloneTabularResourceSession;
}
}
public static void setCloneTabularResourceSession(HttpSession httpSession,
CloneTabularResourceSession cloneTabularResourceSession) {
CloneTabularResourceSession c = (CloneTabularResourceSession) httpSession
.getAttribute(CLONE_TABULAR_RESOURCE_SESSION);
if (c != null) {
httpSession.removeAttribute(CLONE_TABULAR_RESOURCE_SESSION);
}
httpSession.setAttribute(CLONE_TABULAR_RESOURCE_SESSION,
cloneTabularResourceSession);
}
///
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);
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);
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;
}
}
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();
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);
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);
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;
}
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");
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);
}
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);
}
///

View File

@ -100,6 +100,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
@ -2749,7 +2750,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return invocation;
}
protected OperationExecution retrieveOperationExecution(
TabularDataService service, LabelColumnSession labelColumnSession)
throws TDGWTServiceException {
@ -3483,8 +3488,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public void startDeleteRows(DeleteRowsSession deleteRowsSession)
throws TDGWTServiceException {
@ -3518,7 +3521,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public DeleteRowsMonitor getDeleteRowsMonitor()
throws TDGWTServiceException {
@ -3621,5 +3624,45 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
@Override
public TRId startCloneTabularResource(
CloneTabularResourceSession cloneTabularResourceSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
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());
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();
throw new TDGWTServiceException("Error Cloning: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.clone;
import java.io.Serializable;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CloneTabularResourceSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
@Override
public String toString() {
return "CloneTabularResourceSession [trId=" + trId + "]";
}
}