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

View File

@ -1,27 +1,42 @@
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.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchOperationException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OperationDefinitionMap {
public static OperationDefinition map(String op,
List<OperationDefinition> capabilities)
protected static Logger logger = LoggerFactory
.getLogger(OperationDefinitionMap.class);
public static OperationDefinition map(String op, TabularDataService service)
throws TDGWTServiceException {
for (OperationDefinition operation : capabilities) {
if (Long.valueOf(op) == operation.getOperationId()) {
return operation;
}
OperationDefinition operationDefinition = null;
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());
}
throw new TDGWTServiceException("OperationDescriptor not found");
return operationDefinition;
}
}