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.CSVFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession; 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.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.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;

View File

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

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution; package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId; 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.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.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -37,24 +39,32 @@ public class OpExecution4LabelColumn extends OpExecutionBuilder {
@Override @Override
public void buildOpEx() throws TDGWTServiceException { public void buildOpEx() throws TDGWTServiceException {
OperationExecution invocation = null; logger.debug("LabelColumnSession :" + labelColumnSession);
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
logger.debug(labelColumnSession.toString()); HashMap<ColumnData, String> columnsMaps = labelColumnSession.getMaps();
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
ImmutableLocalizedText localizedText = new ImmutableLocalizedText( for (ColumnData key : columnsMaps.keySet()) {
labelColumnSession.getLabel()); OperationExecution invocation = null;
map.put(Constants.NAME_PARAMETER_ID, localizedText); OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
operationDefinition = OperationDefinitionMap.map( ImmutableLocalizedText localizedText = new ImmutableLocalizedText(
OperationsId.ColumnNameAdd.toString(), service); columnsMaps.get(key));
invocation = new OperationExecution(labelColumnSession.getColumnData() map.put(Constants.NAME_PARAMETER_ID, localizedText);
.getColumnId(), operationDefinition.getOperationId(), map);
operationDefinition = OperationDefinitionMap.map(
operationExecutionSpec.setOp(invocation); 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; package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class LabelColumnSession implements Serializable { public class LabelColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L; private static final long serialVersionUID = -1896235499708614266L;
protected ColumnData columnData; protected TRId trId;
protected String label; protected HashMap<ColumnData, String> maps;
public LabelColumnSession() {
public String getLabel() {
return label;
} }
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 @Override
public String toString() { public String toString() {
return "LabelColumnSession [columnData=" + columnData + ", label=" return "LabelColumnSession [trId=" + trId + ", maps=" + maps + "]";
+ label + "]";
} }
} }