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:
parent
12fc60cd34
commit
62c590c405
|
@ -347,14 +347,25 @@ public interface TDGWTService extends RemoteService {
|
||||||
public void startSDMXExport(SDMXExportSession exportSession)
|
public void startSDMXExport(SDMXExportSession exportSession)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
|
||||||
// Change Column Type
|
// Change Column Type
|
||||||
|
|
||||||
// Monitor
|
/**
|
||||||
|
* Get Operation Monitor during the Change Column Type operation
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
public ChangeColumnTypeMonitor getChangeColumnTypeMonitor()
|
public ChangeColumnTypeMonitor getChangeColumnTypeMonitor()
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
// Change Column to Measure
|
/**
|
||||||
public void startChangeToMeasureColumn(
|
* Start change column type
|
||||||
|
*
|
||||||
|
* @param changeColumnTypeSession
|
||||||
|
* @throws TDGWTServiceException
|
||||||
|
*/
|
||||||
|
public void startChangeColumnType(
|
||||||
ChangeColumnTypeSession changeColumnTypeSession) throws TDGWTServiceException;
|
ChangeColumnTypeSession changeColumnTypeSession) throws TDGWTServiceException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,6 @@ public interface TDGWTServiceAsync {
|
||||||
|
|
||||||
//Change Column Type
|
//Change Column Type
|
||||||
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
|
void getChangeColumnTypeMonitor(AsyncCallback<ChangeColumnTypeMonitor> callback);
|
||||||
void startChangeToMeasureColumn(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
|
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback<Void> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* @param changeColumnTypeSession
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected Map<String, Object> retrieveChangeColumnTypeParameters(
|
protected OperationExecution retriveOperationExecution(
|
||||||
ChangeColumnTypeSession changeColumnTypeSession) {
|
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>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
if (changeColumnTypeSession.getColumnTypeCodeTarget().compareTo(
|
||||||
ColumnTypeCode.MEASURE) == 0) {
|
ColumnTypeCode.MEASURE) == 0) {
|
||||||
|
operationDefinition = getOperationDescriptorWithId(
|
||||||
|
OperationsId.ChangeToMeasureColumn.toString(), capabilities);
|
||||||
|
|
||||||
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
|
map.put(Constants.PARAMETER_DATA_TYPE, ColumnDataTypeMap
|
||||||
.map(changeColumnTypeSession.getColumnDataType()));
|
.map(changeColumnTypeSession.getColumnDataType()));
|
||||||
map.put(Constants.PARAMETER_DATA_TYPE_TARGET, ColumnDataTypeMap
|
map.put(Constants.PARAMETER_DATA_TYPE_TARGET, ColumnDataTypeMap
|
||||||
.map(changeColumnTypeSession.getColumnDataTypeTarget()));
|
.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}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void startChangeToMeasureColumn(
|
public void startChangeColumnType(
|
||||||
ChangeColumnTypeSession changeColumnTypeSession)
|
ChangeColumnTypeSession changeColumnTypeSession)
|
||||||
throws TDGWTServiceException {
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
|
@ -2138,22 +2210,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
OperationExecution invocation = retriveOperationExecution(service,
|
||||||
|
changeColumnTypeSession);
|
||||||
OperationDefinition changeToMeasureColumnOperation = getOperationDescriptorWithId(
|
if(invocation==null){
|
||||||
OperationsId.ChangeToMeasureColumn.toString(), capabilities);
|
throw new TDGWTServiceException("Error in ChangeColumnType: Operation not supported for now!");
|
||||||
|
}
|
||||||
logger.debug(changeColumnTypeSession.toString());
|
|
||||||
|
|
||||||
Map<String, Object> parameterInstance = retrieveChangeColumnTypeParameters(changeColumnTypeSession);
|
|
||||||
|
|
||||||
OperationExecution invocation = new OperationExecution(
|
|
||||||
changeColumnTypeSession.getColumnData().getName(),
|
|
||||||
changeToMeasureColumnOperation.getOperationId(),
|
|
||||||
parameterInstance);
|
|
||||||
|
|
||||||
TabularResourceId serviceTR = new TabularResourceId(
|
TabularResourceId serviceTR = new TabularResourceId(
|
||||||
Long.valueOf(changeColumnTypeSession.getColumnData().getTrId().getId()));
|
Long.valueOf(changeColumnTypeSession.getColumnData()
|
||||||
|
.getTrId().getId()));
|
||||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||||
Task trTask = service.execute(invocation, serviceTR);
|
Task trTask = service.execute(invocation, serviceTR);
|
||||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||||
|
@ -2161,7 +2226,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new TDGWTServiceException("Error in ChangeToMeasureColumn: "
|
throw new TDGWTServiceException("Error in ChangeColumnType: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2216,7 +2281,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
||||||
Table table = task.getResult().getPrimaryTable();
|
Table table = task.getResult().getPrimaryTable();
|
||||||
logger.debug("Table retrived: " + table.toString());
|
logger.debug("Table retrived: " + table.toString());
|
||||||
TRId trId = new TRId();
|
TRId trId = new TRId();
|
||||||
trId.setId(changeColumnTypeSession.getColumnData().getTrId().getId());
|
trId.setId(changeColumnTypeSession.getColumnData()
|
||||||
|
.getTrId().getId());
|
||||||
trId.setTableId(String
|
trId.setTableId(String
|
||||||
.valueOf(table.getId().getValue()));
|
.valueOf(table.getId().getValue()));
|
||||||
trId.setTableType(table.getTableType().getName());
|
trId.setTableType(table.getTableType().getName());
|
||||||
|
|
Loading…
Reference in New Issue