Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@94934 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-16 17:10:31 +00:00
parent 69cb564bcb
commit 46bbb61583
3 changed files with 231 additions and 154 deletions

View File

@ -245,6 +245,15 @@ public interface TDGWTService extends RemoteService {
public RollBackSessionMonitor getRollBackMonitor()
throws TDGWTServiceException;
/**
* Call discard operation on tabular resource
*
* @param trId
* @throws TDGWTServiceException
*/
public RollBackSession discard(TRId trId)
throws TDGWTServiceException;
// Share
/**

View File

@ -103,6 +103,7 @@ public interface TDGWTServiceAsync {
//RollBack
void rollBack(RollBackSession rollBackSession,AsyncCallback<Void> callback);
void getRollBackMonitor(AsyncCallback<RollBackSessionMonitor> callback);
void discard(TRId trId,AsyncCallback<RollBackSession> callback);
//Share
void getShareInfo(TRId trId, AsyncCallback<ShareInfo> callback);

View File

@ -241,7 +241,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
@ -265,19 +265,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(
"CURRENT_TABULAR_RESOURCE has TRId null");
}
logger.debug("getCurrentTRId():"+currentTR.getTrId());
logger.debug("getCurrentTRId():" + currentTR.getTrId());
return currentTR.getTrId();
} catch (Throwable e) {
logger.error(
"getCurrentTRID(): "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error retrieving TR id: "
+ e.getLocalizedMessage());
logger.error("getCurrentTRID(): " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error retrieving TR id: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -422,12 +419,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
List<Column> cols = table.getColumns();
int i = 0;
//|| c.getColumnType() instanceof DimensionColumnType
//|| c.getColumnType() instanceof TimeDimensionColumnType
// || c.getColumnType() instanceof DimensionColumnType
// || c.getColumnType() instanceof TimeDimensionColumnType
for (Column c : cols) {
if (c.getColumnType() instanceof IdColumnType
|| c.getColumnType() instanceof ValidationColumnType
) {
|| c.getColumnType() instanceof ValidationColumnType) {
} else {
if (c.contains(ViewColumnMetadata.class)) {
@ -676,14 +672,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setLabel("nolabel");
logger.debug("ColumnLabel no label in en");
} else {
if (cl.getValue() == null
|| cl.getValue().isEmpty()) {
if (cl.getValue() == null || cl.getValue().isEmpty()) {
cData.setLabel("nolabel");
logger.debug("ColumnLabel no label in en");
} else {
cData.setLabel(cl.getValue());
logger.debug("Column Set Label: "
+ cl.getValue());
logger.debug("Column Set Label: " + cl.getValue());
}
}
}
@ -787,14 +781,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
cData.setLabel("nolabel");
logger.debug("ColumnLabel no label in en");
} else {
if (cl.getValue() == null
|| cl.getValue().isEmpty()) {
if (cl.getValue() == null || cl.getValue().isEmpty()) {
cData.setLabel("nolabel");
logger.debug("ColumnLabel no label in en");
} else {
cData.setLabel(cl.getValue());
logger.debug("Column Set Label: "
+ cl.getValue());
logger.debug("Column Set Label: " + cl.getValue());
}
}
}
@ -2888,14 +2880,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* @param trId
* @return
* @throws TDGWTServiceException
*/
public TabValidationsMetadata getTableValidationsMetadata(TRId trId)
public TabValidationsMetadata getTableValidationsMetadata(TRId trId)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
@ -2908,34 +2900,38 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId())));
TabValidationsMetadata tabValidationsMetadata=new TabValidationsMetadata();
if(table.contains(ValidationsMetadata.class)){
ValidationsMetadata validationsMetadata=table.getMetadata(ValidationsMetadata.class);
if(validationsMetadata!=null){
List<Validation> vals=validationsMetadata.getValidations();
if(vals!=null && vals.size()>0){
Validations valid=null;
ArrayList<Validations> vList=new ArrayList<Validations>();
int i=0;
for(Validation v:vals){
valid=new Validations(i,v.getDescription(),v.isValid());
TabValidationsMetadata tabValidationsMetadata = new TabValidationsMetadata();
if (table.contains(ValidationsMetadata.class)) {
ValidationsMetadata validationsMetadata = table
.getMetadata(ValidationsMetadata.class);
if (validationsMetadata != null) {
List<Validation> vals = validationsMetadata
.getValidations();
if (vals != null && vals.size() > 0) {
Validations valid = null;
ArrayList<Validations> vList = new ArrayList<Validations>();
int i = 0;
for (Validation v : vals) {
valid = new Validations(i, v.getDescription(),
v.isValid());
vList.add(valid);
i++;
}
tabValidationsMetadata.setValidations(vList);
}
}
}
}
logger.debug("TabValidationsMetadata: "+tabValidationsMetadata);
logger.debug("TabValidationsMetadata: " + tabValidationsMetadata);
return tabValidationsMetadata;
} catch (Throwable e) {
logger.error(
"Error in getTableValidationMetadata(): " + e.getLocalizedMessage(),
e);
throw new TDGWTServiceException("Error in getTableValidationMetadata: "
+ e.getLocalizedMessage());
"Error in getTableValidationMetadata(): "
+ e.getLocalizedMessage(), e);
throw new TDGWTServiceException(
"Error in getTableValidationMetadata: "
+ e.getLocalizedMessage());
}
}
@ -5738,8 +5734,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
@ -5758,42 +5753,47 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"CURRENT_TABULAR_RESOURCE is null");
}
TRId trId = currentTR.getTrId();
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
List<HistoryStep> history = tabularResource.getHistory();
long historyId = 0;
String opDesc=null, opName=null;
HistoryStep lastStep = null;
OpHistory op = null;
TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(trId.getId()));
TabularResource tabularResource=service.getTabularResource(tabularResourceId);
List<HistoryStep> history =tabularResource.getHistory();
OperationDefinition lastOp=null;
long historyId=0;
HistoryStep lastStep=null;
if(history!=null && history.size()>0){
lastStep=history.get(0);
historyId=lastStep.getId().getValue();
if(lastStep!=null){
lastOp=service.getCapability(lastStep.getOperationInvocation().getOperationId());
if (history != null && history.size() > 0) {
lastStep = history.get(0);
if (lastStep != null) {
opDesc = lastStep.getOperationDescription();
opName = opDesc;
historyId = lastStep.getId().getValue();
op = new OpHistory(historyId, opName,
opDesc, sdf.format(lastStep
.getExecutionDate().getTime()));
}
}
OpHistory op=null;
if(lastOp!=null){
op=new OpHistory(historyId,lastOp.getName(),lastOp.getDescription(),sdf.format(lastStep.getExecutionDate()));
}
logger.debug("Last Operation Info :" + op);
return op;
} catch (Throwable e) {
logger.debug("getLastOperationInfo(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error retrieving last operation info: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error retrieving last operation info: "
+ e.getLocalizedMessage());
}
}
/**
* {@inheritDoc}
*
@ -5805,29 +5805,34 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("getLastOperationInfo: "+trId);
logger.debug("getLastOperationInfo: " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(trId.getId()));
TabularResource tabularResource=service.getTabularResource(tabularResourceId);
List<HistoryStep> history =tabularResource.getHistory();
OperationDefinition lastOp=null;
long historyId=0;
HistoryStep lastStep=null;
if(history!=null && history.size()>0){
lastStep=history.get(0);
historyId=lastStep.getId().getValue();
if(lastStep!=null){
lastOp=service.getCapability(lastStep.getOperationInvocation().getOperationId());
List<HistoryStep> history = tabularResource.getHistory();
long historyId = 0;
String opDesc=null, opName=null;
HistoryStep lastStep = null;
OpHistory op = null;
if (history != null && history.size() > 0) {
lastStep = history.get(0);
if (lastStep != null) {
opDesc = lastStep.getOperationDescription();
opName = opDesc;
historyId = lastStep.getId().getValue();
op = new OpHistory(historyId, opName,
opDesc, sdf.format(lastStep
.getExecutionDate().getTime()));
}
}
OpHistory op=null;
if(lastOp!=null){
op=new OpHistory(historyId,lastOp.getName(),lastOp.getDescription(),sdf.format(lastStep.getExecutionDate()));
}
logger.debug("Last Operation Info :" + op);
return op;
@ -5835,11 +5840,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} catch (Throwable e) {
logger.debug("getLastOperationInfo(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error retrieving last operation info: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error retrieving last operation info: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -5858,29 +5864,35 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"CURRENT_TABULAR_RESOURCE is null");
}
TRId trId = currentTR.getTrId();
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
List<HistoryStep> history = tabularResource.getHistory();
ArrayList<OpHistory> opHistoryList = new ArrayList<OpHistory>();
TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(trId.getId()));
TabularResource tabularResource=service.getTabularResource(tabularResourceId);
List<HistoryStep> history =tabularResource.getHistory();
ArrayList<OpHistory> opHistoryList=new ArrayList<OpHistory>();
OperationDefinition lastOp=null;
long historyId=0;
OpHistory op=null;
for(HistoryStep step:history){
if(step!=null){
historyId=step.getId().getValue();
lastOp=service.getCapability(step.getOperationInvocation().getOperationId());
op=new OpHistory(historyId,lastOp.getName(),lastOp.getDescription(), sdf.format(step.getExecutionDate()));
long historyId = 0;
String opDesc=null, opName=null;
OpHistory op = null;
for (HistoryStep step : history) {
if (step != null) {
historyId = step.getId().getValue();
opDesc = step.getOperationDescription();
opName = step.getOperationDescription();
op = new OpHistory(historyId, opName,
opDesc, sdf.format(step
.getExecutionDate().getTime()));
opHistoryList.add(op);
}
}
logger.debug("History :" + opHistoryList);
return opHistoryList;
@ -5892,9 +5904,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
@ -5906,26 +5916,32 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("getHistory(): "+trId);
logger.debug("getHistory(): " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(trId.getId()));
TabularResource tabularResource=service.getTabularResource(tabularResourceId);
List<HistoryStep> history =tabularResource.getHistory();
ArrayList<OpHistory> opHistoryList=new ArrayList<OpHistory>();
OperationDefinition lastOp=null;
long historyId=0;
OpHistory op=null;
for(HistoryStep step:history){
if(step!=null){
historyId=step.getId().getValue();
lastOp=service.getCapability(step.getOperationInvocation().getOperationId());
op=new OpHistory(historyId,lastOp.getName(),lastOp.getDescription(), sdf.format(step.getExecutionDate()));
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
List<HistoryStep> history = tabularResource.getHistory();
ArrayList<OpHistory> opHistoryList = new ArrayList<OpHistory>();
long historyId = 0;
String opDesc=null, opName=null;
OpHistory op = null;
for (HistoryStep step : history) {
if (step != null) {
historyId = step.getId().getValue();
opDesc = step.getOperationDescription();
opName = step.getOperationDescription();
op = new OpHistory(historyId, opName,
opDesc, sdf.format(step
.getExecutionDate().getTime()));
opHistoryList.add(op);
}
}
@ -5940,12 +5956,68 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
*/
@Override
public RollBackSession discard(TRId trId) throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("discard(): " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
List<HistoryStep> history = tabularResource.getHistory();
long historyId = 0;
String opDesc=null, opName=null;
OpHistory op = null;
RollBackSession rollBackSession=null;
if (history != null) {
HistoryStep step = history.get(1);
if (step != null) {
historyId = step.getId().getValue();
opDesc= step.getOperationDescription();
opName= opDesc;
op = new OpHistory(historyId, opName,
opDesc, sdf.format(step
.getExecutionDate().getTime()));
logger.debug("Discard :"+op);
rollBackSession=new RollBackSession(trId,historyId);
rollBack(rollBackSession);
} else {
logger.debug("Discard : no previous step exist");
}
} else {
logger.debug("Discard : not present");
}
return rollBackSession;
} catch (Throwable e) {
logger.debug("discard(): " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("Error in discard: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
*/
@Override
public void rollBack(RollBackSession rollBackSession)
throws TDGWTServiceException {
@ -5953,23 +6025,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("rollBack(): "+rollBackSession);
logger.debug("rollBack(): " + rollBackSession);
SessionUtil.setRollBackSession(session, rollBackSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId=new TabularResourceId(Long.valueOf(rollBackSession.getTrId().getId()));
HistoryStepId historyStepId=new HistoryStepId(rollBackSession.getHistoryId());
Task trTask=service.rollbackTo(tabularResourceId, historyStepId);
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(rollBackSession.getTrId().getId()));
HistoryStepId historyStepId = new HistoryStepId(
rollBackSession.getHistoryId());
Task trTask = service.rollbackTo(tabularResourceId, historyStepId);
if (trTask == null) {
logger.error("Error on service Task null");
throw new TDGWTServiceException("Task not started");
}
logger.debug("Start Task on service: TaskId " + trTask.getId());
SessionUtil.setRollBackSessionTask(session, trTask);
SessionUtil.setRollBackSessionTask(session, trTask);
return;
} catch (Throwable e) {
@ -5979,8 +6053,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -6009,8 +6082,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
logger.debug("Services TaskStatus: " + task.getStatus());
rollBackMonitor.setStatus(TaskStateMap.map(task
.getStatus()));
rollBackMonitor
.setStatus(TaskStateMap.map(task.getStatus()));
TRId trId;
TabResource tabResource;
@ -6019,20 +6092,18 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
rollBackMonitor.setError(new Throwable(
task.getErrorCause()));
rollBackMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
logger.debug("Task exception: Error In RollBackSessionMonitor");
rollBackMonitor.setError(new Throwable(
"Error in roll back"));
}
rollBackMonitor.setProgress(task
.getProgress());
rollBackMonitor.setProgress(task.getProgress());
break;
case SUCCEDED:
logger.debug("Task Result:" + task.getResult());
rollBackMonitor.setProgress(task
.getProgress());
rollBackMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(rollBackSession.getTrId().getId());
@ -6045,21 +6116,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setTRId(session, trId);
break;
case IN_PROGRESS:
rollBackMonitor.setProgress(task
.getProgress());
rollBackMonitor.setProgress(task.getProgress());
break;
case VALIDATING_RULES:
rollBackMonitor.setProgress(task
.getProgress());
rollBackMonitor.setProgress(task.getProgress());
break;
case ABORTED:
break;
case STOPPED:
logger.debug("Task Result:" + task.getResult());
rollBackMonitor.setProgress(task
.getProgress());
trId = retrieveTabularResourceBasicData(rollBackSession.getTrId());
rollBackMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(rollBackSession
.getTrId());
rollBackMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
@ -6076,8 +6145,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setRollBackSessionTask(session, task);
}
logger.info("RollBackSessionMonitor(): "
+ rollBackMonitor);
logger.info("RollBackSessionMonitor(): " + rollBackMonitor);
return rollBackMonitor;
} catch (Throwable e) {
logger.debug("Error in RollBackSessionMonitor: "
@ -6090,5 +6158,4 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}