diff --git a/main/src/com/google/refine/operations/OperationRegistry.java b/main/src/com/google/refine/operations/OperationRegistry.java index 6f8fcdd0b..c0598b7ca 100644 --- a/main/src/com/google/refine/operations/OperationRegistry.java +++ b/main/src/com/google/refine/operations/OperationRegistry.java @@ -2,6 +2,8 @@ package com.google.refine.operations; import java.lang.reflect.Method; import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import org.json.JSONObject; @@ -13,14 +15,23 @@ import edu.mit.simile.butterfly.ButterflyModule; public abstract class OperationRegistry { - static final public Map> s_opNameToClass = new HashMap>(); - static final public Map, String> s_opClassToName = new HashMap, String>(); + static final public Map>> s_opNameToClass = + new HashMap>>(); + + static final public Map, String> s_opClassToName = + new HashMap, String>(); static public void registerOperation(ButterflyModule module, String name, Class klass) { String key = module.getName() + "/" + name; - s_opNameToClass.put(key, klass); s_opClassToName.put(klass, key); + + List> classes = s_opNameToClass.get(key); + if (classes == null) { + classes = new LinkedList>(); + s_opNameToClass.put(key, classes); + } + classes.add(klass); } static public AbstractOperation reconstruct(Project project, JSONObject obj) { @@ -30,8 +41,10 @@ public abstract class OperationRegistry { op = "core/" + op; // backward compatible } - Class klass = OperationRegistry.s_opNameToClass.get(op); - if (klass != null) { + List> classes = s_opNameToClass.get(op); + if (classes != null && classes.size() > 0) { + Class klass = classes.get(classes.size() - 1); + Method reconstruct = klass.getMethod("reconstruct", Project.class, JSONObject.class); if (reconstruct != null) { return (AbstractOperation) reconstruct.invoke(null, project, obj); diff --git a/main/src/com/google/refine/operations/SaveProtographOperation.java b/main/src/com/google/refine/operations/SaveProtographOperation.java index 3a52fa82c..5c0eaddd5 100644 --- a/main/src/com/google/refine/operations/SaveProtographOperation.java +++ b/main/src/com/google/refine/operations/SaveProtographOperation.java @@ -35,22 +35,20 @@ public class SaveProtographOperation extends AbstractOperation { writer.object(); writer.key("op"); writer.value(OperationRegistry.s_opClassToName.get(this.getClass())); - writer.key("description"); writer.value("Save protograph"); + writer.key("description"); writer.value(getBriefDescription()); writer.key("protograph"); _protograph.write(writer, options); writer.endObject(); } - protected String getBriefDescription(Project project) { - return "Save schema skeleton"; + protected String getBriefDescription() { + return "Save schema alignment skeleton"; } @Override protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception { - String description = "Save schema-alignment protograph"; - Change change = new ProtographChange(_protograph); - return new HistoryEntry(historyEntryID, project, description, SaveProtographOperation.this, change); + return new HistoryEntry(historyEntryID, project, getBriefDescription(), SaveProtographOperation.this, change); } static public class ProtographChange implements Change { diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index 571ae5315..54f229a2a 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -139,7 +139,9 @@ function registerOperations() { OR.registerOperation(module, "recon-judge-similar-cells", Packages.com.google.refine.operations.recon.ReconJudgeSimilarCellsOperation); OR.registerOperation(module, "import-qa-data", Packages.com.google.refine.operations.recon.ImportQADataOperation); + // for backward compatibility OR.registerOperation(module, "save-protograph", Packages.com.google.refine.operations.SaveProtographOperation); + OR.registerOperation(module, "save-schema-alignment-skeleton", Packages.com.google.refine.operations.SaveProtographOperation); } /*