Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@97609 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-06-20 15:49:30 +00:00
parent 53ffaf35da
commit cf26fb2986
1 changed files with 177 additions and 157 deletions

View File

@ -360,11 +360,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTabularResource(new TabularResourceId(Long
.valueOf(currentTR.getTrId().getId())));
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
currentTR.setValid(tr.isValid());
currentTR.setFinalized(tr.isFinalized());
Contacts owner=new Contacts("", tr.getOwner(), false);
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
SessionUtil.setTabResource(session, currentTR);
logger.debug("GetTabResourceInformation() updated information:"
@ -422,7 +421,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
currentTR.setDate(sdf.format(tr.getCreationDate().getTime()));
currentTR.setValid(tr.isValid());
currentTR.setFinalized(tr.isFinalized());
Contacts owner=new Contacts("", tr.getOwner(), false);
Contacts owner = new Contacts("", tr.getOwner(), false);
currentTR.setOwner(owner);
logger.debug("GetTabResourceInformation() updated information:"
@ -1492,7 +1491,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
t.setTrId(trId);
t.setValid(tr.isValid());
t.setFinalized(tr.isFinalized());
Contacts owner=new Contacts("", tr.getOwner(), false);
Contacts owner = new Contacts("", tr.getOwner(), false);
t.setOwner(owner);
if (tr.contains(NameMetadata.class)) {
@ -2561,16 +2560,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the session: null");
}
FileUploadMonitor fileUploadMonitor= SessionUtil
FileUploadMonitor fileUploadMonitor = SessionUtil
.getFileUploadMonitor(session);
if (fileUploadMonitor == null) {
throw new TDGWTServiceException(
"Error retrieving the fileUploadMonitor: null");
}
logger.debug("FileUploadMonitor: "+fileUploadMonitor);
logger.debug("FileUploadMonitor: " + fileUploadMonitor);
return fileUploadMonitor;
}
@ -2987,9 +2984,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
FileUtil.setImportFileCSV(fileUploadSession, is, wi.getName(),
Constants.FILE_CSV_MIMETYPE);
} catch (Throwable e) {
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed(
"An error occured elaborating the file",
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the file",
FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
@ -3001,9 +2997,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
logger.trace("changing state");
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(
FileUploadState.COMPLETED);
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
fum.setState(FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
SessionUtil.setCSVFileUploadSession(session, fileUploadSession);
}
@ -4503,7 +4498,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularDataService service, SplitColumnSession splitColumnSession)
throws TDGWTServiceException {
ArrayList<OperationExecution> invocations=new ArrayList<OperationExecution>();
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
logger.debug(splitColumnSession.toString());
@ -4513,33 +4508,31 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Map<String, Object> map1 = new HashMap<String, Object>();
Map<String, Object> map2 = new HashMap<String, Object>();
ArrayList<Expression> expressions=splitColumnSession.getExpressions();
ArrayList<Expression> expressions = splitColumnSession.getExpressions();
if(expressions==null || expressions.size()<=1){
throw new TDGWTServiceException("No valid expressions in splitColumnSession");
if (expressions == null || expressions.size() <= 1) {
throw new TDGWTServiceException(
"No valid expressions in splitColumnSession");
}
map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE,
ColumnTypeCodeMap.getColumnType(splitColumnSession.getFirstSplitColumnType()));
map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE,
ColumnDataTypeMap.map(splitColumnSession.getFirstSplitColumnDataType()));
map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap
.getColumnType(splitColumnSession.getFirstSplitColumnType()));
map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap
.map(splitColumnSession.getFirstSplitColumnDataType()));
map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(splitColumnSession.getLabel1()));
map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
expressions.get(0));
invocations.add(new OperationExecution(
operationDefinition.getOperationId(), map1));
map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE,
ColumnTypeCodeMap.getColumnType(splitColumnSession.getSecondSplitColumnType()));
map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE,
ColumnDataTypeMap.map(splitColumnSession.getSecondSplitColumnDataType()));
map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expressions.get(0));
invocations.add(new OperationExecution(operationDefinition
.getOperationId(), map1));
map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap
.getColumnType(splitColumnSession.getSecondSplitColumnType()));
map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap
.map(splitColumnSession.getSecondSplitColumnDataType()));
map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(splitColumnSession.getLabel2()));
map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
expressions.get(1));
invocations.add(new OperationExecution(
operationDefinition.getOperationId(), map2));
map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expressions.get(1));
invocations.add(new OperationExecution(operationDefinition
.getOperationId(), map2));
return invocations;
}
@ -4564,24 +4557,22 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Map<String, Object> map = new HashMap<String, Object>();
Expression expression =mergeColumnSession.getExpression();
if(expression==null){
throw new TDGWTServiceException("No valid expression in splitColumnSession");
Expression expression = mergeColumnSession.getExpression();
if (expression == null) {
throw new TDGWTServiceException(
"No valid expression in splitColumnSession");
}
map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE,
ColumnTypeCodeMap.getColumnType(mergeColumnSession.getMergeColumnType()));
map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE,
ColumnDataTypeMap.map(mergeColumnSession.getMergeColumnDataType()));
map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap
.getColumnType(mergeColumnSession.getMergeColumnType()));
map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap
.map(mergeColumnSession.getMergeColumnDataType()));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(mergeColumnSession.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
expression);
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
return invocation;
}
@ -5954,7 +5945,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
String[] usersArray = users.toArray(new String[0]);
logger.debug("Share with Users: " + users);
service.share(serviceTR, usersArray);
service.share(serviceTR, usersArray);
} catch (TDGWTSessionExpiredException e) {
throw e;
@ -5967,6 +5958,38 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
public boolean checkTabularResourceNotFinal(TRId trId)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("checkTabularResourceNotFinal: " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
new Long(trId.getId()));
TabularResource tr = service.getTabularResource(tabularResourceId);
return tr.isFinalized();
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(e.getLocalizedMessage());
} catch (Throwable e) {
logger.debug("Error in checkTabularResourceNotFinal: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(
"Error in checkTabularResourceNotFinal: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -7451,7 +7474,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setTaskResubmitTask(session, trTask);
return;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
@ -7556,8 +7578,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("TaskResubmitMonitor(): " + taskResubmitMonitor);
return taskResubmitMonitor;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
@ -7868,10 +7888,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
// TODO
public void startSplitColumn(SplitColumnSession splitColumnSession, HttpSession session)
throws TDGWTServiceException {
public void startSplitColumn(SplitColumnSession splitColumnSession,
HttpSession session) throws TDGWTServiceException {
try {
//HttpSession session = this.getThreadLocalRequest().getSession();
// HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setSplitColumnSession(session, splitColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (splitColumnSession == null) {
@ -7885,8 +7905,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
ArrayList<OperationExecution> invocations = retrieveOperationExecution(service,
splitColumnSession);
ArrayList<OperationExecution> invocations = retrieveOperationExecution(
service, splitColumnSession);
if (invocations == null) {
throw new TDGWTServiceException(
"Error in invocation: Operation not supported");
@ -7962,7 +7982,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Task Result:" + task.getResult());
splitColumnMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(splitColumnSession.getColumnData().getTrId().getId());
trId.setId(splitColumnSession.getColumnData().getTrId()
.getId());
trId = retrieveTabularResourceBasicData(trId);
splitColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
@ -7985,7 +8006,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
splitColumnMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(splitColumnSession
.getColumnData().getTrId());
.getColumnData().getTrId());
splitColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
@ -8016,10 +8037,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
// TODO
public void startMergeColumn(MergeColumnSession mergeColumnSession, HttpSession session)
throws TDGWTServiceException {
public void startMergeColumn(MergeColumnSession mergeColumnSession,
HttpSession session) throws TDGWTServiceException {
try {
//HttpSession session = this.getThreadLocalRequest().getSession();
// HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setMergeColumnSession(session, mergeColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (mergeColumnSession == null) {
@ -8110,7 +8131,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Task Result:" + task.getResult());
mergeColumnMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(mergeColumnSession.getColumnData().getTrId().getId());
trId.setId(mergeColumnSession.getColumnData().getTrId()
.getId());
trId = retrieveTabularResourceBasicData(trId);
mergeColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
@ -8131,8 +8153,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case STOPPED:
logger.debug("Task Result:" + task.getResult());
mergeColumnMonitor.setProgress(task.getProgress());
trId = retrieveTabularResourceBasicData(mergeColumnSession.getColumnData()
.getTrId());
trId = retrieveTabularResourceBasicData(mergeColumnSession
.getColumnData().getTrId());
mergeColumnMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
@ -8247,9 +8269,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
FileUtil.setImportFileCodelistMapping(fileUploadSession, is,
wi.getName(), Constants.FILE_XML_MIMETYPE);
} catch (Throwable e) {
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setFailed(
"An error occured elaborating the file",
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
fum.setFailed("An error occured elaborating the file",
FileUtil.exceptionDetailMessage(e));
SessionUtil.setFileUploadMonitor(session, fum);
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
@ -8262,9 +8283,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
logger.trace("changing state");
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
fum.setState(
FileUploadState.COMPLETED);
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
fum.setState(FileUploadState.COMPLETED);
SessionUtil.setFileUploadMonitor(session, fum);
SessionUtil.setCodelistMappingFileUploadSession(session,
@ -8296,15 +8316,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("StartCodelistMappingImport: "
+ codelistMappingSession.toString());
importCodelistMappingFileOnService(session, aslSession, user, codelistMappingSession);
importCodelistMappingFileOnService(session, aslSession, user,
codelistMappingSession);
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in Codelist Mapping import: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error in Codelist Mapping import: "
+ e.getLocalizedMessage());
}
}