Remove reconstruct method on operations

This commit is contained in:
Antonin Delpeuch 2018-10-22 14:18:17 +01:00
parent ebcc7b51b5
commit d012ea7f8d
62 changed files with 79 additions and 371 deletions

View File

@ -36,6 +36,7 @@ package com.google.refine.operations;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.Engine;
@ -50,7 +51,9 @@ import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.MassCellChange;
abstract public class EngineDependentMassCellOperation extends EngineDependentOperation {
@JsonIgnore
final protected String _columnName;
@JsonIgnore
final protected boolean _updateRowContextDependencies;
protected EngineDependentMassCellOperation(

View File

@ -35,8 +35,6 @@ package com.google.refine.operations.cell;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -44,21 +42,15 @@ import com.google.refine.browsing.Engine.Mode;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.expr.ExpressionUtils;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class BlankDownOperation extends EngineDependentMassCellOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), BlankDownOperation.class);
}
@JsonCreator
public BlankDownOperation(
@JsonProperty("engineConfig")

View File

@ -35,8 +35,6 @@ package com.google.refine.operations.cell;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -45,21 +43,15 @@ import com.google.refine.browsing.Engine.Mode;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.expr.ExpressionUtils;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class FillDownOperation extends EngineDependentMassCellOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), FillDownOperation.class);
}
@JsonCreator
public FillDownOperation(
@JsonProperty("engineConfig")

View File

@ -33,14 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.cell;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -52,17 +49,12 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowColumnChange;
import com.google.refine.util.ParsingUtilities;
public class KeyValueColumnizeOperation extends AbstractOperation {
final protected String _keyColumnName;
final protected String _valueColumnName;
final protected String _noteColumnName;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), KeyValueColumnizeOperation.class);
}
@JsonCreator
public KeyValueColumnizeOperation(
@JsonProperty("keyColumnName")

View File

@ -40,8 +40,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -50,7 +48,6 @@ import com.google.refine.browsing.RowVisitor;
import com.google.refine.expr.Evaluable;
import com.google.refine.expr.ExpressionUtils;
import com.google.refine.expr.MetaParser;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -106,10 +103,6 @@ public class MassEditOperation extends EngineDependentMassCellOperation {
}
}
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), MassEditOperation.class);
}
public MassEditOperation(EngineConfig engineConfig, String columnName, String expression, List<Edit> edits) {
super(engineConfig, columnName, true);
_expression = expression;

View File

@ -36,8 +36,6 @@ package com.google.refine.operations.cell;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -49,17 +47,12 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowChange;
import com.google.refine.util.ParsingUtilities;
public class MultiValuedCellJoinOperation extends AbstractOperation {
final protected String _columnName;
final protected String _keyColumnName;
final protected String _separator;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), MultiValuedCellJoinOperation.class);
}
@JsonCreator
public MultiValuedCellJoinOperation(
@JsonProperty("columnName")

View File

@ -38,7 +38,6 @@ import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -52,7 +51,6 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowChange;
import com.google.refine.util.ParsingUtilities;
public class MultiValuedCellSplitOperation extends AbstractOperation {
final protected String _columnName;
@ -63,10 +61,6 @@ public class MultiValuedCellSplitOperation extends AbstractOperation {
final protected int[] _fieldLengths;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), MultiValuedCellSplitOperation.class);
}
@JsonCreator
public static MultiValuedCellSplitOperation deserialize(
@JsonProperty("columnName")

View File

@ -37,8 +37,6 @@ import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -48,7 +46,6 @@ import com.google.refine.expr.Evaluable;
import com.google.refine.expr.ExpressionUtils;
import com.google.refine.expr.MetaParser;
import com.google.refine.expr.WrappedCell;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -56,7 +53,6 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.operations.OnError;
import com.google.refine.util.ParsingUtilities;
public class TextTransformOperation extends EngineDependentMassCellOperation {
@JsonProperty("expression")
@ -68,10 +64,6 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
@JsonProperty("repeatCount")
final protected int _repeatCount;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), TextTransformOperation.class);
}
static public OnError stringToOnError(String s) {
if ("set-to-blank".equalsIgnoreCase(s)) {
return OnError.SetToBlank;

View File

@ -36,8 +36,6 @@ package com.google.refine.operations.cell;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -51,7 +49,6 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowColumnChange;
import com.google.refine.util.ParsingUtilities;
public class TransposeColumnsIntoRowsOperation extends AbstractOperation {
@JsonProperty("startColumnName")
@ -82,10 +79,6 @@ public class TransposeColumnsIntoRowsOperation extends AbstractOperation {
return _combinedColumnName == null ? null : _prependColumnName;
}
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), TransposeColumnsIntoRowsOperation.class);
}
@JsonCreator
static public TransposeColumnsIntoRowsOperation deserialize(
@JsonProperty("combinedColumnName")

View File

@ -36,8 +36,6 @@ package com.google.refine.operations.cell;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -48,16 +46,11 @@ import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowColumnChange;
import com.google.refine.util.ParsingUtilities;
public class TransposeRowsIntoColumnsOperation extends AbstractOperation {
final protected String _columnName;
final protected int _rowCount;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), TransposeRowsIntoColumnsOperation.class);
}
@JsonCreator
public TransposeRowsIntoColumnsOperation(
@JsonProperty("columnName")

View File

@ -46,7 +46,6 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.json.JSONException;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -65,7 +64,6 @@ import com.google.refine.expr.ExpressionUtils;
import com.google.refine.expr.MetaParser;
import com.google.refine.expr.WrappedCell;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -107,10 +105,6 @@ public class ColumnAdditionByFetchingURLsOperation extends EngineDependentOperat
final protected boolean _cacheResponses;
final protected List<HttpHeader> _httpHeadersJson;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnAdditionByFetchingURLsOperation.class);
}
@JsonCreator
public ColumnAdditionByFetchingURLsOperation(
@JsonProperty("engineConfig")

View File

@ -33,14 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.column;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -54,7 +51,6 @@ import com.google.refine.expr.MetaParser;
import com.google.refine.expr.WrappedCell;
import com.google.refine.history.Change;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -63,7 +59,6 @@ import com.google.refine.model.changes.CellAtRow;
import com.google.refine.model.changes.ColumnAdditionChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.operations.OnError;
import com.google.refine.util.ParsingUtilities;
public class ColumnAdditionOperation extends EngineDependentOperation {
final protected String _baseColumnName;
@ -73,10 +68,6 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
final protected String _newColumnName;
final protected int _columnInsertIndex;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnAdditionOperation.class);
}
@JsonCreator
public ColumnAdditionOperation(
@JsonProperty("engineConfig")

View File

@ -33,10 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.column;
import java.io.IOException;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -45,16 +41,11 @@ import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.changes.ColumnMoveChange;
import com.google.refine.util.ParsingUtilities;
public class ColumnMoveOperation extends AbstractOperation {
final protected String _columnName;
final protected int _index;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnMoveOperation.class);
}
@JsonCreator
public ColumnMoveOperation(
@JsonProperty("columnName")

View File

@ -33,10 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.column;
import java.io.IOException;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -46,15 +42,10 @@ import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.changes.ColumnRemovalChange;
import com.google.refine.util.ParsingUtilities;
public class ColumnRemovalOperation extends AbstractOperation {
final protected String _columnName;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnRemovalOperation.class);
}
@JsonCreator
public ColumnRemovalOperation(
@JsonProperty("columnName")

View File

@ -33,8 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.column;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.history.Change;
@ -47,13 +45,6 @@ public class ColumnRenameOperation extends AbstractOperation {
final protected String _oldColumnName;
final protected String _newColumnName;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return new ColumnRenameOperation(
obj.getString("oldColumnName"),
obj.getString("newColumnName")
);
}
public ColumnRenameOperation(
String oldColumnName,
String newColumnName

View File

@ -35,8 +35,6 @@ package com.google.refine.operations.column;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -44,13 +42,8 @@ import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.changes.ColumnReorderChange;
import com.google.refine.util.ParsingUtilities;
public class ColumnReorderOperation extends AbstractOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnReorderOperation.class);
}
final protected List<String> _columnNames;
@JsonCreator

View File

@ -33,14 +33,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.column;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -55,13 +53,11 @@ import com.google.refine.expr.ExpressionUtils;
import com.google.refine.history.Change;
import com.google.refine.history.HistoryEntry;
import com.google.refine.importers.ImporterUtilities;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.ColumnSplitChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.util.ParsingUtilities;
public class ColumnSplitOperation extends EngineDependentOperation {
final protected String _columnName;
@ -75,10 +71,6 @@ public class ColumnSplitOperation extends EngineDependentOperation {
final protected int[] _fieldLengths;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ColumnSplitOperation.class);
}
@JsonCreator
public static ColumnSplitOperation deserialize(
@JsonProperty("engineConfig")

View File

@ -42,7 +42,6 @@ import java.util.Properties;
import java.util.Set;
import org.json.JSONException;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -52,7 +51,6 @@ import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.FilteredRows;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -68,7 +66,6 @@ import com.google.refine.model.recon.ReconciledDataExtensionJob.DataExtensionCon
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.process.LongRunningProcess;
import com.google.refine.process.Process;
import com.google.refine.util.ParsingUtilities;
public class ExtendDataOperation extends EngineDependentOperation {
@JsonProperty("baseColumnName")
@ -85,10 +82,6 @@ public class ExtendDataOperation extends EngineDependentOperation {
final protected int _columnInsertIndex;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), ExtendDataOperation.class);
}
@JsonCreator
public ExtendDataOperation(
@JsonProperty("engineConfig")

View File

@ -33,18 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -52,15 +48,10 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconClearSimilarCellsOperation extends EngineDependentMassCellOperation {
final protected String _similarValue;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconClearSimilarCellsOperation.class);
}
@JsonCreator
public ReconClearSimilarCellsOperation(
@JsonProperty("engineConfig")

View File

@ -33,7 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@ -42,7 +41,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -52,7 +50,6 @@ import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.FilteredRows;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -62,8 +59,6 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.MassChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.util.JSONUtilities;
import com.google.refine.util.ParsingUtilities;
public class ReconCopyAcrossColumnsOperation extends EngineDependentOperation {
final protected String _fromColumnName;
@ -71,10 +66,6 @@ public class ReconCopyAcrossColumnsOperation extends EngineDependentOperation {
final protected String[] _judgments;
final protected boolean _applyToJudgedCells;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconCopyAcrossColumnsOperation.class);
}
@JsonCreator
public ReconCopyAcrossColumnsOperation(
@JsonProperty("engineConfig")

View File

@ -33,20 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -56,15 +52,10 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconDiscardJudgmentsOperation extends EngineDependentMassCellOperation {
final protected boolean _clearData;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconDiscardJudgmentsOperation.class);
}
@JsonCreator
public ReconDiscardJudgmentsOperation(
@JsonProperty("engineConfig")

View File

@ -33,13 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@ -49,7 +46,6 @@ import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.expr.ExpressionUtils;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -61,7 +57,6 @@ import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.model.recon.ReconConfig;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconJudgeSimilarCellsOperation extends EngineDependentMassCellOperation {
final protected String _similarValue;
@ -69,10 +64,6 @@ public class ReconJudgeSimilarCellsOperation extends EngineDependentMassCellOper
final protected ReconCandidate _match;
final protected boolean _shareNewTopics;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconJudgeSimilarCellsOperation.class);
}
@JsonCreator
public ReconJudgeSimilarCellsOperation(
@JsonProperty("engineConfig")

View File

@ -33,20 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -57,15 +53,10 @@ import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.model.recon.ReconConfig;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconMarkNewTopicsOperation extends EngineDependentMassCellOperation {
final protected boolean _shareNewTopics;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconMarkNewTopicsOperation.class);
}
@JsonCreator
public ReconMarkNewTopicsOperation(
@JsonProperty("engineConfig")

View File

@ -37,15 +37,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -56,13 +53,8 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconMatchBestCandidatesOperation extends EngineDependentMassCellOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconMatchBestCandidatesOperation.class);
}
@JsonCreator
public ReconMatchBestCandidatesOperation(
@JsonProperty("engineConfig")

View File

@ -37,8 +37,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -46,7 +44,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Cell;
import com.google.refine.model.Column;
import com.google.refine.model.Project;
@ -57,7 +54,6 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconMatchSpecificTopicOperation extends EngineDependentMassCellOperation {
@ -91,10 +87,6 @@ public class ReconMatchSpecificTopicOperation extends EngineDependentMassCellOpe
@JsonProperty("schemaSpace")
final protected String schemaSpace;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconMatchSpecificTopicOperation.class);
}
@JsonCreator
public ReconMatchSpecificTopicOperation(
@JsonProperty("engineConfig")

View File

@ -40,7 +40,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -76,10 +75,6 @@ public class ReconOperation extends EngineDependentOperation {
final protected String _columnName;
final protected ReconConfig _reconConfig;
static public ReconOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconOperation.class);
}
@JsonCreator
public ReconOperation(
@JsonProperty("engineConfig")

View File

@ -1,11 +1,8 @@
package com.google.refine.operations.recon;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -25,7 +22,6 @@ import com.google.refine.model.changes.CellChange;
import com.google.refine.model.changes.ReconChange;
import com.google.refine.model.recon.StandardReconConfig;
import com.google.refine.operations.EngineDependentMassCellOperation;
import com.google.refine.util.ParsingUtilities;
public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCellOperation {
@ -58,10 +54,6 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel
this.reconConfig = new StandardReconConfig(service, identifierSpace, schemaSpace, null, null, true, Collections.emptyList());
}
static public ReconUseValuesAsIdentifiersOperation reconstruct(JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), ReconUseValuesAsIdentifiersOperation.class);
}
@Override
public String getBriefDescription(Project project) {
return "Use values as reconciliation identifiers in column " + _columnName;

View File

@ -36,8 +36,6 @@ package com.google.refine.operations.row;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.google.refine.history.HistoryEntry;
@ -50,10 +48,6 @@ import com.google.refine.model.Row;
import com.google.refine.model.changes.MassRowChange;
public class DenormalizeOperation extends AbstractOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return new DenormalizeOperation();
}
@JsonCreator
public DenormalizeOperation() {
}

View File

@ -36,8 +36,6 @@ package com.google.refine.operations.row;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -47,21 +45,15 @@ import com.google.refine.browsing.FilteredRows;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassChange;
import com.google.refine.model.changes.RowFlagChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.util.ParsingUtilities;
public class RowFlagOperation extends EngineDependentOperation {
final protected boolean _flagged;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
return ParsingUtilities.mapper.readValue(obj.toString(), RowFlagOperation.class);
}
@JsonCreator
public RowFlagOperation(
@JsonProperty("engineConfig")

View File

@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.row;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -47,18 +44,12 @@ import com.google.refine.browsing.EngineConfig;
import com.google.refine.browsing.FilteredRows;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.RowRemovalChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.util.ParsingUtilities;
public class RowRemovalOperation extends EngineDependentOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), RowRemovalOperation.class);
}
@JsonCreator
public RowRemovalOperation(
@JsonProperty("engineConfig")

View File

@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.row;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -55,13 +52,8 @@ import com.google.refine.model.changes.RowReorderChange;
import com.google.refine.sorting.SortingConfig;
import com.google.refine.sorting.SortingRecordVisitor;
import com.google.refine.sorting.SortingRowVisitor;
import com.google.refine.util.ParsingUtilities;
public class RowReorderOperation extends AbstractOperation {
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), RowReorderOperation.class);
}
final protected Mode _mode;
final protected SortingConfig _sorting;

View File

@ -33,12 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.operations.row;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -48,21 +45,15 @@ import com.google.refine.browsing.FilteredRows;
import com.google.refine.browsing.RowVisitor;
import com.google.refine.history.Change;
import com.google.refine.history.HistoryEntry;
import com.google.refine.model.AbstractOperation;
import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.model.changes.MassChange;
import com.google.refine.model.changes.RowStarChange;
import com.google.refine.operations.EngineDependentOperation;
import com.google.refine.util.ParsingUtilities;
public class RowStarOperation extends EngineDependentOperation {
final protected boolean _starred;
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws IOException {
return ParsingUtilities.mapper.readValue(obj.toString(), RowStarOperation.class);
}
@JsonCreator
public RowStarOperation(
@JsonProperty("engineConfig")

View File

@ -1,18 +1,11 @@
package com.google.refine.tests.model.changes;
import com.google.refine.model.ModelException;
import com.google.refine.model.Project;
import com.google.refine.model.changes.DataExtensionChange;
import com.google.refine.model.changes.MassChange;
import static org.junit.Assert.assertEquals;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeMethod;
@ -20,6 +13,9 @@ import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.refine.history.Change;
import com.google.refine.model.ModelException;
import com.google.refine.model.Project;
import com.google.refine.model.changes.DataExtensionChange;
import com.google.refine.tests.RefineTest;
import com.google.refine.util.Pool;

View File

@ -24,7 +24,7 @@ import com.google.refine.operations.cell.FillDownOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.Pool;
import com.google.refine.util.ParsingUtilities;
public class BlankDownTests extends RefineTest {
@ -56,7 +56,7 @@ public class BlankDownTests extends RefineTest {
+ "\"description\":\"Blank down cells in column my column\","
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
+ "\"columnName\":\"my column\"}";
AbstractOperation op = BlankDownOperation.reconstruct(project, new JSONObject(json));
AbstractOperation op = ParsingUtilities.mapper.readValue(json, BlankDownOperation.class);
TestUtils.isSerializedTo(op, json);
}
@ -107,7 +107,6 @@ public class BlankDownTests extends RefineTest {
"second");
Process process = op.createProcess(project, new Properties());
process.performImmediate();
//project.saveToOutputStream(System.out, new Pool());
Assert.assertEquals("c", project.rows.get(0).cells.get(3).value);
Assert.assertNull(project.rows.get(1).cells.get(3));

View File

@ -20,9 +20,10 @@ import com.google.refine.model.Project;
import com.google.refine.model.Row;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.FillDownOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.process.Process;
import com.google.refine.util.ParsingUtilities;
public class FillDownTests extends RefineTest {
@ -54,7 +55,7 @@ public class FillDownTests extends RefineTest {
+ "\"description\":\"Fill down cells in column my key\","
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
+ "\"columnName\":\"my key\"}";
TestUtils.isSerializedTo(FillDownOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, FillDownOperation.class), json);
}
@Test

View File

@ -36,7 +36,6 @@ package com.google.refine.tests.operations.cell;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
@ -51,6 +50,7 @@ import com.google.refine.operations.cell.MultiValuedCellJoinOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class JoinMultiValuedCellsTests extends RefineTest {
@ -85,7 +85,7 @@ public class JoinMultiValuedCellsTests extends RefineTest {
+ "\"columnName\":\"value column\","
+ "\"keyColumnName\":\"key column\","
+ "\"separator\":\",\"}";
TestUtils.isSerializedTo(MultiValuedCellJoinOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellJoinOperation.class), json);
}

View File

@ -67,6 +67,7 @@ import com.google.refine.process.Process;
import com.google.refine.tests.RefineServletStub;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class KeyValueColumnizeTests extends RefineTest {
@ -119,14 +120,14 @@ public class KeyValueColumnizeTests extends RefineTest {
+ "\"keyColumnName\":\"key column\","
+ "\"valueColumnName\":\"value column\","
+ "\"noteColumnName\":null}";
TestUtils.isSerializedTo(KeyValueColumnizeOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, KeyValueColumnizeOperation.class), json);
String jsonFull = "{\"op\":\"core/key-value-columnize\","
+ "\"description\":\"Columnize by key column key column and value column value column with note column note column\","
+ "\"keyColumnName\":\"key column\","
+ "\"valueColumnName\":\"value column\","
+ "\"noteColumnName\":\"note column\"}";
TestUtils.isSerializedTo(KeyValueColumnizeOperation.reconstruct(project, new JSONObject(jsonFull)), jsonFull);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(jsonFull, KeyValueColumnizeOperation.class), jsonFull);
}
/**

View File

@ -3,15 +3,12 @@ package com.google.refine.tests.operations.cell;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import static org.mockito.Mockito.mock;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.MassEditOperation;
import com.google.refine.operations.cell.MassEditOperation.Edit;
@ -31,13 +28,12 @@ public class MassOperationTests extends RefineTest {
@Test
public void serializeMassEditOperation() throws JSONException, Exception {
Project project = mock(Project.class);
String json = "{\"op\":\"core/mass-edit\","
+ "\"description\":\"Mass edit cells in column my column\","
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
+ "\"columnName\":\"my column\",\"expression\":\"value\","
+ "\"edits\":[{\"fromBlank\":false,\"fromError\":false,\"from\":[\"String\"],\"to\":\"newString\"}]}";
TestUtils.isSerializedTo(MassEditOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MassEditOperation.class), json);
}
@Test

View File

@ -37,7 +37,6 @@ package com.google.refine.tests.operations.cell;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
@ -51,6 +50,7 @@ import com.google.refine.operations.cell.MultiValuedCellSplitOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class SplitMultiValuedCellsTests extends RefineTest {
@ -80,7 +80,7 @@ public class SplitMultiValuedCellsTests extends RefineTest {
+ "\"mode\":\"separator\","
+ "\"separator\":\":\","
+ "\"regex\":false}";
TestUtils.isSerializedTo(MultiValuedCellSplitOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellSplitOperation.class), json);
}
@Test
@ -91,7 +91,7 @@ public class SplitMultiValuedCellsTests extends RefineTest {
+ "\"keyColumnName\":\"Key\","
+ "\"mode\":\"lengths\","
+ "\"fieldLengths\":[1,1]}";
TestUtils.isSerializedTo(MultiValuedCellSplitOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, MultiValuedCellSplitOperation.class), json);
}
/**

View File

@ -33,19 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.google.refine.tests.operations.cell;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.cell.TransposeRowsIntoColumnsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class TransposeTests extends RefineTest {
@ -62,8 +59,7 @@ public class TransposeTests extends RefineTest {
+ "\"description\":\"Transpose every 3 cells in column start column into separate columns\","
+ "\"columnName\":\"start column\","
+ "\"rowCount\":3}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(TransposeRowsIntoColumnsOperation.reconstruct(project , new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, TransposeRowsIntoColumnsOperation.class), json);
}
}

View File

@ -63,6 +63,7 @@ import com.google.refine.process.Process;
import com.google.refine.process.ProcessManager;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest {
@ -125,12 +126,12 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest {
@Test
public void serializeColumnAdditionByFetchingURLsOperation() throws JSONException, Exception {
TestUtils.isSerializedTo(ColumnAdditionByFetchingURLsOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class), json);
}
@Test
public void serializeUrlFetchingProcess() throws Exception {
AbstractOperation op = ColumnAdditionByFetchingURLsOperation.reconstruct(project, new JSONObject(json));
AbstractOperation op = ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class);
Process process = op.createProcess(project, new Properties());
TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode()));
}

View File

@ -1,17 +1,14 @@
package com.google.refine.tests.operations.column;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnAdditionOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ColumnAdditionOperationTests extends RefineTest {
@ -28,7 +25,6 @@ public class ColumnAdditionOperationTests extends RefineTest {
+ " \"expression\":\"grel:value.parseJson()[\\\"employment-summary\\\"].join('###')\","
+ " \"onError\":\"set-to-blank\""
+ "}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnAdditionOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnAdditionOperation.class), json);
}
}

View File

@ -1,17 +1,14 @@
package com.google.refine.tests.operations.column;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnMoveOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ColumnMoveOperationTests extends RefineTest {
@ -26,7 +23,6 @@ public class ColumnMoveOperationTests extends RefineTest {
+ "\"description\":\"Move column my column to position 3\","
+ "\"columnName\":\"my column\","
+ "\"index\":3}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnMoveOperation.reconstruct(project , new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnMoveOperation.class), json);
}
}

View File

@ -1,17 +1,14 @@
package com.google.refine.tests.operations.column;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnRemovalOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ColumnRemovalOperationTests extends RefineTest {
@ -26,7 +23,6 @@ public class ColumnRemovalOperationTests extends RefineTest {
String json = "{\"op\":\"core/column-removal\","
+ "\"description\":\"Remove column my column\","
+ "\"columnName\":\"my column\"}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnRemovalOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnRemovalOperation.class), json);
}
}

View File

@ -1,13 +1,10 @@
package com.google.refine.tests.operations.column;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnRenameOperation;
import com.google.refine.tests.RefineTest;
@ -27,7 +24,10 @@ public class ColumnRenameOperationTests extends RefineTest {
+ "\"description\":\"Rename column old name to new name\","
+ "\"oldColumnName\":\"old name\","
+ "\"newColumnName\":\"new name\"}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnRenameOperation.reconstruct(project, new JSONObject(json)), json);
JSONObject obj = new JSONObject(json);
TestUtils.isSerializedTo(new ColumnRenameOperation(
obj.getString("oldColumnName"),
obj.getString("newColumnName")
), json);
}
}

View File

@ -1,17 +1,14 @@
package com.google.refine.tests.operations.column;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.column.ColumnSplitOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ColumnSplitOperationTests extends RefineTest {
@BeforeSuite
@ -36,8 +33,7 @@ public class ColumnSplitOperationTests extends RefineTest {
" \"regex\": false,\n" +
" \"maxColumns\": 0\n" +
" }";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnSplitOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnSplitOperation.class), json);
}
@Test
@ -55,7 +51,6 @@ public class ColumnSplitOperationTests extends RefineTest {
" \"mode\": \"lengths\",\n" +
" \"fieldLengths\": [1,1]\n" +
" }";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ColumnSplitOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnSplitOperation.class), json);
}
}

View File

@ -69,6 +69,7 @@ import com.google.refine.process.Process;
import com.google.refine.process.ProcessManager;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ExtendDataOperationTests extends RefineTest {
@ -165,12 +166,12 @@ public class ExtendDataOperationTests extends RefineTest {
@Test
public void serializeExtendDataOperation() throws JSONException, Exception {
TestUtils.isSerializedTo(ExtendDataOperation.reconstruct(project, new JSONObject(operationJson)), operationJson);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class), operationJson);
}
@Test
public void serializeExtendDataProcess() throws JSONException, Exception {
Process p = ExtendDataOperation.reconstruct(project, new JSONObject(operationJson))
Process p = ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class)
.createProcess(project, new Properties());
TestUtils.isSerializedTo(p, String.format(processJson, p.hashCode()));
}

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconClearSimilarCellsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconClearSimilarCellsOperationTests extends RefineTest {
@BeforeSuite
@ -24,7 +21,6 @@ public class ReconClearSimilarCellsOperationTests extends RefineTest {
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]},"
+ "\"columnName\":\"my column\","
+ "\"similarValue\":\"some value\"}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconClearSimilarCellsOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconClearSimilarCellsOperation.class), json);
}
}

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconCopyAcrossColumnsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconCopyAcrossColumnsOperationTests extends RefineTest {
@BeforeSuite
@ -26,7 +23,6 @@ public class ReconCopyAcrossColumnsOperationTests extends RefineTest {
+ "\"toColumnNames\":[\"first\",\"second\"],"
+ "\"judgments\":[\"matched\",\"new\"],"
+ "\"applyToJudgedCells\":true}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconCopyAcrossColumnsOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconCopyAcrossColumnsOperation.class), json);
}
}

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconDiscardJudgmentsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconDiscardJudgmentsOperationTests extends RefineTest {
@BeforeSuite
@ -29,7 +26,6 @@ public class ReconDiscardJudgmentsOperationTests extends RefineTest {
" \"columnName\": \"researcher\",\n" +
" \"clearData\": true\n" +
" }";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconDiscardJudgmentsOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconDiscardJudgmentsOperation.class), json);
}
}

View File

@ -1,14 +1,12 @@
package com.google.refine.tests.operations.recon;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import static org.mockito.Mockito.mock;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconJudgeSimilarCellsOperationTests extends RefineTest {
@BeforeSuite
@ -26,6 +24,6 @@ public class ReconJudgeSimilarCellsOperationTests extends RefineTest {
+ "\"judgment\":\"matched\","
+ "\"match\":{\"id\":\"Q7884717\",\"name\":\"Unicef Indonesia\",\"score\":71.42857142857143,\"types\":[\"Q43229\"]},"
+ "\"shareNewTopics\":false}";
TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json);
}
}

View File

@ -2,7 +2,6 @@ package com.google.refine.tests.operations.recon;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import java.io.IOException;
import java.util.Collections;
@ -26,6 +25,7 @@ import com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation;
import com.google.refine.process.Process;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconJudgeSimilarCellsTests extends RefineTest {
@ -47,7 +47,7 @@ public class ReconJudgeSimilarCellsTests extends RefineTest {
+ "\"similarValue\":\"foo\","
+ "\"judgment\":\"new\","
+ "\"shareNewTopics\":true}";
TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json);
}
@Test
@ -61,7 +61,7 @@ public class ReconJudgeSimilarCellsTests extends RefineTest {
+ "\"match\":{\"id\":\"Q42\",\"name\":\"Douglas Adams\",\"types\":[\"Q5\"],\"score\":85},"
+ "\"shareNewTopics\":false"
+ "}";
TestUtils.isSerializedTo(ReconJudgeSimilarCellsOperation.reconstruct(mock(Project.class), new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconJudgeSimilarCellsOperation.class), json);
}
@Test

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconMarkNewTopicsOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconMarkNewTopicsOperationTests extends RefineTest {
@BeforeSuite
@ -26,7 +23,6 @@ public class ReconMarkNewTopicsOperationTests extends RefineTest {
+ "\"shareNewTopics\":true,"
+ "\"description\":\"Mark to create new items for cells in column my column, one item for each group of similar cells\""
+ "}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconMarkNewTopicsOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMarkNewTopicsOperation.class), json);
}
}

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconMatchBestCandidatesOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconMatchBestCandidatesOperationTests extends RefineTest {
@BeforeSuite
@ -28,7 +25,6 @@ public class ReconMatchBestCandidatesOperationTests extends RefineTest {
+ "]},"
+ "\"columnName\":\"organization_name\""
+ "}";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconMatchBestCandidatesOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMatchBestCandidatesOperation.class), json);
}
}

View File

@ -1,15 +1,12 @@
package com.google.refine.tests.operations.recon;
import static org.mockito.Mockito.mock;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconMatchSpecificTopicOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconMatchSpecificTopicOperationTests extends RefineTest {
@BeforeSuite
@ -37,7 +34,6 @@ public class ReconMatchSpecificTopicOperationTests extends RefineTest {
" \"identifierSpace\": \"http://www.wikidata.org/entity/\",\n" +
" \"schemaSpace\": \"http://www.wikidata.org/prop/direct/\"\n" +
" }";
Project project = mock(Project.class);
TestUtils.isSerializedTo(ReconMatchSpecificTopicOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconMatchSpecificTopicOperation.class), json);
}
}

View File

@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@ -16,6 +15,7 @@ import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconOperationTests extends RefineTest {
@ -74,12 +74,12 @@ public class ReconOperationTests extends RefineTest {
@Test
public void serializeReconOperation() throws JSONException, Exception {
TestUtils.isSerializedTo(ReconOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconOperation.class), json);
}
@Test
public void serializeReconProcess() throws JSONException, Exception {
ReconOperation op = ReconOperation.reconstruct(project, new JSONObject(json));
ReconOperation op = ParsingUtilities.mapper.readValue(json, ReconOperation.class);
com.google.refine.process.Process process = op.createProcess(project, new Properties());
TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode()));
}

View File

@ -6,7 +6,6 @@ import static org.testng.Assert.assertNull;
import java.util.Properties;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@ -16,6 +15,7 @@ import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.recon.ReconUseValuesAsIdentifiersOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class ReconUseValuesAsIdsOperationTests extends RefineTest {
@ -36,7 +36,7 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
@Test
public void serializeReconUseValuesAsIdentifiersOperation() throws JSONException, Exception {
TestUtils.isSerializedTo(ReconUseValuesAsIdentifiersOperation.reconstruct(new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class), json);
}
@Test
@ -45,7 +45,7 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
+ "Q343,hello\n"
+ ",world\n"
+ "Q31,test");
ReconUseValuesAsIdentifiersOperation op = ReconUseValuesAsIdentifiersOperation.reconstruct(new JSONObject(json));
ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class);
op.createProcess(project, new Properties()).performImmediate();
assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id);

View File

@ -3,7 +3,6 @@ package com.google.refine.tests.operations.row;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@ -26,6 +25,6 @@ public class DenormalizeOperationTests extends RefineTest {
String json = "{"
+ "\"op\":\"core/denormalize\","
+ "\"description\":\"Denormalize\"}";
TestUtils.isSerializedTo(DenormalizeOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(new DenormalizeOperation(), json);
}
}

View File

@ -3,7 +3,6 @@ package com.google.refine.tests.operations.row;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@ -12,6 +11,7 @@ import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.row.RowFlagOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class RowFlagOperationTests extends RefineTest {
@BeforeSuite
@ -27,6 +27,6 @@ public class RowFlagOperationTests extends RefineTest {
+ "\"description\":\"Flag rows\","
+ "\"flagged\":true,"
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
TestUtils.isSerializedTo(RowFlagOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowFlagOperation.class), json);
}
}

View File

@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock;
import java.io.IOException;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
@ -14,6 +13,7 @@ import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.row.RowRemovalOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class RowRemovalOperationTests extends RefineTest {
@BeforeSuite
@ -28,6 +28,6 @@ public class RowRemovalOperationTests extends RefineTest {
+ "\"op\":\"core/row-removal\","
+ "\"description\":\"Remove rows\","
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
TestUtils.isSerializedTo(RowRemovalOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowRemovalOperation.class), json);
}
}

View File

@ -23,6 +23,7 @@ import com.google.refine.process.Process;
import com.google.refine.sorting.SortingConfig;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class RowReorderOperationTests extends RefineTest {
@ -85,7 +86,7 @@ public class RowReorderOperationTests extends RefineTest {
" ]\n" +
" }\n" +
" }";
TestUtils.isSerializedTo(RowReorderOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowReorderOperation.class), json);
}
}

View File

@ -3,14 +3,15 @@ package com.google.refine.tests.operations.row;
import static org.mockito.Mockito.mock;
import org.json.JSONException;
import org.json.JSONObject;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import com.google.refine.model.Project;
import com.google.refine.operations.OperationRegistry;
import com.google.refine.operations.row.RowStarOperation;
import com.google.refine.tests.RefineTest;
import com.google.refine.tests.util.TestUtils;
import com.google.refine.util.ParsingUtilities;
public class RowStarOperationTests extends RefineTest {
@BeforeSuite
@ -26,6 +27,6 @@ public class RowStarOperationTests extends RefineTest {
+ "\"description\":\"Star rows\","
+ "\"starred\":true,"
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]}}";
TestUtils.isSerializedTo(RowStarOperation.reconstruct(project, new JSONObject(json)), json);
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, RowStarOperation.class), json);
}
}