Updated Change Column Label

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99385 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-02 10:12:37 +00:00
parent 2c6fe8920e
commit ff386c26c1
4 changed files with 68 additions and 47 deletions

View File

@ -17,6 +17,7 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;

View File

@ -3683,6 +3683,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
*
* {@inheritDoc}
*/
//TODO
public String startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException {
try {
@ -3700,23 +3702,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
OperationExecution invocation = director.getOperationExecution();
List<OperationExecution> invocations = director
.getListOperationExecution();
if (invocation == null) {
throw new TDGWTServiceException(
"Error Changing the Column Label: Operation not supported for now!");
if (invocations == null) {
throw new TDGWTServiceException("Operation not supported");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(labelColumnSession.getColumnData().getTrId()
Long.valueOf(labelColumnSession.getTrId()
.getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("OperationInvocation: \n" + invocations);
Task trTask = service.executeBatch(invocations, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeColumnLabel, labelColumnSession
.getColumnData().getTrId());
.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
return trTask.getId().getValue();

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@ -11,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitio
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,24 +39,32 @@ public class OpExecution4LabelColumn extends OpExecutionBuilder {
@Override
public void buildOpEx() throws TDGWTServiceException {
OperationExecution invocation = null;
logger.debug("LabelColumnSession :" + labelColumnSession);
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
logger.debug(labelColumnSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
HashMap<ColumnData, String> columnsMaps = labelColumnSession.getMaps();
ImmutableLocalizedText localizedText = new ImmutableLocalizedText(
labelColumnSession.getLabel());
for (ColumnData key : columnsMaps.keySet()) {
OperationExecution invocation = null;
map.put(Constants.NAME_PARAMETER_ID, localizedText);
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
operationDefinition = OperationDefinitionMap.map(
OperationsId.ColumnNameAdd.toString(), service);
ImmutableLocalizedText localizedText = new ImmutableLocalizedText(
columnsMaps.get(key));
invocation = new OperationExecution(labelColumnSession.getColumnData()
.getColumnId(), operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation);
map.put(Constants.NAME_PARAMETER_ID, localizedText);
operationDefinition = OperationDefinitionMap.map(
OperationsId.ColumnNameAdd.toString(), service);
invocation = new OperationExecution(key.getColumnId(),
operationDefinition.getOperationId(), map);
invocations.add(invocation);
}
operationExecutionSpec.setOps(invocations);
}

View File

@ -1,43 +1,53 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
import java.io.Serializable;
import java.util.HashMap;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class LabelColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected ColumnData columnData;
protected String label;
public String getLabel() {
return label;
protected TRId trId;
protected HashMap<ColumnData, String> maps;
public LabelColumnSession() {
}
public void setLabel(String label) {
this.label = label;
public LabelColumnSession(TRId trId, HashMap<ColumnData, String> maps) {
super();
this.trId = trId;
this.maps = maps;
}
public ColumnData getColumnData() {
return columnData;
public TRId getTrId() {
return trId;
}
public void setColumnData(ColumnData columnData) {
this.columnData = columnData;
public void setTrId(TRId trId) {
this.trId = trId;
}
public HashMap<ColumnData, String> getMaps() {
return maps;
}
public void setMaps(HashMap<ColumnData, String> maps) {
this.maps = maps;
}
@Override
public String toString() {
return "LabelColumnSession [columnData=" + columnData + ", label="
+ label + "]";
return "LabelColumnSession [trId=" + trId + ", maps=" + maps + "]";
}
}