Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@97618 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
193cead53f
commit
c1f8e83fc0
|
@ -0,0 +1,94 @@
|
||||||
|
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||||
|
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExpressionGenerator;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation Execution for replace column
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OperationExecution4ReplaceColumn extends OperationExecutionBuilder {
|
||||||
|
protected static Logger logger = LoggerFactory
|
||||||
|
.getLogger(OperationExecution4ReplaceColumn.class);
|
||||||
|
|
||||||
|
private TabularDataService service;
|
||||||
|
private ReplaceColumnSession replaceColumnSession;
|
||||||
|
|
||||||
|
public OperationExecution4ReplaceColumn(TabularDataService service,
|
||||||
|
ReplaceColumnSession replaceColumnSession) {
|
||||||
|
this.service = service;
|
||||||
|
this.replaceColumnSession = replaceColumnSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildOpEx() throws TDGWTServiceException {
|
||||||
|
|
||||||
|
OperationExecution invocation = null;
|
||||||
|
|
||||||
|
logger.debug(replaceColumnSession.toString());
|
||||||
|
OperationDefinition operationDefinition;
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
if (replaceColumnSession.isReplaceDimension()) {
|
||||||
|
logger.debug("Is a Replace of view column");
|
||||||
|
operationDefinition = OperationDefinitionMap.map(
|
||||||
|
OperationsId.ReplaceColumnByExpression.toString(), service);
|
||||||
|
|
||||||
|
Expression condition = ExpressionGenerator
|
||||||
|
.genReplaceValueParameterCondition(replaceColumnSession);
|
||||||
|
Expression value = ExpressionGenerator
|
||||||
|
.genReplaceValueParameterValue(replaceColumnSession);
|
||||||
|
|
||||||
|
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION,
|
||||||
|
condition);
|
||||||
|
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE,
|
||||||
|
value);
|
||||||
|
|
||||||
|
invocation = new OperationExecution(replaceColumnSession
|
||||||
|
.getColumnData().getColumnViewData()
|
||||||
|
.getSourceTableDimensionColumnId(),
|
||||||
|
operationDefinition.getOperationId(), map);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.debug("Is a Replace of basic column");
|
||||||
|
|
||||||
|
operationDefinition = OperationDefinitionMap.map(
|
||||||
|
OperationsId.ReplaceColumnByExpression.toString(), service);
|
||||||
|
|
||||||
|
Expression condition = ExpressionGenerator
|
||||||
|
.genReplaceValueParameterCondition(replaceColumnSession);
|
||||||
|
Expression value = ExpressionGenerator
|
||||||
|
.genReplaceValueParameterValue(replaceColumnSession);
|
||||||
|
|
||||||
|
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION,
|
||||||
|
condition);
|
||||||
|
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE,
|
||||||
|
value);
|
||||||
|
|
||||||
|
invocation = new OperationExecution(replaceColumnSession
|
||||||
|
.getColumnData().getColumnId(),
|
||||||
|
operationDefinition.getOperationId(), map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
operationExecutionSpec.setOp(invocation);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
|
||||||
|
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
|
||||||
|
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||||
|
import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText;
|
||||||
|
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnTypeCodeMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.SplitColumnSession;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation Execution for split column
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OperationExecution4SplitColumn extends OperationExecutionBuilder {
|
||||||
|
protected static Logger logger = LoggerFactory
|
||||||
|
.getLogger(OperationExecution4SplitColumn.class);
|
||||||
|
|
||||||
|
private TabularDataService service;
|
||||||
|
private SplitColumnSession splitColumnSession;
|
||||||
|
|
||||||
|
public OperationExecution4SplitColumn(TabularDataService service,
|
||||||
|
SplitColumnSession splitColumnSession) {
|
||||||
|
this.service = service;
|
||||||
|
this.splitColumnSession = splitColumnSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildOpEx() throws TDGWTServiceException {
|
||||||
|
|
||||||
|
ArrayList<OperationExecution> invocations = new ArrayList<OperationExecution>();
|
||||||
|
|
||||||
|
logger.debug(splitColumnSession.toString());
|
||||||
|
|
||||||
|
OperationDefinition operationDefinition = OperationDefinitionMap.map(
|
||||||
|
OperationsId.AddColumn.toString(), service);
|
||||||
|
|
||||||
|
Map<String, Object> map1 = new HashMap<String, Object>();
|
||||||
|
Map<String, Object> map2 = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
ArrayList<Expression> expressions = splitColumnSession.getExpressions();
|
||||||
|
|
||||||
|
if (expressions == null || expressions.size() <= 1) {
|
||||||
|
throw new TDGWTServiceException(
|
||||||
|
"No valid expressions in splitColumnSession");
|
||||||
|
}
|
||||||
|
|
||||||
|
map1.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE, ColumnTypeCodeMap
|
||||||
|
.getColumnType(splitColumnSession.getFirstSplitColumnType()));
|
||||||
|
map1.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap
|
||||||
|
.map(splitColumnSession.getFirstSplitColumnDataType()));
|
||||||
|
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(splitColumnSession.getSecondSplitColumnType()));
|
||||||
|
map2.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE, ColumnDataTypeMap
|
||||||
|
.map(splitColumnSession.getSecondSplitColumnDataType()));
|
||||||
|
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));
|
||||||
|
|
||||||
|
|
||||||
|
operationExecutionSpec.setOps(invocations);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue