Package org.openrefine.operations.column
Class ColumnAdditionOperation
- java.lang.Object
-
- org.openrefine.operations.EngineDependentOperation
-
- org.openrefine.operations.RowMapOperation
-
- org.openrefine.operations.ExpressionBasedOperation
-
- org.openrefine.operations.column.ColumnAdditionOperation
-
- All Implemented Interfaces:
Operation
public class ColumnAdditionOperation extends ExpressionBasedOperation
Adds a new column by evaluating an expression, based on a given column.- Author:
- Antonin Delpeuch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColumnAdditionOperation.Joiner
-
Nested classes/interfaces inherited from class org.openrefine.operations.ExpressionBasedOperation
ExpressionBasedOperation.NegativeRowMapper, ExpressionBasedOperation.PositiveRowMapper
-
Nested classes/interfaces inherited from class org.openrefine.operations.RowMapOperation
RowMapOperation.GridMap
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_columnInsertIndex
protected String
_newColumnName
-
Fields inherited from class org.openrefine.operations.ExpressionBasedOperation
_baseColumnName, _changeDataId, _eval, _expression, _forceEagerEvaluation, _onError, _repeatCount
-
Fields inherited from class org.openrefine.operations.EngineDependentOperation
_engineConfig
-
-
Constructor Summary
Constructors Constructor Description ColumnAdditionOperation(EngineConfig engineConfig, String baseColumnName, String expression, OnError onError, String newColumnName, int columnInsertIndex)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RowInRecordChangeDataJoiner
changeDataJoiner(Grid grid, ChangeContext context)
Returns the joiner used to insert the result of the evaluation of the expression into a row or record.String
getBaseColumnName()
int
getColumnInsertIndex()
String
getDescription()
A short human-readable description of what this operation does.String
getExpression()
protected ColumnModel
getNewColumnModel(Grid state, ChangeContext context, Evaluable eval)
Returns the new column model after the operation has run.String
getNewColumnName()
OnError
getOnError()
protected static RowInRecordMapper
negativeMapper(int columnInsertIndex, int keyColumnIndex)
-
Methods inherited from class org.openrefine.operations.ExpressionBasedOperation
apply, evaluatingChangeDataProducer, getChangeDataProducer, getEvaluable, getGridMap, getNewOverlayModels, postTransform
-
Methods inherited from class org.openrefine.operations.RowMapOperation
getNegativeRowMapper, getNewColumnModel, getNewOverlayModels, getPositiveRowMapper, postTransform
-
Methods inherited from class org.openrefine.operations.EngineDependentOperation
getEngine, getEngineConfig
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrefine.operations.Operation
getOperationId, isReproducible
-
-
-
-
Field Detail
-
_newColumnName
protected final String _newColumnName
-
_columnInsertIndex
protected final int _columnInsertIndex
-
-
Constructor Detail
-
ColumnAdditionOperation
public ColumnAdditionOperation(EngineConfig engineConfig, String baseColumnName, String expression, OnError onError, String newColumnName, int columnInsertIndex)
-
-
Method Detail
-
getNewColumnName
public String getNewColumnName()
-
getColumnInsertIndex
public int getColumnInsertIndex()
-
getBaseColumnName
public String getBaseColumnName()
-
getExpression
public String getExpression()
-
getOnError
public OnError getOnError()
-
getDescription
public String getDescription()
Description copied from interface:Operation
A short human-readable description of what this operation does.
-
getNewColumnModel
protected ColumnModel getNewColumnModel(Grid state, ChangeContext context, Evaluable eval) throws OperationException
Description copied from class:ExpressionBasedOperation
Returns the new column model after the operation has run.- Overrides:
getNewColumnModel
in classExpressionBasedOperation
- Throws:
OperationException
-
changeDataJoiner
protected RowInRecordChangeDataJoiner changeDataJoiner(Grid grid, ChangeContext context) throws OperationException
Description copied from class:ExpressionBasedOperation
Returns the joiner used to insert the result of the evaluation of the expression into a row or record. Depending on whether the expression is local or not (seeEvaluable.isLocal()
), this will either be used to build a row / record mapper to apply the change lazily on the grid, or the results of the evaluation will be stored in aChangeData
object which will then be joined by this joiner.- Specified by:
changeDataJoiner
in classExpressionBasedOperation
- Parameters:
grid
- the initial state of the grid- Throws:
OperationException
-
negativeMapper
protected static RowInRecordMapper negativeMapper(int columnInsertIndex, int keyColumnIndex)
-
-