Made sure commands that create new columns check for duplicate column names.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1126 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-08-01 04:44:21 +00:00
parent 4ad31ffcde
commit 965ef20790
5 changed files with 24 additions and 19 deletions

View File

@ -31,10 +31,14 @@ public class UndoRedoCommand extends Command {
}
}
boolean done = lastDoneID == -1 ||
project.processManager.queueProcess(
new HistoryProcess(project, lastDoneID));
respond(response, "{ \"code\" : " + (done ? "\"ok\"" : "\"pending\"") + " }");
try {
boolean done = lastDoneID == -1 ||
project.processManager.queueProcess(
new HistoryProcess(project, lastDoneID));
respond(response, "{ \"code\" : " + (done ? "\"ok\"" : "\"pending\"") + " }");
} catch (Exception e) {
respondException(response, e);
}
}
}

View File

@ -73,6 +73,12 @@ public class TransposeColumnsIntoRowsOperation extends AbstractOperation {
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
if (_combinedColumnName != null &&
!_combinedColumnName.isEmpty() &&
project.columnModel.getColumnByName(_combinedColumnName) != null) {
throw new Exception("Another column already named " + _combinedColumnName);
}
List<Column> newColumns = new ArrayList<Column>();
List<Column> oldColumns = project.columnModel.columns;

View File

@ -105,6 +105,9 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
if (column == null) {
throw new Exception("No column named " + _baseColumnName);
}
if (project.columnModel.getColumnByName(_newColumnName) != null) {
throw new Exception("Another column already named " + _newColumnName);
}
List<CellAtRow> cellsAtRows = new ArrayList<CellAtRow>(project.rows.size());

View File

@ -31,14 +31,9 @@ public class ProcessManager implements Jsonizable {
writer.endObject();
}
public HistoryEntry queueProcess(Process process) {
public HistoryEntry queueProcess(Process process) throws Exception {
if (process.isImmediate() && _processes.size() == 0) {
try {
return process.performImmediate();
} catch (Exception e) {
// TODO: Not sure what to do yet
e.printStackTrace();
}
return process.performImmediate();
} else {
_processes.add(process);
@ -47,14 +42,9 @@ public class ProcessManager implements Jsonizable {
return null;
}
public boolean queueProcess(HistoryProcess process) {
public boolean queueProcess(HistoryProcess process) throws Exception {
if (process.isImmediate() && _processes.size() == 0) {
try {
return process.performImmediate() != null;
} catch (Exception e) {
// TODO: Not sure what to do yet
e.printStackTrace();
}
return process.performImmediate() != null;
} else {
_processes.add(process);

View File

@ -243,6 +243,8 @@ Gridworks.postProcess = function(command, params, body, updateOptions, callbacks
} catch (e) {
Gridworks.reportException(e);
}
} else {
alert(o.message);
}
} else {
if ("onDone" in callbacks) {