Updated Task Resume added mapping

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@98638 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-15 11:04:59 +00:00
parent 7f26a7c2fc
commit 45bb3c033b
2 changed files with 74 additions and 28 deletions

View File

@ -165,6 +165,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSessi
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnViewData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCodeMap;
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
import org.gcube.portlets.user.td.gwtservice.shared.tr.RefColumn;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
@ -185,6 +186,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnMonit
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.mapping.ColumnMappingData;
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.groupby.GroupByMonitor;
@ -1103,19 +1105,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Table table = service.getLastTable(new TabularResourceId(Long
.valueOf(trId.getId())));
logger.debug("Table retrieved: "+table);
logger.debug("Table retrieved: " + table);
Table viewTable = null;
if (table.contains(DatasetViewTableMetadata.class)) {
DatasetViewTableMetadata dwm = table
.getMetadata(DatasetViewTableMetadata.class);
logger.debug("DatasetViewTableMetadata: "+dwm);
logger.debug("DatasetViewTableMetadata: " + dwm);
try {
viewTable = service.getTable(dwm
.getTargetDatasetViewTableId());
} catch (Exception e) {
logger.error("View table not found: "+e.getLocalizedMessage());
logger.error("View table not found: "
+ e.getLocalizedMessage());
}
} else {
logger.debug("Table not contains DataseViewTableMetadata");
@ -1126,12 +1129,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (viewTable == null) {
logger.debug("ViewTable is null");
newTRId=new TRId(trId.getId());
newTRId = new TRId(trId.getId());
newTRId.setTabularResourceType(trId.getTabularResourceType());
newTRId.setTableId(String.valueOf(table.getId().getValue()));
newTRId.setTableType(table.getTableType().getName());
newTRId.setViewTable(false);
logger.debug("NewTRId: "+newTRId);
logger.debug("NewTRId: " + newTRId);
tData.setTrId(newTRId);
tData.setName(table.getName());
@ -1187,14 +1190,14 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} else {
logger.debug("ViewTable is not null");
newTRId= new TRId(trId.getId());
newTRId = new TRId(trId.getId());
newTRId.setTabularResourceType(trId.getTabularResourceType());
newTRId.setTableId(String.valueOf(viewTable.getId().getValue()));
newTRId.setTableType(viewTable.getTableType().getName());
newTRId.setReferenceTargetTableId(String.valueOf(table.getId()
.getValue()));
newTRId.setViewTable(true);
logger.debug("NewTRId: "+newTRId);
logger.debug("NewTRId: " + newTRId);
tData.setTrId(newTRId);
tData.setName(viewTable.getName());
@ -1275,7 +1278,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("getTable(): "+trId);
logger.debug("getTable(): " + trId);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
@ -1305,7 +1308,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
newTRId.setTableId(String.valueOf(table.getId().getValue()));
newTRId.setTableType(table.getTableType().getName());
newTRId.setViewTable(false);
logger.debug("NewTRId: "+newTRId);
logger.debug("NewTRId: " + newTRId);
tData.setTrId(newTRId);
tData.setName(table.getName());
@ -1368,7 +1371,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
newTRId.setReferenceTargetTableId(String.valueOf(table.getId()
.getValue()));
newTRId.setViewTable(true);
logger.debug("NewTRId: "+newTRId);
logger.debug("NewTRId: " + newTRId);
tData.setTrId(newTRId);
tData.setName(viewTable.getName());
@ -7017,7 +7020,31 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskId taskId = new TaskId(taskResumeSession.getTaskId());
Task trTask = service.resubmit(taskId);
Map<String, Object> map = new HashMap<String, Object>();
ArrayList<ColumnMappingData> columnMapping = taskResumeSession
.getColumnMapping();
Task trTask;
if (columnMapping != null && columnMapping.size() > 0) {
HashMap<Long, Long> mapping = new HashMap<Long, Long>();
for (ColumnMappingData columnMappingData : columnMapping) {
if (columnMappingData.getSourceArg() != null
&& columnMappingData.getTargetArg() != null) {
DimensionRow source = columnMappingData.getSourceArg();
DimensionRow target = columnMappingData.getTargetArg();
mapping.put(new Long(source.getRowId()), new Long(
target.getRowId()));
}
}
map.put(Constants.PARAMETER_COLUMN_MAPPING, mapping);
trTask = service.resume(taskId,map);
} else {
trTask = service.resume(taskId);
}
logger.debug("Resume Task on service: TaskId " + trTask.getId());
SessionUtil.setTaskResumeTask(session, trTask);
return;

View File

@ -1,12 +1,15 @@
package org.gcube.portlets.user.td.gwtservice.shared.task;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.mapping.ColumnMappingData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TaskResumeSession implements Serializable {
@ -15,14 +18,23 @@ public class TaskResumeSession implements Serializable {
protected TRId trId;
protected String taskId;
protected ArrayList<ColumnMappingData> columnMapping;
public TaskResumeSession(){
public TaskResumeSession() {
}
public TaskResumeSession(TRId trId, String taskId){
this.trId=trId;
this.taskId=taskId;
public TaskResumeSession(TRId trId, String taskId) {
this.trId = trId;
this.taskId = taskId;
this.columnMapping = null;
}
public TaskResumeSession(TRId trId, String taskId,
ArrayList<ColumnMappingData> columnMapping) {
this.trId = trId;
this.taskId = taskId;
this.columnMapping = columnMapping;
}
public TRId getTrId() {
@ -41,13 +53,20 @@ public class TaskResumeSession implements Serializable {
this.taskId = taskId;
}
public ArrayList<ColumnMappingData> getColumnMapping() {
return columnMapping;
}
public void setColumnMapping(ArrayList<ColumnMappingData> columnMapping) {
this.columnMapping = columnMapping;
}
@Override
public String toString() {
return "TaskResumeSession [trId=" + trId + ", taskId=" + taskId + "]";
return "TaskResumeSession [trId=" + trId + ", taskId=" + taskId
+ ", columnMapping=" + columnMapping + "]";
}
}