diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index a0868d0..2197374 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -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; } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index f8930ba..f47ad8b 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -119,6 +119,6 @@ public interface TDGWTServiceAsync { //Change Column Type void getChangeColumnTypeMonitor(AsyncCallback callback); - void startChangeToMeasureColumn(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback callback); + void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession,AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 48a9a3d..a583b6f 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -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 retrieveChangeColumnTypeParameters( - ChangeColumnTypeSession changeColumnTypeSession) { + protected OperationExecution retriveOperationExecution( + TabularDataService service, + ChangeColumnTypeSession changeColumnTypeSession) + throws TDGWTServiceException { + OperationExecution invocation = null; + List capabilities = service.getCapabilities(); + + logger.debug(changeColumnTypeSession.toString()); + OperationDefinition operationDefinition; Map map = new HashMap(); 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 capabilities = service.getCapabilities(); - - OperationDefinition changeToMeasureColumnOperation = getOperationDescriptorWithId( - OperationsId.ChangeToMeasureColumn.toString(), capabilities); - - logger.debug(changeColumnTypeSession.toString()); - - Map 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());