Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@93418 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-21 13:22:29 +00:00
parent cce2146b7c
commit 7b76183b3e
2 changed files with 213 additions and 9 deletions

View File

@ -22,6 +22,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
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.template.TemplateApplyMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
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;
@ -104,7 +106,10 @@ public class SessionUtil {
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 TEMPLATE_APPLY_SESSION = "TEMPLATE_APPLY_SESSION";
protected static final String TEMPLATE_APPLY_MONITOR = "TEMPLATE_APPLY_MONITOR";
protected static final String TEMPLATE_APPLY_TASK = "TEMPLATE_APPLY_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";
@ -912,6 +917,69 @@ public class SessionUtil {
//
public static TemplateApplySession getTemplateApplySession(HttpSession httpSession) {
TemplateApplySession templateApplySession = (TemplateApplySession) httpSession
.getAttribute(TEMPLATE_APPLY_SESSION);
if (templateApplySession != null) {
return templateApplySession;
} else {
templateApplySession = new TemplateApplySession();
httpSession.setAttribute(TEMPLATE_APPLY_SESSION, templateApplySession);
return templateApplySession;
}
}
public static void setTemplateApplySession(HttpSession httpSession,
TemplateApplySession templateApplySession) {
TemplateApplySession dr = (TemplateApplySession) httpSession
.getAttribute(TEMPLATE_APPLY_SESSION);
if (dr != null) {
httpSession.removeAttribute(TEMPLATE_APPLY_SESSION);
}
httpSession.setAttribute(TEMPLATE_APPLY_SESSION, templateApplySession);
}
public static TemplateApplyMonitor getTemplateApplyMonitor(HttpSession httpSession) {
TemplateApplyMonitor templateApplyMonitor = (TemplateApplyMonitor) httpSession
.getAttribute(TEMPLATE_APPLY_MONITOR);
if (templateApplyMonitor != null) {
return templateApplyMonitor;
} else {
templateApplyMonitor = new TemplateApplyMonitor();
httpSession.setAttribute(TEMPLATE_APPLY_MONITOR, templateApplyMonitor);
return templateApplyMonitor;
}
}
public static void setTemplateApplyMonitor(HttpSession httpSession,
TemplateApplyMonitor templateApplyMonitor) {
TemplateApplyMonitor d = (TemplateApplyMonitor) httpSession
.getAttribute(TEMPLATE_APPLY_MONITOR);
if (d != null) {
httpSession.removeAttribute(TEMPLATE_APPLY_MONITOR);
}
httpSession.setAttribute(TEMPLATE_APPLY_MONITOR, templateApplyMonitor);
}
public static Task getTemplateApplyTask(HttpSession httpSession) {
Task monitor = (Task) httpSession.getAttribute(TEMPLATE_APPLY_TASK);
if (monitor == null) {
logger.error("TEMPLATE_APPLY_TASK was not acquired");
}
return monitor;
}
public static void setTemplateApplyTask(HttpSession httpSession, Task task) {
Task monitor = (Task) httpSession.getAttribute(TEMPLATE_APPLY_TASK);
if (monitor != null)
httpSession.removeAttribute(TEMPLATE_APPLY_TASK);
httpSession.setAttribute(TEMPLATE_APPLY_TASK, task);
}
//
public static DuplicatesSession getDuplicatesSession(HttpSession httpSession) {
DuplicatesSession duplicatesSession = (DuplicatesSession) httpSession
.getAttribute(DUPLICATES_ROWS_SESSION);
@ -973,6 +1041,9 @@ public class SessionUtil {
httpSession.setAttribute(DUPLICATES_ROWS_TASK, task);
}
//
//
public static ArrayList<TabResource> getCodelistsPagingLoaded(

View File

@ -74,6 +74,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionM
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.TabularResourceMetadata;
import org.gcube.data.analysis.tabulardata.service.template.TemplateId;
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor;
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType;
import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor;
@ -4321,7 +4322,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public ArrayList<TemplateData> getTemplates() throws TDGWTServiceException {
try {
@ -4357,16 +4362,144 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
public TemplateApplyMonitor getTemplateApplyMonitor() throws TDGWTServiceException {
// TODO Auto-generated method stub
return null;
}
public void startTemplateApply(TemplateApplySession templateApplySession) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("startTemplateApply: "+ templateApplySession);
SessionUtil.setTemplateApplySession(session, templateApplySession);
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);
logger.debug("startTemplateApply task start");
SessionUtil.setTemplateApplyTask(session, task);
} catch (Throwable e) {
logger.debug("Error StartTemplateApply: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(
"Error StartTemplateApply: "
+ e.getLocalizedMessage());
}
@Override
public void startTemplateApply(TemplateApplySession applyTemplateSession) throws TDGWTServiceException {
// TODO Auto-generated method stub
}
/**
*
* {@inheritDoc}
*/
@Override
public TemplateApplyMonitor getTemplateApplyMonitor() throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
TemplateApplySession templateApplySession = SessionUtil
.getTemplateApplySession(session);
Task task = SessionUtil.getTemplateApplyTask(session);
TemplateApplyMonitor templateApplyMonitor = new TemplateApplyMonitor();
if (task == null) {
logger.debug("Task null");
throw new TDGWTServiceException(
"Error in TemplateApplyMonitor task null");
} else {
TaskStatus status = task.getStatus();
if (status == null) {
logger.debug("Services TaskStatus : null");
throw new TDGWTServiceException(
"Error in TemplateApplyMonitor Status null");
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
templateApplyMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
TRId trId;
TabResource tabResource;
switch (templateApplyMonitor.getStatus()) {
case FAILED:
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
templateApplyMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In TemplateApplyMonitor");
templateApplyMonitor.setError(new Throwable(
"Error in operation applying template"));
}
templateApplyMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
templateApplyMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(templateApplySession.getTrId().getId());
retrieveTabularResourceBasicData(trId);
templateApplyMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
templateApplyMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
templateApplyMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
templateApplyMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(templateApplySession.getTrId().getId());
retrieveTabularResourceBasicData(trId);
templateApplyMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
default:
break;
}
}
SessionUtil.setTemplateApplyTask(session, task);
}
logger.info("TemplateApplyMonitor(): " + templateApplyMonitor);
return templateApplyMonitor;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Error in monitor DuplicatesMonitor: "
+ e.getLocalizedMessage());
}
}
}