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:
parent
22872c5ba5
commit
3bf30a2420
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
@ -60,6 +61,7 @@ public interface TDGWTServiceAsync {
|
|||
|
||||
void createTabularResource(TabResource tabResource,AsyncCallback<TabResource> callback);
|
||||
|
||||
|
||||
void getTabResourceInformation(AsyncCallback<TabResource> callback);
|
||||
|
||||
void getTabResourceInformation(TRId trId,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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -58,6 +59,8 @@ public class SessionUtil {
|
|||
|
||||
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";
|
||||
|
@ -817,6 +820,36 @@ public class SessionUtil {
|
|||
|
||||
|
||||
|
||||
///
|
||||
|
||||
public static CloneTabularResourceSession getCloneTabularResourceSession(
|
||||
HttpSession httpSession) {
|
||||
CloneTabularResourceSession cloneTabularResourceSession = (CloneTabularResourceSession) httpSession
|
||||
.getAttribute(CLONE_TABULAR_RESOURCE_SESSION);
|
||||
if (cloneTabularResourceSession != null) {
|
||||
return cloneTabularResourceSession;
|
||||
} else {
|
||||
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(
|
||||
|
|
|
@ -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;
|
||||
|
@ -2750,6 +2751,10 @@ 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 {
|
||||
|
@ -3622,4 +3625,44 @@ 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue