Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@111606 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-02-03 09:53:51 +00:00
parent 05bab63e7f
commit a62a11db11
4 changed files with 72 additions and 59 deletions

View File

@ -6685,7 +6685,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskS taskS = new TaskS(task.getId().getValue(),
task.getProgress(), state, task.getErrorCause(),
task.getSubmitter(), task.getStartTime(),
task.getEndTime(), jobSList, collateralTRIds);
task.getEndTime(), jobSList, collateralTRIds, null);
taskSList.add(taskS);
}

View File

@ -201,7 +201,7 @@ public class BackgroundOperationMonitorCreator {
.getTask().getSubmitter(), taskWrapper.getTask()
.getStartTime(),
taskWrapper.getTask().getEndTime(), jobSList,
collateralTRIds);
collateralTRIds, String.valueOf(taskWrapper.getTask().getTabularResourceId().getValue()));
} catch (Throwable e) {
logger.error("error retrieving information about the task, "

View File

@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory;
*/
public class OperationMonitorCreator {
private static final String SECURITY_EXCEPTION_RIGHTS = "Security exception, you don't have the required rights!";
private static Logger logger = LoggerFactory
.getLogger(OperationMonitorCreator.class);
@ -59,15 +59,12 @@ public class OperationMonitorCreator {
"yyyy-MM-dd HH:mm");
@SuppressWarnings("unused")
private static SimpleDateFormat sdfDate = new SimpleDateFormat(
"yyyy-MM-dd");
private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
private HttpSession session;
private TaskWrapper taskWrapper;
private OperationMonitorSession operationMonitorSession;
private ASLSession aslSession;
/**
*
@ -82,10 +79,7 @@ public class OperationMonitorCreator {
this.aslSession = aslSession;
this.taskWrapper = taskWrapper;
this.operationMonitorSession = operationMonitorSession;
}
/**
@ -155,7 +149,7 @@ public class OperationMonitorCreator {
return operationMonitor;
}
protected TaskS createTaskS() throws TDGWTServiceException {
protected TaskS createTaskS() throws TDGWTServiceException {
TaskS taskS = new TaskS();
ArrayList<JobS> jobSList = new ArrayList<JobS>();
@ -185,31 +179,36 @@ public class OperationMonitorCreator {
}
try {
ArrayList<TRId> collateralTRIds=new ArrayList<TRId>();
TaskResult taskResult=taskWrapper.getTask().getResult();
if(taskResult!=null){
List<TableId> collaterals=taskResult.getCollateralTables();
for(TableId tId:collaterals){
String tabulRId=retrieveTabularResourceIdFromTable(tId);
TRId tabularRId=new TRId(tabulRId);
ArrayList<TRId> collateralTRIds = new ArrayList<TRId>();
TaskResult taskResult = taskWrapper.getTask().getResult();
if (taskResult != null) {
List<TableId> collaterals = taskResult.getCollateralTables();
for (TableId tId : collaterals) {
String tabulRId = retrieveTabularResourceIdFromTable(tId);
TRId tabularRId = new TRId(tabulRId);
tabularRId.setTableId(String.valueOf(tId.getValue()));
collateralTRIds.add(tabularRId);
}
}
taskS = new TaskS(taskWrapper.getTask().getId().getValue(),
taskWrapper.getTask().getProgress(),
TaskStateMap.map(taskWrapper.getTask().getStatus()),
taskWrapper.getTask().getErrorCause(), taskWrapper
.getTask().getSubmitter(), taskWrapper.getTask()
.getStartTime(),
taskWrapper.getTask().getEndTime(), jobSList, collateralTRIds);
taskWrapper.getTask().getEndTime(), jobSList,
collateralTRIds, String.valueOf(taskWrapper.getTask()
.getTabularResourceId().getValue()));
} catch (Throwable e) {
logger.error("error retrieving information about the task, "+e.getLocalizedMessage());
logger.error("error retrieving information about the task, "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException("error retrieving information about the task, "+e.getLocalizedMessage());
throw new TDGWTServiceException(
"error retrieving information about the task, "
+ e.getLocalizedMessage());
}
logger.debug("Retrieved task information");
return taskS;
@ -260,7 +259,7 @@ public class OperationMonitorCreator {
Table table;
TabExportMetadata trExportMetadata;
ExportMetadata exportMetadata;
switch (taskWrapper.getOperationId()) {
case CSVExport:
table = taskWrapper.getTask().getResult().getPrimaryTable();
@ -293,7 +292,7 @@ public class OperationMonitorCreator {
logger.debug("ExportMetadata: " + exportMetadata);
operationMonitor.setTrId(SessionUtil.getTRId(session));
trExportMetadata = new TabExportMetadata();
trExportMetadata.setUrl(exportMetadata.getUri());
trExportMetadata.setDestinationType(exportMetadata
@ -302,8 +301,8 @@ public class OperationMonitorCreator {
.getExportDate()));
saveJSONExportInDestination(exportMetadata);
break;
case CSVImport:
break;
case CSVImport:
trId = new TRId();
trId.setId(taskWrapper.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
@ -320,9 +319,9 @@ public class OperationMonitorCreator {
SessionUtil.setTabResource(session, tabResource);
}
SessionUtil.setTRId(session, trId);
SessionUtil.addToCurrentTabularResourcesOpen(session,tabResource);
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
break;
case SDMXImport:
case SDMXImport:
trId = new TRId();
trId.setId(taskWrapper.getTrId().getId());
trId = retrieveTabularResourceBasicData(trId);
@ -339,8 +338,8 @@ public class OperationMonitorCreator {
SessionUtil.setTabResource(session, tabResource);
}
SessionUtil.setTRId(session, trId);
SessionUtil.addToCurrentTabularResourcesOpen(session,tabResource);
break;
SessionUtil.addToCurrentTabularResourcesOpen(session, tabResource);
break;
case Clone:
trId = new TRId();
trId.setId(taskWrapper.getTrId().getId());
@ -386,7 +385,7 @@ public class OperationMonitorCreator {
logger.error("Tabular Resource Null [id=" + trId.getId() + "]");
throw new TDGWTServiceException("Tabular Resource Null " + trId);
}
//logger.debug("Retrieve Tabular Resource Basic Data: "+tr);
// logger.debug("Retrieve Tabular Resource Basic Data: "+tr);
Table table = service.getLastTable(tabularResourceId);
if (table == null) {
@ -409,14 +408,18 @@ public class OperationMonitorCreator {
TRId newTRId;
if (viewTable == null) {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
newTRId = new TRId(
String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
} else {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
newTRId = new TRId(
String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
.getName(), String.valueOf(table.getId()
.getValue()), true);
@ -429,8 +432,7 @@ public class OperationMonitorCreator {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
SECURITY_EXCEPTION_RIGHTS);
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error Retrieving Basic Data: "
@ -483,8 +485,7 @@ public class OperationMonitorCreator {
"Error in export csv: no destination present");
}
}
/**
* Save export json data on Workspace
*
@ -530,14 +531,14 @@ public class OperationMonitorCreator {
"Error in export json: no destination present");
}
}
private String retrieveTabularResourceIdFromTable(
TableId tableId) throws TDGWTServiceException {
private String retrieveTabularResourceIdFromTable(TableId tableId)
throws TDGWTServiceException {
try {
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
Table table = service.getTable(tableId);
if (table.contains(TableDescriptorMetadata.class)) {
@ -555,6 +556,5 @@ public class OperationMonitorCreator {
}
}
}

View File

@ -15,15 +15,16 @@ public class TaskS implements Serializable {
private static final long serialVersionUID = 8228657333318157153L;
protected String id;
protected float progress;
protected State state;
protected Throwable errorCause;
protected String submitter;
protected Date startTime;
protected Date endTime;
protected ArrayList<JobS> jobs;
protected ArrayList<TRId> collateralTRIds;
private String id;
private float progress;
private State state;
private Throwable errorCause;
private String submitter;
private Date startTime;
private Date endTime;
private ArrayList<JobS> jobs;
private ArrayList<TRId> collateralTRIds;
private String tabularResourceId;
public TaskS() {
@ -40,11 +41,12 @@ public class TaskS implements Serializable {
* @param endTime
* @param jobs
* @param collateralTRIds
* @param tabularResourceId TODO
*
*/
public TaskS(String id, float progress, State state, Throwable errorCause,
String submitter, Date startTime, Date endTime,
ArrayList<JobS> jobs, ArrayList<TRId> collateralTRIds) {
ArrayList<JobS> jobs, ArrayList<TRId> collateralTRIds, String tabularResourceId) {
this.id = id;
this.progress = progress;
this.state = state;
@ -54,6 +56,7 @@ public class TaskS implements Serializable {
this.endTime = endTime;
this.jobs = jobs;
this.collateralTRIds = collateralTRIds;
this.tabularResourceId=tabularResourceId;
}
public String getId() {
@ -127,6 +130,14 @@ public class TaskS implements Serializable {
public void setCollateralTRIds(ArrayList<TRId> collateralTRIds) {
this.collateralTRIds = collateralTRIds;
}
public String getTabularResourceId() {
return tabularResourceId;
}
public void setTabularResourceId(String tabularResourceId) {
this.tabularResourceId = tabularResourceId;
}
@Override
public String toString() {
@ -134,7 +145,9 @@ public class TaskS implements Serializable {
+ state + ", errorCause=" + errorCause + ", submitter="
+ submitter + ", startTime=" + startTime + ", endTime="
+ endTime + ", jobs=" + jobs + ", collateralTRIds="
+ collateralTRIds + "]";
+ collateralTRIds + ", tabularResourceId=" + tabularResourceId
+ "]";
}
}