Added Delete Template

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@93496 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-25 09:23:06 +00:00
parent b2c3024afe
commit 0f51554616
4 changed files with 161 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
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;
@ -201,6 +202,15 @@ public interface TDGWTService extends RemoteService {
*/
public ArrayList<TabResource> getTabularResources()
throws TDGWTServiceException;
/**
* Return all tabular resource of a user and last tables
*
* @return
* @throws TDGWTServiceException
*/
/*public ArrayList<TabResource> getTabularResourcesAndLastTables()
throws TDGWTServiceException;*/
//Clone
/**
@ -598,7 +608,7 @@ public interface TDGWTService extends RemoteService {
public ArrayList<TemplateData> getTemplates() throws TDGWTServiceException;
/**
* Get Operation Monitor during ApplyTemplate operation
* Get Operation Monitor during Apply Template operation
*
* @param callback
*/
@ -611,7 +621,17 @@ public interface TDGWTService extends RemoteService {
* @param applyTemplateSession
*
*/
void startTemplateApply(TemplateApplySession applyTemplateSession) throws TDGWTServiceException;
void startTemplateApply(TemplateApplySession templateApplySession) throws TDGWTServiceException;
/**
* Start Delete Template
*
* @param applyTemplateSession
*
*/
void startTemplateDelete(TemplateDeleteSession templateDeleteSession) throws TDGWTServiceException;
}

View File

@ -22,6 +22,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
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;
@ -80,6 +81,8 @@ public interface TDGWTServiceAsync {
void getTabularResources(AsyncCallback<ArrayList<TabResource>> callback);
//void getTabularResourcesAndLastTables(AsyncCallback<ArrayList<TabResource>> callback);
void getLastTable(TRId trId, AsyncCallback<TableData> callback);
void getTable(TRId trId, AsyncCallback<TableData> callback);
@ -187,7 +190,9 @@ public interface TDGWTServiceAsync {
//Templates
void getTemplates(AsyncCallback<ArrayList<TemplateData>> callback);
void getTemplateApplyMonitor(AsyncCallback<TemplateApplyMonitor> callback);
void startTemplateApply(TemplateApplySession applyTemplateSession,AsyncCallback<Void> callback);
void startTemplateApply(TemplateApplySession templateDeleteSession,AsyncCallback<Void> callback);
void startTemplateDelete(TemplateDeleteSession templateDeleteSession,AsyncCallback<Void> callback);

View File

@ -65,6 +65,7 @@ import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.model.table.type.CodelistTableType;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTemplateException;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.operation.Task;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
@ -110,6 +111,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
@ -1163,7 +1165,60 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
*
* {@inheritDoc}
@Override
public ArrayList<TabResource> getTabularResourcesAndLastTables()
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("GetTabularResources");
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
List<TabularResource> trs = service.getTabularResources();
SessionUtil.setTabularResources(session, trs);
ArrayList<TabResource> ltr = new ArrayList<TabResource>();
int i;
for (i = 0; i < trs.size(); i++) {
TabularResource tr = trs.get(i);
logger.debug("GetTabularResources RetrieveMetadata");
try {
TabResource t = retrieveTRMetadataFromService(service, tr,
i);
if (t.getTrId() != null) {
ltr.add(t);
}
} catch (Throwable e) {
logger.error("TabResource discarded: " + tr + " cause: "
+ e.getMessage());
}
}
logger.debug("Tabular Resources retrived: " + ltr);
return ltr;
} catch (Throwable e) {
e.printStackTrace();
logger.error("Error retrieving TabularResources: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error retrieving TabularResources: "
+ e.getLocalizedMessage());
}
}
*/
/**
*
*
* {@inheritDoc}
*/
@Override
public ArrayList<TabResource> getTabularResources()
throws TDGWTServiceException {
try {
@ -1208,6 +1263,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
@ -4378,7 +4434,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TemplateId templateId=new TemplateId(templateApplySession.getTemplateData().getId());
TabularResourceId tabularResourceId=new TabularResourceId(new Long(templateApplySession.getTrId().getId()));
Task task=service.applyTemplate(templateId, tabularResourceId);
@ -4501,5 +4557,45 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public void startTemplateDelete(TemplateDeleteSession templateDeleteSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("startTemplateDelete: "+ templateDeleteSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TemplateId templateId;
for(TemplateData template: templateDeleteSession.getTemplates()){
templateId=new TemplateId(template.getId());
service.remove(templateId);
}
} catch (NoSuchTemplateException e) {
logger.debug("Error StartTemplateDelete: No such Template");
e.printStackTrace();
throw new TDGWTServiceException(
"Error StartTemplateDelete: No such Template");
} catch (Throwable e) {
logger.debug("Error StartTemplateDelete: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(
"Error StartTemplateDelete: "
+ e.getLocalizedMessage());
}
}
}

View File

@ -0,0 +1,36 @@
package org.gcube.portlets.user.td.gwtservice.shared.template;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Delete Template Session
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TemplateDeleteSession implements Serializable {
private static final long serialVersionUID = -8834066207159106968L;
protected ArrayList<TemplateData> templates;
public ArrayList<TemplateData> getTemplates() {
return templates;
}
public void setTemplates(ArrayList<TemplateData> templates) {
this.templates = templates;
}
@Override
public String toString() {
return "TemplateDeleteSession [templates=" + templates + "]";
}
}