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:
David Huynh 2010-02-17 00:26:38 +00:00
parent e6a98f23bd
commit 32157ce76b
23 changed files with 134 additions and 108 deletions

View File

@ -13,14 +13,14 @@ public class AddColumnCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { JSONObject engineConfig) throws Exception {
int baseCellIndex = Integer.parseInt(request.getParameter("baseCellIndex")); String baseColumnName = request.getParameter("baseColumnName");
String expression = request.getParameter("expression"); String expression = request.getParameter("expression");
String headerLabel = request.getParameter("headerLabel"); String headerLabel = request.getParameter("headerLabel");
int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex")); int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex"));
return new ColumnAdditionOperation( return new ColumnAdditionOperation(
engineConfig, engineConfig,
baseCellIndex, baseColumnName,
expression, expression,
headerLabel, headerLabel,
columnInsertIndex columnInsertIndex

View File

@ -14,9 +14,9 @@ public class DoTextTransformCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { JSONObject engineConfig) throws Exception {
int cellIndex = Integer.parseInt(request.getParameter("cell")); String columnName = request.getParameter("columnName");
String expression = request.getParameter("expression"); String expression = request.getParameter("expression");
return new TextTransformOperation(engineConfig, cellIndex, expression); return new TextTransformOperation(engineConfig, columnName, expression);
} }
} }

View File

@ -21,11 +21,11 @@ public class JoinMultiValueCellsCommand extends Command {
try { try {
Project project = getProject(request); Project project = getProject(request);
int cellIndex = Integer.parseInt(request.getParameter("cellIndex")); String columnName = request.getParameter("columnName");
int keyCellIndex = Integer.parseInt(request.getParameter("keyCellIndex")); String keyColumnName = request.getParameter("keyColumnName");
String separator = request.getParameter("separator"); 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()); Process process = op.createProcess(project, new Properties());
boolean done = project.processManager.queueProcess(process); boolean done = project.processManager.queueProcess(process);

View File

@ -21,9 +21,9 @@ public class RemoveColumnCommand extends Command {
try { try {
Project project = getProject(request); 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()); Process process = op.createProcess(project, new Properties());
boolean done = project.processManager.queueProcess(process); boolean done = project.processManager.queueProcess(process);

View File

@ -21,12 +21,12 @@ public class SplitMultiValueCellsCommand extends Command {
try { try {
Project project = getProject(request); Project project = getProject(request);
int cellIndex = Integer.parseInt(request.getParameter("cellIndex")); String columnName = request.getParameter("columnName");
int keyCellIndex = Integer.parseInt(request.getParameter("keyCellIndex")); String keyColumnName = request.getParameter("keyColumnName");
String separator = request.getParameter("separator"); String separator = request.getParameter("separator");
String mode = request.getParameter("mode"); 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()); Process process = op.createProcess(project, new Properties());
boolean done = project.processManager.queueProcess(process); boolean done = project.processManager.queueProcess(process);

View File

@ -14,8 +14,8 @@ public class ApproveNewReconcileCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { 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);
} }
} }

View File

@ -14,8 +14,8 @@ public class ApproveReconcileCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { 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);
} }
} }

View File

@ -13,8 +13,8 @@ public class DiscardReconcileCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { 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);
} }
} }

View File

@ -14,9 +14,9 @@ public class ReconcileCommand extends EngineDependentCommand {
protected AbstractOperation createOperation(HttpServletRequest request, protected AbstractOperation createOperation(HttpServletRequest request,
JSONObject engineConfig) throws Exception { JSONObject engineConfig) throws Exception {
int cellIndex = Integer.parseInt(request.getParameter("cell")); String columnName = request.getParameter("columnName");
String typeID = request.getParameter("type"); String typeID = request.getParameter("type");
return new ReconOperation(engineConfig, cellIndex, typeID); return new ReconOperation(engineConfig, columnName, typeID);
} }
} }

View File

@ -79,6 +79,7 @@ public class ColumnModel implements Serializable, Jsonizable {
writer.endArray(); writer.endArray();
writer.key("keyCellIndex"); writer.value(getKeyColumnIndex()); writer.key("keyCellIndex"); writer.value(getKeyColumnIndex());
writer.key("keyColumnName"); writer.value(columns.get(_keyColumnIndex).getHeaderLabel());
writer.key("columnGroups"); writer.key("columnGroups");
writer.array(); writer.array();
for (ColumnGroup g : _rootColumnGroups) { for (ColumnGroup g : _rootColumnGroups) {

View File

@ -19,14 +19,18 @@ import com.metaweb.gridworks.model.changes.CellChange;
public class ApproveNewReconOperation extends EngineDependentMassCellOperation { public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = -5205694623711144436L; private static final long serialVersionUID = -5205694623711144436L;
public ApproveNewReconOperation(JSONObject engineConfig, int cellIndex) { public ApproveNewReconOperation(JSONObject engineConfig, String columnName) {
super(engineConfig, cellIndex, false); super(engineConfig, columnName, false);
} }
public void write(JSONWriter writer, Properties options) public void write(JSONWriter writer, Properties options)
throws JSONException { 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, protected String createDescription(Column column,
@ -37,7 +41,8 @@ public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
} }
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception { protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
// TODO Auto-generated method stub Column column = project.columnModel.getColumnByName(_columnName);
return new RowVisitor() { return new RowVisitor() {
int cellIndex; int cellIndex;
List<CellChange> cellChanges; List<CellChange> cellChanges;
@ -64,6 +69,6 @@ public class ApproveNewReconOperation extends EngineDependentMassCellOperation {
} }
return false; return false;
} }
}.init(_cellIndex, cellChanges); }.init(column.getCellIndex(), cellChanges);
} }
} }

View File

@ -18,8 +18,8 @@ import com.metaweb.gridworks.model.changes.CellChange;
public class ApproveReconOperation extends EngineDependentMassCellOperation { public class ApproveReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = 5393888241057341155L; private static final long serialVersionUID = 5393888241057341155L;
public ApproveReconOperation(JSONObject engineConfig, int cellIndex) { public ApproveReconOperation(JSONObject engineConfig, String columnName) {
super(engineConfig, cellIndex, false); super(engineConfig, columnName, false);
} }
public void write(JSONWriter writer, Properties options) 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 { protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
// TODO Auto-generated method stub Column column = project.columnModel.getColumnByName(_columnName);
return new RowVisitor() { return new RowVisitor() {
int cellIndex; int cellIndex;
List<CellChange> cellChanges; List<CellChange> cellChanges;
@ -64,6 +65,6 @@ public class ApproveReconOperation extends EngineDependentMassCellOperation {
} }
return false; return false;
} }
}.init(_cellIndex, cellChanges); }.init(column.getCellIndex(), cellChanges);
} }
} }

View File

@ -28,7 +28,7 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
public class ColumnAdditionOperation extends EngineDependentOperation { public class ColumnAdditionOperation extends EngineDependentOperation {
private static final long serialVersionUID = -5672677479629932356L; private static final long serialVersionUID = -5672677479629932356L;
final protected int _baseCellIndex; final protected String _baseColumnName;
final protected String _expression; final protected String _expression;
final protected String _headerLabel; final protected String _headerLabel;
@ -36,14 +36,14 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
public ColumnAdditionOperation( public ColumnAdditionOperation(
JSONObject engineConfig, JSONObject engineConfig,
int baseCellIndex, String baseColumnName,
String expression, String expression,
String headerLabel, String headerLabel,
int columnInsertIndex int columnInsertIndex
) { ) {
super(engineConfig); super(engineConfig);
_baseCellIndex = baseCellIndex; _baseColumnName = baseColumnName;
_expression = expression; _expression = expression;
_headerLabel = headerLabel; _headerLabel = headerLabel;
@ -55,9 +55,9 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
Engine engine = createEngine(project); Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByCellIndex(_baseCellIndex); Column column = project.columnModel.getColumnByName(_baseColumnName);
if (column == null) { 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()); 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 { protected RowVisitor createRowVisitor(Project project, List<CellAtRow> cellsAtRows) throws Exception {
Column column = project.columnModel.getColumnByName(_baseColumnName);
Evaluable eval = new Parser(_expression).getExpression(); Evaluable eval = new Parser(_expression).getExpression();
Properties bindings = ExpressionUtils.createBindings(project); Properties bindings = ExpressionUtils.createBindings(project);
@ -119,6 +121,6 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
return false; return false;
} }
}.init(_baseCellIndex, bindings, cellsAtRows, eval); }.init(column.getCellIndex(), bindings, cellsAtRows, eval);
} }
} }

View File

@ -17,25 +17,25 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
public class ColumnRemovalOperation implements AbstractOperation { public class ColumnRemovalOperation implements AbstractOperation {
private static final long serialVersionUID = 8422079695048733734L; private static final long serialVersionUID = 8422079695048733734L;
final protected int _columnRemovalIndex; final protected String _columnName;
public ColumnRemovalOperation( public ColumnRemovalOperation(
int columnRemoveIndex String columnName
) { ) {
_columnRemovalIndex = columnRemoveIndex; _columnName = columnName;
} }
public Process createProcess(Project project, Properties options) public Process createProcess(Project project, Properties options)
throws Exception { throws Exception {
Column column = project.columnModel.columns.get(_columnRemovalIndex); Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) { if (column == null) {
throw new Exception("No column at index " + _columnRemovalIndex); throw new Exception("No column named " + _columnName);
} }
String description = "Remove column " + column.getHeaderLabel(); String description = "Remove column " + column.getHeaderLabel();
Change change = new ColumnRemovalChange(_columnRemovalIndex); Change change = new ColumnRemovalChange(project.columnModel.columns.indexOf(column));
HistoryEntry historyEntry = new HistoryEntry( HistoryEntry historyEntry = new HistoryEntry(
project, description, this, change); project, description, this, change);

View File

@ -17,8 +17,8 @@ import com.metaweb.gridworks.model.changes.CellChange;
public class DiscardReconOperation extends EngineDependentMassCellOperation { public class DiscardReconOperation extends EngineDependentMassCellOperation {
private static final long serialVersionUID = 6799029731665369179L; private static final long serialVersionUID = 6799029731665369179L;
public DiscardReconOperation(JSONObject engineConfig, int cellIndex) { public DiscardReconOperation(JSONObject engineConfig, String columnName) {
super(engineConfig, cellIndex, false); super(engineConfig, columnName, false);
} }
public void write(JSONWriter writer, Properties options) 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 { protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
// TODO Auto-generated method stub Column column = project.columnModel.getColumnByName(_columnName);
return new RowVisitor() { return new RowVisitor() {
int cellIndex; int cellIndex;
List<CellChange> cellChanges; List<CellChange> cellChanges;
@ -57,6 +58,6 @@ public class DiscardReconOperation extends EngineDependentMassCellOperation {
} }
return false; return false;
} }
}.init(_cellIndex, cellChanges); }.init(column.getCellIndex(), cellChanges);
} }
} }

View File

@ -20,22 +20,22 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
abstract public class EngineDependentMassCellOperation extends EngineDependentOperation { abstract public class EngineDependentMassCellOperation extends EngineDependentOperation {
private static final long serialVersionUID = -8962461328087299452L; private static final long serialVersionUID = -8962461328087299452L;
final protected int _cellIndex; final protected String _columnName;
final protected boolean _updateRowContextDependencies; final protected boolean _updateRowContextDependencies;
protected EngineDependentMassCellOperation( protected EngineDependentMassCellOperation(
JSONObject engineConfig, int cellIndex, boolean updateRowContextDependencies) { JSONObject engineConfig, String columnName, boolean updateRowContextDependencies) {
super(engineConfig); super(engineConfig);
_cellIndex = cellIndex; _columnName = columnName;
_updateRowContextDependencies = updateRowContextDependencies; _updateRowContextDependencies = updateRowContextDependencies;
} }
public Process createProcess(Project project, Properties options) throws Exception { public Process createProcess(Project project, Properties options) throws Exception {
Engine engine = createEngine(project); Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByCellIndex(_cellIndex); Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) { 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()); List<CellChange> cellChanges = new ArrayList<CellChange>(project.rows.size());
@ -45,7 +45,7 @@ abstract public class EngineDependentMassCellOperation extends EngineDependentOp
String description = createDescription(column, cellChanges); String description = createDescription(column, cellChanges);
MassCellChange massCellChange = new MassCellChange(cellChanges, _cellIndex, _updateRowContextDependencies); MassCellChange massCellChange = new MassCellChange(cellChanges, column.getCellIndex(), _updateRowContextDependencies);
HistoryEntry historyEntry = new HistoryEntry( HistoryEntry historyEntry = new HistoryEntry(
project, description, this, massCellChange); project, description, this, massCellChange);

View File

@ -22,27 +22,34 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
public class MultiValueCellJoinOperation implements AbstractOperation { public class MultiValueCellJoinOperation implements AbstractOperation {
private static final long serialVersionUID = 3134524625206033285L; private static final long serialVersionUID = 3134524625206033285L;
final protected int _cellIndex; final protected String _columnName;
final protected int _keyCellIndex; final protected String _keyColumnName;
final protected String _separator; final protected String _separator;
public MultiValueCellJoinOperation( public MultiValueCellJoinOperation(
int cellIndex, String columnName,
int keyCellIndex, String keyColumnName,
String separator String separator
) { ) {
_cellIndex = cellIndex; _columnName = columnName;
_keyCellIndex = keyCellIndex; _keyColumnName = keyColumnName;
_separator = separator; _separator = separator;
} }
public Process createProcess(Project project, Properties options) public Process createProcess(Project project, Properties options)
throws Exception { throws Exception {
Column column = project.columnModel.getColumnByCellIndex(_cellIndex); Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) { 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>(); List<Row> newRows = new ArrayList<Row>();
@ -50,13 +57,13 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
for (int r = 0; r < oldRowCount; r++) { for (int r = 0; r < oldRowCount; r++) {
Row oldRow = project.rows.get(r); Row oldRow = project.rows.get(r);
if (oldRow.isCellBlank(_keyCellIndex)) { if (oldRow.isCellBlank(keyCellIndex)) {
newRows.add(oldRow.dup()); newRows.add(oldRow.dup());
continue; continue;
} }
int r2 = r + 1; int r2 = r + 1;
while (r2 < oldRowCount && project.rows.get(r2).isCellBlank(_keyCellIndex)) { while (r2 < oldRowCount && project.rows.get(r2).isCellBlank(keyCellIndex)) {
r2++; r2++;
} }
@ -67,7 +74,7 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (int r3 = r; r3 < r2; r3++) { 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 (!ExpressionUtils.isBlank(value)) {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append(_separator); sb.append(_separator);
@ -79,9 +86,9 @@ public class MultiValueCellJoinOperation implements AbstractOperation {
for (int r3 = r; r3 < r2; r3++) { for (int r3 = r; r3 < r2; r3++) {
Row newRow = project.rows.get(r3).dup(); Row newRow = project.rows.get(r3).dup();
if (r3 == r) { if (r3 == r) {
newRow.setCell(_cellIndex, new Cell(sb.toString(), null)); newRow.setCell(cellIndex, new Cell(sb.toString(), null));
} else { } else {
newRow.setCell(_cellIndex, null); newRow.setCell(cellIndex, null);
} }
if (!newRow.isEmpty()) { if (!newRow.isEmpty()) {

View File

@ -22,19 +22,19 @@ import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
public class MultiValueCellSplitOperation implements AbstractOperation { public class MultiValueCellSplitOperation implements AbstractOperation {
private static final long serialVersionUID = 8217930220439070322L; private static final long serialVersionUID = 8217930220439070322L;
final protected int _cellIndex; final protected String _columnName;
final protected int _keyCellIndex; final protected String _keyColumnName;
final protected String _separator; final protected String _separator;
final protected String _mode; final protected String _mode;
public MultiValueCellSplitOperation( public MultiValueCellSplitOperation(
int cellIndex, String columnName,
int keyCellIndex, String keyColumnName,
String separator, String separator,
String mode String mode
) { ) {
_cellIndex = cellIndex; _columnName = columnName;
_keyCellIndex = keyCellIndex; _keyColumnName = keyColumnName;
_separator = separator; _separator = separator;
_mode = mode; _mode = mode;
} }
@ -42,22 +42,29 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
public Process createProcess(Project project, Properties options) public Process createProcess(Project project, Properties options)
throws Exception { throws Exception {
Column column = project.columnModel.getColumnByCellIndex(_cellIndex); Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) { 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>(); List<Row> newRows = new ArrayList<Row>();
int oldRowCount = project.rows.size(); int oldRowCount = project.rows.size();
for (int r = 0; r < oldRowCount; r++) { for (int r = 0; r < oldRowCount; r++) {
Row oldRow = project.rows.get(r); Row oldRow = project.rows.get(r);
if (oldRow.isCellBlank(_cellIndex)) { if (oldRow.isCellBlank(cellIndex)) {
newRows.add(oldRow.dup()); newRows.add(oldRow.dup());
continue; continue;
} }
Object value = oldRow.getCellValue(_cellIndex); Object value = oldRow.getCellValue(cellIndex);
String s = value instanceof String ? ((String) value) : value.toString(); String s = value instanceof String ? ((String) value) : value.toString();
String[] values = null; String[] values = null;
if (_mode.equals("regex")) { if (_mode.equals("regex")) {
@ -74,7 +81,7 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
// First value goes into the same row // First value goes into the same row
{ {
Row firstNewRow = oldRow.dup(); 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); newRows.add(firstNewRow);
} }
@ -85,11 +92,11 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
if (r2 < project.rows.size()) { if (r2 < project.rows.size()) {
Row oldRow2 = project.rows.get(r2); Row oldRow2 = project.rows.get(r2);
if (oldRow2.isCellBlank(_cellIndex) && if (oldRow2.isCellBlank(cellIndex) &&
oldRow2.isCellBlank(_keyCellIndex)) { oldRow2.isCellBlank(keyCellIndex)) {
Row newRow = oldRow2.dup(); Row newRow = oldRow2.dup();
newRow.setCell(_cellIndex, newCell); newRow.setCell(cellIndex, newCell);
newRows.add(newRow); newRows.add(newRow);
r2++; r2++;
@ -98,8 +105,8 @@ public class MultiValueCellSplitOperation implements AbstractOperation {
} }
} }
Row newRow = new Row(_cellIndex + 1); Row newRow = new Row(cellIndex + 1);
newRow.setCell(_cellIndex, newCell); newRow.setCell(cellIndex, newCell);
newRows.add(newRow); newRows.add(newRow);
} }

View File

@ -43,21 +43,21 @@ import com.metaweb.gridworks.util.ParsingUtilities;
public class ReconOperation extends EngineDependentOperation { public class ReconOperation extends EngineDependentOperation {
private static final long serialVersionUID = 838795186905314865L; private static final long serialVersionUID = 838795186905314865L;
final protected int _cellIndex; final protected String _columnName;
final protected String _typeID; final protected String _typeID;
public ReconOperation(JSONObject engineConfig, int cellIndex, String typeID) { public ReconOperation(JSONObject engineConfig, String columnName, String typeID) {
super(engineConfig); super(engineConfig);
_cellIndex = cellIndex; _columnName = columnName;
_typeID = typeID; _typeID = typeID;
} }
public Process createProcess(Project project, Properties options) throws Exception { public Process createProcess(Project project, Properties options) throws Exception {
Engine engine = createEngine(project); Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByCellIndex(_cellIndex); Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) { 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()); List<ReconEntry> entries = new ArrayList<ReconEntry>(project.rows.size());
@ -82,14 +82,14 @@ public class ReconOperation extends EngineDependentOperation {
} }
return false; return false;
} }
}.init(_cellIndex, entries)); }.init(column.getCellIndex(), entries));
String description = String description =
"Reconcile " + entries.size() + "Reconcile " + entries.size() +
" cells in column " + column.getHeaderLabel() + " cells in column " + column.getHeaderLabel() +
" to type " + _typeID; " to type " + _typeID;
return new ReconProcess(project, description, entries); return new ReconProcess(project, description, entries, column.getCellIndex());
} }
public void write(JSONWriter writer, Properties options) public void write(JSONWriter writer, Properties options)
@ -146,11 +146,13 @@ public class ReconOperation extends EngineDependentOperation {
public class ReconProcess extends LongRunningProcess implements Runnable { public class ReconProcess extends LongRunningProcess implements Runnable {
final protected Project _project; final protected Project _project;
final protected List<ReconEntry> _entries; 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); super(description);
_project = project; _project = project;
_entries = entries; _entries = entries;
_cellIndex = cellIndex;
} }
protected Runnable getRunnable() { protected Runnable getRunnable() {

View File

@ -22,8 +22,8 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
final protected String _expression; final protected String _expression;
public TextTransformOperation(JSONObject engineConfig, int cellIndex, String expression) { public TextTransformOperation(JSONObject engineConfig, String columnName, String expression) {
super(engineConfig, cellIndex, true); super(engineConfig, columnName, true);
_expression = expression; _expression = expression;
} }
@ -40,6 +40,8 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
} }
protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception { protected RowVisitor createRowVisitor(Project project, List<CellChange> cellChanges) throws Exception {
Column column = project.columnModel.getColumnByName(_columnName);
Evaluable eval = new Parser(_expression).getExpression(); Evaluable eval = new Parser(_expression).getExpression();
Properties bindings = ExpressionUtils.createBindings(project); Properties bindings = ExpressionUtils.createBindings(project);
@ -72,6 +74,6 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
return false; return false;
} }
}.init(_cellIndex, bindings, cellChanges, eval); }.init(column.getCellIndex(), bindings, cellChanges, eval);
} }
} }

View File

@ -187,7 +187,7 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
label: "Start Reconciling ...", label: "Start Reconciling ...",
tooltip: "Reconcile text in this column with topics on Freebase", tooltip: "Reconcile text in this column with topics on Freebase",
click: function() { click: function() {
new ReconDialog(self._columnIndex); new ReconDialog(self._column);
} }
}, },
{}, {},
@ -367,7 +367,7 @@ DataTableColumnHeaderUI.prototype._doFilterByExpressionPrompt = function(express
DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) { DataTableColumnHeaderUI.prototype._doTextTransform = function(expression) {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"do-text-transform", "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() { DataTableColumnHeaderUI.prototype._doDiscardReconResults = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"discard-reconcile", "discard-reconcile",
{ cell: this._column.cellIndex } { columnName: this._column.headerLabel }
); );
}; };
DataTableColumnHeaderUI.prototype._doApproveBestCandidates = function() { DataTableColumnHeaderUI.prototype._doApproveBestCandidates = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"approve-reconcile", "approve-reconcile",
{ cell: this._column.cellIndex } { columnName: this._column.headerLabel }
); );
}; };
DataTableColumnHeaderUI.prototype._doApproveNewTopics = function() { DataTableColumnHeaderUI.prototype._doApproveNewTopics = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"approve-new-reconcile", "approve-new-reconcile",
{ cell: this._column.cellIndex } { columnName: this._column.headerLabel }
); );
}; };
@ -416,7 +416,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
self._dataTableView.doPostThenUpdate( self._dataTableView.doPostThenUpdate(
"add-column", "add-column",
{ {
baseCellIndex: self._column.cellIndex, baseColumnName: self._column.headerLabel,
expression: expression, expression: expression,
headerLabel: headerLabel, headerLabel: headerLabel,
columnInsertIndex: self._columnIndex + 1 columnInsertIndex: self._columnIndex + 1
@ -431,7 +431,7 @@ DataTableColumnHeaderUI.prototype._doAddColumn = function(initialExpression) {
DataTableColumnHeaderUI.prototype._doRemoveColumn = function() { DataTableColumnHeaderUI.prototype._doRemoveColumn = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"remove-column", "remove-column",
{ columnRemovalIndex: this._columnIndex }, { columnName: this._column.headerLabel },
true true
); );
}; };
@ -442,8 +442,8 @@ DataTableColumnHeaderUI.prototype._doJoinMultiValueCells = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"join-multi-value-cells", "join-multi-value-cells",
{ {
cellIndex: this._column.cellIndex, columnName: this._column.headerLabel,
keyCellIndex: theProject.columnModel.keyCellIndex, keyColumnName: theProject.columnModel.keyColumnName,
separator: separator separator: separator
} }
); );
@ -456,8 +456,8 @@ DataTableColumnHeaderUI.prototype._doSplitMultiValueCells = function() {
this._dataTableView.doPostThenUpdate( this._dataTableView.doPostThenUpdate(
"split-multi-value-cells", "split-multi-value-cells",
{ {
cellIndex: this._column.cellIndex, columnName: this._column.headerLabel,
keyCellIndex: theProject.columnModel.keyCellIndex, keyColumnName: theProject.columnModel.keyColumnName,
separator: separator, separator: separator,
mode: "plain" mode: "plain"
} }

View File

@ -227,7 +227,7 @@ DataTableView.prototype.render = function() {
td.innerHTML = "&nbsp;"; td.innerHTML = "&nbsp;";
} else { } else {
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null; 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);
} }
} }
} }

View File

@ -1,7 +1,5 @@
function ReconDialog(columnIndex) { function ReconDialog(column) {
this._columnIndex = columnIndex; this._column = column;
this._column = theProject.columnModel.columns[columnIndex];
this._createDialog(); this._createDialog();
} }
@ -25,7 +23,7 @@ ReconDialog.prototype._createDialog = function() {
$('<button></button>').text("Start Reconciling").click(function() { $('<button></button>').text("Start Reconciling").click(function() {
DialogSystem.dismissUntil(level - 1); DialogSystem.dismissUntil(level - 1);
$.post( $.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()) }, { engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) { function(data) {
if (data.code != "error") { if (data.code != "error") {