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 359d80e..4146c83 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 @@ -215,6 +215,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeMap; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.slf4j.Logger; @@ -4142,7 +4143,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ColumnTypeCodeMap.getColumnType(defNewColumn .getColumnType())); map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataType.Text); + ColumnDataTypeMap.map(ColumnDataType.Text)); map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, new ImmutableLocalizedText(defNewColumn.getLabel())); map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, @@ -4155,7 +4156,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap.getColumnType(defNewColumn .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap.map(defNewColumn.getColumnDataType())); map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, new ImmutableLocalizedText(defNewColumn.getLabel())); @@ -4170,7 +4171,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ColumnTypeCodeMap.getColumnType(defNewColumn .getColumnType())); map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataType.Text); + ColumnDataTypeMap.map(ColumnDataType.Text)); map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, new ImmutableLocalizedText(defNewColumn.getLabel())); map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, @@ -4184,7 +4185,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ColumnTypeCodeMap.getColumnType(defNewColumn .getColumnType())); map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataType.Text); + ColumnDataTypeMap.map(ColumnDataType.Text)); map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, new ImmutableLocalizedText(defNewColumn.getLabel())); map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, @@ -4198,7 +4199,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ColumnTypeCodeMap.getColumnType(defNewColumn .getColumnType())); map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, - ColumnDataType.Text); + ColumnDataTypeMap.map(ColumnDataType.Text)); map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, new ImmutableLocalizedText(defNewColumn.getLabel())); map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, @@ -4208,16 +4209,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements operationDefinition.getOperationId(), map); break; case DIMENSION: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); break; case MEASURE: map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, @@ -4234,16 +4225,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements operationDefinition.getOperationId(), map); break; case TIMEDIMENSION: - map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, - ColumnTypeCodeMap.getColumnType(defNewColumn - .getColumnType())); - map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, - new ImmutableLocalizedText(defNewColumn.getLabel())); - map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, - TDTypeValueMap.map(ColumnDataType.Text, - defNewColumn.getDefaultValue())); - invocation = new OperationExecution( - operationDefinition.getOperationId(), map); break; default: break; @@ -4439,25 +4420,174 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements * @return * @throws TDGWTServiceException */ - protected OperationExecution retrieveOperationExecution( + protected ArrayList retrieveOperationExecution( TabularDataService service, SplitColumnSession splitColumnSession) throws TDGWTServiceException { - - OperationExecution invocation = null; + + ArrayList invocations=new ArrayList(); logger.debug(splitColumnSession.toString()); - /* - * OperationDefinition operationDefinition; Map map = - * new HashMap(); - * - * operationDefinition = OperationDefinitionMap.map( - * OperationsId.Col.toString(), service); map.put(Constants., - * splitColumnSession .getTableType().toString()); - * - * invocation = new OperationExecution( - * operationDefinition.getOperationId(), map); - */ - return invocation; + + OperationDefinition operationDefinition = OperationDefinitionMap.map( + OperationsId.AddColumn.toString(), service); + + Map map1 = new HashMap(); + Map map2 = new HashMap(); + + ColumnData columnData=splitColumnSession.getColumnData(); + + ColumnTypeCode type = ColumnTypeMap.getColumnTypeCode(columnData.getTypeCode()); + ColumnDataType dataType =ColumnTypeMap.getColumnDataType(columnData.getDataTypeName()); + ArrayList expressions=splitColumnSession.getExpressions(); + + if(expressions==null || expressions.size()<=1){ + throw new TDGWTServiceException("No valid expressions in splitColumnSession"); + } + + switch (type) { + case ANNOTATION: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + + break; + case ATTRIBUTE: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + break; + case CODE: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + break; + case CODEDESCRIPTION: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + break; + case CODENAME: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + break; + case DIMENSION: + break; + case MEASURE: + map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map1.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel1())); + map1.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(0)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map1)); + map2.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map2.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(splitColumnSession.getLabel2())); + map2.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expressions.get(1)); + invocations.add(new OperationExecution( + operationDefinition.getOperationId(), map2)); + break; + case TIMEDIMENSION: + break; + default: + break; + + } + + return invocations; } /** @@ -4474,17 +4604,105 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements OperationExecution invocation = null; logger.debug(mergeColumnSession.toString()); - /* - * OperationDefinition operationDefinition; Map map = - * new HashMap(); - * - * operationDefinition = OperationDefinitionMap.map( - * OperationsId.Col.toString(), service); map.put(Constants., - * splitColumnSession .getTableType().toString()); - * - * invocation = new OperationExecution( - * operationDefinition.getOperationId(), map); - */ + + OperationDefinition operationDefinition = OperationDefinitionMap.map( + OperationsId.AddColumn.toString(), service); + + Map map = new HashMap(); + + ColumnData columnData=mergeColumnSession.getColumnData(); + + ColumnTypeCode type = ColumnTypeMap.getColumnTypeCode(columnData.getTypeCode()); + ColumnDataType dataType =ColumnTypeMap.getColumnDataType(columnData.getDataTypeName()); + + Expression expression =mergeColumnSession.getExpression(); + if(expression==null){ + throw new TDGWTServiceException("No valid expression in splitColumnSession"); + } + + switch (type) { + case ANNOTATION: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case ATTRIBUTE: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case CODE: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case CODEDESCRIPTION: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case CODENAME: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(ColumnDataType.Text)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case DIMENSION: + break; + case MEASURE: + map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, + ColumnTypeCodeMap.getColumnType(type)); + map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, + ColumnDataTypeMap.map(dataType)); + map.put(Constants.PARAMETER_ADD_COLUMN_LABEL, + new ImmutableLocalizedText(mergeColumnSession.getLabel())); + map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, + expression); + invocation = new OperationExecution( + operationDefinition.getOperationId(), map); + break; + case TIMEDIMENSION: + break; + default: + break; + + } + + return invocation; } @@ -7695,9 +7913,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements aslSession.getUsername())); TabularDataService service = TabularDataServiceFactory.getService(); - OperationExecution invocation = retrieveOperationExecution(service, + ArrayList invocations = retrieveOperationExecution(service, splitColumnSession); - if (invocation == null) { + if (invocations == null) { throw new TDGWTServiceException( "Error in invocation: Operation not supported"); } @@ -7705,8 +7923,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements .getId()); TabularResourceId serviceTR = new TabularResourceId(id); - logger.debug("OperationInvocation: \n" + invocation.toString()); - Task trTask = service.execute(invocation, serviceTR); + logger.debug("OperationInvocation: \n" + invocations.toString()); + Task trTask = service.executeBatch(invocations, serviceTR); logger.debug("Split Column on service: TaskId " + trTask.getId()); SessionUtil.setSplitColumnTask(session, trTask); return;