Schema alignment dialog now saves protograph and re-renders it properly.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@92 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
425140261f
commit
8189ba74fd
@ -1,14 +1,17 @@
|
||||
package com.metaweb.gridworks.protograph;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
public class AnonymousNode implements Node {
|
||||
public class AnonymousNode implements Node, NodeWithLinks {
|
||||
private static final long serialVersionUID = -6956243664838720646L;
|
||||
|
||||
final public FreebaseType type;
|
||||
final public List<Link> links = new LinkedList<Link>();
|
||||
|
||||
public AnonymousNode(FreebaseType type) {
|
||||
this.type = type;
|
||||
@ -20,7 +23,17 @@ public class AnonymousNode implements Node {
|
||||
writer.object();
|
||||
writer.key("nodeType"); writer.value("anonymous");
|
||||
writer.key("type"); type.write(writer, options);
|
||||
if (links != null) {
|
||||
writer.key("links"); writer.array();
|
||||
for (Link link : links) {
|
||||
link.write(writer, options);
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
public void addLink(Link link) {
|
||||
links.add(link);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class CellTopicNode extends CellNode implements NodeWithLinks {
|
||||
writer.object();
|
||||
writer.key("nodeType"); writer.value("cell-as-topic");
|
||||
writer.key("columnName"); writer.value(columnName);
|
||||
writer.key("createUnlessRecon"); writer.value(createForNoReconMatch);
|
||||
writer.key("createForNoReconMatch"); writer.value(createForNoReconMatch);
|
||||
if (createForNoReconMatch && type != null) {
|
||||
writer.key("type"); type.write(writer, options);
|
||||
}
|
||||
|
@ -62,7 +62,10 @@ SchemaAlignmentDialog.UILink.prototype._renderMain = function() {
|
||||
|
||||
SchemaAlignmentDialog.UILink.prototype._renderDetails = function() {
|
||||
var tableDetails = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._expandedDetailDiv)[0];
|
||||
this._targetUI = new SchemaAlignmentDialog.UINode(this._link.target, tableDetails, true);
|
||||
this._targetUI = new SchemaAlignmentDialog.UINode(
|
||||
this._link.target,
|
||||
tableDetails,
|
||||
{ expanded: "links" in this._link.target && this._link.target.links.length > 0 });
|
||||
};
|
||||
|
||||
SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt) {
|
||||
|
@ -23,7 +23,9 @@ SchemaAlignmentDialog.UINode = function(node, table, options) {
|
||||
};
|
||||
|
||||
SchemaAlignmentDialog.UINode.prototype._isExpandable = function() {
|
||||
return this._node.nodeType == "cell-as-topic";
|
||||
return this._node.nodeType == "cell-as-topic" ||
|
||||
this._node.nodeType == "anonymous" ||
|
||||
this._node.nodeType == "topic";
|
||||
};
|
||||
|
||||
SchemaAlignmentDialog.UINode.prototype._renderMain = function() {
|
||||
@ -68,8 +70,6 @@ SchemaAlignmentDialog.UINode.prototype._renderMain = function() {
|
||||
} else if (this._node.nodeType == "anonymous") {
|
||||
a.html("(anonymous)");
|
||||
}
|
||||
|
||||
$('<img />').attr("src", "images/down-arrow.png").appendTo(a);
|
||||
};
|
||||
|
||||
SchemaAlignmentDialog.UINode.prototype._showExpandable = function() {
|
||||
@ -399,7 +399,6 @@ SchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function() {
|
||||
elmts.valueNodeTypeLanguageInput
|
||||
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; })
|
||||
.suggest({ type: "/type/lang" });
|
||||
|
||||
|
||||
elmts.radioNodeTypeCellAsTopicCreate
|
||||
.click(function() {
|
||||
@ -449,6 +448,36 @@ SchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function() {
|
||||
elmts.radioNodeTypeValue[0].checked = true;
|
||||
}
|
||||
|
||||
if ("type" in this._node) {
|
||||
elmts.anonymousNodeTypeInput[0].value = this._node.type.name;
|
||||
elmts.anonymousNodeTypeInput.data("data.suggest", this._node.type);
|
||||
|
||||
elmts.cellAsTopicNodeTypeInput[0].value = this._node.type.name;
|
||||
elmts.cellAsTopicNodeTypeInput.data("data.suggest", this._node.type);
|
||||
}
|
||||
if ("topic" in this._node) {
|
||||
elmts.topicNodeTypeInput[0].value = this._node.topic.name;
|
||||
elmts.topicNodeTypeInput.data("data.suggest", this._node.topic);
|
||||
}
|
||||
if ("namespace" in this._node) {
|
||||
elmts.cellAsKeyInput[0].value = this._node.namespace.name;
|
||||
elmts.cellAsKeyInput.data("data.suggest", this._node.namespace);
|
||||
}
|
||||
if ("createForNoReconMatch" in this._node) {
|
||||
elmts.radioNodeTypeCellAsTopicCreate[0].checked = this._node.createForNoReconMatch;
|
||||
}
|
||||
if ("lang" in this._node) {
|
||||
elmts.valueNodeTypeLanguageInput[0].value = this._node.lang;
|
||||
elmts.valueNodeTypeLanguageInput.data("data.suggest", { id: this._node.lang });
|
||||
|
||||
elmts.cellAsValueLanguageInput[0].value = this._node.lang;
|
||||
elmts.cellAsValueLanguageInput.data("data.suggest", { id: this._node.lang });
|
||||
}
|
||||
if ("valueType" in this._node) {
|
||||
elmts.valueNodeTypeValueTypeSelect[0].value = this._node.valueType;
|
||||
elmts.cellAsValueTypeSelect.value(this._node.valueType);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
* Footer
|
||||
*--------------------------------------------------
|
||||
|
@ -144,6 +144,8 @@ SchemaAlignmentDialog.prototype._renderFooter = function(footer) {
|
||||
|
||||
DialogSystem.dismissUntil(self._level - 1);
|
||||
|
||||
theProject.protograph = protograph;
|
||||
|
||||
self._onDone(protograph);
|
||||
},
|
||||
"json"
|
||||
|
Loading…
Reference in New Issue
Block a user