Changed operations to record column names instead of cell indices.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@98 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
e6a98f23bd
commit
32157ce76b
@ -13,14 +13,14 @@ public class AddColumnCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int baseCellIndex = Integer.parseInt(request.getParameter("baseCellIndex"));
|
||||
String baseColumnName = request.getParameter("baseColumnName");
|
||||
String expression = request.getParameter("expression");
|
||||
String headerLabel = request.getParameter("headerLabel");
|
||||
int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex"));
|
||||
|
||||
return new ColumnAdditionOperation(
|
||||
engineConfig,
|
||||
baseCellIndex,
|
||||
baseColumnName,
|
||||
expression,
|
||||
headerLabel,
|
||||
columnInsertIndex
|
||||
|
@ -14,9 +14,9 @@ public class DoTextTransformCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cell"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
String expression = request.getParameter("expression");
|
||||
|
||||
return new TextTransformOperation(engineConfig, cellIndex, expression);
|
||||
return new TextTransformOperation(engineConfig, columnName, expression);
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ public class JoinMultiValueCellsCommand extends Command {
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cellIndex"));
|
||||
int keyCellIndex = Integer.parseInt(request.getParameter("keyCellIndex"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
String keyColumnName = request.getParameter("keyColumnName");
|
||||
String separator = request.getParameter("separator");
|
||||
|
||||
AbstractOperation op = new MultiValueCellJoinOperation(cellIndex, keyCellIndex, separator);
|
||||
AbstractOperation op = new MultiValueCellJoinOperation(columnName, keyColumnName, separator);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
boolean done = project.processManager.queueProcess(process);
|
||||
|
@ -21,9 +21,9 @@ public class RemoveColumnCommand extends Command {
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
|
||||
int columnRemovalIndex = Integer.parseInt(request.getParameter("columnRemovalIndex"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
|
||||
AbstractOperation op = new ColumnRemovalOperation(columnRemovalIndex);
|
||||
AbstractOperation op = new ColumnRemovalOperation(columnName);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
boolean done = project.processManager.queueProcess(process);
|
||||
|
@ -21,12 +21,12 @@ public class SplitMultiValueCellsCommand extends Command {
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cellIndex"));
|
||||
int keyCellIndex = Integer.parseInt(request.getParameter("keyCellIndex"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
String keyColumnName = request.getParameter("keyColumnName");
|
||||
String separator = request.getParameter("separator");
|
||||
String mode = request.getParameter("mode");
|
||||
|
||||
AbstractOperation op = new MultiValueCellSplitOperation(cellIndex, keyCellIndex, separator, mode);
|
||||
AbstractOperation op = new MultiValueCellSplitOperation(columnName, keyColumnName, separator, mode);
|
||||
Process process = op.createProcess(project, new Properties());
|
||||
|
||||
boolean done = project.processManager.queueProcess(process);
|
||||
|
@ -14,8 +14,8 @@ public class ApproveNewReconcileCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cell"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
|
||||
return new ApproveNewReconOperation(engineConfig, cellIndex);
|
||||
return new ApproveNewReconOperation(engineConfig, columnName);
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ public class ApproveReconcileCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cell"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
|
||||
return new ApproveReconOperation(engineConfig, cellIndex);
|
||||
return new ApproveReconOperation(engineConfig, columnName);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public class DiscardReconcileCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cell"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
|
||||
return new DiscardReconOperation(engineConfig, cellIndex);
|
||||
return new DiscardReconOperation(engineConfig, columnName);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ public class ReconcileCommand extends EngineDependentCommand {
|
||||
protected AbstractOperation createOperation(HttpServletRequest request,
|
||||
JSONObject engineConfig) throws Exception {
|
||||
|
||||
int cellIndex = Integer.parseInt(request.getParameter("cell"));
|
||||
String columnName = request.getParameter("columnName");
|
||||
String typeID = request.getParameter("type");
|
||||
|
||||
return new ReconOperation(engineConfig, cellIndex, typeID);
|
||||
return new ReconOperation(engineConfig, columnName, typeID);
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ public class ColumnModel implements Serializable, Jsonizable {
|
||||
writer.endArray();
|
||||
|
||||
writer.key("keyCellIndex"); writer.value(getKeyColumnIndex());
|
||||
writer.key("keyColumnName"); writer.value(columns.get(_keyColumnIndex).getHeaderLabel());
|
||||
writer.key("columnGroups");
|
||||
writer.array();
|
||||
for (ColumnGroup g : _rootColumnGroups) {
|
||||
|
@ -19,14 +19,18 @@ import com.metaweb.gridworks.model.changes.CellChange;
|
||||
public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
|
||||
private static final long serialVersionUID = -5205694623711144436L;
|
||||
|
||||
public ApproveNewReconOperation(JSONObject engineConfig, int cellIndex) {
|
||||
super(engineConfig, cellIndex, false);
|
||||
public ApproveNewReconOperation(JSONObject engineConfig, String columnName) {
|
||||
super(engineConfig, columnName, false);
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
throws JSONException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
writer.object();
|
||||
writer.key("description"); writer.value("Approve new topics in column " + _columnName);
|
||||
writer.key("engineConfig"); writer.value(_engineConfig);
|
||||
writer.key("columnName"); writer.value(_columnName);
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
protected String createDescription(Column column,
|
||||
@ -37,7 +41,8 @@ public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
|
||||
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
|
||||
return new RowVisitor() {
|
||||
int cellIndex;
|
||||
List<CellChange> cellChanges;
|
||||
@ -64,6 +69,6 @@ public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}.init(_cellIndex, cellChanges);
|
||||
}.init(column.getCellIndex(), cellChanges);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ import com.metaweb.gridworks.model.changes.CellChange;
|
||||
public class ApproveReconOperation extends EngineDependentMassCellOperation {
|
||||
private static final long serialVersionUID = 5393888241057341155L;
|
||||
|
||||
public ApproveReconOperation(JSONObject engineConfig, int cellIndex) {
|
||||
super(engineConfig, cellIndex, false);
|
||||
public ApproveReconOperation(JSONObject engineConfig, String columnName) {
|
||||
super(engineConfig, columnName, false);
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
@ -36,7 +36,8 @@ public class ApproveReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
|
||||
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
|
||||
return new RowVisitor() {
|
||||
int cellIndex;
|
||||
List<CellChange> cellChanges;
|
||||
@ -64,6 +65,6 @@ public class ApproveReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}.init(_cellIndex, cellChanges);
|
||||
}.init(column.getCellIndex(), cellChanges);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
||||
public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
private static final long serialVersionUID = -5672677479629932356L;
|
||||
|
||||
final protected int _baseCellIndex;
|
||||
final protected String _baseColumnName;
|
||||
final protected String _expression;
|
||||
|
||||
final protected String _headerLabel;
|
||||
@ -36,14 +36,14 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
|
||||
public ColumnAdditionOperation(
|
||||
JSONObject engineConfig,
|
||||
int baseCellIndex,
|
||||
String baseColumnName,
|
||||
String expression,
|
||||
String headerLabel,
|
||||
int columnInsertIndex
|
||||
) {
|
||||
super(engineConfig);
|
||||
|
||||
_baseCellIndex = baseCellIndex;
|
||||
_baseColumnName = baseColumnName;
|
||||
_expression = expression;
|
||||
|
||||
_headerLabel = headerLabel;
|
||||
@ -55,9 +55,9 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
|
||||
Engine engine = createEngine(project);
|
||||
|
||||
Column column = project.columnModel.getColumnByCellIndex(_baseCellIndex);
|
||||
Column column = project.columnModel.getColumnByName(_baseColumnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column corresponding to cell index " + _baseCellIndex);
|
||||
throw new Exception("No column named " + _baseColumnName);
|
||||
}
|
||||
|
||||
List<CellAtRow> cellsAtRows = new ArrayList<CellAtRow>(project.rows.size());
|
||||
@ -88,6 +88,8 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
}
|
||||
|
||||
protected RowVisitor createRowVisitor(Project project, List<CellAtRow> cellsAtRows) throws Exception {
|
||||
Column column = project.columnModel.getColumnByName(_baseColumnName);
|
||||
|
||||
Evaluable eval = new Parser(_expression).getExpression();
|
||||
Properties bindings = ExpressionUtils.createBindings(project);
|
||||
|
||||
@ -119,6 +121,6 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
|
||||
return false;
|
||||
}
|
||||
}.init(_baseCellIndex, bindings, cellsAtRows, eval);
|
||||
}.init(column.getCellIndex(), bindings, cellsAtRows, eval);
|
||||
}
|
||||
}
|
||||
|
@ -17,25 +17,25 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
||||
public class ColumnRemovalOperation implements AbstractOperation {
|
||||
private static final long serialVersionUID = 8422079695048733734L;
|
||||
|
||||
final protected int _columnRemovalIndex;
|
||||
final protected String _columnName;
|
||||
|
||||
public ColumnRemovalOperation(
|
||||
int columnRemoveIndex
|
||||
String columnName
|
||||
) {
|
||||
_columnRemovalIndex = columnRemoveIndex;
|
||||
_columnName = columnName;
|
||||
}
|
||||
|
||||
public Process createProcess(Project project, Properties options)
|
||||
throws Exception {
|
||||
|
||||
Column column = project.columnModel.columns.get(_columnRemovalIndex);
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column at index " + _columnRemovalIndex);
|
||||
throw new Exception("No column named " + _columnName);
|
||||
}
|
||||
|
||||
String description = "Remove column " + column.getHeaderLabel();
|
||||
|
||||
Change change = new ColumnRemovalChange(_columnRemovalIndex);
|
||||
Change change = new ColumnRemovalChange(project.columnModel.columns.indexOf(column));
|
||||
HistoryEntry historyEntry = new HistoryEntry(
|
||||
project, description, this, change);
|
||||
|
||||
|
@ -17,8 +17,8 @@ import com.metaweb.gridworks.model.changes.CellChange;
|
||||
public class DiscardReconOperation extends EngineDependentMassCellOperation {
|
||||
private static final long serialVersionUID = 6799029731665369179L;
|
||||
|
||||
public DiscardReconOperation(JSONObject engineConfig, int cellIndex) {
|
||||
super(engineConfig, cellIndex, false);
|
||||
public DiscardReconOperation(JSONObject engineConfig, String columnName) {
|
||||
super(engineConfig, columnName, false);
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
@ -35,7 +35,8 @@ public class DiscardReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
|
||||
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
|
||||
return new RowVisitor() {
|
||||
int cellIndex;
|
||||
List<CellChange> cellChanges;
|
||||
@ -57,6 +58,6 @@ public class DiscardReconOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}.init(_cellIndex, cellChanges);
|
||||
}.init(column.getCellIndex(), cellChanges);
|
||||
}
|
||||
}
|
||||
|
@ -20,22 +20,22 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
||||
abstract public class EngineDependentMassCellOperation extends EngineDependentOperation {
|
||||
private static final long serialVersionUID = -8962461328087299452L;
|
||||
|
||||
final protected int _cellIndex;
|
||||
final protected String _columnName;
|
||||
final protected boolean _updateRowContextDependencies;
|
||||
|
||||
protected EngineDependentMassCellOperation(
|
||||
JSONObject engineConfig, int cellIndex, boolean updateRowContextDependencies) {
|
||||
JSONObject engineConfig, String columnName, boolean updateRowContextDependencies) {
|
||||
super(engineConfig);
|
||||
_cellIndex = cellIndex;
|
||||
_columnName = columnName;
|
||||
_updateRowContextDependencies = updateRowContextDependencies;
|
||||
}
|
||||
|
||||
public Process createProcess(Project project, Properties options) throws Exception {
|
||||
Engine engine = createEngine(project);
|
||||
|
||||
Column column = project.columnModel.getColumnByCellIndex(_cellIndex);
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column corresponding to cell index " + _cellIndex);
|
||||
throw new Exception("No column named " + _columnName);
|
||||
}
|
||||
|
||||
List<CellChange> cellChanges = new ArrayList<CellChange>(project.rows.size());
|
||||
@ -45,7 +45,7 @@ abstract public class EngineDependentMassCellOperation extends EngineDependentOp
|
||||
|
||||
String description = createDescription(column, cellChanges);
|
||||
|
||||
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex, _updateRowContextDependencies);
|
||||
MassCellChange massCellChange = new MassCellChange(cellChanges, column.getCellIndex(), _updateRowContextDependencies);
|
||||
HistoryEntry historyEntry = new HistoryEntry(
|
||||
project, description, this, massCellChange);
|
||||
|
||||
|
@ -22,27 +22,34 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
||||
public class MultiValueCellJoinOperation implements AbstractOperation {
|
||||
private static final long serialVersionUID = 3134524625206033285L;
|
||||
|
||||
final protected int _cellIndex;
|
||||
final protected int _keyCellIndex;
|
||||
final protected String _columnName;
|
||||
final protected String _keyColumnName;
|
||||
final protected String _separator;
|
||||
|
||||
public MultiValueCellJoinOperation(
|
||||
int cellIndex,
|
||||
int keyCellIndex,
|
||||
String columnName,
|
||||
String keyColumnName,
|
||||
String separator
|
||||
) {
|
||||
_cellIndex = cellIndex;
|
||||
_keyCellIndex = keyCellIndex;
|
||||
_columnName = columnName;
|
||||
_keyColumnName = keyColumnName;
|
||||
_separator = separator;
|
||||
}
|
||||
|
||||
public Process createProcess(Project project, Properties options)
|
||||
throws Exception {
|
||||
|
||||
Column column = project.columnModel.getColumnByCellIndex(_cellIndex);
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column corresponding to cell index " + _cellIndex);
|
||||
throw new Exception("No column named " + _columnName);
|
||||
}
|
||||
int cellIndex = column.getCellIndex();
|
||||
|
||||
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No key column named " + _keyColumnName);
|
||||
}
|
||||
int keyCellIndex = keyColumn.getCellIndex();
|
||||
|
||||
List<Row> newRows = new ArrayList<Row>();
|
||||
|
||||
@ -50,13 +57,13 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
|
||||
for (int r = 0; r < oldRowCount; r++) {
|
||||
Row oldRow = project.rows.get(r);
|
||||
|
||||
if (oldRow.isCellBlank(_keyCellIndex)) {
|
||||
if (oldRow.isCellBlank(keyCellIndex)) {
|
||||
newRows.add(oldRow.dup());
|
||||
continue;
|
||||
}
|
||||
|
||||
int r2 = r + 1;
|
||||
while (r2 < oldRowCount && project.rows.get(r2).isCellBlank(_keyCellIndex)) {
|
||||
while (r2 < oldRowCount && project.rows.get(r2).isCellBlank(keyCellIndex)) {
|
||||
r2++;
|
||||
}
|
||||
|
||||
@ -67,7 +74,7 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int r3 = r; r3 < r2; r3++) {
|
||||
Object value = project.rows.get(r3).getCellValue(_cellIndex);
|
||||
Object value = project.rows.get(r3).getCellValue(cellIndex);
|
||||
if (!ExpressionUtils.isBlank(value)) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(_separator);
|
||||
@ -79,9 +86,9 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
|
||||
for (int r3 = r; r3 < r2; r3++) {
|
||||
Row newRow = project.rows.get(r3).dup();
|
||||
if (r3 == r) {
|
||||
newRow.setCell(_cellIndex, new Cell(sb.toString(), null));
|
||||
newRow.setCell(cellIndex, new Cell(sb.toString(), null));
|
||||
} else {
|
||||
newRow.setCell(_cellIndex, null);
|
||||
newRow.setCell(cellIndex, null);
|
||||
}
|
||||
|
||||
if (!newRow.isEmpty()) {
|
||||
|
@ -22,19 +22,19 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
||||
public class MultiValueCellSplitOperation implements AbstractOperation {
|
||||
private static final long serialVersionUID = 8217930220439070322L;
|
||||
|
||||
final protected int _cellIndex;
|
||||
final protected int _keyCellIndex;
|
||||
final protected String _columnName;
|
||||
final protected String _keyColumnName;
|
||||
final protected String _separator;
|
||||
final protected String _mode;
|
||||
|
||||
public MultiValueCellSplitOperation(
|
||||
int cellIndex,
|
||||
int keyCellIndex,
|
||||
String columnName,
|
||||
String keyColumnName,
|
||||
String separator,
|
||||
String mode
|
||||
) {
|
||||
_cellIndex = cellIndex;
|
||||
_keyCellIndex = keyCellIndex;
|
||||
_columnName = columnName;
|
||||
_keyColumnName = keyColumnName;
|
||||
_separator = separator;
|
||||
_mode = mode;
|
||||
}
|
||||
@ -42,22 +42,29 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
|
||||
public Process createProcess(Project project, Properties options)
|
||||
throws Exception {
|
||||
|
||||
Column column = project.columnModel.getColumnByCellIndex(_cellIndex);
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column corresponding to cell index " + _cellIndex);
|
||||
throw new Exception("No column named " + _columnName);
|
||||
}
|
||||
int cellIndex = column.getCellIndex();
|
||||
|
||||
Column keyColumn = project.columnModel.getColumnByName(_keyColumnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No key column named " + _keyColumnName);
|
||||
}
|
||||
int keyCellIndex = keyColumn.getCellIndex();
|
||||
|
||||
List<Row> newRows = new ArrayList<Row>();
|
||||
|
||||
int oldRowCount = project.rows.size();
|
||||
for (int r = 0; r < oldRowCount; r++) {
|
||||
Row oldRow = project.rows.get(r);
|
||||
if (oldRow.isCellBlank(_cellIndex)) {
|
||||
if (oldRow.isCellBlank(cellIndex)) {
|
||||
newRows.add(oldRow.dup());
|
||||
continue;
|
||||
}
|
||||
|
||||
Object value = oldRow.getCellValue(_cellIndex);
|
||||
Object value = oldRow.getCellValue(cellIndex);
|
||||
String s = value instanceof String ? ((String) value) : value.toString();
|
||||
String[] values = null;
|
||||
if (_mode.equals("regex")) {
|
||||
@ -74,7 +81,7 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
|
||||
// First value goes into the same row
|
||||
{
|
||||
Row firstNewRow = oldRow.dup();
|
||||
firstNewRow.setCell(_cellIndex, new Cell(values[0].trim(), null));
|
||||
firstNewRow.setCell(cellIndex, new Cell(values[0].trim(), null));
|
||||
|
||||
newRows.add(firstNewRow);
|
||||
}
|
||||
@ -85,11 +92,11 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
|
||||
|
||||
if (r2 < project.rows.size()) {
|
||||
Row oldRow2 = project.rows.get(r2);
|
||||
if (oldRow2.isCellBlank(_cellIndex) &&
|
||||
oldRow2.isCellBlank(_keyCellIndex)) {
|
||||
if (oldRow2.isCellBlank(cellIndex) &&
|
||||
oldRow2.isCellBlank(keyCellIndex)) {
|
||||
|
||||
Row newRow = oldRow2.dup();
|
||||
newRow.setCell(_cellIndex, newCell);
|
||||
newRow.setCell(cellIndex, newCell);
|
||||
|
||||
newRows.add(newRow);
|
||||
r2++;
|
||||
@ -98,8 +105,8 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
|
||||
}
|
||||
}
|
||||
|
||||
Row newRow = new Row(_cellIndex + 1);
|
||||
newRow.setCell(_cellIndex, newCell);
|
||||
Row newRow = new Row(cellIndex + 1);
|
||||
newRow.setCell(cellIndex, newCell);
|
||||
|
||||
newRows.add(newRow);
|
||||
}
|
||||
|
@ -43,21 +43,21 @@ import com.metaweb.gridworks.util.ParsingUtilities;
|
||||
public class ReconOperation extends EngineDependentOperation {
|
||||
private static final long serialVersionUID = 838795186905314865L;
|
||||
|
||||
final protected int _cellIndex;
|
||||
final protected String _columnName;
|
||||
final protected String _typeID;
|
||||
|
||||
public ReconOperation(JSONObject engineConfig, int cellIndex, String typeID) {
|
||||
public ReconOperation(JSONObject engineConfig, String columnName, String typeID) {
|
||||
super(engineConfig);
|
||||
_cellIndex = cellIndex;
|
||||
_columnName = columnName;
|
||||
_typeID = typeID;
|
||||
}
|
||||
|
||||
public Process createProcess(Project project, Properties options) throws Exception {
|
||||
Engine engine = createEngine(project);
|
||||
|
||||
Column column = project.columnModel.getColumnByCellIndex(_cellIndex);
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
if (column == null) {
|
||||
throw new Exception("No column corresponding to cell index " + _cellIndex);
|
||||
throw new Exception("No column named " + _columnName);
|
||||
}
|
||||
|
||||
List<ReconEntry> entries = new ArrayList<ReconEntry>(project.rows.size());
|
||||
@ -82,14 +82,14 @@ public class ReconOperation extends EngineDependentOperation {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}.init(_cellIndex, entries));
|
||||
}.init(column.getCellIndex(), entries));
|
||||
|
||||
String description =
|
||||
"Reconcile " + entries.size() +
|
||||
" cells in column " + column.getHeaderLabel() +
|
||||
" to type " + _typeID;
|
||||
|
||||
return new ReconProcess(project, description, entries);
|
||||
return new ReconProcess(project, description, entries, column.getCellIndex());
|
||||
}
|
||||
|
||||
public void write(JSONWriter writer, Properties options)
|
||||
@ -146,11 +146,13 @@ public class ReconOperation extends EngineDependentOperation {
|
||||
public class ReconProcess extends LongRunningProcess implements Runnable {
|
||||
final protected Project _project;
|
||||
final protected List<ReconEntry> _entries;
|
||||
final protected int _cellIndex;
|
||||
|
||||
public ReconProcess(Project project, String description, List<ReconEntry> entries) {
|
||||
public ReconProcess(Project project, String description, List<ReconEntry> entries, int cellIndex) {
|
||||
super(description);
|
||||
_project = project;
|
||||
_entries = entries;
|
||||
_cellIndex = cellIndex;
|
||||
}
|
||||
|
||||
protected Runnable getRunnable() {
|
||||
|
@ -22,8 +22,8 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
|
||||
final protected String _expression;
|
||||
|
||||
public TextTransformOperation(JSONObject engineConfig, int cellIndex, String expression) {
|
||||
super(engineConfig, cellIndex, true);
|
||||
public TextTransformOperation(JSONObject engineConfig, String columnName, String expression) {
|
||||
super(engineConfig, columnName, true);
|
||||
_expression = expression;
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
|
||||
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
|
||||
Column column = project.columnModel.getColumnByName(_columnName);
|
||||
|
||||
Evaluable eval = new Parser(_expression).getExpression();
|
||||
Properties bindings = ExpressionUtils.createBindings(project);
|
||||
|
||||
@ -72,6 +74,6 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
|
||||
return false;
|
||||
}
|
||||
}.init(_cellIndex, bindings, cellChanges, eval);
|
||||
}.init(column.getCellIndex(), bindings, cellChanges, eval);
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
|
||||
label: "Start Reconciling ...",
|
||||
tooltip: "Reconcile text in this column with topics on Freebase",
|
||||
click: function() {
|
||||
new ReconDialog(self._columnIndex);
|
||||
new ReconDialog(self._column);
|
||||
}
|
||||
},
|
||||
{},
|
||||
@ -367,7 +367,7 @@ DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(express
|
||||
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"do-text-transform",
|
||||
{ cell: this._column.cellIndex, expression: expression }
|
||||
{ columnName: this._column.headerLabel, expression: expression }
|
||||
);
|
||||
};
|
||||
|
||||
@ -386,21 +386,21 @@ DataTableColumnHeaderUI.prototype._doTextTransformPrompt = function() {
|
||||
DataTableColumnHeaderUI.prototype._doDiscardReconResults = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"discard-reconcile",
|
||||
{ cell: this._column.cellIndex }
|
||||
{ columnName: this._column.headerLabel }
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doApproveBestCandidates = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"approve-reconcile",
|
||||
{ cell: this._column.cellIndex }
|
||||
{ columnName: this._column.headerLabel }
|
||||
);
|
||||
};
|
||||
|
||||
DataTableColumnHeaderUI.prototype._doApproveNewTopics = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"approve-new-reconcile",
|
||||
{ cell: this._column.cellIndex }
|
||||
{ columnName: this._column.headerLabel }
|
||||
);
|
||||
};
|
||||
|
||||
@ -416,7 +416,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
self._dataTableView.doPostThenUpdate(
|
||||
"add-column",
|
||||
{
|
||||
baseCellIndex: self._column.cellIndex,
|
||||
baseColumnName: self._column.headerLabel,
|
||||
expression: expression,
|
||||
headerLabel: headerLabel,
|
||||
columnInsertIndex: self._columnIndex + 1
|
||||
@ -431,7 +431,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
|
||||
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"remove-column",
|
||||
{ columnRemovalIndex: this._columnIndex },
|
||||
{ columnName: this._column.headerLabel },
|
||||
true
|
||||
);
|
||||
};
|
||||
@ -442,8 +442,8 @@ DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"join-multi-value-cells",
|
||||
{
|
||||
cellIndex: this._column.cellIndex,
|
||||
keyCellIndex: theProject.columnModel.keyCellIndex,
|
||||
columnName: this._column.headerLabel,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator
|
||||
}
|
||||
);
|
||||
@ -456,8 +456,8 @@ DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() {
|
||||
this._dataTableView.doPostThenUpdate(
|
||||
"split-multi-value-cells",
|
||||
{
|
||||
cellIndex: this._column.cellIndex,
|
||||
keyCellIndex: theProject.columnModel.keyCellIndex,
|
||||
columnName: this._column.headerLabel,
|
||||
keyColumnName: theProject.columnModel.keyColumnName,
|
||||
separator: separator,
|
||||
mode: "plain"
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ DataTableView.prototype.render = function() {
|
||||
td.innerHTML = " ";
|
||||
} else {
|
||||
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;
|
||||
new DataTableCellUI(this, cell, r, column.cellIndex, td);
|
||||
new DataTableCellUI(this, cell, row.i, column.cellIndex, td);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
function ReconDialog(columnIndex) {
|
||||
this._columnIndex = columnIndex;
|
||||
this._column = theProject.columnModel.columns[columnIndex];
|
||||
|
||||
function ReconDialog(column) {
|
||||
this._column = column;
|
||||
this._createDialog();
|
||||
}
|
||||
|
||||
@ -25,7 +23,7 @@ ReconDialog.prototype._createDialog = function() {
|
||||
$('<button></button>').text("Start Reconciling").click(function() {
|
||||
DialogSystem.dismissUntil(level - 1);
|
||||
$.post(
|
||||
"/command/reconcile?" + $.param({ project: theProject.id, cell: self._column.cellIndex, type: type }),
|
||||
"/command/reconcile?" + $.param({ project: theProject.id, columnName: self._column.headerLabel, type: type }),
|
||||
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
||||
function(data) {
|
||||
if (data.code != "error") {
|
||||
|
Loading…
Reference in New Issue
Block a user