Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@95781 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-16 13:21:50 +00:00
parent c774265772
commit 837d70c6c4
2 changed files with 54 additions and 50 deletions

View File

@ -2179,12 +2179,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
aslSession.getUsername())); aslSession.getUsername()));
TabularDataService service = TabularDataServiceFactory.getService(); TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
// Import SDMX Codelist takes id 200 // Import SDMX Codelist takes id 200
OperationDefinition importSDMXCodelistOperation = OperationDefinitionMap OperationDefinition importSDMXCodelistOperation = OperationDefinitionMap
.map(OperationsId.SDMXCodelistImport.toString(), .map(OperationsId.SDMXCodelistImport.toString(),
capabilities); service);
TabResource sdmxImportTabResource = sdmxImportSession TabResource sdmxImportTabResource = sdmxImportSession
.getTabResource(); .getTabResource();
@ -2668,12 +2667,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getUsername())); .getUsername()));
TabularDataService service = TabularDataServiceFactory.getService(); TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
// Import CSV file // Import CSV file
OperationDefinition importCSVFileOperation = OperationDefinitionMap OperationDefinition importCSVFileOperation = OperationDefinitionMap
.map(OperationsId.CSVImport.toString(), capabilities); .map(OperationsId.CSVImport.toString(), service);
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(
importCSVFileOperation.getOperationId(), parameterInstance); importCSVFileOperation.getOperationId(), parameterInstance);
@ -3341,11 +3339,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getUsername())); .getUsername()));
TabularDataService service = TabularDataServiceFactory.getService(); TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
// Export SDMX Codelist // Export SDMX Codelist
OperationDefinition exportSDMXOperation = OperationDefinitionMap.map( OperationDefinition exportSDMXOperation = OperationDefinitionMap.map(
OperationsId.SDMXCodelistExport.toString(), capabilities); OperationsId.SDMXCodelistExport.toString(), service);
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(
exportSDMXOperation.getOperationId(), parameterInstance); exportSDMXOperation.getOperationId(), parameterInstance);
@ -3521,11 +3517,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getUsername())); .getUsername()));
TabularDataService service = TabularDataServiceFactory.getService(); TabularDataService service = TabularDataServiceFactory.getService();
List<OperationDefinition> capabilities = service.getCapabilities();
// Export CSV file // Export CSV file
OperationDefinition exportCSVFileOperation = OperationDefinitionMap OperationDefinition exportCSVFileOperation = OperationDefinitionMap
.map(OperationsId.CSVExport.toString(), capabilities); .map(OperationsId.CSVExport.toString(), service);
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(
exportCSVFileOperation.getOperationId(), parameterInstance); exportCSVFileOperation.getOperationId(), parameterInstance);
@ -3721,7 +3716,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(changeColumnTypeSession.toString()); logger.debug(changeColumnTypeSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -3733,7 +3728,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case ANNOTATION: case ANNOTATION:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToAnnotationColumn.toString(), OperationsId.ChangeToAnnotationColumn.toString(),
capabilities); service);
invocation = new OperationExecution(changeColumnTypeSession invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(), .getColumnData().getColumnId(),
operationDefinition.getOperationId(), map); operationDefinition.getOperationId(), map);
@ -3741,7 +3736,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case ATTRIBUTE: case ATTRIBUTE:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToAttributeColumn.toString(), OperationsId.ChangeToAttributeColumn.toString(),
capabilities); service);
map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataTypeTarget())); .map(changeColumnTypeSession.getColumnDataTypeTarget()));
@ -3751,7 +3746,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
break; break;
case CODE: case CODE:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToCodeColumn.toString(), capabilities); OperationsId.ChangeToCodeColumn.toString(), service);
invocation = new OperationExecution(changeColumnTypeSession invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(), .getColumnData().getColumnId(),
operationDefinition.getOperationId(), map); operationDefinition.getOperationId(), map);
@ -3759,7 +3754,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case CODEDESCRIPTION: case CODEDESCRIPTION:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToCodeDescription.toString(), OperationsId.ChangeToCodeDescription.toString(),
capabilities); service);
invocation = new OperationExecution(changeColumnTypeSession invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(), .getColumnData().getColumnId(),
operationDefinition.getOperationId(), map); operationDefinition.getOperationId(), map);
@ -3769,7 +3764,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
changeColumnTypeSession.getLocale()); changeColumnTypeSession.getLocale());
map.put(Constants.PARAMETER_ADDITIONAL_META, locale); map.put(Constants.PARAMETER_ADDITIONAL_META, locale);
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToCodeName.toString(), capabilities); OperationsId.ChangeToCodeName.toString(), service);
invocation = new OperationExecution(changeColumnTypeSession invocation = new OperationExecution(changeColumnTypeSession
.getColumnData().getColumnId(), .getColumnData().getColumnId(),
operationDefinition.getOperationId(), map); operationDefinition.getOperationId(), map);
@ -3777,7 +3772,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case DIMENSION: case DIMENSION:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToDimensionColumn.toString(), OperationsId.ChangeToDimensionColumn.toString(),
capabilities); service);
ColumnData col = changeColumnTypeSession ColumnData col = changeColumnTypeSession
.getCodelistColumnReference(); .getCodelistColumnReference();
logger.debug("ReferenceColumn To Set: " + col); logger.debug("ReferenceColumn To Set: " + col);
@ -3796,7 +3791,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case MEASURE: case MEASURE:
operationDefinition = OperationDefinitionMap operationDefinition = OperationDefinitionMap
.map(OperationsId.ChangeToMeasureColumn.toString(), .map(OperationsId.ChangeToMeasureColumn.toString(),
capabilities); service);
map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap map.put(Constants.PARAMETER_TARGET_DATA_TYPE, ColumnDataTypeMap
.map(changeColumnTypeSession.getColumnDataTypeTarget())); .map(changeColumnTypeSession.getColumnDataTypeTarget()));
@ -3807,7 +3802,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case TIMEDIMENSION: case TIMEDIMENSION:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeToTimeDimensionColumn.toString(), OperationsId.ChangeToTimeDimensionColumn.toString(),
capabilities); service);
map.put(Constants.PARAMETER_PERIOD_FORMAT, changeColumnTypeSession map.put(Constants.PARAMETER_PERIOD_FORMAT, changeColumnTypeSession
.getTimeDimensionType().toString()); .getTimeDimensionType().toString());
@ -3835,7 +3830,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(replaceColumnSession.toString()); logger.debug(replaceColumnSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -3845,7 +3839,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Is a Replace of view column"); logger.debug("Is a Replace of view column");
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(), OperationsId.ReplaceColumnByExpression.toString(),
capabilities); service);
Expression condition = ExpressionGenerator Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition(replaceColumnSession); .genReplaceValueParameterCondition(replaceColumnSession);
@ -3867,7 +3861,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(), OperationsId.ReplaceColumnByExpression.toString(),
capabilities); service);
Expression condition = ExpressionGenerator Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition(replaceColumnSession); .genReplaceValueParameterCondition(replaceColumnSession);
@ -3901,7 +3895,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(editRowSession.toString()); logger.debug(editRowSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -3914,7 +3907,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Is a add row"); logger.debug("Is a add row");
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.AddRow.toString(), OperationsId.AddRow.toString(),
capabilities); service);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue); compositeValue);
@ -3926,7 +3919,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.AddRow.toString(), OperationsId.AddRow.toString(),
capabilities); service);
map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE, map.put(Constants.PARAMETER_ADD_ROW_COMPOSITE,
compositeValue); compositeValue);
@ -3953,7 +3946,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
for (ReplaceEntry re : replaceBatchColumnSession.getReplaceEntryList()) { for (ReplaceEntry re : replaceBatchColumnSession.getReplaceEntryList()) {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(replaceBatchColumnSession.toString()); logger.debug(replaceBatchColumnSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -3963,7 +3956,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Is a Replace of view column"); logger.debug("Is a Replace of view column");
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(), OperationsId.ReplaceColumnByExpression.toString(),
capabilities); service);
Expression condition = ExpressionGenerator Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition( .genReplaceValueParameterCondition(
@ -3987,7 +3980,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceColumnByExpression.toString(), OperationsId.ReplaceColumnByExpression.toString(),
capabilities); service);
Expression condition = ExpressionGenerator Expression condition = ExpressionGenerator
.genReplaceValueParameterCondition( .genReplaceValueParameterCondition(
@ -4022,10 +4015,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
logger.debug(deleteColumnSession.toString()); logger.debug(deleteColumnSession.toString());
List<OperationDefinition> capabilities = service.getCapabilities();
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.RemoveColumn.toString(), capabilities); OperationsId.RemoveColumn.toString(), service);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>(); ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
@ -4053,7 +4046,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(duplicatesSession.toString()); logger.debug(duplicatesSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -4077,7 +4069,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case VALIDATE: case VALIDATE:
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.DuplicateTupleValidation.toString(), OperationsId.DuplicateTupleValidation.toString(),
capabilities); service);
map.put(Constants.PARAMETER_KEY, columnReferences); map.put(Constants.PARAMETER_KEY, columnReferences);
@ -4088,7 +4080,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
case DELETE: case DELETE:
operationDefinition = OperationDefinitionMap operationDefinition = OperationDefinitionMap
.map(OperationsId.RemoveDuplicateTuples.toString(), .map(OperationsId.RemoveDuplicateTuples.toString(),
capabilities); service);
map.put(Constants.PARAMETER_KEY, columnReferences); map.put(Constants.PARAMETER_KEY, columnReferences);
@ -4116,7 +4108,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(labelColumnSession.toString()); logger.debug(labelColumnSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -4128,7 +4119,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
map.put(Constants.NAME_PARAMETER_ID, localizedText); map.put(Constants.NAME_PARAMETER_ID, localizedText);
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ColumnNameAdd.toString(), capabilities); OperationsId.ColumnNameAdd.toString(), service);
invocation = new OperationExecution(labelColumnSession.getColumnData() invocation = new OperationExecution(labelColumnSession.getColumnData()
.getColumnId(), operationDefinition.getOperationId(), map); .getColumnId(), operationDefinition.getOperationId(), map);
@ -4149,14 +4140,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(changeTableTypeSession.toString()); logger.debug(changeTableTypeSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeTableType.toString(), capabilities); OperationsId.ChangeTableType.toString(), service);
map.put(Constants.PARAMETER_TABLE_TYPE, changeTableTypeSession map.put(Constants.PARAMETER_TABLE_TYPE, changeTableTypeSession
.getTableType().toString()); .getTableType().toString());
@ -4178,7 +4168,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throws TDGWTServiceException { throws TDGWTServiceException {
OperationExecution invocation = null; OperationExecution invocation = null;
List<OperationDefinition> capabilities = service.getCapabilities();
logger.debug(deleteRowsSession.toString()); logger.debug(deleteRowsSession.toString());
OperationDefinition operationDefinition; OperationDefinition operationDefinition;
@ -4195,7 +4184,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
} }
operationDefinition = OperationDefinitionMap.map( operationDefinition = OperationDefinitionMap.map(
OperationsId.RemoveRowById.toString(), capabilities); OperationsId.RemoveRowById.toString(), service);
map.put(Constants.PARAMETER_ROW_ID, rowsInt); map.put(Constants.PARAMETER_ROW_ID, rowsInt);
invocation = new OperationExecution( invocation = new OperationExecution(

View File

@ -1,27 +1,42 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice; package org.gcube.portlets.user.td.gwtservice.server.trservice;
import java.util.List;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchOperationException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @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 OperationDefinitionMap { public class OperationDefinitionMap {
public static OperationDefinition map(String op, protected static Logger logger = LoggerFactory
List<OperationDefinition> capabilities) .getLogger(OperationDefinitionMap.class);
public static OperationDefinition map(String op, TabularDataService service)
throws TDGWTServiceException { throws TDGWTServiceException {
for (OperationDefinition operation : capabilities) { OperationDefinition operationDefinition = null;
if (Long.valueOf(op) == operation.getOperationId()) {
return operation; try {
operationDefinition = service.getCapability(Long.valueOf(op));
} catch (NumberFormatException e) {
logger.error("No valid operation type: " + op);
e.printStackTrace();
throw new TDGWTServiceException(
"No valid operation type: " + op);
} catch (NoSuchOperationException e) {
logger.error("NoSuchOperationException: " + e.getLocalizedMessage());
e.printStackTrace();
throw new TDGWTServiceException(
"NoSuchOperationException: " + e.getLocalizedMessage());
} }
} return operationDefinition;
throw new TDGWTServiceException("OperationDescriptor not found");
} }
} }