Add logic for new customized facets

This commit is contained in:
Joanne 2018-03-16 23:05:00 +08:00
parent 14e49d0099
commit 64b01a2319
3 changed files with 33 additions and 3 deletions

View File

@ -141,6 +141,7 @@ import com.google.refine.grel.controls.ForRange;
import com.google.refine.grel.controls.If;
import com.google.refine.grel.controls.IsBlank;
import com.google.refine.grel.controls.IsError;
import com.google.refine.grel.controls.IsEmptyString;
import com.google.refine.grel.controls.IsNonBlank;
import com.google.refine.grel.controls.IsNotNull;
import com.google.refine.grel.controls.IsNull;
@ -305,6 +306,7 @@ public class ControlFunctionRegistry {
registerControl("isNull", new IsNull());
registerControl("isNotNull", new IsNotNull());
registerControl("isEmptyString", new IsEmptyString());
registerControl("isBlank", new IsBlank());
registerControl("isNonBlank", new IsNonBlank());
registerControl("isNumeric", new IsNumeric());

View File

@ -0,0 +1,14 @@
package com.google.refine.grel.controls;
public class IsEmptyString extends IsTest {
@Override
protected String getDescription() {
return "Returns whether o is an empty string";
}
@Override
protected boolean test(Object o) {
return o != null && o.getClass().equals(String.class)
&& o.equals("");
}
}

View File

@ -246,15 +246,29 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
}
},
{
id: "core/blank-facet",
label: $.i18n._('core-views')["facet-blank"],
id: "core/null-facet",
label: $.i18n._('core-views')["facet-null"],
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isBlank(value)"
"expression": "isNull(value)"
}
);
}
},
{
id: "core/empty-string-facet",
label: $.i18n._('core-views')["facet-empty-string"],
click: function() {
ui.browsingEngine.addFacet(
"list",
{
"name": column.name,
"columnName": column.name,
"expression": "isEmptyString(value)"
}
);
}