diff --git a/main/src/com/google/gridworks/protograph/BooleanColumnCondition.java b/main/src/com/google/gridworks/protograph/BooleanColumnCondition.java index d97508508..a53bfcf36 100644 --- a/main/src/com/google/gridworks/protograph/BooleanColumnCondition.java +++ b/main/src/com/google/gridworks/protograph/BooleanColumnCondition.java @@ -1,5 +1,10 @@ package com.google.gridworks.protograph; +import java.util.Properties; + +import org.json.JSONException; +import org.json.JSONWriter; + import com.google.gridworks.model.Column; import com.google.gridworks.model.Project; import com.google.gridworks.model.Row; @@ -28,4 +33,10 @@ public class BooleanColumnCondition implements Condition { return false; } + @Override + public void write(JSONWriter writer, Properties options) throws JSONException { + writer.object(); + writer.key("columnName"); writer.value(columnName); + writer.endObject(); + } } diff --git a/main/src/com/google/gridworks/protograph/Condition.java b/main/src/com/google/gridworks/protograph/Condition.java index b406a10f6..ab45c0490 100644 --- a/main/src/com/google/gridworks/protograph/Condition.java +++ b/main/src/com/google/gridworks/protograph/Condition.java @@ -1,8 +1,9 @@ package com.google.gridworks.protograph; +import com.google.gridworks.Jsonizable; import com.google.gridworks.model.Project; import com.google.gridworks.model.Row; -public interface Condition { +public interface Condition extends Jsonizable { public boolean test(Project project, int rowIndex, Row row); } diff --git a/main/src/com/google/gridworks/protograph/Link.java b/main/src/com/google/gridworks/protograph/Link.java index 19843c08e..6ec3ea898 100644 --- a/main/src/com/google/gridworks/protograph/Link.java +++ b/main/src/com/google/gridworks/protograph/Link.java @@ -37,6 +37,10 @@ public class Link implements Jsonizable { writer.key("target"); target.write(writer, options); } + if (condition != null) { + writer.key("condition"); + condition.write(writer, options); + } writer.endObject(); } diff --git a/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js b/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js index b9e08da88..6db33ce5e 100644 --- a/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js +++ b/main/webapp/modules/core/scripts/protograph/schema-alignment-ui-link.js @@ -49,7 +49,9 @@ SchemaAlignmentDialog.UILink = function(dialog, link, table, options, parentUINo SchemaAlignmentDialog.UILink.prototype._renderMain = function() { $(this._tdMain).empty(); - var label = this._link.property !== null ? this._link.property.id : "property?"; + var label = this._link.property !== null ? + (this._link.property.id + ((this._link.condition) ? " [?]" : "")) : + "property?"; var self = this; @@ -98,7 +100,7 @@ SchemaAlignmentDialog.UILink.prototype._startEditProperty = function(elmt) { var sourceTypeID = this._parentUINode.getExpectedType(); var targetNode = this._targetUI._node; var targetTypeID = "type" in targetNode && targetNode.type !== null ? targetNode.type.id : null; - var targetTypeName = "columnName" in targetNode ? targetNode.columnName : null; + var targetTypeName = "columnNames" in targetNode ? targetNode.columnNames[0] : null; if (sourceTypeID !== null) { var self = this; @@ -191,13 +193,46 @@ SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt name: p.name }; } + + var conditionColumnName = conditionalSelect[0].value; + if (conditionColumnName != "") { + self._link.condition = { columnName: conditionColumnName }; + } else { + delete self._link.condition; + } + self._configureTarget(); }; - var divSearch; + var divConditional = $('
') + .addClass("schema-alignment-link-menu-section") + .html("Assert link when 'true' is found in column
").appendTo(menu); + + var conditionalSelect = $('').appendTo($('
').appendTo(divSearch)); @@ -235,19 +272,9 @@ SchemaAlignmentDialog.UILink.prototype._showPropertySuggestPopup = function(elmt var suggestOptions = { type : '/type/property' }; - if (this._link.target !== null && "type" in this._link.target && this._link.target.type !== null) { - /* - suggestOptions.mql_filter = [{ - "/type/property/expected_type" : { - id: this._link.target.type.id - } - }]; - */ - } else { - var sourceTypeID = this._parentUINode.getExpectedType(); - if (sourceTypeID !== null) { - suggestOptions.ac_param = { schema: sourceTypeID }; - } + var sourceTypeID = this._parentUINode.getExpectedType(); + if (sourceTypeID !== null) { + suggestOptions.ac_param = { schema: sourceTypeID }; } input.suggestP(suggestOptions).bind("fb-select", function(e, data) { commitProperty(data); }); @@ -260,10 +287,14 @@ SchemaAlignmentDialog.UILink.prototype.getJSON = function() { var targetJSON = this._targetUI.getJSON(); if (targetJSON !== null) { - return { + var json = { property: cloneDeep(this._link.property), target: targetJSON }; + if (this._link.condition) { + json.condition = cloneDeep(this._link.condition); + } + return json; } } return null; diff --git a/main/webapp/modules/core/scripts/widgets/history-extract-dialog.html b/main/webapp/modules/core/scripts/widgets/history-extract-dialog.html new file mode 100644 index 000000000..46252ff58 --- /dev/null +++ b/main/webapp/modules/core/scripts/widgets/history-extract-dialog.html @@ -0,0 +1,21 @@ +
+
Extract Operations
+
+ + + +
+ The following JSON code encodes the operations you have done that can be abstracted. + You can copy and save it in order to apply the same operations in the future. +
+
+
+