Added Split and Merge Operations
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96333 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a99b5a602d
commit
93149de235
|
@ -94,4 +94,15 @@ public class SessionConstants {
|
|||
protected static final String EXTRACT_CODELIST_MONITOR = "EXTRACT_CODELIST_MONITOR";
|
||||
protected static final String EXTRACT_CODELIST_TASK = "EXTRACT_CODELIST_TASK";
|
||||
|
||||
protected static final String SPLIT_COLUMN_SESSION = "SPLIT_COLUMN_SESSION";
|
||||
protected static final String SPLIT_COLUMN_MONITOR = "SPLIT_COLUMN_MONITOR";
|
||||
protected static final String SPLIT_COLUMN_TASK = "SPLIT_COLUMN_TASK";
|
||||
|
||||
protected static final String MERGE_COLUMN_SESSION = "MERGE_COLUMN_SESSION";
|
||||
protected static final String MERGE_COLUMN_MONITOR = "MERGE_COLUMN_MONITOR";
|
||||
protected static final String MERGE_COLUMN_TASK = "MERGE_COLUMN_TASK";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,8 +42,12 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.SplitColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.SplitColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession;
|
||||
|
@ -1608,7 +1612,138 @@ public class SessionUtil {
|
|||
httpSession.setAttribute(SessionConstants.EXTRACT_CODELIST_TASK, task);
|
||||
}
|
||||
|
||||
//
|
||||
public static SplitColumnSession getSplitColumnSession(
|
||||
HttpSession httpSession) {
|
||||
SplitColumnSession splitColumnSession = (SplitColumnSession) httpSession
|
||||
.getAttribute(SessionConstants.SPLIT_COLUMN_SESSION);
|
||||
if (splitColumnSession != null) {
|
||||
return splitColumnSession;
|
||||
} else {
|
||||
splitColumnSession = new SplitColumnSession();
|
||||
httpSession
|
||||
.setAttribute(SessionConstants.SPLIT_COLUMN_SESSION, splitColumnSession);
|
||||
return splitColumnSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSplitColumnSession(HttpSession httpSession,
|
||||
SplitColumnSession splitColumnSession) {
|
||||
SplitColumnSession sc = (SplitColumnSession) httpSession
|
||||
.getAttribute(SessionConstants.SPLIT_COLUMN_SESSION);
|
||||
if (sc != null) {
|
||||
httpSession.removeAttribute(SessionConstants.SPLIT_COLUMN_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.SPLIT_COLUMN_SESSION, splitColumnSession);
|
||||
|
||||
}
|
||||
|
||||
public static SplitColumnMonitor getSplitColumnMonitor(
|
||||
HttpSession httpSession) {
|
||||
SplitColumnMonitor splitColumnMonitor = (SplitColumnMonitor) httpSession
|
||||
.getAttribute(SessionConstants.SPLIT_COLUMN_MONITOR);
|
||||
if (splitColumnMonitor != null) {
|
||||
return splitColumnMonitor;
|
||||
} else {
|
||||
splitColumnMonitor = new SplitColumnMonitor();
|
||||
httpSession
|
||||
.setAttribute(SessionConstants.SPLIT_COLUMN_MONITOR, splitColumnMonitor);
|
||||
return splitColumnMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSplitColumnMonitor(HttpSession httpSession,
|
||||
SplitColumnMonitor splitColumnMonitor) {
|
||||
SplitColumnMonitor sm = (SplitColumnMonitor) httpSession
|
||||
.getAttribute(SessionConstants.SPLIT_COLUMN_MONITOR);
|
||||
if (sm != null) {
|
||||
httpSession.removeAttribute(SessionConstants.SPLIT_COLUMN_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.SPLIT_COLUMN_MONITOR, splitColumnMonitor);
|
||||
|
||||
}
|
||||
|
||||
public static Task getSplitColumnTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.SPLIT_COLUMN_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("SPLIT_COLUMN_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setSplitColumnTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.SPLIT_COLUMN_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(SessionConstants.SPLIT_COLUMN_TASK);
|
||||
httpSession.setAttribute(SessionConstants.SPLIT_COLUMN_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static MergeColumnSession getMergeColumnSession(
|
||||
HttpSession httpSession) {
|
||||
MergeColumnSession mergeColumnSession = (MergeColumnSession) httpSession
|
||||
.getAttribute(SessionConstants.MERGE_COLUMN_SESSION);
|
||||
if (mergeColumnSession != null) {
|
||||
return mergeColumnSession;
|
||||
} else {
|
||||
mergeColumnSession = new MergeColumnSession();
|
||||
httpSession
|
||||
.setAttribute(SessionConstants.MERGE_COLUMN_SESSION, mergeColumnSession);
|
||||
return mergeColumnSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMergeColumnSession(HttpSession httpSession,
|
||||
MergeColumnSession splitColumnSession) {
|
||||
MergeColumnSession mc = (MergeColumnSession) httpSession
|
||||
.getAttribute(SessionConstants.MERGE_COLUMN_SESSION);
|
||||
if (mc != null) {
|
||||
httpSession.removeAttribute(SessionConstants.MERGE_COLUMN_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.MERGE_COLUMN_SESSION, splitColumnSession);
|
||||
|
||||
}
|
||||
|
||||
public static MergeColumnMonitor getMergeColumnMonitor(
|
||||
HttpSession httpSession) {
|
||||
MergeColumnMonitor mergeColumnMonitor = (MergeColumnMonitor) httpSession
|
||||
.getAttribute(SessionConstants.MERGE_COLUMN_MONITOR);
|
||||
if (mergeColumnMonitor != null) {
|
||||
return mergeColumnMonitor;
|
||||
} else {
|
||||
mergeColumnMonitor = new MergeColumnMonitor();
|
||||
httpSession
|
||||
.setAttribute(SessionConstants.MERGE_COLUMN_MONITOR, mergeColumnMonitor);
|
||||
return mergeColumnMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMergeColumnMonitor(HttpSession httpSession,
|
||||
MergeColumnMonitor mergeColumnMonitor) {
|
||||
MergeColumnMonitor sm = (MergeColumnMonitor) httpSession
|
||||
.getAttribute(SessionConstants.MERGE_COLUMN_MONITOR);
|
||||
if (sm != null) {
|
||||
httpSession.removeAttribute(SessionConstants.MERGE_COLUMN_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.MERGE_COLUMN_MONITOR, mergeColumnMonitor);
|
||||
|
||||
}
|
||||
|
||||
public static Task getMergeColumnTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.MERGE_COLUMN_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("MERGE_COLUMN_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setMergeColumnTask(HttpSession httpSession, Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(SessionConstants.MERGE_COLUMN_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(SessionConstants.MERGE_COLUMN_TASK);
|
||||
httpSession.setAttribute(SessionConstants.MERGE_COLUMN_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -167,8 +167,12 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonito
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.SplitColumnMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.SplitColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeMonitor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.type.ChangeColumnTypeSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.metadata.TRAgencyMetadata;
|
||||
|
@ -389,7 +393,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
.getTrId());
|
||||
updateTabResourceInformation(currentTR, trMetadatas);
|
||||
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
@ -3946,9 +3949,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @param replaceColumnSession
|
||||
* @return
|
||||
*/
|
||||
//TODO
|
||||
// TODO
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service, ExtractCodelistSession extractCodelistSession)
|
||||
TabularDataService service,
|
||||
ExtractCodelistSession extractCodelistSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
OperationExecution invocation = null;
|
||||
|
@ -3961,7 +3965,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
ArrayList<Map<String, Object>> compositeValue = extractMap
|
||||
.genMap(extractCodelistSession);
|
||||
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.ExtractCodelist.toString(), service);
|
||||
|
||||
|
@ -3973,7 +3976,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve OperationExecution for change column type
|
||||
*
|
||||
|
@ -4103,7 +4105,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
//TODO
|
||||
// TODO
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service, AddColumnSession addColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -4115,18 +4117,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
OperationsId.AddColumn.toString(), service);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
|
||||
DefNewColumn col = addColumnSession.getColumn();
|
||||
|
||||
OperationExecution invocation = null;
|
||||
|
||||
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param service
|
||||
|
@ -4278,6 +4278,68 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param service
|
||||
* @param changeTableTypeSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service,
|
||||
SplitColumnSession splitColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
OperationExecution invocation = null;
|
||||
|
||||
logger.debug(splitColumnSession.toString());
|
||||
/*
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.Col.toString(), service);
|
||||
map.put(Constants., splitColumnSession
|
||||
.getTableType().toString());
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
*/
|
||||
return invocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param service
|
||||
* @param changeTableTypeSession
|
||||
* @return
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service,
|
||||
MergeColumnSession mergeColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
OperationExecution invocation = null;
|
||||
|
||||
logger.debug(mergeColumnSession.toString());
|
||||
/*
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.Col.toString(), service);
|
||||
map.put(Constants., splitColumnSession
|
||||
.getTableType().toString());
|
||||
|
||||
invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
*/
|
||||
return invocation;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param service
|
||||
|
@ -4474,7 +4536,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
//TODO
|
||||
// TODO
|
||||
public void startAddColumn(AddColumnSession addColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
|
@ -4486,8 +4548,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
OperationExecution invocation = retrieveOperationExecution(
|
||||
service, addColumnSession);
|
||||
OperationExecution invocation = retrieveOperationExecution(service,
|
||||
addColumnSession);
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error Add Column: Operation not supported for now!");
|
||||
|
@ -4514,8 +4576,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AddColumnMonitor getAddColumnMonitor()
|
||||
throws TDGWTServiceException {
|
||||
public AddColumnMonitor getAddColumnMonitor() throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
AddColumnSession addColumnSession = SessionUtil
|
||||
|
@ -4621,9 +4682,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -5652,7 +5710,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
TabularResource tr = service.getTabularResource(tabularResourceId);
|
||||
|
||||
|
||||
if (tabResource.getName() != null) {
|
||||
NameMetadata name = new NameMetadata(tabResource.getName());
|
||||
tr.setMetadata(name);
|
||||
|
@ -5676,8 +5733,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
tr.setMetadata(rights);
|
||||
}
|
||||
|
||||
if(tabResource.isFinalized()){
|
||||
if(!tr.isFinalized()){
|
||||
if (tabResource.isFinalized()) {
|
||||
if (!tr.isFinalized()) {
|
||||
tr.finalize();
|
||||
}
|
||||
}
|
||||
|
@ -7176,7 +7233,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
// TODO
|
||||
@Override
|
||||
public void startTaskResume(TaskResumeSession taskResumeSession)
|
||||
throws TDGWTServiceException {
|
||||
|
@ -7320,14 +7377,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
// TODO
|
||||
@Override
|
||||
public void startExtractCodelist(
|
||||
ExtractCodelistSession extractCodelistSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setExtractCodelistSession(session, extractCodelistSession);
|
||||
SessionUtil.setExtractCodelistSession(session,
|
||||
extractCodelistSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
if (extractCodelistSession == null) {
|
||||
logger.error("ExtractCodelistSession is null");
|
||||
|
@ -7346,12 +7404,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
throw new TDGWTServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
}
|
||||
Long id= Long.valueOf(extractCodelistSession.getTrId().getId());
|
||||
Long id = Long.valueOf(extractCodelistSession.getTrId().getId());
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(id);
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, serviceTR);
|
||||
logger.debug("Extract Codelist on service: TaskId " + trTask.getId());
|
||||
logger.debug("Extract Codelist on service: TaskId "
|
||||
+ trTask.getId());
|
||||
SessionUtil.setExtractCodelistTask(session, trTask);
|
||||
return;
|
||||
|
||||
|
@ -7466,4 +7525,292 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void startSplitColumn(SplitColumnSession splitColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setSplitColumnSession(session, splitColumnSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
if (splitColumnSession == null) {
|
||||
logger.error("SplitColumnSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in split column: SplitColumnSession is null");
|
||||
}
|
||||
|
||||
logger.debug("StartSplitColumn: " + splitColumnSession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
OperationExecution invocation = retrieveOperationExecution(service,
|
||||
splitColumnSession);
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
}
|
||||
Long id = Long.valueOf(splitColumnSession.getColumnData().getTrId()
|
||||
.getId());
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(id);
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, serviceTR);
|
||||
logger.debug("Split Column on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setSplitColumnTask(session, trTask);
|
||||
return;
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in split column: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SplitColumnMonitor getSplitColumnMonitor()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ExtractCodelistSession extractCodelistSession = SessionUtil
|
||||
.getExtractCodelistSession(session);
|
||||
|
||||
Task task = SessionUtil.getSplitColumnTask(session);
|
||||
SplitColumnMonitor splitColumnMonitor = new SplitColumnMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in SplitColumnMonitor task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in SplitColumnMonitor Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
splitColumnMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
|
||||
TRId trId;
|
||||
TabResource tabResource;
|
||||
switch (splitColumnMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
task.getErrorCause().printStackTrace();
|
||||
splitColumnMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In SplitColumnMonitor");
|
||||
splitColumnMonitor.setError(new Throwable(
|
||||
"Error task resume"));
|
||||
}
|
||||
splitColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
splitColumnMonitor.setProgress(task.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(extractCodelistSession.getTrId().getId());
|
||||
trId = retrieveTabularResourceBasicData(trId);
|
||||
splitColumnMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
splitColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
splitColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case GENERATING_VIEW:
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
splitColumnMonitor.setProgress(task.getProgress());
|
||||
|
||||
trId = retrieveTabularResourceBasicData(extractCodelistSession
|
||||
.getTrId());
|
||||
|
||||
splitColumnMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SessionUtil.setSplitColumnTask(session, task);
|
||||
}
|
||||
|
||||
logger.debug("SplitColumnMonitor(): " + splitColumnMonitor);
|
||||
return splitColumnMonitor;
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in SplitColumnMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void startMergeColumn(MergeColumnSession mergeColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.setMergeColumnSession(session, mergeColumnSession);
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
if (mergeColumnSession == null) {
|
||||
logger.error("MergeColumnSession is null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in split column: MergeColumnSession is null");
|
||||
}
|
||||
|
||||
logger.debug("StartMergeColumn: " + mergeColumnSession);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
OperationExecution invocation = retrieveOperationExecution(service,
|
||||
mergeColumnSession);
|
||||
if (invocation == null) {
|
||||
throw new TDGWTServiceException(
|
||||
"Error in invocation: Operation not supported");
|
||||
}
|
||||
Long id = Long.valueOf(mergeColumnSession.getColumnData().getTrId()
|
||||
.getId());
|
||||
|
||||
TabularResourceId serviceTR = new TabularResourceId(id);
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
Task trTask = service.execute(invocation, serviceTR);
|
||||
logger.debug("Merge Column on service: TaskId " + trTask.getId());
|
||||
SessionUtil.setMergeColumnTask(session, trTask);
|
||||
return;
|
||||
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in split column: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MergeColumnMonitor getMergeColumnMonitor()
|
||||
throws TDGWTServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ExtractCodelistSession extractCodelistSession = SessionUtil
|
||||
.getExtractCodelistSession(session);
|
||||
|
||||
Task task = SessionUtil.getMergeColumnTask(session);
|
||||
MergeColumnMonitor mergeColumnMonitor = new MergeColumnMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in MergeColumnMonitor task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in MergeColumnMonitor Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
mergeColumnMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
|
||||
TRId trId;
|
||||
TabResource tabResource;
|
||||
switch (mergeColumnMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
task.getErrorCause().printStackTrace();
|
||||
mergeColumnMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In MergeColumnMonitor");
|
||||
mergeColumnMonitor.setError(new Throwable(
|
||||
"Error task resume"));
|
||||
}
|
||||
mergeColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
mergeColumnMonitor.setProgress(task.getProgress());
|
||||
trId = new TRId();
|
||||
trId.setId(extractCodelistSession.getTrId().getId());
|
||||
trId = retrieveTabularResourceBasicData(trId);
|
||||
mergeColumnMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
mergeColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
mergeColumnMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case GENERATING_VIEW:
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
mergeColumnMonitor.setProgress(task.getProgress());
|
||||
|
||||
trId = retrieveTabularResourceBasicData(extractCodelistSession
|
||||
.getTrId());
|
||||
|
||||
mergeColumnMonitor.setTrId(trId);
|
||||
tabResource = SessionUtil.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
SessionUtil.setMergeColumnTask(session, task);
|
||||
}
|
||||
|
||||
logger.debug("MergeColumnMonitor(): " + mergeColumnMonitor);
|
||||
return mergeColumnMonitor;
|
||||
} catch (TDGWTSessionExpiredException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.debug("Error in MergeColumnMonitor: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error: " + e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,8 +28,26 @@ public class DefNewColumn implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For Attribute Column
|
||||
* For Code, CodeDescription and Annotation Column
|
||||
*
|
||||
* @param label
|
||||
* @param columnType
|
||||
* @param localeName
|
||||
* @param defaultValue
|
||||
*/
|
||||
public DefNewColumn(String label, ColumnTypeCode columnType,
|
||||
String defaultValue) {
|
||||
this.label = label;
|
||||
this.columnType = columnType;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For Attribute and Measure Column
|
||||
*
|
||||
* @param label
|
||||
* @param columnType
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MergeColumnMonitor extends OperationMonitor implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -7694151843138161474L;
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MergeColumnSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1896235499708614266L;
|
||||
|
||||
protected ColumnData columnData;
|
||||
protected String value;
|
||||
protected Expression expression;
|
||||
|
||||
|
||||
public MergeColumnSession(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnData
|
||||
* @param value
|
||||
* @param expression
|
||||
*/
|
||||
public MergeColumnSession(ColumnData columnData, String value, Expression expression){
|
||||
this.columnData=columnData;
|
||||
this.value=value;
|
||||
this.expression=expression;
|
||||
|
||||
}
|
||||
|
||||
public ColumnData getColumnData() {
|
||||
return columnData;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnData(ColumnData columnData) {
|
||||
this.columnData = columnData;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public Expression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
|
||||
public void setExpression(Expression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MergeColumnSession [columnData=" + columnData + ", value="
|
||||
+ value + ", expression=" + expression + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.OperationMonitor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SplitColumnMonitor extends OperationMonitor implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -7694151843138161474L;
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SplitColumnSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1896235499708614266L;
|
||||
|
||||
protected ColumnData columnData;
|
||||
protected String value;
|
||||
protected Expression expression;
|
||||
|
||||
|
||||
public SplitColumnSession(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnData
|
||||
* @param value
|
||||
* @param expression
|
||||
*/
|
||||
public SplitColumnSession(ColumnData columnData, String value, Expression expression){
|
||||
this.columnData=columnData;
|
||||
this.value=value;
|
||||
this.expression=expression;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ColumnData getColumnData() {
|
||||
return columnData;
|
||||
}
|
||||
|
||||
|
||||
public void setColumnData(ColumnData columnData) {
|
||||
this.columnData = columnData;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public Expression getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
|
||||
public void setExpression(Expression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SplitColumnSession [columnData=" + columnData + ", value="
|
||||
+ value + ", expression=" + expression + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue