Updated change column type

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@91004 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-07 09:03:28 +00:00
parent 12fc60cd34
commit 62c590c405
3 changed files with 104 additions and 27 deletions

View File

@ -347,14 +347,25 @@ public interface TDGWTService extends RemoteService {
public void startSDMXExport(SDMXExportSession exportSession)
throws TDGWTServiceException;
// Change Column Type
// Monitor
/**
* Get Operation Monitor during the Change Column Type operation
*
* @return
* @throws TDGWTServiceException
*/
public ChangeColumnTypeMonitor getChangeColumnTypeMonitor()
throws TDGWTServiceException;
// Change Column to Measure
public void startChangeToMeasureColumn(
/**
* Start change column type
*
* @param changeColumnTypeSession
* @throws TDGWTServiceException
*/
public void startChangeColumnType(
ChangeColumnTypeSession changeColumnTypeSession) throws TDGWTServiceException;
}

View File

@ -119,6 +119,6 @@ public interface TDGWTServiceAsync {
//Change Column Type
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
void startChangeToMeasureColumn(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
}

View File

@ -2100,32 +2100,104 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
* Retrive parameters for change column type operation
* Retrieve OperationExecution for change column type
*
* @param changeColumnTypeSession
* @return
*/
protected Map<String, Object> retrieveChangeColumnTypeParameters(
ChangeColumnTypeSession changeColumnTypeSession) {
protected OperationExecution retriveOperationExecution(
TabularDataService service,
ChangeColumnTypeSession changeColumnTypeSession)
throws TDGWTServiceException {
OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(changeColumnTypeSession.toString());
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.MEASURE) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToMeasureColumn.toString(), capabilities);
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataType()));
map.put(Constants.PARAMETER_DATA_TYPE_TARGET, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataTypeTarget()));
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(), map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.ATTRIBUTE) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToAttributeColumn.toString(), capabilities);
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataType()));
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(), map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.CODE) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToCodeColumn.toString(), capabilities);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(),map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.CODENAME) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToCodeName.toString(), capabilities);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(),map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.CODEDESCRIPTION) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToCodeDescription.toString(), capabilities);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(),map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.ANNOTATION) == 0) {
operationDefinition = getOperationDescriptorWithId(
OperationsId.ChangeToAnnotationColumn.toString(), capabilities);
invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getName(),
operationDefinition.getOperationId(),map);
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.DIMENSION) == 0) {
} else {
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
ColumnTypeCode.TIMEDIMENSION) == 0) {
} else {
}
}
}
}
}
}
}
}
return map;
};
return invocation;
}
/**
*
* {@inheritDoc}
*/
public void startChangeToMeasureColumn(
public void startChangeColumnType(
ChangeColumnTypeSession changeColumnTypeSession)
throws TDGWTServiceException {
try {
@ -2138,22 +2210,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
OperationDefinition changeToMeasureColumnOperation = getOperationDescriptorWithId(
OperationsId.ChangeToMeasureColumn.toString(), capabilities);
logger.debug(changeColumnTypeSession.toString());
Map<String, Object> parameterInstance = retrieveChangeColumnTypeParameters(changeColumnTypeSession);
OperationExecution invocation = new OperationExecution(
changeColumnTypeSession.getColumnData().getName(),
changeToMeasureColumnOperation.getOperationId(),
parameterInstance);
OperationExecution invocation = retriveOperationExecution(service,
changeColumnTypeSession);
if(invocation==null){
throw new TDGWTServiceException("Error in ChangeColumnType: Operation not supported for now!");
}
TabularResourceId serviceTR = new TabularResourceId(
Long.valueOf(changeColumnTypeSession.getColumnData().getTrId().getId()));
Long.valueOf(changeColumnTypeSession.getColumnData()
.getTrId().getId()));
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR);
logger.debug("Start Task on service: TaskId " + trTask.getId());
@ -2161,7 +2226,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return;
} catch (Exception e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in ChangeToMeasureColumn: "
throw new TDGWTServiceException("Error in ChangeColumnType: "
+ e.getLocalizedMessage());
}
@ -2216,7 +2281,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Table table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
TRId trId = new TRId();
trId.setId(changeColumnTypeSession.getColumnData().getTrId().getId());
trId.setId(changeColumnTypeSession.getColumnData()
.getTrId().getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());