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");
@ -1123,15 +1126,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TableData tData = new TableData();
TRId newTRId;
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,16 +1190,16 @@ 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());
tData.setTypeName(viewTable.getTableType().getName());
tData.setTypeCode(viewTable.getTableType().getCode());
@ -1248,7 +1251,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
tData.setListColumnData(lColumnData);
}
logger.debug("getLastTable: " + tData);
return tData;
@ -1274,8 +1277,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
try {
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());
@ -5009,7 +5012,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TabularResource cloned = service.cloneTabularResource(serviceTR);
logger.debug("Clone: " + cloned.toString());
Table table = service.getLastTable(cloned.getId());
if (table == null) {
String report = "This tabular resource has not valid last table! (TR id="
+ cloned.getId() + ")";
@ -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,28 +1,40 @@
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 {
private static final long serialVersionUID = -4503878699159491057L;
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 + "]";
}
}