2010-02-05 00:38:40 +01:00
|
|
|
package com.metaweb.gridworks.model.operations;
|
|
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
import org.json.JSONWriter;
|
|
|
|
|
|
|
|
import com.metaweb.gridworks.history.Change;
|
|
|
|
import com.metaweb.gridworks.history.HistoryEntry;
|
|
|
|
import com.metaweb.gridworks.model.AbstractOperation;
|
|
|
|
import com.metaweb.gridworks.model.Column;
|
|
|
|
import com.metaweb.gridworks.model.Project;
|
|
|
|
import com.metaweb.gridworks.model.changes.ColumnRemovalChange;
|
|
|
|
import com.metaweb.gridworks.process.Process;
|
|
|
|
import com.metaweb.gridworks.process.QuickHistoryEntryProcess;
|
|
|
|
|
|
|
|
public class ColumnRemovalOperation implements AbstractOperation {
|
|
|
|
private static final long serialVersionUID = 8422079695048733734L;
|
|
|
|
|
2010-02-17 01:26:38 +01:00
|
|
|
final protected String _columnName;
|
2010-02-05 00:38:40 +01:00
|
|
|
|
|
|
|
public ColumnRemovalOperation(
|
2010-02-17 01:26:38 +01:00
|
|
|
String columnName
|
2010-02-05 00:38:40 +01:00
|
|
|
) {
|
2010-02-17 01:26:38 +01:00
|
|
|
_columnName = columnName;
|
2010-02-05 00:38:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Process createProcess(Project project, Properties options)
|
|
|
|
throws Exception {
|
|
|
|
|
2010-02-17 01:26:38 +01:00
|
|
|
Column column = project.columnModel.getColumnByName(_columnName);
|
2010-02-05 00:38:40 +01:00
|
|
|
if (column == null) {
|
2010-02-17 01:26:38 +01:00
|
|
|
throw new Exception("No column named " + _columnName);
|
2010-02-05 00:38:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String description = "Remove column " + column.getHeaderLabel();
|
|
|
|
|
2010-02-17 01:26:38 +01:00
|
|
|
Change change = new ColumnRemovalChange(project.columnModel.columns.indexOf(column));
|
2010-02-05 00:38:40 +01:00
|
|
|
HistoryEntry historyEntry = new HistoryEntry(
|
|
|
|
project, description, this, change);
|
|
|
|
|
|
|
|
return new QuickHistoryEntryProcess(project, historyEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void write(JSONWriter writer, Properties options)
|
|
|
|
throws JSONException {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|