We're starting to be able to save protographs.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@91 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
634d666949
commit
425140261f
@ -31,14 +31,17 @@ public class CellTopicNode extends CellNode implements NodeWithLinks {
|
|||||||
writer.object();
|
writer.object();
|
||||||
writer.key("nodeType"); writer.value("cell-as-topic");
|
writer.key("nodeType"); writer.value("cell-as-topic");
|
||||||
writer.key("columnName"); writer.value(columnName);
|
writer.key("columnName"); writer.value(columnName);
|
||||||
writer.key("type"); type.write(writer, options);
|
|
||||||
writer.key("createUnlessRecon"); writer.value(createForNoReconMatch);
|
writer.key("createUnlessRecon"); writer.value(createForNoReconMatch);
|
||||||
|
if (createForNoReconMatch && type != null) {
|
||||||
writer.key("links"); writer.array();
|
writer.key("type"); type.write(writer, options);
|
||||||
for (Link link : links) {
|
}
|
||||||
link.write(writer, options);
|
if (links != null) {
|
||||||
|
writer.key("links"); writer.array();
|
||||||
|
for (Link link : links) {
|
||||||
|
link.write(writer, options);
|
||||||
|
}
|
||||||
|
writer.endArray();
|
||||||
}
|
}
|
||||||
writer.endArray();
|
|
||||||
|
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,9 @@ package com.metaweb.gridworks.protograph;
|
|||||||
public class FreebaseProperty extends FreebaseTopic {
|
public class FreebaseProperty extends FreebaseTopic {
|
||||||
private static final long serialVersionUID = 7909539492956342421L;
|
private static final long serialVersionUID = 7909539492956342421L;
|
||||||
|
|
||||||
final protected FreebaseType _expectedType;
|
//final protected FreebaseType _expectedType;
|
||||||
|
|
||||||
public FreebaseProperty(String id, String name, FreebaseType expectedType) {
|
public FreebaseProperty(String id, String name) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
_expectedType = expectedType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FreebaseType getExpectedType() {
|
|
||||||
return _expectedType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,11 @@ public class FreebaseTopic implements Serializable, Jsonizable {
|
|||||||
|
|
||||||
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("id"); writer.value(id);
|
||||||
|
writer.key("name"); writer.value(name);
|
||||||
|
writer.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,13 @@ public class FreebaseTopicNode implements Node, NodeWithLinks {
|
|||||||
writer.object();
|
writer.object();
|
||||||
writer.key("nodeType"); writer.value("topic");
|
writer.key("nodeType"); writer.value("topic");
|
||||||
writer.key("topic"); topic.write(writer, options);
|
writer.key("topic"); topic.write(writer, options);
|
||||||
|
if (links != null) {
|
||||||
writer.key("links"); writer.array();
|
writer.key("links"); writer.array();
|
||||||
for (Link link : links) {
|
for (Link link : links) {
|
||||||
link.write(writer, options);
|
link.write(writer, options);
|
||||||
|
}
|
||||||
|
writer.endArray();
|
||||||
}
|
}
|
||||||
writer.endArray();
|
|
||||||
|
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,8 @@ package com.metaweb.gridworks.protograph;
|
|||||||
public class FreebaseType extends FreebaseTopic {
|
public class FreebaseType extends FreebaseTopic {
|
||||||
private static final long serialVersionUID = -3070300264980791404L;
|
private static final long serialVersionUID = -3070300264980791404L;
|
||||||
|
|
||||||
final public boolean compoundValueType;
|
public FreebaseType(String id, String name) {
|
||||||
|
|
||||||
public FreebaseType(String id, String name, boolean compoundValueType) {
|
|
||||||
super(id, name);
|
super(id, name);
|
||||||
this.compoundValueType = compoundValueType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,16 +95,14 @@ public class Protograph implements Serializable, Jsonizable {
|
|||||||
static protected FreebaseProperty reconstructProperty(JSONObject o) throws JSONException {
|
static protected FreebaseProperty reconstructProperty(JSONObject o) throws JSONException {
|
||||||
return new FreebaseProperty(
|
return new FreebaseProperty(
|
||||||
o.getString("id"),
|
o.getString("id"),
|
||||||
o.getString("name"),
|
o.getString("name")
|
||||||
reconstructType(o.getJSONObject("expected"))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected FreebaseType reconstructType(JSONObject o) throws JSONException {
|
static protected FreebaseType reconstructType(JSONObject o) throws JSONException {
|
||||||
return new FreebaseType(
|
return new FreebaseType(
|
||||||
o.getString("id"),
|
o.getString("id"),
|
||||||
o.getString("name"),
|
o.getString("name")
|
||||||
o.getBoolean("cvt")
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gridlock</title>
<link type="text/css" rel="stylesheet" href="externals/suggest/css/suggest-1.0.3.min.css" />
<link type="text/css" rel="stylesheet" href="externals/jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" href="/styles/common.css" />
<link rel="stylesheet" href="/styles/menu.css" />
<link rel="stylesheet" href="/styles/dialog.css" />
<link rel="stylesheet" href="/styles/project.css" />
<link rel="stylesheet" href="/styles/data-table-view.css" />
<link rel="stylesheet" href="/styles/history.css" />
<link rel="stylesheet" href="/styles/browsing.css" />
<link rel="stylesheet" href="/styles/process.css" />
<link rel="stylesheet" href="/styles/menu-bar.css" />
<link rel="stylesheet" href="/styles/expression-preview-dialog.css" />
<link rel="stylesheet" href="/styles/schema-alignment-dialog.css" />
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gridlock</title>
<link type="text/css" rel="stylesheet" href="externals/suggest/css/suggest-1.0.3.min.css" />
<link type="text/css" rel="stylesheet" href="externals/jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" href="/styles/common.css" />
<link rel="stylesheet" href="/styles/menu.css" />
<link rel="stylesheet" href="/styles/dialog.css" />
<link rel="stylesheet" href="/styles/project.css" />
<link rel="stylesheet" href="/styles/data-table-view.css" />
<link rel="stylesheet" href="/styles/history.css" />
<link rel="stylesheet" href="/styles/browsing.css" />
<link rel="stylesheet" href="/styles/process.css" />
<link rel="stylesheet" href="/styles/menu-bar.css" />
<link rel="stylesheet" href="/styles/expression-preview-dialog.css" />
<link rel="stylesheet" href="/styles/schema-alignment-dialog.css" />
|
||||||
<script type="text/javascript" src="externals/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="externals/suggest/suggest-1.0.3.min.js"></script>
<script type="text/javascript" src="externals/jquery-ui/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="scripts/util/misc.js"></script>
<script type="text/javascript" src="scripts/util/url.js"></script>
<script type="text/javascript" src="scripts/util/string.js"></script>
<script type="text/javascript" src="scripts/util/ajax.js"></script>
<script type="text/javascript" src="scripts/util/menu.js"></script>
<script type="text/javascript" src="scripts/util/dialog.js"></script>
<script type="text/javascript" src="scripts/util/dom.js"></script>
<script type="text/javascript" src="scripts/project.js"></script>
<script type="text/javascript" src="scripts/project/list-facet.js"></script>
<script type="text/javascript" src="scripts/project/range-facet.js"></script>
<script type="text/javascript" src="scripts/project/text-search-facet.js"></script>
<script type="text/javascript" src="scripts/project/browsing-engine.js"></script>
<script type="text/javascript" src="scripts/project/data-table-view.js"></script>
<script type="text/javascript" src="scripts/project/data-table-cell-ui.js"></script>
<script type="text/javascript" src="scripts/project/data-table-column-header-ui.js"></script>
<script type="text/javascript" src="scripts/project/history-widget.js"></script>
<script type="text/javascript" src="scripts/project/process-widget.js"></script>
<script type="text/javascript" src="scripts/project/menu-bar.js"></script>
<script type="text/javascript" src="scripts/project/recon-dialog.js"></script>
<script type="text/javascript" src="scripts/project/expression-preview-dialog.js"></script>
<script type="text/javascript" src="scripts/project/schema-alignment.js"></script>
</head>
<body>
<div id="header">
<div id="path"><a class="app-path-section" href="./index.html">Gridworks</a> » </div>
</div>
<div id="body">
<div id="loading-message"><img src="images/large-spinner.gif" /> starting up ...</div>
</div>
</body>
</html>
|
<script type="text/javascript" src="externals/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="externals/suggest/suggest-1.0.3.min.js"></script>
<script type="text/javascript" src="externals/jquery-ui/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="scripts/util/misc.js"></script>
<script type="text/javascript" src="scripts/util/url.js"></script>
<script type="text/javascript" src="scripts/util/string.js"></script>
<script type="text/javascript" src="scripts/util/ajax.js"></script>
<script type="text/javascript" src="scripts/util/menu.js"></script>
<script type="text/javascript" src="scripts/util/dialog.js"></script>
<script type="text/javascript" src="scripts/util/dom.js"></script>
<script type="text/javascript" src="scripts/project.js"></script>
<script type="text/javascript" src="scripts/project/list-facet.js"></script>
<script type="text/javascript" src="scripts/project/range-facet.js"></script>
<script type="text/javascript" src="scripts/project/text-search-facet.js"></script>
<script type="text/javascript" src="scripts/project/browsing-engine.js"></script>
<script type="text/javascript" src="scripts/project/data-table-view.js"></script>
<script type="text/javascript" src="scripts/project/data-table-cell-ui.js"></script>
<script type="text/javascript" src="scripts/project/data-table-column-header-ui.js"></script>
<script type="text/javascript" src="scripts/project/history-widget.js"></script>
<script type="text/javascript" src="scripts/project/process-widget.js"></script>
<script type="text/javascript" src="scripts/project/menu-bar.js"></script>
<script type="text/javascript" src="scripts/project/recon-dialog.js"></script>
<script type="text/javascript" src="scripts/project/expression-preview-dialog.js"></script>
<script type="text/javascript" src="scripts/project/schema-alignment.js"></script>
<script type="text/javascript" src="scripts/project/schema-alignment-ui-node.js"></script>
<script type="text/javascript" src="scripts/project/schema-alignment-ui-link.js"></script>
</head>
<body>
<div id="header">
<div id="path"><a class="app-path-section" href="./index.html">Gridworks</a> » </div>
</div>
<div id="body">
<div id="loading-message"><img src="images/large-spinner.gif" /> starting up ...</div>
</div>
</body>
</html>
|
@ -137,17 +137,7 @@ MenuBar.prototype._doExportRows = function() {
|
|||||||
MenuBar.prototype._doAutoSchemaAlignment = function() {
|
MenuBar.prototype._doAutoSchemaAlignment = function() {
|
||||||
//SchemaAlignment.autoAlign();
|
//SchemaAlignment.autoAlign();
|
||||||
|
|
||||||
var protograph = theProject.protograph != null ? theProject.protograph : {
|
new SchemaAlignmentDialog(theProject.protograph, function(newProtograph) {
|
||||||
rootNodes: [
|
|
||||||
{
|
|
||||||
nodeType: "cell-as-topic",
|
|
||||||
links: [
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
new SchemaAlignmentDialog(protograph, function(newProtograph) {
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
109
src/main/webapp/scripts/project/schema-alignment-ui-link.js
Normal file
109
src/main/webapp/scripts/project/schema-alignment-ui-link.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
SchemaAlignmentDialog.UILink = function(link, table, expanded) {
|
||||||
|
this._link = link;
|
||||||
|
this._expanded = expanded;
|
||||||
|
|
||||||
|
this._tr = table.insertRow(table.rows.length);
|
||||||
|
this._tdMain = this._tr.insertCell(0);
|
||||||
|
this._tdToggle = this._tr.insertCell(1);
|
||||||
|
this._tdDetails = this._tr.insertCell(2);
|
||||||
|
|
||||||
|
$(this._tdMain).addClass("schema-alignment-link-main").attr("width", "250").addClass("padded");
|
||||||
|
$(this._tdToggle).addClass("schema-alignment-link-toggle").attr("width", "1%").addClass("padded");
|
||||||
|
$(this._tdDetails).addClass("schema-alignment-link-details").attr("width", "90%");
|
||||||
|
|
||||||
|
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
|
||||||
|
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
|
||||||
|
var self = this;
|
||||||
|
var show = function() {
|
||||||
|
if (self._expanded) {
|
||||||
|
self._collapsedDetailDiv.hide();
|
||||||
|
self._expandedDetailDiv.show();
|
||||||
|
} else {
|
||||||
|
self._collapsedDetailDiv.show();
|
||||||
|
self._expandedDetailDiv.hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
show();
|
||||||
|
|
||||||
|
$(this._tdToggle).html(" ");
|
||||||
|
$('<img />')
|
||||||
|
.attr("src", this._expanded ? "images/expanded.png" : "images/collapsed.png")
|
||||||
|
.appendTo(this._tdToggle)
|
||||||
|
.click(function() {
|
||||||
|
self._expanded = !self._expanded;
|
||||||
|
|
||||||
|
$(this).attr("src", self._expanded ? "images/expanded.png" : "images/collapsed.png");
|
||||||
|
|
||||||
|
show();
|
||||||
|
});
|
||||||
|
|
||||||
|
this._renderMain();
|
||||||
|
this._renderDetails();
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UILink.prototype._renderMain = function() {
|
||||||
|
$(this._tdMain).empty()
|
||||||
|
|
||||||
|
var label = this._link.property != null ? this._link.property.id : "property?";
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var a = $('<a href="javascript:{}"></a>')
|
||||||
|
.addClass("schema-alignment-link-tag")
|
||||||
|
.html(label)
|
||||||
|
.appendTo(this._tdMain)
|
||||||
|
.click(function(evt) {
|
||||||
|
self._showPropertySuggestPopup(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('<img />').attr("src", "images/arrow-start.png").prependTo(a);
|
||||||
|
$('<img />').attr("src", "images/arrow-end.png").appendTo(a);
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt) {
|
||||||
|
self = this;
|
||||||
|
|
||||||
|
var fakeMenu = MenuSystem.createMenu()
|
||||||
|
.width(300)
|
||||||
|
.height(100)
|
||||||
|
.css("background", "none")
|
||||||
|
.css("border", "none");
|
||||||
|
|
||||||
|
var input = $('<input />').appendTo(fakeMenu);
|
||||||
|
|
||||||
|
var level = MenuSystem.showMenu(fakeMenu, function(){});
|
||||||
|
MenuSystem.positionMenuAboveBelow(fakeMenu, $(elmt));
|
||||||
|
|
||||||
|
input.suggest({ type : '/type/property' }).bind("fb-select", function(e, data) {
|
||||||
|
self._link.property = {
|
||||||
|
id: data.id,
|
||||||
|
name: data.name
|
||||||
|
};
|
||||||
|
|
||||||
|
window.setTimeout(function() {
|
||||||
|
MenuSystem.dismissAll();
|
||||||
|
self._renderMain();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
input[0].focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UILink.prototype.getJSON = function() {
|
||||||
|
if ("property" in this._link && this._link.property != null &&
|
||||||
|
"target" in this._link && this._link.target != null) {
|
||||||
|
|
||||||
|
var targetJSON = this._targetUI.getJSON();
|
||||||
|
if (targetJSON != null) {
|
||||||
|
return {
|
||||||
|
property: cloneDeep(this._link.property),
|
||||||
|
target: targetJSON
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
634
src/main/webapp/scripts/project/schema-alignment-ui-node.js
Normal file
634
src/main/webapp/scripts/project/schema-alignment-ui-node.js
Normal file
@ -0,0 +1,634 @@
|
|||||||
|
SchemaAlignmentDialog.UINode = function(node, table, options) {
|
||||||
|
this._node = node;
|
||||||
|
this._options = options;
|
||||||
|
|
||||||
|
this._linkUIs = [];
|
||||||
|
this._detailsRendered = false;
|
||||||
|
|
||||||
|
this._tr = table.insertRow(table.rows.length);
|
||||||
|
this._tdMain = this._tr.insertCell(0);
|
||||||
|
this._tdToggle = this._tr.insertCell(1);
|
||||||
|
this._tdDetails = this._tr.insertCell(2);
|
||||||
|
|
||||||
|
$(this._tdMain).addClass("schema-alignment-node-main").attr("width", "250").addClass("padded");
|
||||||
|
$(this._tdToggle).addClass("schema-alignment-node-toggle").attr("width", "1%").addClass("padded").hide();
|
||||||
|
$(this._tdDetails).addClass("schema-alignment-node-details").attr("width", "90%").hide();
|
||||||
|
|
||||||
|
this._renderMain();
|
||||||
|
|
||||||
|
this._expanded = options.expanded;
|
||||||
|
if (this._isExpandable()) {
|
||||||
|
this._showExpandable();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._isExpandable = function() {
|
||||||
|
return this._node.nodeType == "cell-as-topic";
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._renderMain = function() {
|
||||||
|
$(this._tdMain).empty();
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var a = $('<a href="javascript:{}"></a>')
|
||||||
|
.addClass("schema-alignment-node-tag")
|
||||||
|
.appendTo(this._tdMain)
|
||||||
|
.click(function(evt) {
|
||||||
|
self._showNodeConfigDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this._node.nodeType == "cell-as-topic" ||
|
||||||
|
this._node.nodeType == "cell-as-value" ||
|
||||||
|
this._node.nodeType == "cell-as-key") {
|
||||||
|
|
||||||
|
if ("columnName" in this._node) {
|
||||||
|
a.html(" cell");
|
||||||
|
|
||||||
|
$('<span></span>')
|
||||||
|
.text(this._node.columnName)
|
||||||
|
.addClass("schema-alignment-node-column")
|
||||||
|
.prependTo(a);
|
||||||
|
} else {
|
||||||
|
a.html(this._options.mustBeCellTopic ? "Which column?" : "Configure...");
|
||||||
|
}
|
||||||
|
} else if (this._node.nodeType == "topic") {
|
||||||
|
if ("topic" in this._node) {
|
||||||
|
a.html(this._node.topic.name);
|
||||||
|
} else if ("id" in this._node) {
|
||||||
|
a.html(this._node.topic.id);
|
||||||
|
} else {
|
||||||
|
a.html("Which topic?");
|
||||||
|
}
|
||||||
|
} else if (this._node.nodeType == "value") {
|
||||||
|
if ("value" in this._node) {
|
||||||
|
a.html(this._node.value);
|
||||||
|
} else {
|
||||||
|
a.html("What value?");
|
||||||
|
}
|
||||||
|
} else if (this._node.nodeType == "anonymous") {
|
||||||
|
a.html("(anonymous)");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('<img />').attr("src", "images/down-arrow.png").appendTo(a);
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._showExpandable = function() {
|
||||||
|
$(this._tdToggle).show();
|
||||||
|
$(this._tdDetails).show();
|
||||||
|
|
||||||
|
if (this._detailsRendered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._detailsRendered = true;
|
||||||
|
|
||||||
|
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
|
||||||
|
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
|
||||||
|
|
||||||
|
this._renderDetails();
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var show = function() {
|
||||||
|
if (self._expanded) {
|
||||||
|
self._collapsedDetailDiv.hide();
|
||||||
|
self._expandedDetailDiv.show();
|
||||||
|
} else {
|
||||||
|
self._collapsedDetailDiv.show();
|
||||||
|
self._expandedDetailDiv.hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
show();
|
||||||
|
|
||||||
|
$(this._tdToggle).html(" ");
|
||||||
|
$('<img />')
|
||||||
|
.attr("src", this._expanded ? "images/expanded.png" : "images/collapsed.png")
|
||||||
|
.appendTo(this._tdToggle)
|
||||||
|
.click(function() {
|
||||||
|
self._expanded = !self._expanded;
|
||||||
|
|
||||||
|
$(this).attr("src", self._expanded ? "images/expanded.png" : "images/collapsed.png");
|
||||||
|
|
||||||
|
show();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._hideExpandable = function() {
|
||||||
|
$(this._tdToggle).hide();
|
||||||
|
$(this._tdDetails).hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._renderDetails = function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this._tableLinks = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._expandedDetailDiv)[0];
|
||||||
|
|
||||||
|
if ("links" in this._node && this._node.links != null) {
|
||||||
|
for (var i = 0; i < this._node.links.length; i++) {
|
||||||
|
this._linkUIs.push(new SchemaAlignmentDialog.UILink(this._node.links[i], this._tableLinks, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var divFooter = $('<div></div>').addClass("padded").appendTo(this._expandedDetailDiv);
|
||||||
|
|
||||||
|
$('<a href="javascript:{}"></a>')
|
||||||
|
.addClass("action")
|
||||||
|
.text("add property")
|
||||||
|
.appendTo(divFooter)
|
||||||
|
.click(function() {
|
||||||
|
var newLink = {
|
||||||
|
property: null,
|
||||||
|
target: {
|
||||||
|
nodeType: "cell-as-value"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self._linkUIs.push(new SchemaAlignmentDialog.UILink(
|
||||||
|
newLink,
|
||||||
|
self._tableLinks,
|
||||||
|
{
|
||||||
|
expanded: true,
|
||||||
|
mustBeCellTopic: false
|
||||||
|
}
|
||||||
|
));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._showColumnPopupMenu = function(elmt) {
|
||||||
|
self = this;
|
||||||
|
|
||||||
|
var menu = [];
|
||||||
|
|
||||||
|
if (!this._options.mustBeCellTopic) {
|
||||||
|
menu.push({
|
||||||
|
label: "Anonymous Node",
|
||||||
|
click: function() {
|
||||||
|
self._node.nodeType = "anonymous";
|
||||||
|
self._showExpandable();
|
||||||
|
self._renderMain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.push({
|
||||||
|
label: "Freebase Topic",
|
||||||
|
click: function() {
|
||||||
|
self._node.nodeType = "topic";
|
||||||
|
self._hideExpandable();
|
||||||
|
self._renderMain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.push({
|
||||||
|
label: "Value",
|
||||||
|
click: function() {
|
||||||
|
self._node.nodeType = "value";
|
||||||
|
self._hideExpandable();
|
||||||
|
self._renderMain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.push({}); // separator
|
||||||
|
}
|
||||||
|
|
||||||
|
var columns = theProject.columnModel.columns;
|
||||||
|
var createColumnMenuItem = function(index) {
|
||||||
|
menu.push({
|
||||||
|
label: columns[index].headerLabel,
|
||||||
|
click: function() {
|
||||||
|
self._node.nodeType = "cell-as-topic";
|
||||||
|
self._node.columnName = columns[index].headerLabel;
|
||||||
|
self._showExpandable();
|
||||||
|
self._renderMain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
for (var i = 0; i < columns.length; i++) {
|
||||||
|
createColumnMenuItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuSystem.createAndShowStandardMenu(menu, elmt);
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype._showNodeConfigDialog = function() {
|
||||||
|
var self = this;
|
||||||
|
var frame = DialogSystem.createDialog();
|
||||||
|
|
||||||
|
frame.width("800px");
|
||||||
|
|
||||||
|
var header = $('<div></div>').addClass("dialog-header").text("Protograph Node").appendTo(frame);
|
||||||
|
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
||||||
|
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
* Body
|
||||||
|
*--------------------------------------------------
|
||||||
|
*/
|
||||||
|
var literalTypeSelectHtml =
|
||||||
|
'<option value="/type/text" checked>text</option>' +
|
||||||
|
'<option value="/type/int">int</option>' +
|
||||||
|
'<option value="/type/float">float</option>' +
|
||||||
|
'<option value="/type/double">double</option>' +
|
||||||
|
'<option value="/type/boolean">boolean</option>' +
|
||||||
|
'<option value="/type/datetime">date/time</option>';
|
||||||
|
|
||||||
|
var html = $(
|
||||||
|
'<table class="schema-align-node-dialog-layout">' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'<table class="schema-align-node-dialog-layout2">' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td colspan="3">' +
|
||||||
|
'<div class="schema-align-node-dialog-node-type">' +
|
||||||
|
'<input type="radio" name="schema-align-node-dialog-node-type" value="anonymous" id="radioNodeTypeAnonymous" /> Generate an anonymous graph node' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td>Assign a type to the node</td>' +
|
||||||
|
'<td> <input id="anonymousNodeTypeInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
|
||||||
|
'<tr>' +
|
||||||
|
'<td colspan="3">' +
|
||||||
|
'<div class="schema-align-node-dialog-node-type">' +
|
||||||
|
'<input type="radio" name="schema-align-node-dialog-node-type" value="topic" id="radioNodeTypeTopic" /> Use one existing Freebase topic' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td>Topic</td>' +
|
||||||
|
'<td><input id="topicNodeTypeInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
|
||||||
|
'<tr>' +
|
||||||
|
'<td colspan="3">' +
|
||||||
|
'<div class="schema-align-node-dialog-node-type">' +
|
||||||
|
'<input type="radio" name="schema-align-node-dialog-node-type" value="value" id="radioNodeTypeValue" /> Use a literal value' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td>Value</td>' +
|
||||||
|
'<td><input id="valueNodeTypeValueInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td>Value type</td>' +
|
||||||
|
'<td><select id="valueNodeTypeValueTypeSelect">' + literalTypeSelectHtml + '</select></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td>Language</td>' +
|
||||||
|
'<td><input id="valueNodeTypeLanguageInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</table>' +
|
||||||
|
'</td>' +
|
||||||
|
|
||||||
|
'<td>' +
|
||||||
|
'<table class="schema-align-node-dialog-layout2">' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'<div class="schema-align-node-dialog-node-type">' +
|
||||||
|
'<input type="radio" name="schema-align-node-dialog-node-type" value="cell-as" id="radioNodeTypeCellAs" /> Set to Cell in Column' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'<table class="schema-align-node-dialog-layout2">' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td><div class="schema-alignment-node-dialog-column-list" id="divColumns"></div></td>' +
|
||||||
|
'<td>' +
|
||||||
|
'<table class="schema-align-node-dialog-layout2" cols="4">' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td colspan="4">The cell\'s content is used ...</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-topic" id="radioNodeTypeCellAsTopic" /></td>' +
|
||||||
|
'<td colspan="3">to specify a Freebase topic, as reconciled</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td colspan="1" width="1%"><input type="checkbox" id="radioNodeTypeCellAsTopicCreate" /></td>' +
|
||||||
|
'<td colspan="2">If not reconciled, create new topic named by the cell\'s content, and assign it a type</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td colspan="1">Type:</td>' +
|
||||||
|
'<td colspan="1"><input id="cellAsTopicNodeTypeInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
|
||||||
|
'<tr>' +
|
||||||
|
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-value" id="radioNodeTypeCellAsValue" /></td>' +
|
||||||
|
'<td colspan="3">as a literal value</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td colspan="2">Literal type</td>' +
|
||||||
|
'<td colspan="1"><select id="cellAsValueTypeSelect">' + literalTypeSelectHtml + '</select></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td colspan="2">Language (for text)</td>' +
|
||||||
|
'<td colspan="1"><input id="cellAsValueLanguageInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
|
||||||
|
'<tr>' +
|
||||||
|
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-key" id="radioNodeTypeCellAsKey" /></td>' +
|
||||||
|
'<td colspan="3">as a key in a namespace</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<td></td>' +
|
||||||
|
'<td colspan="2">Namespace</td>' +
|
||||||
|
'<td colspan="1"><input id="cellAsKeyInput" /></td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</table>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</table>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</table>' +
|
||||||
|
'</td>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</table>'
|
||||||
|
).appendTo(body);
|
||||||
|
|
||||||
|
var elmts = DOM.bind(html);
|
||||||
|
|
||||||
|
var tableColumns = $('<table></table>')
|
||||||
|
.attr("cellspacing", "5")
|
||||||
|
.attr("cellpadding", "0")
|
||||||
|
.appendTo(elmts.divColumns)[0];
|
||||||
|
|
||||||
|
var makeColumnChoice = function(column, columnIndex) {
|
||||||
|
var tr = tableColumns.insertRow(tableColumns.rows.length);
|
||||||
|
|
||||||
|
var radio = $('<input />')
|
||||||
|
.attr("type", "radio")
|
||||||
|
.attr("value", column.headerLabel)
|
||||||
|
.attr("name", "schema-align-node-dialog-column")
|
||||||
|
.appendTo(tr.insertCell(0))
|
||||||
|
.click(function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ((!("columnName" in self._node) || self._node.columnName == null) && columnIndex == 0) {
|
||||||
|
radio.attr("checked", "true");
|
||||||
|
} else if (column.headerLabel == self._node.columnName) {
|
||||||
|
radio.attr("checked", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
$('<span></span>').text(column.headerLabel).appendTo(tr.insertCell(1));
|
||||||
|
};
|
||||||
|
var columns = theProject.columnModel.columns;
|
||||||
|
for (var i = 0; i < columns.length; i++) {
|
||||||
|
makeColumnChoice(columns[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
elmts.anonymousNodeTypeInput
|
||||||
|
.bind("focus", function() { elmts.radioNodeTypeAnonymous[0].checked = true; })
|
||||||
|
.suggest({ type: "/type/type" });
|
||||||
|
|
||||||
|
elmts.topicNodeTypeInput
|
||||||
|
.bind("focus", function() { elmts.radioNodeTypeTopic[0].checked = true; })
|
||||||
|
.suggest({});
|
||||||
|
|
||||||
|
elmts.valueNodeTypeValueInput
|
||||||
|
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; });
|
||||||
|
elmts.valueNodeTypeValueTypeSelect
|
||||||
|
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; });
|
||||||
|
elmts.valueNodeTypeLanguageInput
|
||||||
|
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; })
|
||||||
|
.suggest({ type: "/type/lang" });
|
||||||
|
|
||||||
|
|
||||||
|
elmts.radioNodeTypeCellAsTopicCreate
|
||||||
|
.click(function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
||||||
|
});
|
||||||
|
elmts.cellAsTopicNodeTypeInput
|
||||||
|
.bind("focus", function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
||||||
|
})
|
||||||
|
.suggest({ type: "/type/type" });
|
||||||
|
|
||||||
|
elmts.cellAsValueTypeSelect
|
||||||
|
.bind("focus", function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
||||||
|
});
|
||||||
|
elmts.cellAsValueLanguageInput
|
||||||
|
.bind("focus", function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
||||||
|
})
|
||||||
|
.suggest({ type: "/type/lang" });
|
||||||
|
|
||||||
|
elmts.cellAsKeyInput
|
||||||
|
.bind("focus", function() {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
elmts.radioNodeTypeCellAsKey[0].checked = true;
|
||||||
|
})
|
||||||
|
.suggest({ type: "/type/namespace" });
|
||||||
|
|
||||||
|
if (this._node.nodeType.match(/^cell-as-/)) {
|
||||||
|
elmts.radioNodeTypeCellAs[0].checked = true;
|
||||||
|
if (this._node.nodeType == "cell-as-topic") {
|
||||||
|
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
||||||
|
} else if (this._node.nodeType == "cell-as-value") {
|
||||||
|
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
||||||
|
} else if (this._node.nodeType == "cell-as-key") {
|
||||||
|
elmts.radioNodeTypeCellAsKey[0].checked = true;
|
||||||
|
}
|
||||||
|
} else if (this._node.nodeType == "anonymous") {
|
||||||
|
elmts.radioNodeTypeAnonymous[0].checked = true;
|
||||||
|
} else if (this._node.nodeType == "topic") {
|
||||||
|
elmts.radioNodeTypeTopic[0].checked = true;
|
||||||
|
} else if (this._node.nodeType == "value") {
|
||||||
|
elmts.radioNodeTypeValue[0].checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
* Footer
|
||||||
|
*--------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
var getResultJSON = function() {
|
||||||
|
var node = {
|
||||||
|
nodeType: $("input[name='schema-align-node-dialog-node-type']:checked")[0].value
|
||||||
|
};
|
||||||
|
if (node.nodeType == "cell-as") {
|
||||||
|
node.nodeType = $("input[name='schema-align-node-dialog-node-subtype']:checked")[0].value;
|
||||||
|
node.columnName = $("input[name='schema-align-node-dialog-column']:checked")[0].value;
|
||||||
|
|
||||||
|
if (node.nodeType == "cell-as-topic") {
|
||||||
|
if (elmts.radioNodeTypeCellAsTopicCreate[0].checked) {
|
||||||
|
node.createForNoReconMatch = true;
|
||||||
|
|
||||||
|
var t = elmts.cellAsTopicNodeTypeInput.data("data.suggest");
|
||||||
|
if (!(t)) {
|
||||||
|
alert("For creating a new graph node, you need to specify a type for it.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node.type = {
|
||||||
|
id: t.id,
|
||||||
|
name: t.name
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
node.createForNoReconMatch = false;
|
||||||
|
}
|
||||||
|
} else if (node.nodeType == "cell-as-value") {
|
||||||
|
node.valueType = elmts.cellAsValueTypeSelect[0].value;
|
||||||
|
|
||||||
|
var l = elmts.cellAsValueLanguageInput[0].data("data.suggest");
|
||||||
|
node.lang = (l) ? l.id : "/type/text";
|
||||||
|
} else if (node.nodeType == "cell-as-key") {
|
||||||
|
var t = elmts.cellAsKeyInput.data("data.suggest");
|
||||||
|
if (!(t)) {
|
||||||
|
alert("Please specify the namespace.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node.namespace = {
|
||||||
|
id: t.id,
|
||||||
|
name: t.name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (node.nodeType == "anonymous") {
|
||||||
|
var t = elmts.anonymousNodeTypeInput.data("data.suggest");
|
||||||
|
if (!(t)) {
|
||||||
|
alert("For generating an anonymous graph node, you need to specify a type for it.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node.type = {
|
||||||
|
id: t.id,
|
||||||
|
name: t.name
|
||||||
|
};
|
||||||
|
} else if (node.nodeType == "topic") {
|
||||||
|
var t = elmts.topicNodeTypeInput.data("data.suggest");
|
||||||
|
if (!(t)) {
|
||||||
|
alert("Please specify which existing Freebase topic to use.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node.topic = {
|
||||||
|
id: t.id,
|
||||||
|
name: t.name
|
||||||
|
};
|
||||||
|
} else if (node.nodeType == "value") {
|
||||||
|
node.value = $.trim(elmts.valueNodeTypeValueInput[0].value);
|
||||||
|
if (node.value.length == 0) {
|
||||||
|
alert("Please specify the value to use.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
node.valueType = elmts.valueNodeTypeValueTypeSelect[0].value;
|
||||||
|
|
||||||
|
var l = elmts.valueNodeTypeLanguageInput[0].data("data.suggest");
|
||||||
|
node.lang = (l) ? l.id : "/type/text";
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
};
|
||||||
|
|
||||||
|
$('<button></button>').html(" OK ").click(function() {
|
||||||
|
var node = getResultJSON();
|
||||||
|
if (node != null) {
|
||||||
|
DialogSystem.dismissUntil(level - 1);
|
||||||
|
|
||||||
|
self._node = node;
|
||||||
|
if (self._isExpandable()) {
|
||||||
|
self._showExpandable();
|
||||||
|
} else {
|
||||||
|
self._hideExpandable();
|
||||||
|
}
|
||||||
|
self._renderMain();
|
||||||
|
}
|
||||||
|
}).appendTo(footer);
|
||||||
|
|
||||||
|
$('<button></button>').text("Cancel").click(function() {
|
||||||
|
DialogSystem.dismissUntil(level - 1);
|
||||||
|
}).appendTo(footer);
|
||||||
|
|
||||||
|
var level = DialogSystem.showDialog(frame);
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaAlignmentDialog.UINode.prototype.getJSON = function() {
|
||||||
|
var result = null;
|
||||||
|
var getLinks = false;
|
||||||
|
|
||||||
|
if (this._node.nodeType.match(/^cell-as-/)) {
|
||||||
|
if (!("columnName" in this._node) || this._node.columnName == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._node.nodeType == "cell-as-topic") {
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
columnName: this._node.columnName,
|
||||||
|
type: "type" in this._node ? cloneDeep(this._node.type) : { "id" : "/common/topic", "name" : "Topic", "cvt" : false },
|
||||||
|
createForNoReconMatch: "createForNoReconMatch" in this._node ? this._node.createForNoReconMatch : true
|
||||||
|
};
|
||||||
|
getLinks = true;
|
||||||
|
} else if (this._node.nodeType == "cell-as-value") {
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
columnName: this._node.columnName,
|
||||||
|
valueType: "valueType" in this._node ? this._node.valueType : "/type/text",
|
||||||
|
lang: "lang" in this._node ? this._node.lang : "/lang/en"
|
||||||
|
};
|
||||||
|
} else if (this._node.nodeType == "cell-as-key") {
|
||||||
|
if (!("namespace" in this._node) || this._node.namespace == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
columnName: this._node.columnName,
|
||||||
|
type: cloneDeep(this._node.namespace)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (this._node.nodeType == "topic") {
|
||||||
|
if (!("topic" in this._node) || this._node.topic == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
topic: cloneDeep(this._node.topic)
|
||||||
|
};
|
||||||
|
getLinks = true;
|
||||||
|
} else if (this._node.nodeType == "value") {
|
||||||
|
if (!("value" in this._node) || this._node.value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
value: this._node.value,
|
||||||
|
valueType: "valueType" in this._node ? this._node.valueType : "/type/text",
|
||||||
|
lang: "lang" in this._node ? this._node.lang : "/lang/en"
|
||||||
|
};
|
||||||
|
} else if (this._node.nodeType == "anonymous") {
|
||||||
|
if (!("type" in this._node) || this._node.type == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result = {
|
||||||
|
nodeType: this._node.nodeType,
|
||||||
|
type: cloneDeep(this._node.type)
|
||||||
|
};
|
||||||
|
getLinks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (getLinks) {
|
||||||
|
var links = [];
|
||||||
|
for (var i = 0; i < this._linkUIs.length; i++) {
|
||||||
|
var link = this._linkUIs[i].getJSON();
|
||||||
|
if (link != null) {
|
||||||
|
links.push(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.links = links;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
@ -92,10 +92,18 @@ SchemaAlignment._cleanName = function(s) {
|
|||||||
|
|
||||||
function SchemaAlignmentDialog(protograph, onDone) {
|
function SchemaAlignmentDialog(protograph, onDone) {
|
||||||
this._onDone = onDone;
|
this._onDone = onDone;
|
||||||
this._originalProtograph = protograph;
|
this._originalProtograph = protograph || { rootNodes: [] };
|
||||||
this._protograph = cloneDeep(protograph); // this is what can be munched on
|
this._protograph = cloneDeep(protograph); // this is what can be munched on
|
||||||
this._nodeUIs = [];
|
|
||||||
|
|
||||||
|
if (this._protograph.rootNodes.length == 0) {
|
||||||
|
this._protograph.rootNodes.push({
|
||||||
|
nodeType: "cell-as-topic",
|
||||||
|
links: [
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this._nodeUIs = [];
|
||||||
this._createDialog();
|
this._createDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,7 +143,8 @@ SchemaAlignmentDialog.prototype._renderFooter = function(footer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DialogSystem.dismissUntil(self._level - 1);
|
DialogSystem.dismissUntil(self._level - 1);
|
||||||
self._onDone(prototgraph);
|
|
||||||
|
self._onDone(protograph);
|
||||||
},
|
},
|
||||||
"json"
|
"json"
|
||||||
);
|
);
|
||||||
@ -160,7 +169,7 @@ SchemaAlignmentDialog.prototype._renderBody = function(body) {
|
|||||||
this._canvas = $('<div></div>').addClass("schema-alignment-dialog-canvas").appendTo(body);
|
this._canvas = $('<div></div>').addClass("schema-alignment-dialog-canvas").appendTo(body);
|
||||||
this._nodeTable = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._canvas)[0];
|
this._nodeTable = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._canvas)[0];
|
||||||
|
|
||||||
for (var i = 0; i < this._originalProtograph.rootNodes.length; i++) {
|
for (var i = 0; i < this._protograph.rootNodes.length; i++) {
|
||||||
this._nodeUIs.push(new SchemaAlignmentDialog.UINode(
|
this._nodeUIs.push(new SchemaAlignmentDialog.UINode(
|
||||||
this._protograph.rootNodes[i],
|
this._protograph.rootNodes[i],
|
||||||
this._nodeTable,
|
this._nodeTable,
|
||||||
@ -186,38 +195,6 @@ SchemaAlignmentDialog.prototype.getJSON = function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
|
||||||
* UINode
|
|
||||||
*----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
SchemaAlignmentDialog.UINode = function(node, table, options) {
|
|
||||||
this._node = node;
|
|
||||||
this._options = options;
|
|
||||||
|
|
||||||
this._linkUIs = [];
|
|
||||||
this._detailsRendered = false;
|
|
||||||
|
|
||||||
this._tr = table.insertRow(table.rows.length);
|
|
||||||
this._tdMain = this._tr.insertCell(0);
|
|
||||||
this._tdToggle = this._tr.insertCell(1);
|
|
||||||
this._tdDetails = this._tr.insertCell(2);
|
|
||||||
|
|
||||||
$(this._tdMain).addClass("schema-alignment-node-main").attr("width", "250").addClass("padded");
|
|
||||||
$(this._tdToggle).addClass("schema-alignment-node-toggle").attr("width", "1%").addClass("padded").hide();
|
|
||||||
$(this._tdDetails).addClass("schema-alignment-node-details").attr("width", "90%").hide();
|
|
||||||
|
|
||||||
this._renderMain();
|
|
||||||
|
|
||||||
this._expanded = options.expanded;
|
|
||||||
if (this._isExpandable()) {
|
|
||||||
this._showExpandable();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._isExpandable = function() {
|
|
||||||
return this._node.nodeType == "cell-as-topic";
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog._findColumn = function(cellIndex) {
|
SchemaAlignmentDialog._findColumn = function(cellIndex) {
|
||||||
var columns = theProject.columnModel.columns;
|
var columns = theProject.columnModel.columns;
|
||||||
for (var i = 0; i < columns.length; i++) {
|
for (var i = 0; i < columns.length; i++) {
|
||||||
@ -228,641 +205,3 @@ SchemaAlignmentDialog._findColumn = function(cellIndex) {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._renderMain = function() {
|
|
||||||
$(this._tdMain).empty();
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
var a = $('<a href="javascript:{}"></a>')
|
|
||||||
.addClass("schema-alignment-node-tag")
|
|
||||||
.appendTo(this._tdMain)
|
|
||||||
.click(function(evt) {
|
|
||||||
if (self._options.mustBeCellTopic) {
|
|
||||||
self._showTagMenu(this);
|
|
||||||
} else {
|
|
||||||
self._showTagDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this._node.nodeType == "cell-as-topic" ||
|
|
||||||
this._node.nodeType == "cell-as-value" ||
|
|
||||||
this._node.nodeType == "cell-as-key") {
|
|
||||||
|
|
||||||
if ("cellIndex" in this._node) {
|
|
||||||
a.html(" cell");
|
|
||||||
|
|
||||||
$('<span></span>')
|
|
||||||
.text(SchemaAlignmentDialog._findColumn(this._node.cellIndex).headerLabel)
|
|
||||||
.addClass("schema-alignment-node-column")
|
|
||||||
.prependTo(a);
|
|
||||||
} else {
|
|
||||||
a.html(this._options.mustBeCellTopic ? "Which column?" : "Configure...");
|
|
||||||
}
|
|
||||||
} else if (this._node.nodeType == "topic") {
|
|
||||||
if ("topic" in this._node) {
|
|
||||||
a.html(this._node.topic.name);
|
|
||||||
} else if ("id" in this._node) {
|
|
||||||
a.html(this._node.topic.id);
|
|
||||||
} else {
|
|
||||||
a.html("Which topic?");
|
|
||||||
}
|
|
||||||
} else if (this._node.nodeType == "value") {
|
|
||||||
if ("value" in this._node) {
|
|
||||||
a.html(this._node.value);
|
|
||||||
} else {
|
|
||||||
a.html("What value?");
|
|
||||||
}
|
|
||||||
} else if (this._node.nodeType == "anonymous") {
|
|
||||||
a.html("(anonymous)");
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<img />').attr("src", "images/down-arrow.png").appendTo(a);
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._showExpandable = function() {
|
|
||||||
$(this._tdToggle).show();
|
|
||||||
$(this._tdDetails).show();
|
|
||||||
|
|
||||||
if (this._detailsRendered) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._detailsRendered = true;
|
|
||||||
|
|
||||||
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
|
|
||||||
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
|
|
||||||
|
|
||||||
this._renderDetails();
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
var show = function() {
|
|
||||||
if (self._expanded) {
|
|
||||||
self._collapsedDetailDiv.hide();
|
|
||||||
self._expandedDetailDiv.show();
|
|
||||||
} else {
|
|
||||||
self._collapsedDetailDiv.show();
|
|
||||||
self._expandedDetailDiv.hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
show();
|
|
||||||
|
|
||||||
$(this._tdToggle).html(" ");
|
|
||||||
$('<img />')
|
|
||||||
.attr("src", this._expanded ? "images/expanded.png" : "images/collapsed.png")
|
|
||||||
.appendTo(this._tdToggle)
|
|
||||||
.click(function() {
|
|
||||||
self._expanded = !self._expanded;
|
|
||||||
|
|
||||||
$(this).attr("src", self._expanded ? "images/expanded.png" : "images/collapsed.png");
|
|
||||||
|
|
||||||
show();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._hideExpandable = function() {
|
|
||||||
$(this._tdToggle).hide();
|
|
||||||
$(this._tdDetails).hide();
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._renderDetails = function() {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this._tableLinks = $('<table></table>').addClass("schema-alignment-table-layout").appendTo(this._expandedDetailDiv)[0];
|
|
||||||
|
|
||||||
if ("links" in this._node && this._node.links != null) {
|
|
||||||
for (var i = 0; i < this._node.links.length; i++) {
|
|
||||||
this._linkUIs.push(new SchemaAlignmentDialog.UILink(this._node.links[i], this._tableLinks, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var divFooter = $('<div></div>').addClass("padded").appendTo(this._expandedDetailDiv);
|
|
||||||
|
|
||||||
$('<a href="javascript:{}"></a>')
|
|
||||||
.addClass("action")
|
|
||||||
.text("add property")
|
|
||||||
.appendTo(divFooter)
|
|
||||||
.click(function() {
|
|
||||||
var newLink = {
|
|
||||||
property: null,
|
|
||||||
target: {
|
|
||||||
nodeType: "cell-as-value"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self._linkUIs.push(new SchemaAlignmentDialog.UILink(
|
|
||||||
newLink,
|
|
||||||
self._tableLinks,
|
|
||||||
{
|
|
||||||
expanded: true,
|
|
||||||
mustBeCellTopic: false
|
|
||||||
}
|
|
||||||
));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._showTagMenu = function(elmt) {
|
|
||||||
self = this;
|
|
||||||
|
|
||||||
var menu = [];
|
|
||||||
|
|
||||||
if (!this._options.mustBeCellTopic) {
|
|
||||||
menu.push({
|
|
||||||
label: "Anonymous Node",
|
|
||||||
click: function() {
|
|
||||||
self._node.nodeType = "anonymous";
|
|
||||||
self._showExpandable();
|
|
||||||
self._renderMain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.push({
|
|
||||||
label: "Freebase Topic",
|
|
||||||
click: function() {
|
|
||||||
self._node.nodeType = "topic";
|
|
||||||
self._hideExpandable();
|
|
||||||
self._renderMain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.push({
|
|
||||||
label: "Value",
|
|
||||||
click: function() {
|
|
||||||
self._node.nodeType = "value";
|
|
||||||
self._hideExpandable();
|
|
||||||
self._renderMain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.push({}); // separator
|
|
||||||
}
|
|
||||||
|
|
||||||
var columns = theProject.columnModel.columns;
|
|
||||||
var createColumnMenuItem = function(index) {
|
|
||||||
menu.push({
|
|
||||||
label: columns[index].headerLabel,
|
|
||||||
click: function() {
|
|
||||||
self._node.nodeType = "cell-as-topic";
|
|
||||||
self._node.cellIndex = columns[index].cellIndex;
|
|
||||||
self._showExpandable();
|
|
||||||
self._renderMain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
for (var i = 0; i < columns.length; i++) {
|
|
||||||
createColumnMenuItem(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuSystem.createAndShowStandardMenu(menu, elmt);
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype._showTagDialog = function() {
|
|
||||||
var self = this;
|
|
||||||
var frame = DialogSystem.createDialog();
|
|
||||||
|
|
||||||
frame.width("800px");
|
|
||||||
|
|
||||||
var header = $('<div></div>').addClass("dialog-header").text("Protograph Node").appendTo(frame);
|
|
||||||
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
|
||||||
var footer = $('<div></div>').addClass("dialog-footer").appendTo(frame);
|
|
||||||
|
|
||||||
/*--------------------------------------------------
|
|
||||||
* Body
|
|
||||||
*--------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
var html = $(
|
|
||||||
'<table class="schema-align-node-dialog-layout">' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td>' +
|
|
||||||
'<table class="schema-align-node-dialog-layout2">' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td colspan="3">' +
|
|
||||||
'<div class="schema-align-node-dialog-node-type">' +
|
|
||||||
'<input type="radio" name="schema-align-node-dialog-node-type" value="anonymous" id="radioNodeTypeAnonymous" /> Generate an anonymous graph node' +
|
|
||||||
'</div>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td>Assign a type to the node</td>' +
|
|
||||||
'<td> <input id="anonymousNodeTypeInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
|
|
||||||
'<tr>' +
|
|
||||||
'<td colspan="3">' +
|
|
||||||
'<div class="schema-align-node-dialog-node-type">' +
|
|
||||||
'<input type="radio" name="schema-align-node-dialog-node-type" value="topic" id="radioNodeTypeTopic" /> Use one existing Freebase topic' +
|
|
||||||
'</div>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td>Topic</td>' +
|
|
||||||
'<td><input id="topicNodeTypeInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
|
|
||||||
'<tr>' +
|
|
||||||
'<td colspan="3">' +
|
|
||||||
'<div class="schema-align-node-dialog-node-type">' +
|
|
||||||
'<input type="radio" name="schema-align-node-dialog-node-type" value="value" id="radioNodeTypeValue" /> Use a literal value' +
|
|
||||||
'</div>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td>Value</td>' +
|
|
||||||
'<td><input id="valueNodeTypeValueInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td>Value type</td>' +
|
|
||||||
'<td><input id="valueNodeTypeValueTypeInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td>Language</td>' +
|
|
||||||
'<td><input id="valueNodeTypeLanguageInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</table>' +
|
|
||||||
'</td>' +
|
|
||||||
|
|
||||||
'<td>' +
|
|
||||||
'<table class="schema-align-node-dialog-layout2">' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td>' +
|
|
||||||
'<div class="schema-align-node-dialog-node-type">' +
|
|
||||||
'<input type="radio" name="schema-align-node-dialog-node-type" value="cell-as" id="radioNodeTypeCellAs" /> Set to Cell in Column' +
|
|
||||||
'</div>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td>' +
|
|
||||||
'<table class="schema-align-node-dialog-layout2">' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td><div class="schema-alignment-node-dialog-column-list" id="divColumns"></div></td>' +
|
|
||||||
'<td>' +
|
|
||||||
'<table class="schema-align-node-dialog-layout2" cols="4">' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td colspan="4">The cell\'s content is used ...</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-topic" id="radioNodeTypeCellAsTopic" /></td>' +
|
|
||||||
'<td colspan="3">to specify a Freebase topic, as reconciled</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td colspan="1" width="1%"><input type="checkbox" id="radioNodeTypeCellAsTopicCreate" /></td>' +
|
|
||||||
'<td colspan="2">If not reconciled, create new topic named by the cell\'s content, and assign it a type</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td colspan="1">Type:</td>' +
|
|
||||||
'<td colspan="1"><input id="cellAsTopicNodeTypeInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
|
|
||||||
'<tr>' +
|
|
||||||
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-value" id="radioNodeTypeCellAsValue" /></td>' +
|
|
||||||
'<td colspan="3">as a literal value</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td colspan="2">Literal type</td>' +
|
|
||||||
'<td colspan="1"><input id="cellAsValueTypeInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td colspan="2">Language (for text)</td>' +
|
|
||||||
'<td colspan="1"><input id="cellAsValueLanguageInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
|
|
||||||
'<tr>' +
|
|
||||||
'<td><input type="radio" name="schema-align-node-dialog-node-subtype" value="cell-as-key" id="radioNodeTypeCellAsKey" /></td>' +
|
|
||||||
'<td colspan="3">as a key in a namespace</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'<tr>' +
|
|
||||||
'<td></td>' +
|
|
||||||
'<td colspan="2">Namespace</td>' +
|
|
||||||
'<td colspan="1"><input id="cellAsKeyInput" /></td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</table>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</table>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</table>' +
|
|
||||||
'</td>' +
|
|
||||||
'</tr>' +
|
|
||||||
'</table>'
|
|
||||||
).appendTo(body);
|
|
||||||
|
|
||||||
var elmts = DOM.bind(html);
|
|
||||||
|
|
||||||
var tableColumns = $('<table></table>')
|
|
||||||
.attr("cellspacing", "5")
|
|
||||||
.attr("cellpadding", "0")
|
|
||||||
.appendTo(elmts.divColumns)[0];
|
|
||||||
|
|
||||||
var makeColumnChoice = function(column, columnIndex) {
|
|
||||||
var tr = tableColumns.insertRow(tableColumns.rows.length);
|
|
||||||
|
|
||||||
var radio = $('<input />')
|
|
||||||
.attr("type", "radio")
|
|
||||||
.attr("value", column.cellIndex)
|
|
||||||
.attr("name", "schema-align-node-dialog-column")
|
|
||||||
.appendTo(tr.insertCell(0))
|
|
||||||
.click(function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if ((!("cellIndex" in self._node) || self._node.cellIndex == null) && columnIndex == 0) {
|
|
||||||
radio.attr("checked", "true");
|
|
||||||
} else if (column.cellIndex == self._node.cellIndex) {
|
|
||||||
radio.attr("checked", "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
$('<span></span>').text(column.headerLabel).appendTo(tr.insertCell(1));
|
|
||||||
};
|
|
||||||
var columns = theProject.columnModel.columns;
|
|
||||||
for (var i = 0; i < columns.length; i++) {
|
|
||||||
makeColumnChoice(columns[i], i);
|
|
||||||
}
|
|
||||||
|
|
||||||
elmts.anonymousNodeTypeInput
|
|
||||||
.bind("focus", function() { elmts.radioNodeTypeAnonymous[0].checked = true; })
|
|
||||||
.suggest({ type: "/type/type" });
|
|
||||||
|
|
||||||
elmts.topicNodeTypeInput
|
|
||||||
.bind("focus", function() { elmts.radioNodeTypeTopic[0].checked = true; })
|
|
||||||
.suggest({});
|
|
||||||
|
|
||||||
elmts.valueNodeTypeValueInput
|
|
||||||
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; })
|
|
||||||
elmts.valueNodeTypeValueTypeInput
|
|
||||||
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; })
|
|
||||||
elmts.valueNodeTypeLanguageInput
|
|
||||||
.bind("focus", function() { elmts.radioNodeTypeValue[0].checked = true; })
|
|
||||||
|
|
||||||
elmts.radioNodeTypeCellAsTopicCreate
|
|
||||||
.click(function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
|
||||||
});
|
|
||||||
elmts.cellAsTopicNodeTypeInput
|
|
||||||
.bind("focus", function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
|
||||||
})
|
|
||||||
.suggest({ type: "/type/type" });
|
|
||||||
|
|
||||||
elmts.cellAsValueTypeInput
|
|
||||||
.bind("focus", function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
|
||||||
})
|
|
||||||
elmts.cellAsValueLanguageInput
|
|
||||||
.bind("focus", function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
|
||||||
})
|
|
||||||
|
|
||||||
elmts.cellAsKeyInput
|
|
||||||
.bind("focus", function() {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
elmts.radioNodeTypeCellAsKey[0].checked = true;
|
|
||||||
})
|
|
||||||
.suggest({ type: "/type/namespace" });
|
|
||||||
|
|
||||||
if (this._node.nodeType.match(/^cell-as-/)) {
|
|
||||||
elmts.radioNodeTypeCellAs[0].checked = true;
|
|
||||||
if (this._node.nodeType == "cell-as-topic") {
|
|
||||||
elmts.radioNodeTypeCellAsTopic[0].checked = true;
|
|
||||||
} else if (this._node.nodeType == "cell-as-value") {
|
|
||||||
elmts.radioNodeTypeCellAsValue[0].checked = true;
|
|
||||||
} else if (this._node.nodeType == "cell-as-key") {
|
|
||||||
elmts.radioNodeTypeCellAsKey[0].checked = true;
|
|
||||||
}
|
|
||||||
} else if (this._node.nodeType == "anonymous") {
|
|
||||||
elmts.radioNodeTypeAnonymous[0].checked = true;
|
|
||||||
} else if (this._node.nodeType == "topic") {
|
|
||||||
elmts.radioNodeTypeTopic[0].checked = true;
|
|
||||||
} else if (this._node.nodeType == "value") {
|
|
||||||
elmts.radioNodeTypeValue[0].checked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*--------------------------------------------------
|
|
||||||
* Footer
|
|
||||||
*--------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
var getResultJSON = function() {
|
|
||||||
};
|
|
||||||
|
|
||||||
$('<button></button>').html(" OK ").click(function() {
|
|
||||||
DialogSystem.dismissUntil(level - 1);
|
|
||||||
self._node = getResultJSON();
|
|
||||||
if (self._isExpandable()) {
|
|
||||||
self._showExpandable();
|
|
||||||
} else {
|
|
||||||
hide._showExpandable();
|
|
||||||
}
|
|
||||||
self._renderMain();
|
|
||||||
}).appendTo(footer);
|
|
||||||
|
|
||||||
$('<button></button>').text("Cancel").click(function() {
|
|
||||||
DialogSystem.dismissUntil(level - 1);
|
|
||||||
}).appendTo(footer);
|
|
||||||
|
|
||||||
var level = DialogSystem.showDialog(frame);
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UINode.prototype.getJSON = function() {
|
|
||||||
var result = null;
|
|
||||||
var getLinks = false;
|
|
||||||
|
|
||||||
if (this._node.nodeType.match(/^cell-as-/)) {
|
|
||||||
if (!("columnName" in this._node) || this._node.columnName == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._node.nodeType == "cell-as-topic") {
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
columnName: this._node.columnName,
|
|
||||||
type: "type" in this._node ? cloneNode(this._node.type) : { "id" : "/common/topic", "name" : "Topic", "cvt" : false },
|
|
||||||
createForNoReconMatch: "createForNoReconMatch" in this._node ? this._node.createForNoReconMatch : true
|
|
||||||
};
|
|
||||||
getLinks = true;
|
|
||||||
} else if (this._node.nodeType == "cell-as-value") {
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
columnName: this._node.columnName,
|
|
||||||
valueType: "valueType" in this._node ? this._node.valueType : "/type/text",
|
|
||||||
lang: "lang" in this._node ? this._node.lang : "/lang/en"
|
|
||||||
};
|
|
||||||
} else if (this._node.nodeType == "cell-as-key") {
|
|
||||||
if (!("namespace" in this._node) || this._node.namespace == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
columnName: this._node.columnName,
|
|
||||||
type: cloneNode(this._node.namespace)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else if (this._node.nodeType == "topic") {
|
|
||||||
if (!("topic" in this._node) || this._node.topic == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
topic: cloneNode(this._node.topic)
|
|
||||||
};
|
|
||||||
getLinks = true;
|
|
||||||
} else if (this._node.nodeType == "value") {
|
|
||||||
if (!("value" in this._node) || this._node.value == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
value: this._node.value,
|
|
||||||
valueType: "valueType" in this._node ? this._node.valueType : "/type/text",
|
|
||||||
lang: "lang" in this._node ? this._node.lang : "/lang/en"
|
|
||||||
};
|
|
||||||
} else if (this._node.nodeType == "anonymous") {
|
|
||||||
if (!("type" in this._node) || this._node.type == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
result = {
|
|
||||||
nodeType: this._node.nodeType,
|
|
||||||
type: cloneNode(this._node.type)
|
|
||||||
};
|
|
||||||
getLinks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (getLinks) {
|
|
||||||
var links = [];
|
|
||||||
for (var i = 0; i < this._linkUIs.length; i++) {
|
|
||||||
var link = this._linkUIs[i].getJSON();
|
|
||||||
if (link != null) {
|
|
||||||
links.push(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.links = links;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
|
||||||
* UILink
|
|
||||||
*----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
SchemaAlignmentDialog.UILink = function(link, table, expanded) {
|
|
||||||
this._link = link;
|
|
||||||
this._expanded = expanded;
|
|
||||||
|
|
||||||
this._tr = table.insertRow(table.rows.length);
|
|
||||||
this._tdMain = this._tr.insertCell(0);
|
|
||||||
this._tdToggle = this._tr.insertCell(1);
|
|
||||||
this._tdDetails = this._tr.insertCell(2);
|
|
||||||
|
|
||||||
$(this._tdMain).addClass("schema-alignment-link-main").attr("width", "250").addClass("padded");
|
|
||||||
$(this._tdToggle).addClass("schema-alignment-link-toggle").attr("width", "1%").addClass("padded");
|
|
||||||
$(this._tdDetails).addClass("schema-alignment-link-details").attr("width", "90%");
|
|
||||||
|
|
||||||
this._collapsedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("padded").html("...");
|
|
||||||
this._expandedDetailDiv = $('<div></div>').appendTo(this._tdDetails).addClass("schema-alignment-detail-container");
|
|
||||||
var self = this;
|
|
||||||
var show = function() {
|
|
||||||
if (self._expanded) {
|
|
||||||
self._collapsedDetailDiv.hide();
|
|
||||||
self._expandedDetailDiv.show();
|
|
||||||
} else {
|
|
||||||
self._collapsedDetailDiv.show();
|
|
||||||
self._expandedDetailDiv.hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
show();
|
|
||||||
|
|
||||||
$(this._tdToggle).html(" ");
|
|
||||||
$('<img />')
|
|
||||||
.attr("src", this._expanded ? "images/expanded.png" : "images/collapsed.png")
|
|
||||||
.appendTo(this._tdToggle)
|
|
||||||
.click(function() {
|
|
||||||
self._expanded = !self._expanded;
|
|
||||||
|
|
||||||
$(this).attr("src", self._expanded ? "images/expanded.png" : "images/collapsed.png");
|
|
||||||
|
|
||||||
show();
|
|
||||||
});
|
|
||||||
|
|
||||||
this._renderMain();
|
|
||||||
this._renderDetails();
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UILink.prototype._renderMain = function() {
|
|
||||||
$(this._tdMain).empty()
|
|
||||||
|
|
||||||
var label = this._link.property != null ? this._link.property.id : "property?";
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var a = $('<a href="javascript:{}"></a>')
|
|
||||||
.addClass("schema-alignment-link-tag")
|
|
||||||
.html(label)
|
|
||||||
.appendTo(this._tdMain)
|
|
||||||
.click(function(evt) {
|
|
||||||
self._showTagSuggest(this);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('<img />').attr("src", "images/arrow-start.png").prependTo(a);
|
|
||||||
$('<img />').attr("src", "images/arrow-end.png").appendTo(a);
|
|
||||||
};
|
|
||||||
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UILink.prototype._showTagSuggest = function(elmt) {
|
|
||||||
self = this;
|
|
||||||
|
|
||||||
var fakeMenu = MenuSystem.createMenu()
|
|
||||||
.width(300)
|
|
||||||
.height(100)
|
|
||||||
.css("background", "none")
|
|
||||||
.css("border", "none");
|
|
||||||
|
|
||||||
var input = $('<input />').appendTo(fakeMenu);
|
|
||||||
|
|
||||||
var level = MenuSystem.showMenu(fakeMenu, function(){});
|
|
||||||
MenuSystem.positionMenuAboveBelow(fakeMenu, $(elmt));
|
|
||||||
|
|
||||||
input.suggest({ type : '/type/property' }).bind("fb-select", function(e, data) {
|
|
||||||
self._link.property = {
|
|
||||||
id: data.id,
|
|
||||||
name: data.name
|
|
||||||
};
|
|
||||||
|
|
||||||
window.setTimeout(function() {
|
|
||||||
MenuSystem.dismissAll();
|
|
||||||
self._renderMain();
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
input[0].focus();
|
|
||||||
};
|
|
||||||
|
|
||||||
SchemaAlignmentDialog.UILink.prototype.getJSON = function() {
|
|
||||||
if ("property" in this._link && this._link.property != null &&
|
|
||||||
"target" in this._link && this._link.target != null) {
|
|
||||||
|
|
||||||
var targetJSON = this._targetUI.getJSON();
|
|
||||||
if (targetJSON != null) {
|
|
||||||
return {
|
|
||||||
property: cloneNode(this._link.property),
|
|
||||||
target: targetJSON
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
Loading…
Reference in New Issue
Block a user