Merge branch 'master' of ssh://github.com/OpenRefine/OpenRefine
This commit is contained in:
commit
21468a35a5
@ -153,13 +153,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>2.9.8</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>2.9.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
"wikidata-schema/add-statement": "add statement",
|
"wikidata-schema/add-statement": "add statement",
|
||||||
"wikidata-schema/add-value": "add value",
|
"wikidata-schema/add-value": "add value",
|
||||||
"wikidata-schema/add-qualifier": "add qualifier",
|
"wikidata-schema/add-qualifier": "add qualifier",
|
||||||
|
"wikidata-schema/copy-reference": "copy",
|
||||||
|
"wikidata-schema/paste-reference": "paste reference",
|
||||||
|
"wikidata-schema/reference-copied": "copied",
|
||||||
"wikidata-schema/add-reference": "add reference",
|
"wikidata-schema/add-reference": "add reference",
|
||||||
"wikidata-schema/add-reference-snak": "add",
|
"wikidata-schema/add-reference-snak": "add",
|
||||||
"wikidata-schema/property-placeholder": "property",
|
"wikidata-schema/property-placeholder": "property",
|
||||||
@ -146,4 +149,4 @@
|
|||||||
"warnings-messages/no-unit-provided/body": "Values such as <span class=\"wb-issue-preformat\">{example_value}</span> on {example_item_entity} are expected to have units.",
|
"warnings-messages/no-unit-provided/body": "Values such as <span class=\"wb-issue-preformat\">{example_value}</span> on {example_item_entity} are expected to have units.",
|
||||||
"warnings-messages/invalid-entity-type/title": "{property_entity} used on items",
|
"warnings-messages/invalid-entity-type/title": "{property_entity} used on items",
|
||||||
"warnings-messages/invalid-entity-type/body": "Uses of {property_entity} on items such as {example_entity} are invalid."
|
"warnings-messages/invalid-entity-type/body": "Uses of {property_entity} on items such as {example_entity} are invalid."
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
"wikidata-schema/add-statement": "ajouter une déclaration",
|
"wikidata-schema/add-statement": "ajouter une déclaration",
|
||||||
"wikidata-schema/add-value": "ajouter une valeur",
|
"wikidata-schema/add-value": "ajouter une valeur",
|
||||||
"wikidata-schema/add-qualifier": "ajouter un qualificatif",
|
"wikidata-schema/add-qualifier": "ajouter un qualificatif",
|
||||||
|
"wikidata-schema/copy-reference": "copier",
|
||||||
|
"wikidata-schema/paste-reference": "coller une référence",
|
||||||
|
"wikidata-schema/reference-copied": "copiée",
|
||||||
"wikidata-schema/add-reference": "ajouter une référence",
|
"wikidata-schema/add-reference": "ajouter une référence",
|
||||||
"wikidata-schema/add-reference-snak": "ajouter",
|
"wikidata-schema/add-reference-snak": "ajouter",
|
||||||
"wikidata-schema/property-placeholder": "propriété",
|
"wikidata-schema/property-placeholder": "propriété",
|
||||||
@ -139,4 +142,4 @@
|
|||||||
"warnings-messages/no-unit-provided/body": "Des valeurs telles que <span class=\"wb-issue-preformat\">{example_value}</span> sur {example_item_entity} devraient avoir des unités.",
|
"warnings-messages/no-unit-provided/body": "Des valeurs telles que <span class=\"wb-issue-preformat\">{example_value}</span> sur {example_item_entity} devraient avoir des unités.",
|
||||||
"warnings-messages/invalid-entity-type/title": "{property_entity} utilisée sur des éléments",
|
"warnings-messages/invalid-entity-type/title": "{property_entity} utilisée sur des éléments",
|
||||||
"warnings-messages/invalid-entity-type/body": "Les utilisations de {property_entity} sur des éléments tels que {example_entity} sont invalides."
|
"warnings-messages/invalid-entity-type/body": "Les utilisations de {property_entity} sur des éléments tels que {example_entity} sont invalides."
|
||||||
}
|
}
|
||||||
|
@ -244,12 +244,18 @@ SchemaAlignmentDialog._reset = function(schema) {
|
|||||||
if (!this._schema.itemDocuments.length) {
|
if (!this._schema.itemDocuments.length) {
|
||||||
// this._addItem();
|
// this._addItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._copiedReference = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
SchemaAlignmentDialog._save = function(onDone) {
|
SchemaAlignmentDialog._save = function(onDone) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var schema = this.getJSON();
|
var schema = this.getJSON();
|
||||||
|
|
||||||
|
if (schema === null) {
|
||||||
|
alert($.i18n('wikidata-schema/incomplete-schema-could-not-be-saved'));
|
||||||
|
}
|
||||||
|
|
||||||
Refine.postProcess(
|
Refine.postProcess(
|
||||||
"wikidata",
|
"wikidata",
|
||||||
"save-wikibase-schema",
|
"save-wikibase-schema",
|
||||||
@ -394,17 +400,32 @@ SchemaAlignmentDialog._addItem = function(json) {
|
|||||||
|
|
||||||
SchemaAlignmentDialog._itemToJSON = function (item) {
|
SchemaAlignmentDialog._itemToJSON = function (item) {
|
||||||
var statementGroupLst = new Array();
|
var statementGroupLst = new Array();
|
||||||
item.find('.wbs-statement-group').each(function () {
|
var statementsDom = item.find('.wbs-statement-group');
|
||||||
statementGroupLst.push(SchemaAlignmentDialog._statementGroupToJSON($(this)));
|
statementsDom.each(function () {
|
||||||
|
var statementGroupJSON = SchemaAlignmentDialog._statementGroupToJSON($(this));
|
||||||
|
if (statementGroupJSON !== null) {
|
||||||
|
statementGroupLst.push(statementGroupJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var nameDescLst = new Array();
|
var nameDescLst = new Array();
|
||||||
item.find('.wbs-namedesc').each(function () {
|
var nameDescsDom = item.find('.wbs-namedesc');
|
||||||
nameDescLst.push(SchemaAlignmentDialog._nameDescToJSON($(this)));
|
nameDescsDom.each(function () {
|
||||||
|
var nameDescJSON = SchemaAlignmentDialog._nameDescToJSON($(this));
|
||||||
|
if (nameDescJSON !== null) {
|
||||||
|
nameDescLst.push(nameDescJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var inputContainer = item.find(".wbs-item-input").first();
|
var inputContainer = item.find(".wbs-item-input").first();
|
||||||
return {subject: SchemaAlignmentDialog._inputContainerToJSON(inputContainer),
|
var subjectJSON = SchemaAlignmentDialog._inputContainerToJSON(inputContainer);
|
||||||
|
if (subjectJSON !== null &&
|
||||||
|
statementGroupLst.length === statementsDom.length &&
|
||||||
|
nameDescLst.length === nameDescsDom.length) {
|
||||||
|
return {subject: subjectJSON,
|
||||||
statementGroups: statementGroupLst,
|
statementGroups: statementGroupLst,
|
||||||
nameDescs: nameDescLst};
|
nameDescs: nameDescLst};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************************
|
/**************************
|
||||||
@ -513,12 +534,21 @@ SchemaAlignmentDialog._addStatementGroup = function(item, json) {
|
|||||||
|
|
||||||
SchemaAlignmentDialog._statementGroupToJSON = function (statementGroup) {
|
SchemaAlignmentDialog._statementGroupToJSON = function (statementGroup) {
|
||||||
var lst = new Array();
|
var lst = new Array();
|
||||||
statementGroup.find('.wbs-statement-container').first().children('.wbs-statement').each(function () {
|
var domStatements = statementGroup.find('.wbs-statement-container').first().children('.wbs-statement');
|
||||||
lst.push(SchemaAlignmentDialog._statementToJSON($(this)));
|
domStatements.each(function () {
|
||||||
|
var statementJSON = SchemaAlignmentDialog._statementToJSON($(this));
|
||||||
|
if (statementJSON !== null) {
|
||||||
|
lst.push(statementJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var inputContainer = statementGroup.find(".wbs-prop-input").first();
|
var inputContainer = statementGroup.find(".wbs-prop-input").first();
|
||||||
return {property: SchemaAlignmentDialog._inputContainerToJSON(inputContainer),
|
var propertyJSON = SchemaAlignmentDialog._inputContainerToJSON(inputContainer);
|
||||||
statements: lst};
|
if (propertyJSON !== null && domStatements.length === lst.length && lst.length > 0) {
|
||||||
|
return {property: propertyJSON,
|
||||||
|
statements: lst};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
@ -593,6 +623,30 @@ SchemaAlignmentDialog._addStatement = function(container, datatype, json) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}).appendTo(toolbar3);
|
}).appendTo(toolbar3);
|
||||||
SchemaAlignmentDialog._plusButton($.i18n('wikidata-schema/add-reference'), addReferenceButton);
|
SchemaAlignmentDialog._plusButton($.i18n('wikidata-schema/add-reference'), addReferenceButton);
|
||||||
|
|
||||||
|
var pasteToolbar = $('<div></div>').addClass('wbs-toolbar').appendTo(referencesToggleContainer);
|
||||||
|
var referencePaste = $('<span></span>')
|
||||||
|
.addClass('wbs-paste-reference')
|
||||||
|
.appendTo(pasteToolbar);
|
||||||
|
if (SchemaAlignmentDialog._copiedReference === null) {
|
||||||
|
referencePaste.hide();
|
||||||
|
}
|
||||||
|
var pasteIcon = $('<span></span>').addClass('wbs-icon').appendTo(referencePaste);
|
||||||
|
var referencePasteButton = $('<a></a>')
|
||||||
|
.addClass('wbs-paste-reference-button')
|
||||||
|
.text($.i18n('wikidata-schema/paste-reference'))
|
||||||
|
.appendTo(referencePaste)
|
||||||
|
.click(function(e) {
|
||||||
|
if (SchemaAlignmentDialog._copiedReference !== null) {
|
||||||
|
SchemaAlignmentDialog._addReference(referenceContainer, SchemaAlignmentDialog._copiedReference);
|
||||||
|
SchemaAlignmentDialog._updateReferencesNumber(referenceContainer);
|
||||||
|
referencePaste.hide();
|
||||||
|
SchemaAlignmentDialog._hasChanged();
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
if (references) {
|
if (references) {
|
||||||
for (var i = 0; i != references.length; i++) {
|
for (var i = 0; i != references.length; i++) {
|
||||||
SchemaAlignmentDialog._addReference(referenceContainer, references[i]);
|
SchemaAlignmentDialog._addReference(referenceContainer, references[i]);
|
||||||
@ -607,17 +661,32 @@ SchemaAlignmentDialog._statementToJSON = function (statement) {
|
|||||||
var inputContainer = statement.find(".wbs-target-input").first();
|
var inputContainer = statement.find(".wbs-target-input").first();
|
||||||
var qualifiersList = new Array();
|
var qualifiersList = new Array();
|
||||||
var referencesList = new Array();
|
var referencesList = new Array();
|
||||||
statement.find('.wbs-qualifier-container').first().children().each(function () {
|
var qualifiersDom = statement.find('.wbs-qualifier-container').first().children();
|
||||||
qualifiersList.push(SchemaAlignmentDialog._qualifierToJSON($(this)));
|
qualifiersDom.each(function () {
|
||||||
|
var qualifierJSON = SchemaAlignmentDialog._qualifierToJSON($(this));
|
||||||
|
if (qualifierJSON !== null) {
|
||||||
|
qualifiersList.push(qualifierJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
statement.find('.wbs-reference-container').first().children().each(function () {
|
var referencesDom = statement.find('.wbs-reference-container').first().children();
|
||||||
referencesList.push(SchemaAlignmentDialog._referenceToJSON($(this)));
|
referencesDom.each(function () {
|
||||||
|
var referenceJSON = SchemaAlignmentDialog._referenceToJSON($(this));
|
||||||
|
if (referenceJSON !== null) {
|
||||||
|
referencesList.push(referenceJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return {
|
var valueJSON = SchemaAlignmentDialog._inputContainerToJSON(inputContainer);
|
||||||
value:SchemaAlignmentDialog._inputContainerToJSON(inputContainer),
|
if (referencesList.length === referencesDom.length &&
|
||||||
|
qualifiersList.length === qualifiersDom.length &&
|
||||||
|
valueJSON !== null) {
|
||||||
|
return {
|
||||||
|
value: valueJSON,
|
||||||
qualifiers: qualifiersList,
|
qualifiers: qualifiersList,
|
||||||
references: referencesList,
|
references: referencesList,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
@ -655,10 +724,16 @@ SchemaAlignmentDialog._addQualifier = function(container, json) {
|
|||||||
SchemaAlignmentDialog._qualifierToJSON = function(elem) {
|
SchemaAlignmentDialog._qualifierToJSON = function(elem) {
|
||||||
var prop = elem.find(".wbs-prop-input").first();
|
var prop = elem.find(".wbs-prop-input").first();
|
||||||
var target = elem.find(".wbs-target-input").first();
|
var target = elem.find(".wbs-target-input").first();
|
||||||
return {
|
var propJSON = SchemaAlignmentDialog._inputContainerToJSON(prop);
|
||||||
prop: SchemaAlignmentDialog._inputContainerToJSON(prop),
|
var valueJSON = SchemaAlignmentDialog._inputContainerToJSON(target);
|
||||||
value: SchemaAlignmentDialog._inputContainerToJSON(target),
|
if (propJSON !== null && valueJSON !== null) {
|
||||||
};
|
return {
|
||||||
|
prop: propJSON,
|
||||||
|
value: valueJSON,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
@ -673,6 +748,20 @@ SchemaAlignmentDialog._addReference = function(container, json) {
|
|||||||
|
|
||||||
var reference = $('<div></div>').addClass('wbs-reference').appendTo(container);
|
var reference = $('<div></div>').addClass('wbs-reference').appendTo(container);
|
||||||
var referenceHeader = $('<div></div>').addClass('wbs-reference-header').appendTo(reference);
|
var referenceHeader = $('<div></div>').addClass('wbs-reference-header').appendTo(reference);
|
||||||
|
var referenceCopy = $('<span></span>').addClass('wbs-copy-reference').appendTo(referenceHeader);
|
||||||
|
var referenceCopyIcon = $('<span></span>').addClass('wbs-icon').appendTo(referenceCopy);
|
||||||
|
var copyButton = $('<span></span>')
|
||||||
|
.addClass('wbs-copy-reference-button')
|
||||||
|
.text($.i18n('wikidata-schema/copy-reference'))
|
||||||
|
.appendTo(referenceCopy)
|
||||||
|
.click(function(e) {
|
||||||
|
if (SchemaAlignmentDialog._copyReference(reference)) {
|
||||||
|
$(this).text($.i18n('wikidata-schema/reference-copied'))
|
||||||
|
.parent().addClass('wbs-copied-reference');
|
||||||
|
container.parent().parent().find('.wbs-paste-reference').hide();
|
||||||
|
}
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
var toolbarRef = $('<div></div>').addClass('wbs-toolbar').appendTo(referenceHeader);
|
var toolbarRef = $('<div></div>').addClass('wbs-toolbar').appendTo(referenceHeader);
|
||||||
SchemaAlignmentDialog._makeDeleteButton().click(function(e) {
|
SchemaAlignmentDialog._makeDeleteButton().click(function(e) {
|
||||||
reference.remove();
|
reference.remove();
|
||||||
@ -703,9 +792,16 @@ SchemaAlignmentDialog._referenceToJSON = function(reference) {
|
|||||||
var snaks = reference.find('.wbs-qualifier-container').first().children();
|
var snaks = reference.find('.wbs-qualifier-container').first().children();
|
||||||
var snaksList = new Array();
|
var snaksList = new Array();
|
||||||
snaks.each(function () {
|
snaks.each(function () {
|
||||||
snaksList.push(SchemaAlignmentDialog._qualifierToJSON($(this)));
|
var qualifier = SchemaAlignmentDialog._qualifierToJSON($(this));
|
||||||
|
if (qualifier !== null) {
|
||||||
|
snaksList.push(qualifier);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return {snaks:snaksList};
|
if (snaksList.length === snaks.length) {
|
||||||
|
return {snaks:snaksList};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SchemaAlignmentDialog._updateReferencesNumber = function(container) {
|
SchemaAlignmentDialog._updateReferencesNumber = function(container) {
|
||||||
@ -715,6 +811,22 @@ SchemaAlignmentDialog._updateReferencesNumber = function(container) {
|
|||||||
a.html(childrenCount+$.i18n('wikidata-schema/nb-references'));
|
a.html(childrenCount+$.i18n('wikidata-schema/nb-references'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SchemaAlignmentDialog._copyReference = function(reference) {
|
||||||
|
// mark any other copied reference as not copied
|
||||||
|
$('.wbs-copy-reference-button')
|
||||||
|
.text($.i18n('wikidata-schema/copy-reference'));
|
||||||
|
$('.wbs-copy-reference')
|
||||||
|
.removeClass('wbs-copied-reference');
|
||||||
|
var copiedReference = SchemaAlignmentDialog._referenceToJSON(reference);
|
||||||
|
if (copiedReference !== null) {
|
||||||
|
SchemaAlignmentDialog._copiedReference = copiedReference;
|
||||||
|
$('.wbs-paste-reference').show();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* FIELD INITIALIZATION *
|
* FIELD INITIALIZATION *
|
||||||
************************/
|
************************/
|
||||||
@ -802,8 +914,12 @@ SchemaAlignmentDialog._initField = function(inputContainer, mode, initialValue,
|
|||||||
var suggestConfig = $.extend({}, endpoint);
|
var suggestConfig = $.extend({}, endpoint);
|
||||||
suggestConfig.key = null;
|
suggestConfig.key = null;
|
||||||
suggestConfig.query_param_name = "prefix";
|
suggestConfig.query_param_name = "prefix";
|
||||||
|
if ('view' in this._reconService && 'url' in this._reconService.view && !('view_url' in endpoint)) {
|
||||||
|
suggestConfig.view_url = this._reconService.view.url;
|
||||||
|
}
|
||||||
|
|
||||||
input.suggestP(suggestConfig).bind("fb-select", function(evt, data) {
|
|
||||||
|
input.suggest(suggestConfig).bind("fb-select", function(evt, data) {
|
||||||
inputContainer.data("jsonValue", {
|
inputContainer.data("jsonValue", {
|
||||||
type : "wbitemconstant",
|
type : "wbitemconstant",
|
||||||
qid : data.id,
|
qid : data.id,
|
||||||
@ -1076,7 +1192,7 @@ SchemaAlignmentDialog.setupStringInputValidation = function(input, regex) {
|
|||||||
|
|
||||||
SchemaAlignmentDialog._inputContainerToJSON = function (inputContainer) {
|
SchemaAlignmentDialog._inputContainerToJSON = function (inputContainer) {
|
||||||
var data = inputContainer.data();
|
var data = inputContainer.data();
|
||||||
if (data) {
|
if (data && 'jsonValue' in data) {
|
||||||
return data.jsonValue;
|
return data.jsonValue;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -1095,13 +1211,21 @@ SchemaAlignmentDialog._removeStatement = function(statement) {
|
|||||||
|
|
||||||
SchemaAlignmentDialog.getJSON = function() {
|
SchemaAlignmentDialog.getJSON = function() {
|
||||||
var list = new Array();
|
var list = new Array();
|
||||||
$('#schema-alignment-statements-container .wbs-item').each(function () {
|
var itemsDom = $('#schema-alignment-statements-container .wbs-item');
|
||||||
list.push(SchemaAlignmentDialog._itemToJSON($(this)));
|
itemsDom.each(function () {
|
||||||
|
var itemJSON = SchemaAlignmentDialog._itemToJSON($(this));
|
||||||
|
if (itemJSON !== null) {
|
||||||
|
list.push(itemJSON);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return {
|
if (list.length === itemsDom.length) {
|
||||||
|
return {
|
||||||
'itemDocuments': list,
|
'itemDocuments': list,
|
||||||
'wikibasePrefix': this._wikibasePrefix,
|
'wikibasePrefix': this._wikibasePrefix,
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SchemaAlignmentDialog._hasChanged = function() {
|
SchemaAlignmentDialog._hasChanged = function() {
|
||||||
@ -1114,6 +1238,10 @@ SchemaAlignmentDialog._hasChanged = function() {
|
|||||||
SchemaAlignmentDialog._schemaElmts.discardButton
|
SchemaAlignmentDialog._schemaElmts.discardButton
|
||||||
.prop('disabled', false)
|
.prop('disabled', false)
|
||||||
.removeClass('disabled');
|
.removeClass('disabled');
|
||||||
|
$('.wbs-copy-reference-button')
|
||||||
|
.text($.i18n('wikidata-schema/copy-reference'));
|
||||||
|
$('.wbs-copy-reference')
|
||||||
|
.removeClass('wbs-copied-reference');
|
||||||
}
|
}
|
||||||
|
|
||||||
SchemaAlignmentDialog.updateNbEdits = function(nb_edits) {
|
SchemaAlignmentDialog.updateNbEdits = function(nb_edits) {
|
||||||
@ -1130,6 +1258,10 @@ SchemaAlignmentDialog.preview = function() {
|
|||||||
this.issueSpinner.show();
|
this.issueSpinner.show();
|
||||||
this.previewSpinner.show();
|
this.previewSpinner.show();
|
||||||
var schema = this.getJSON();
|
var schema = this.getJSON();
|
||||||
|
if (schema === null) {
|
||||||
|
$('.invalid-schema-warning').show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$.post(
|
$.post(
|
||||||
"command/wikidata/preview-wikibase-schema?" + $.param({ project: theProject.id }),
|
"command/wikidata/preview-wikibase-schema?" + $.param({ project: theProject.id }),
|
||||||
{ schema: JSON.stringify(schema), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
{ schema: JSON.stringify(schema), engine: JSON.stringify(ui.browsingEngine.getJSON()) },
|
||||||
|
@ -143,6 +143,7 @@
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.wbs-remove .wbs-icon {
|
.wbs-remove .wbs-icon {
|
||||||
background-image:linear-gradient(transparent,transparent),url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2224%22%20height=%2224%22%20viewBox=%220%200%2024%2024%22%3E%20%3Cg%20id=%22remove%22%3E%20%3Cpath%20id=%22trash-can%22%20d=%22M12%2010h-1v6h1v-6zm-2%200H9v6h1v-6zm4%200h-1v6h1v-6zm0-4V5H9v1H6v3h1v7.966l1%201.03v-.073V18h6.984l.016-.018v.015l1-1.03V9h1V6h-3zm1%2011H8V9h7v8zm1-9H7V7h9v1z%22/%3E%20%3C/g%3E%20%3C/svg%3E");
|
background-image:linear-gradient(transparent,transparent),url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%2224%22%20height=%2224%22%20viewBox=%220%200%2024%2024%22%3E%20%3Cg%20id=%22remove%22%3E%20%3Cpath%20id=%22trash-can%22%20d=%22M12%2010h-1v6h1v-6zm-2%200H9v6h1v-6zm4%200h-1v6h1v-6zm0-4V5H9v1H6v3h1v7.966l1%201.03v-.073V18h6.984l.016-.018v.015l1-1.03V9h1V6h-3zm1%2011H8V9h7v8zm1-9H7V7h9v1z%22/%3E%20%3C/g%3E%20%3C/svg%3E");
|
||||||
}
|
}
|
||||||
@ -211,7 +212,8 @@
|
|||||||
|
|
||||||
.wbs-remove,
|
.wbs-remove,
|
||||||
.wbs-add-item, .wbs-add-statement-group, .wbs-add-statement,
|
.wbs-add-item, .wbs-add-statement-group, .wbs-add-statement,
|
||||||
.wbs-add-qualifier, .wbs-add-reference, .wbs-add-namedesc {
|
.wbs-add-qualifier, .wbs-add-reference, .wbs-add-namedesc,
|
||||||
|
.wbs-copy-reference-button, .wbs-paste-reference-button {
|
||||||
color: #0645ad !important;
|
color: #0645ad !important;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -250,6 +252,10 @@
|
|||||||
color: gray;
|
color: gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.schema-alignment-dialog-preview .wbs-prop-input {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
.schema-alignment-dialog-preview .wbs-qualifier .wbs-statement-container {
|
.schema-alignment-dialog-preview .wbs-qualifier .wbs-statement-container {
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
@ -303,7 +309,7 @@
|
|||||||
|
|
||||||
.wbs-qualifier, .wbs-reference {
|
.wbs-qualifier, .wbs-reference {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow-x: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wbs-qualifier .wbs-right {
|
.wbs-qualifier .wbs-right {
|
||||||
@ -318,14 +324,50 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.wbs-references-toggle {
|
.wbs-references-toggle {
|
||||||
width: 12em;
|
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wbs-references-toggle a {
|
.wbs-references-toggle a {
|
||||||
color: #0645ad !important;
|
color: #0645ad !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wbs-copy-reference {
|
||||||
|
float: left;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wbs-copied-reference {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wbs-copied-reference .wbs-copy-reference-button {
|
||||||
|
color: black !important;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wbs-copied-reference span:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wbs-paste-reference .wbs-icon,
|
||||||
|
.wbs-copy-reference .wbs-icon {
|
||||||
|
height: 13px;
|
||||||
|
width: 13px;
|
||||||
|
background-size: 13px 13px;
|
||||||
|
opacity: 0.6;
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* source: Font Awesome by Dave Gandy. https://commons.wikimedia.org/wiki/File:Paste_font_awesome.svg */
|
||||||
|
.wbs-paste-reference .wbs-icon {
|
||||||
|
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg version='1.1' viewBox='0 -256 1900 1900' xmlns='http://www.w3.org/2000/svg' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23'%3E%3Cmetadata%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg transform='matrix(1 0 0 -1 53.153 1325.1)'%3E%3Cpath d='m768-128h896v640h-416q-40 0-68 28t-28 68v416h-384v-1152zm256 1440v64q0 13-9.5 22.5t-22.5 9.5h-704q-13 0-22.5-9.5t-9.5-22.5v-64q0-13 9.5-22.5t22.5-9.5h704q13 0 22.5 9.5t9.5 22.5zm256-672h299l-299 299v-299zm512-128v-672q0-40-28-68t-68-28h-960q-40 0-68 28t-28 68v160h-544q-40 0-68 28t-28 68v1344q0 40 28 68t68 28h1088q40 0 68-28t28-68v-328q21-13 36-28l408-408q28-28 48-76t20-88z' fill='currentColor'/%3E%3C/g%3E%3C/svg%3E%0A");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* source: Font Awesome by Dave Gandy. https://commons.wikimedia.org/wiki/File:Copy_font_awesome.svg */
|
||||||
|
.wbs-copy-reference .wbs-icon {
|
||||||
|
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg version='1.1' viewBox='0 -256 1850 1850' xmlns='http://www.w3.org/2000/svg' xmlns:cc='http://creativecommons.org/ns%23' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23'%3E%3Cmetadata%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=''%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Cg transform='matrix(1 0 0 -1 37.966 1305.5)'%3E%3Cpath d='m1696 1152q40 0 68-28t28-68v-1216q0-40-28-68t-68-28h-960q-40 0-68 28t-28 68v288h-544q-40 0-68 28t-28 68v672q0 40 20 88t48 76l408 408q28 28 76 48t88 20h416q40 0 68-28t28-68v-328q68 40 128 40h416zm-544-213-299-299h299v299zm-640 384-299-299h299v299zm196-647 316 316v416h-384v-416q0-40-28-68t-68-28h-416v-640h512v256q0 40 20 88t48 76zm956-804v1152h-384v-416q0-40-28-68t-68-28h-416v-640h896z' fill='currentColor'/%3E%3C/g%3E%3C/svg%3E");
|
||||||
|
}
|
||||||
|
|
||||||
.wbs-references-toggle .triangle-icon {
|
.wbs-references-toggle .triangle-icon {
|
||||||
background: transparent url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone%3D%22no%22%3F%3E%0A%3Csvg%0A%20%20%20xmlns%3Adc%3D%22http%3A//purl.org/dc/elements/1.1/%22%0A%20%20%20xmlns%3Acc%3D%22http%3A//creativecommons.org/ns%23%22%0A%20%20%20xmlns%3Ardf%3D%22http%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%22%0A%20%20%20xmlns%3Asvg%3D%22http%3A//www.w3.org/2000/svg%22%0A%20%20%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%0A%20%20%20id%3D%22svg8%22%0A%20%20%20version%3D%221.1%22%0A%20%20%20viewBox%3D%220%200%202.6458332%202.6458332%22%0A%20%20%20height%3D%2210%22%0A%20%20%20width%3D%2210%22%3E%0A%20%20%3Cdefs%0A%20%20%20%20%20id%3D%22defs2%22%20/%3E%0A%20%20%3Cmetadata%0A%20%20%20%20%20id%3D%22metadata5%22%3E%0A%20%20%20%20%3Crdf%3ARDF%3E%0A%20%20%20%20%20%20%3Ccc%3AWork%0A%20%20%20%20%20%20%20%20%20rdf%3Aabout%3D%22%22%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Aformat%3Eimage/svg+xml%3C/dc%3Aformat%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Atype%0A%20%20%20%20%20%20%20%20%20%20%20rdf%3Aresource%3D%22http%3A//purl.org/dc/dcmitype/StillImage%22%20/%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Atitle%3E%3C/dc%3Atitle%3E%0A%20%20%20%20%20%20%3C/cc%3AWork%3E%0A%20%20%20%20%3C/rdf%3ARDF%3E%0A%20%20%3C/metadata%3E%0A%20%20%3Cg%0A%20%20%20%20%20transform%3D%22translate%280%2C-294.35416%29%22%0A%20%20%20%20%20id%3D%22layer1%22%3E%0A%20%20%20%20%3Cpath%0A%20%20%20%20%20%20%20id%3D%22path12%22%0A%20%20%20%20%20%20%20d%3D%22m%200.21601809%2C294.5035%202.28763941%2C1.14744%20-2.29850705%2C1.20871%20z%22%0A%20%20%20%20%20%20%20style%3D%22fill%3A%23645eea%3Bfill-opacity%3A1%3Bfill-rule%3Aevenodd%3Bstroke%3A%23645eea%3Bstroke-width%3A0.06161711px%3Bstroke-linecap%3Abutt%3Bstroke-linejoin%3Amiter%3Bstroke-opacity%3A1%22%20/%3E%0A%20%20%3C/g%3E%0A%3C/svg%3E%0A) no-repeat center center;
|
background: transparent url(data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone%3D%22no%22%3F%3E%0A%3Csvg%0A%20%20%20xmlns%3Adc%3D%22http%3A//purl.org/dc/elements/1.1/%22%0A%20%20%20xmlns%3Acc%3D%22http%3A//creativecommons.org/ns%23%22%0A%20%20%20xmlns%3Ardf%3D%22http%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%22%0A%20%20%20xmlns%3Asvg%3D%22http%3A//www.w3.org/2000/svg%22%0A%20%20%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%0A%20%20%20id%3D%22svg8%22%0A%20%20%20version%3D%221.1%22%0A%20%20%20viewBox%3D%220%200%202.6458332%202.6458332%22%0A%20%20%20height%3D%2210%22%0A%20%20%20width%3D%2210%22%3E%0A%20%20%3Cdefs%0A%20%20%20%20%20id%3D%22defs2%22%20/%3E%0A%20%20%3Cmetadata%0A%20%20%20%20%20id%3D%22metadata5%22%3E%0A%20%20%20%20%3Crdf%3ARDF%3E%0A%20%20%20%20%20%20%3Ccc%3AWork%0A%20%20%20%20%20%20%20%20%20rdf%3Aabout%3D%22%22%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Aformat%3Eimage/svg+xml%3C/dc%3Aformat%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Atype%0A%20%20%20%20%20%20%20%20%20%20%20rdf%3Aresource%3D%22http%3A//purl.org/dc/dcmitype/StillImage%22%20/%3E%0A%20%20%20%20%20%20%20%20%3Cdc%3Atitle%3E%3C/dc%3Atitle%3E%0A%20%20%20%20%20%20%3C/cc%3AWork%3E%0A%20%20%20%20%3C/rdf%3ARDF%3E%0A%20%20%3C/metadata%3E%0A%20%20%3Cg%0A%20%20%20%20%20transform%3D%22translate%280%2C-294.35416%29%22%0A%20%20%20%20%20id%3D%22layer1%22%3E%0A%20%20%20%20%3Cpath%0A%20%20%20%20%20%20%20id%3D%22path12%22%0A%20%20%20%20%20%20%20d%3D%22m%200.21601809%2C294.5035%202.28763941%2C1.14744%20-2.29850705%2C1.20871%20z%22%0A%20%20%20%20%20%20%20style%3D%22fill%3A%23645eea%3Bfill-opacity%3A1%3Bfill-rule%3Aevenodd%3Bstroke%3A%23645eea%3Bstroke-width%3A0.06161711px%3Bstroke-linecap%3Abutt%3Bstroke-linejoin%3Amiter%3Bstroke-opacity%3A1%22%20/%3E%0A%20%20%3C/g%3E%0A%3C/svg%3E%0A) no-repeat center center;
|
||||||
|
@ -169,8 +169,13 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
|
|||||||
|
|
||||||
// Generate batch token
|
// Generate batch token
|
||||||
long token = (new Random()).nextLong();
|
long token = (new Random()).nextLong();
|
||||||
String summary = _summary + String.format(" ([[:toollabs:editgroups/b/OR/%s|details]])",
|
// The following replacement is a fix for: https://github.com/Wikidata/editgroups/issues/4
|
||||||
(Long.toHexString(token).substring(0, 8)));
|
// Because commas and colons are used by Wikibase to separate the auto-generated summaries
|
||||||
|
// from the user-supplied ones, we replace these separators by similar unicode characters to
|
||||||
|
// make sure they can be told apart.
|
||||||
|
String summaryWithoutCommas = _summary.replaceAll(", ","ꓹ ").replaceAll(": ","։ ");
|
||||||
|
String summary = summaryWithoutCommas + String.format(" ([[:toollabs:editgroups/b/OR/%s|details]])",
|
||||||
|
(Long.toHexString(token).substring(0, 9)));
|
||||||
|
|
||||||
// Evaluate the schema
|
// Evaluate the schema
|
||||||
List<ItemUpdate> itemDocuments = _schema.evaluate(_project, _engine);
|
List<ItemUpdate> itemDocuments = _schema.evaluate(_project, _engine);
|
||||||
|
@ -278,12 +278,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>2.9.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.9.7</version>
|
<version>2.9.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
@ -95,12 +95,6 @@ public class ListFacet implements Facet {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public List<DecoratedValue> selection = new LinkedList<>();
|
public List<DecoratedValue> selection = new LinkedList<>();
|
||||||
@JsonProperty("selectNumber")
|
|
||||||
public boolean selectNumber;
|
|
||||||
@JsonProperty("selectDateTime")
|
|
||||||
public boolean selectDateTime;
|
|
||||||
@JsonProperty("selectBoolean")
|
|
||||||
public boolean selectBoolean;
|
|
||||||
@JsonProperty("selectBlank")
|
@JsonProperty("selectBlank")
|
||||||
public boolean selectBlank;
|
public boolean selectBlank;
|
||||||
@JsonProperty("selectError")
|
@JsonProperty("selectError")
|
||||||
@ -162,9 +156,6 @@ public class ListFacet implements Facet {
|
|||||||
* Computed results
|
* Computed results
|
||||||
*/
|
*/
|
||||||
protected List<NominalFacetChoice> _choices = new LinkedList<NominalFacetChoice>();
|
protected List<NominalFacetChoice> _choices = new LinkedList<NominalFacetChoice>();
|
||||||
protected int _numberCount;
|
|
||||||
protected int _datetimeCount;
|
|
||||||
protected int _booleanCount;
|
|
||||||
protected int _blankCount;
|
protected int _blankCount;
|
||||||
protected int _errorCount;
|
protected int _errorCount;
|
||||||
|
|
||||||
@ -278,16 +269,13 @@ public class ListFacet implements Facet {
|
|||||||
return
|
return
|
||||||
_eval == null ||
|
_eval == null ||
|
||||||
_errorMessage != null ||
|
_errorMessage != null ||
|
||||||
(_config.selection.size() == 0 && !_config.selectBlank && !_config.selectError && !_config.selectNumber && !_config.selectDateTime && !_config.selectBoolean) ?
|
(_config.selection.size() == 0 && !_config.selectBlank && !_config.selectError) ?
|
||||||
null :
|
null :
|
||||||
new ExpressionEqualRowFilter(
|
new ExpressionEqualRowFilter(
|
||||||
_eval,
|
_eval,
|
||||||
_config.columnName,
|
_config.columnName,
|
||||||
_cellIndex,
|
_cellIndex,
|
||||||
createMatches(),
|
createMatches(),
|
||||||
_config.selectNumber,
|
|
||||||
_config.selectDateTime,
|
|
||||||
_config.selectBoolean,
|
|
||||||
_config.selectBlank,
|
_config.selectBlank,
|
||||||
_config.selectError,
|
_config.selectError,
|
||||||
_config.invert);
|
_config.invert);
|
||||||
@ -353,9 +341,6 @@ public class ListFacet implements Facet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_numberCount = grouper.numberCount;
|
|
||||||
_datetimeCount = grouper.datetimeCount;
|
|
||||||
_booleanCount = grouper.booleanCount;
|
|
||||||
_blankCount = grouper.blankCount;
|
_blankCount = grouper.blankCount;
|
||||||
_errorCount = grouper.errorCount;
|
_errorCount = grouper.errorCount;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
package com.google.refine.browsing.filters;
|
package com.google.refine.browsing.filters;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -58,10 +57,8 @@ public class ExpressionEqualRowFilter implements RowFilter {
|
|||||||
final protected int _cellIndex; // the expression is based on this column;
|
final protected int _cellIndex; // the expression is based on this column;
|
||||||
// -1 if based on no column in particular,
|
// -1 if based on no column in particular,
|
||||||
// for expression such as "row.starred".
|
// for expression such as "row.starred".
|
||||||
|
|
||||||
final protected Object[] _matches;
|
final protected Object[] _matches;
|
||||||
final protected boolean _selectNumber;
|
|
||||||
final protected boolean _selectDateTime;
|
|
||||||
final protected boolean _selectBoolean;
|
|
||||||
final protected boolean _selectBlank;
|
final protected boolean _selectBlank;
|
||||||
final protected boolean _selectError;
|
final protected boolean _selectError;
|
||||||
final protected boolean _invert;
|
final protected boolean _invert;
|
||||||
@ -71,9 +68,6 @@ public class ExpressionEqualRowFilter implements RowFilter {
|
|||||||
String columnName,
|
String columnName,
|
||||||
int cellIndex,
|
int cellIndex,
|
||||||
Object[] matches,
|
Object[] matches,
|
||||||
boolean selectNumber,
|
|
||||||
boolean selectDateTime,
|
|
||||||
boolean selectBoolean,
|
|
||||||
boolean selectBlank,
|
boolean selectBlank,
|
||||||
boolean selectError,
|
boolean selectError,
|
||||||
boolean invert
|
boolean invert
|
||||||
@ -82,9 +76,6 @@ public class ExpressionEqualRowFilter implements RowFilter {
|
|||||||
_columnName = columnName;
|
_columnName = columnName;
|
||||||
_cellIndex = cellIndex;
|
_cellIndex = cellIndex;
|
||||||
_matches = matches;
|
_matches = matches;
|
||||||
_selectNumber = selectNumber;
|
|
||||||
_selectDateTime = selectDateTime;
|
|
||||||
_selectBoolean = selectBoolean;
|
|
||||||
_selectBlank = selectBlank;
|
_selectBlank = selectBlank;
|
||||||
_selectError = selectError;
|
_selectError = selectError;
|
||||||
_invert = invert;
|
_invert = invert;
|
||||||
@ -178,12 +169,6 @@ public class ExpressionEqualRowFilter implements RowFilter {
|
|||||||
protected boolean testValue(Object v) {
|
protected boolean testValue(Object v) {
|
||||||
if (ExpressionUtils.isError(v)) {
|
if (ExpressionUtils.isError(v)) {
|
||||||
return _selectError;
|
return _selectError;
|
||||||
} else if (v instanceof Number) {
|
|
||||||
return _selectNumber;
|
|
||||||
} else if (v instanceof OffsetDateTime) {
|
|
||||||
return _selectDateTime;
|
|
||||||
} else if (v instanceof Boolean) {
|
|
||||||
return _selectBoolean;
|
|
||||||
} else if (ExpressionUtils.isNonBlankData(v)) {
|
} else if (ExpressionUtils.isNonBlankData(v)) {
|
||||||
for (Object match : _matches) {
|
for (Object match : _matches) {
|
||||||
if (testValue(v, match)) {
|
if (testValue(v, match)) {
|
||||||
|
@ -57,6 +57,15 @@ import com.google.refine.util.StringUtils;
|
|||||||
* from a given expression.
|
* from a given expression.
|
||||||
*/
|
*/
|
||||||
public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor {
|
public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor {
|
||||||
|
static public class IndexedNominalFacetChoice extends NominalFacetChoice {
|
||||||
|
int _latestIndex;
|
||||||
|
|
||||||
|
public IndexedNominalFacetChoice(DecoratedValue decoratedValue, int latestIndex) {
|
||||||
|
super(decoratedValue);
|
||||||
|
_latestIndex = latestIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configuration
|
* Configuration
|
||||||
*/
|
*/
|
||||||
@ -68,29 +77,14 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
* Computed results
|
* Computed results
|
||||||
*/
|
*/
|
||||||
final public Map<Object, IndexedNominalFacetChoice> choices = new HashMap<Object, IndexedNominalFacetChoice>();
|
final public Map<Object, IndexedNominalFacetChoice> choices = new HashMap<Object, IndexedNominalFacetChoice>();
|
||||||
public int numberCount = 0;
|
|
||||||
public int datetimeCount = 0;
|
|
||||||
public int booleanCount = 0;
|
|
||||||
public int blankCount = 0;
|
public int blankCount = 0;
|
||||||
public int errorCount = 0;
|
public int errorCount = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scratch pad variables
|
* Scratch pad variables
|
||||||
*/
|
*/
|
||||||
protected boolean hasNumber;
|
|
||||||
protected boolean hasDateTime;
|
|
||||||
protected boolean hasBoolean;
|
|
||||||
protected boolean hasBlank;
|
protected boolean hasBlank;
|
||||||
protected boolean hasError;
|
protected boolean hasError;
|
||||||
|
|
||||||
static public class IndexedNominalFacetChoice extends NominalFacetChoice {
|
|
||||||
int _latestIndex;
|
|
||||||
|
|
||||||
public IndexedNominalFacetChoice(DecoratedValue decoratedValue, int latestIndex) {
|
|
||||||
super(decoratedValue);
|
|
||||||
_latestIndex = latestIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExpressionNominalValueGrouper(Evaluable evaluable, String columnName, int cellIndex) {
|
public ExpressionNominalValueGrouper(Evaluable evaluable, String columnName, int cellIndex) {
|
||||||
_evaluable = evaluable;
|
_evaluable = evaluable;
|
||||||
@ -110,25 +104,13 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(Project project, int rowIndex, Row row) {
|
public boolean visit(Project project, int rowIndex, Row row) {
|
||||||
hasNumber = false;
|
|
||||||
hasDateTime = false;
|
|
||||||
hasBoolean = false;
|
|
||||||
hasError = false;
|
hasError = false;
|
||||||
hasBlank = false;
|
hasBlank = false;
|
||||||
|
|
||||||
Properties bindings = ExpressionUtils.createBindings(project);
|
Properties bindings = ExpressionUtils.createBindings(project);
|
||||||
|
|
||||||
visitRow(project, rowIndex, row, bindings, rowIndex);
|
visitRow(project, rowIndex, row, bindings, rowIndex);
|
||||||
|
|
||||||
if (hasNumber) {
|
|
||||||
numberCount++;
|
|
||||||
}
|
|
||||||
if (hasDateTime) {
|
|
||||||
datetimeCount++;
|
|
||||||
}
|
|
||||||
if (hasBoolean) {
|
|
||||||
booleanCount++;
|
|
||||||
}
|
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
@ -141,9 +123,6 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(Project project, Record record) {
|
public boolean visit(Project project, Record record) {
|
||||||
hasNumber = false;
|
|
||||||
hasDateTime = false;
|
|
||||||
hasBoolean = false;
|
|
||||||
hasError = false;
|
hasError = false;
|
||||||
hasBlank = false;
|
hasBlank = false;
|
||||||
|
|
||||||
@ -154,15 +133,6 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
visitRow(project, r, row, bindings, record.recordIndex);
|
visitRow(project, r, row, bindings, record.recordIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNumber) {
|
|
||||||
numberCount++;
|
|
||||||
}
|
|
||||||
if (hasDateTime) {
|
|
||||||
datetimeCount++;
|
|
||||||
}
|
|
||||||
if (hasBoolean) {
|
|
||||||
booleanCount++;
|
|
||||||
}
|
|
||||||
if (hasError) {
|
if (hasError) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
@ -204,12 +174,6 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
protected void processValue(Object value, int index) {
|
protected void processValue(Object value, int index) {
|
||||||
if (ExpressionUtils.isError(value)) {
|
if (ExpressionUtils.isError(value)) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
} else if (ExpressionUtils.isNumber(value)) {
|
|
||||||
hasNumber = true;
|
|
||||||
} else if (ExpressionUtils.isDateTime(value)) {
|
|
||||||
hasDateTime = true;
|
|
||||||
} else if (ExpressionUtils.isBoolean(value)) {
|
|
||||||
hasBoolean = true;
|
|
||||||
} else if (ExpressionUtils.isNonBlankData(value)) {
|
} else if (ExpressionUtils.isNonBlankData(value)) {
|
||||||
String valueString = StringUtils.toString(value);
|
String valueString = StringUtils.toString(value);
|
||||||
IndexedNominalFacetChoice facetChoice = choices.get(valueString);
|
IndexedNominalFacetChoice facetChoice = choices.get(valueString);
|
||||||
@ -272,12 +236,6 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
|
|||||||
public Integer getChoiceValueCount(Object choiceValue) {
|
public Integer getChoiceValueCount(Object choiceValue) {
|
||||||
if (ExpressionUtils.isError(choiceValue)) {
|
if (ExpressionUtils.isError(choiceValue)) {
|
||||||
return errorCount;
|
return errorCount;
|
||||||
} else if (ExpressionUtils.isNumber(choiceValue)) {
|
|
||||||
return numberCount;
|
|
||||||
} else if (ExpressionUtils.isDateTime(choiceValue)) {
|
|
||||||
return datetimeCount;
|
|
||||||
} else if (ExpressionUtils.isBoolean(choiceValue)) {
|
|
||||||
return booleanCount;
|
|
||||||
} else if (ExpressionUtils.isNonBlankData(choiceValue)) {
|
} else if (ExpressionUtils.isNonBlankData(choiceValue)) {
|
||||||
IndexedNominalFacetChoice choice = choices.get(StringUtils.toString(choiceValue));
|
IndexedNominalFacetChoice choice = choices.get(StringUtils.toString(choiceValue));
|
||||||
return choice != null ? choice.count : 0;
|
return choice != null ? choice.count : 0;
|
||||||
|
@ -102,19 +102,11 @@ public class ExpressionUtils {
|
|||||||
static public boolean isError(Object o) {
|
static public boolean isError(Object o) {
|
||||||
return o instanceof EvalError;
|
return o instanceof EvalError;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
static public boolean isNumber(Object v) {
|
static public boolean isBlank(Object o) {
|
||||||
return v != null && (v instanceof Number);
|
return o == null || (o instanceof String && ((String) o).length() == 0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
static public boolean isBoolean(Object v) {
|
|
||||||
return v != null && v instanceof Boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public boolean isDateTime(Object v) {
|
|
||||||
return v != null && v instanceof OffsetDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public boolean isNonBlankData(Object o) {
|
static public boolean isNonBlankData(Object o) {
|
||||||
return
|
return
|
||||||
o != null &&
|
o != null &&
|
||||||
|
@ -566,8 +566,8 @@ public class StandardReconConfig extends ReconConfig {
|
|||||||
* @param text
|
* @param text
|
||||||
* the cell value to compare the reconciliation data to
|
* the cell value to compare the reconciliation data to
|
||||||
*/
|
*/
|
||||||
public void computeFeatures(Recon recon, String text) {
|
public void computeFeatures(Recon recon, String text) {
|
||||||
if (!recon.candidates.isEmpty()) {
|
if (recon.candidates != null && !recon.candidates.isEmpty()) {
|
||||||
ReconCandidate candidate = recon.candidates.get(0);
|
ReconCandidate candidate = recon.candidates.get(0);
|
||||||
|
|
||||||
recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name));
|
recon.setFeature(Recon.Feature_nameMatch, text.equalsIgnoreCase(candidate.name));
|
||||||
@ -587,7 +587,7 @@ public class StandardReconConfig extends ReconConfig {
|
|||||||
} else {
|
} else {
|
||||||
recon.features = new Object[Recon.Feature_max];
|
recon.features = new Object[Recon.Feature_max];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected double wordDistance(String s1, String s2) {
|
static protected double wordDistance(String s1, String s2) {
|
||||||
Set<String> words1 = breakWords(s1);
|
Set<String> words1 = breakWords(s1);
|
||||||
|
@ -116,6 +116,9 @@ public class ReconUseValuesAsIdentifiersOperation extends EngineDependentMassCel
|
|||||||
Cell cell = row.getCell(cellIndex);
|
Cell cell = row.getCell(cellIndex);
|
||||||
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
|
||||||
String id = cell.value.toString();
|
String id = cell.value.toString();
|
||||||
|
if(id.startsWith(identifierSpace)) {
|
||||||
|
id = id.substring(identifierSpace.length());
|
||||||
|
}
|
||||||
|
|
||||||
ReconCandidate match = new ReconCandidate(id, id, new String[0], 100);
|
ReconCandidate match = new ReconCandidate(id, id, new String[0], 100);
|
||||||
Recon newRecon = reconConfig.createNewRecon(historyEntryID);
|
Recon newRecon = reconConfig.createNewRecon(historyEntryID);
|
||||||
|
@ -45,14 +45,11 @@ public class ListFacetTests extends RefineTest {
|
|||||||
private static String jsonConfig = "{"
|
private static String jsonConfig = "{"
|
||||||
+ "\"type\":\"list\","
|
+ "\"type\":\"list\","
|
||||||
+ "\"name\":\"facet A\","
|
+ "\"name\":\"facet A\","
|
||||||
+ "\"expression\":\"value+\\\"bar\\\"\","
|
|
||||||
+ "\"columnName\":\"Column A\","
|
+ "\"columnName\":\"Column A\","
|
||||||
|
+ "\"expression\":\"value+\\\"bar\\\"\","
|
||||||
+ "\"omitBlank\":false,"
|
+ "\"omitBlank\":false,"
|
||||||
+ "\"omitError\":false,"
|
+ "\"omitError\":false,"
|
||||||
+ "\"selection\":[{\"v\":{\"v\":\"foobar\",\"l\":\"true\"}}],"
|
+ "\"selection\":[{\"v\":{\"v\":\"foobar\",\"l\":\"true\"}}],"
|
||||||
+ "\"selectNumber\":false,"
|
|
||||||
+ "\"selectDateTime\":false,"
|
|
||||||
+ "\"selectBoolean\":false,"
|
|
||||||
+ "\"selectBlank\":false,"
|
+ "\"selectBlank\":false,"
|
||||||
+ "\"selectError\":false,"
|
+ "\"selectError\":false,"
|
||||||
+ "\"invert\":false"
|
+ "\"invert\":false"
|
||||||
|
@ -1,435 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018, Owen Stephens
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of the copyright holder nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.google.refine.tests.browsing.facets;
|
|
||||||
|
|
||||||
import com.google.refine.model.Cell;
|
|
||||||
import com.google.refine.model.Row;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.BeforeMethod;
|
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.refine.model.ModelException;
|
|
||||||
import com.google.refine.model.Project;
|
|
||||||
import com.google.refine.browsing.RowFilter;
|
|
||||||
import com.google.refine.browsing.facets.Facet;
|
|
||||||
import com.google.refine.browsing.facets.ListFacet.ListFacetConfig;
|
|
||||||
import com.google.refine.tests.RefineTest;
|
|
||||||
import com.google.refine.util.ParsingUtilities;
|
|
||||||
|
|
||||||
|
|
||||||
public class TextListFacetTests extends RefineTest {
|
|
||||||
// dependencies
|
|
||||||
private Project project;
|
|
||||||
private RowFilter rowfilter;
|
|
||||||
|
|
||||||
// Variables
|
|
||||||
private static OffsetDateTime dateTimeValue = OffsetDateTime.parse("2017-05-12T05:45:00+00:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
|
||||||
private static int integerValue = 1;
|
|
||||||
private static String stringValue = "a";
|
|
||||||
private static String emptyStringValue = "";
|
|
||||||
private static Boolean booleanValue = true;
|
|
||||||
|
|
||||||
private static final String projectName = "TextListFacet";
|
|
||||||
private static final String columnName = "Col1";
|
|
||||||
private static final int numberOfRows = 5;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeTest
|
|
||||||
public void init() {
|
|
||||||
logger = LoggerFactory.getLogger(this.getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeMethod
|
|
||||||
public void setUp() throws IOException, ModelException {
|
|
||||||
project = createProjectWithColumns(projectName, columnName);
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(stringValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(dateTimeValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(integerValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(booleanValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(null, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(emptyStringValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTextSelection() throws Exception {
|
|
||||||
//Need to work out the correct facet config for these tests to work
|
|
||||||
//Also need all rows in all tests so can check that rows aren't being selected when they shouldn't be
|
|
||||||
String jsonConfig = "{"
|
|
||||||
+ "\"type\": \"list\","
|
|
||||||
+ "\"name\": \"Value\","
|
|
||||||
+ "\"columnName\": \"" + columnName + "\","
|
|
||||||
+ "\"expression\": \"value\","
|
|
||||||
+ "\"omitBlank\": false,"
|
|
||||||
+ "\"omitError\": false,"
|
|
||||||
+ "\"selection\": ["
|
|
||||||
+ " {"
|
|
||||||
+ "\"v\": {"
|
|
||||||
+ "\"v\": \"a\","
|
|
||||||
+ "\"l\": \"a\""
|
|
||||||
+ "}"
|
|
||||||
+ "}"
|
|
||||||
+ "],"
|
|
||||||
+ "\"selectNumber\": false,"
|
|
||||||
+ "\"selectDateTime\": false,"
|
|
||||||
+ "\"selectBoolean\": false,"
|
|
||||||
+ "\"selectBlank\": false,"
|
|
||||||
+ "\"selectError\": false,"
|
|
||||||
+ "\"invert\": false"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
//Add the facet to the project and create a row filter
|
|
||||||
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
|
||||||
Facet facet = facetConfig.apply(project);
|
|
||||||
rowfilter = facet.getRowFilter(project);
|
|
||||||
|
|
||||||
//Check each row in the project against the filter
|
|
||||||
//Rows 1-5 are strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 0, project.rows.get(0)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 1, project.rows.get(1)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 4, project.rows.get(4)),true);
|
|
||||||
//Rows 6-10 are DateTimes
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 5, project.rows.get(5)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 6, project.rows.get(6)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 7, project.rows.get(7)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 8, project.rows.get(8)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 9, project.rows.get(9)),false);
|
|
||||||
//Rows 11-15 are integers
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 10, project.rows.get(10)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 11, project.rows.get(11)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 12, project.rows.get(12)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 13, project.rows.get(13)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 14, project.rows.get(14)),false);
|
|
||||||
//Rows 16-20 are booleans
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 15, project.rows.get(15)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 16, project.rows.get(16)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 17, project.rows.get(17)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 18, project.rows.get(18)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 19, project.rows.get(19)),false);
|
|
||||||
//Rows 21-25 are nulls
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 20, project.rows.get(20)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 21, project.rows.get(21)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 22, project.rows.get(22)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 23, project.rows.get(23)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 24, project.rows.get(24)),false);
|
|
||||||
//Rows 26-30 are empty strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 25, project.rows.get(25)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 26, project.rows.get(26)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 27, project.rows.get(27)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 28, project.rows.get(28)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 29, project.rows.get(29)),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDateSelection() throws Exception {
|
|
||||||
String jsonConfig = "{"
|
|
||||||
+ "\"type\": \"list\","
|
|
||||||
+ "\"name\": \"Value\","
|
|
||||||
+ "\"columnName\": \"" + columnName + "\","
|
|
||||||
+ "\"expression\": \"value\","
|
|
||||||
+ "\"omitBlank\": false,"
|
|
||||||
+ "\"omitError\": false,"
|
|
||||||
+ "\"selection\": [],"
|
|
||||||
+ "\"selectNumber\": false,"
|
|
||||||
+ "\"selectDateTime\": true,"
|
|
||||||
+ "\"selectBoolean\": false,"
|
|
||||||
+ "\"selectBlank\": false,"
|
|
||||||
+ "\"selectError\": false,"
|
|
||||||
+ "\"invert\": false"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
//Add the facet to the project and create a row filter
|
|
||||||
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
|
||||||
Facet facet = facetConfig.apply(project);
|
|
||||||
rowfilter = facet.getRowFilter(project);
|
|
||||||
|
|
||||||
//Check each row in the project against the filter
|
|
||||||
//Rows 1-5 are strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 0, project.rows.get(0)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 1, project.rows.get(1)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 4, project.rows.get(4)),false);
|
|
||||||
//Rows 6-10 are DateTimes
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 5, project.rows.get(5)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 6, project.rows.get(6)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 7, project.rows.get(7)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 8, project.rows.get(8)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 9, project.rows.get(9)),true);
|
|
||||||
//Rows 11-15 are integers
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 10, project.rows.get(10)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 11, project.rows.get(11)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 12, project.rows.get(12)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 13, project.rows.get(13)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 14, project.rows.get(14)),false);
|
|
||||||
//Rows 16-20 are booleans
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 15, project.rows.get(15)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 16, project.rows.get(16)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 17, project.rows.get(17)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 18, project.rows.get(18)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 19, project.rows.get(19)),false);
|
|
||||||
//Rows 21-25 are nulls
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 20, project.rows.get(20)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 21, project.rows.get(21)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 22, project.rows.get(22)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 23, project.rows.get(23)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 24, project.rows.get(24)),false);
|
|
||||||
//Rows 26-30 are empty strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 25, project.rows.get(25)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 26, project.rows.get(26)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 27, project.rows.get(27)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 28, project.rows.get(28)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 29, project.rows.get(29)),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIntegerSelection() throws Exception {
|
|
||||||
String jsonConfig = "{"
|
|
||||||
+ "\"type\": \"list\","
|
|
||||||
+ "\"name\": \"Value\","
|
|
||||||
+ "\"columnName\": \"" + columnName + "\","
|
|
||||||
+ "\"expression\": \"value\","
|
|
||||||
+ "\"omitBlank\": false,"
|
|
||||||
+ "\"omitError\": false,"
|
|
||||||
+ "\"selection\": [],"
|
|
||||||
+ "\"selectNumber\": true,"
|
|
||||||
+ "\"selectDateTime\": false,"
|
|
||||||
+ "\"selectBoolean\": false,"
|
|
||||||
+ "\"selectBlank\": false,"
|
|
||||||
+ "\"selectError\": false,"
|
|
||||||
+ "\"invert\": false"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
//Add the facet to the project and create a row filter
|
|
||||||
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
|
||||||
Facet facet = facetConfig.apply(project);
|
|
||||||
rowfilter = facet.getRowFilter(project);
|
|
||||||
|
|
||||||
//Check each row in the project against the filter
|
|
||||||
//Rows 1-5 are strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 0, project.rows.get(0)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 1, project.rows.get(1)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 4, project.rows.get(4)),false);
|
|
||||||
//Rows 6-10 are DateTimes
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 5, project.rows.get(5)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 6, project.rows.get(6)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 7, project.rows.get(7)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 8, project.rows.get(8)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 9, project.rows.get(9)),false);
|
|
||||||
//Rows 11-15 are integers
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 10, project.rows.get(10)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 11, project.rows.get(11)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 12, project.rows.get(12)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 13, project.rows.get(13)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 14, project.rows.get(14)),true);
|
|
||||||
//Rows 16-20 are booleans
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 15, project.rows.get(15)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 16, project.rows.get(16)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 17, project.rows.get(17)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 18, project.rows.get(18)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 19, project.rows.get(19)),false);
|
|
||||||
//Rows 21-25 are nulls
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 20, project.rows.get(20)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 21, project.rows.get(21)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 22, project.rows.get(22)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 23, project.rows.get(23)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 24, project.rows.get(24)),false);
|
|
||||||
//Rows 26-30 are empty strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 25, project.rows.get(25)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 26, project.rows.get(26)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 27, project.rows.get(27)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 28, project.rows.get(28)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 29, project.rows.get(29)),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBooleanSelection() throws Exception {
|
|
||||||
String jsonConfig = "{"
|
|
||||||
+ "\"type\": \"list\","
|
|
||||||
+ "\"name\": \"Value\","
|
|
||||||
+ "\"columnName\": \"" + columnName + "\","
|
|
||||||
+ "\"expression\": \"value\","
|
|
||||||
+ "\"omitBlank\": false,"
|
|
||||||
+ "\"omitError\": false,"
|
|
||||||
+ "\"selection\": [],"
|
|
||||||
+ "\"selectNumber\": false,"
|
|
||||||
+ "\"selectDateTime\": false,"
|
|
||||||
+ "\"selectBoolean\": true,"
|
|
||||||
+ "\"selectBlank\": false,"
|
|
||||||
+ "\"selectError\": false,"
|
|
||||||
+ "\"invert\": false"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
//Add the facet to the project and create a row filter
|
|
||||||
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
|
||||||
Facet facet = facetConfig.apply(project);
|
|
||||||
rowfilter = facet.getRowFilter(project);
|
|
||||||
|
|
||||||
//Check each row in the project against the filter
|
|
||||||
//Rows 1-5 are strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 0, project.rows.get(0)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 1, project.rows.get(1)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 4, project.rows.get(4)),false);
|
|
||||||
//Rows 6-10 are DateTimes
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 5, project.rows.get(5)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 6, project.rows.get(6)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 7, project.rows.get(7)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 8, project.rows.get(8)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 9, project.rows.get(9)),false);
|
|
||||||
//Rows 11-15 are integers
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 10, project.rows.get(10)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 11, project.rows.get(11)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 12, project.rows.get(12)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 13, project.rows.get(13)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 14, project.rows.get(14)),false);
|
|
||||||
//Rows 16-20 are booleans
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 15, project.rows.get(15)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 16, project.rows.get(16)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 17, project.rows.get(17)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 18, project.rows.get(18)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 19, project.rows.get(19)),true);
|
|
||||||
//Rows 21-25 are nulls
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 20, project.rows.get(20)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 21, project.rows.get(21)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 22, project.rows.get(22)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 23, project.rows.get(23)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 24, project.rows.get(24)),false);
|
|
||||||
//Rows 26-30 are empty strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 25, project.rows.get(25)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 26, project.rows.get(26)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 27, project.rows.get(27)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 28, project.rows.get(28)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 29, project.rows.get(29)),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBlankSelection() throws Exception {
|
|
||||||
String jsonConfig = "{"
|
|
||||||
+ "\"type\": \"list\","
|
|
||||||
+ "\"name\": \"Value\","
|
|
||||||
+ "\"columnName\": \"" + columnName + "\","
|
|
||||||
+ "\"expression\": \"value\","
|
|
||||||
+ "\"omitBlank\": false,"
|
|
||||||
+ "\"omitError\": false,"
|
|
||||||
+ "\"selection\": [],"
|
|
||||||
+ "\"selectNumber\": false,"
|
|
||||||
+ "\"selectDateTime\": false,"
|
|
||||||
+ "\"selectBoolean\": false,"
|
|
||||||
+ "\"selectBlank\": true,"
|
|
||||||
+ "\"selectError\": false,"
|
|
||||||
+ "\"invert\": false"
|
|
||||||
+ "}";
|
|
||||||
|
|
||||||
//Add the facet to the project and create a row filter
|
|
||||||
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
|
||||||
Facet facet = facetConfig.apply(project);
|
|
||||||
rowfilter = facet.getRowFilter(project);
|
|
||||||
|
|
||||||
//Check each row in the project against the filter
|
|
||||||
//Rows 1-5 are strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 0, project.rows.get(0)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 1, project.rows.get(1)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 2, project.rows.get(2)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 3, project.rows.get(3)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 4, project.rows.get(4)),false);
|
|
||||||
//Rows 6-10 are DateTimes
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 5, project.rows.get(5)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 6, project.rows.get(6)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 7, project.rows.get(7)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 8, project.rows.get(8)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 9, project.rows.get(9)),false);
|
|
||||||
//Rows 11-15 are integers
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 10, project.rows.get(10)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 11, project.rows.get(11)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 12, project.rows.get(12)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 13, project.rows.get(13)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 14, project.rows.get(14)),false);
|
|
||||||
//Rows 16-20 are booleans
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 15, project.rows.get(15)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 16, project.rows.get(16)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 17, project.rows.get(17)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 18, project.rows.get(18)),false);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 19, project.rows.get(19)),false);
|
|
||||||
//Rows 21-25 are nulls
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 20, project.rows.get(20)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 21, project.rows.get(21)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 22, project.rows.get(22)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 23, project.rows.get(23)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 24, project.rows.get(24)),true);
|
|
||||||
//Rows 26-30 are empty strings
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 25, project.rows.get(25)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 26, project.rows.get(26)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 27, project.rows.get(27)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 28, project.rows.get(28)),true);
|
|
||||||
Assert.assertEquals(rowfilter.filterRow(project, 29, project.rows.get(29)),true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// should add tests for errors as well
|
|
||||||
}
|
|
@ -59,9 +59,10 @@ public class ExpressionNominalValueGrouperTests extends RefineTest {
|
|||||||
private static Properties bindings;
|
private static Properties bindings;
|
||||||
|
|
||||||
private static OffsetDateTime dateTimeValue = OffsetDateTime.parse("2017-05-12T05:45:00+00:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
private static OffsetDateTime dateTimeValue = OffsetDateTime.parse("2017-05-12T05:45:00+00:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||||
|
private static String dateTimeStringValue = "2017-05-12T05:45:00Z";
|
||||||
private static int integerValue = 1;
|
private static int integerValue = 1;
|
||||||
|
private static String integerStringValue = "1";
|
||||||
private static String stringStringValue = "a";
|
private static String stringStringValue = "a";
|
||||||
private static Boolean booleanValue = true;
|
|
||||||
|
|
||||||
private static ExpressionNominalValueGrouper grouper;
|
private static ExpressionNominalValueGrouper grouper;
|
||||||
private static Evaluable eval;
|
private static Evaluable eval;
|
||||||
@ -139,7 +140,11 @@ public class ExpressionNominalValueGrouperTests extends RefineTest {
|
|||||||
grouper.end(project);
|
grouper.end(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(grouper.choices.size(),0);
|
Assert.assertEquals(grouper.choices.size(),1);
|
||||||
|
|
||||||
|
Assert.assertTrue(grouper.choices.containsKey(integerStringValue));
|
||||||
|
Assert.assertEquals(grouper.choices.get(integerStringValue).decoratedValue.label,integerStringValue);
|
||||||
|
Assert.assertEquals(grouper.choices.get(integerStringValue).decoratedValue.value.toString(),integerStringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -163,30 +168,10 @@ public class ExpressionNominalValueGrouperTests extends RefineTest {
|
|||||||
grouper.end(project);
|
grouper.end(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertEquals(grouper.choices.size(),0);
|
Assert.assertEquals(grouper.choices.size(),1);
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void expressionNominalValueGrouperBooleans() throws Exception {
|
|
||||||
//populate project
|
|
||||||
for (int i = 0; i < numberOfRows; i++) {
|
|
||||||
Row row = new Row(1);
|
|
||||||
row.setCell(0, new Cell(booleanValue, null));
|
|
||||||
project.rows.add(row);
|
|
||||||
}
|
|
||||||
//create grouper
|
|
||||||
eval = MetaParser.parse("value");
|
|
||||||
grouper = new ExpressionNominalValueGrouper(eval, columnName, cellIndex);
|
|
||||||
try {
|
|
||||||
grouper.start(project);
|
|
||||||
for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {
|
|
||||||
Row row = project.rows.get(rowIndex);
|
|
||||||
grouper.visit(project, rowIndex, row);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
grouper.end(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertEquals(grouper.choices.size(),0);
|
Assert.assertTrue(grouper.choices.containsKey(dateTimeStringValue));
|
||||||
|
Assert.assertEquals(grouper.choices.get(dateTimeStringValue).decoratedValue.label,dateTimeStringValue);
|
||||||
|
Assert.assertEquals(grouper.choices.get(dateTimeStringValue).decoratedValue.value.toString(),dateTimeStringValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ import com.google.refine.tests.RefineTest;
|
|||||||
public class CacheTests extends RefineTest {
|
public class CacheTests extends RefineTest {
|
||||||
|
|
||||||
// Equivalent to duplicate facet on Column A with true selected
|
// Equivalent to duplicate facet on Column A with true selected
|
||||||
static private final String ENGINE_JSON_DUPLICATES = "{\"facets\":[{\"type\":\"list\",\"name\":\"facet A\",\"columnName\":\"Column A\",\"expression\":\"(facetCount(value, 'value', 'Column A') > 1).toString()\",\"omitBlank\":false,\"omitError\":false,\"selection\":[{\"v\":{\"v\":\"true\",\"l\":\"true\"}}],\"selectBlank\":false,\"selectError\":false,\"invert\":false}],\"mode\":\"row-based\"}}";
|
static final String ENGINE_JSON_DUPLICATES = "{\"facets\":[{\"type\":\"list\",\"name\":\"facet A\",\"columnName\":\"Column A\",\"expression\":\"facetCount(value, 'value', 'Column A') > 1\",\"omitBlank\":false,\"omitError\":false,\"selection\":[{\"v\":{\"v\":true,\"l\":\"true\"}}],\"selectBlank\":false,\"selectError\":false,\"invert\":false}],\"mode\":\"row-based\"}}";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
package com.google.refine.tests.model.recon;
|
package com.google.refine.tests.model.recon;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
@ -333,4 +334,15 @@ public class StandardReconConfigTests extends RefineTest {
|
|||||||
assertEquals(recon.candidates.get(0).score, 0.3);
|
assertEquals(recon.candidates.get(0).score, 0.3);
|
||||||
assertEquals(recon.candidates.get(0).id, "18951129");
|
assertEquals(recon.candidates.get(0).id, "18951129");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* computing the features on an empty recon should not fail
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testComputeFeatures() {
|
||||||
|
StandardReconConfigStub stub = new StandardReconConfigStub();
|
||||||
|
Recon recon = stub.createNewRecon(2384738L);
|
||||||
|
stub.computeFeatures(recon, "my string");
|
||||||
|
assertNotNull(recon.features);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
|
|||||||
+ "\"columnName\":\"ids\","
|
+ "\"columnName\":\"ids\","
|
||||||
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]},"
|
+ "\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]},"
|
||||||
+ "\"service\":\"http://localhost:8080/api\","
|
+ "\"service\":\"http://localhost:8080/api\","
|
||||||
+ "\"identifierSpace\":\"http://test.org/entities\","
|
+ "\"identifierSpace\":\"http://test.org/entities/\","
|
||||||
+ "\"schemaSpace\":\"http://test.org/schema\""
|
+ "\"schemaSpace\":\"http://test.org/schema/\""
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
@BeforeSuite
|
@BeforeSuite
|
||||||
@ -69,15 +69,15 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
|
|||||||
Project project = createCSVProject("ids,v\n"
|
Project project = createCSVProject("ids,v\n"
|
||||||
+ "Q343,hello\n"
|
+ "Q343,hello\n"
|
||||||
+ ",world\n"
|
+ ",world\n"
|
||||||
+ "Q31,test");
|
+ "http://test.org/entities/Q31,test");
|
||||||
ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class);
|
ReconUseValuesAsIdentifiersOperation op = ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class);
|
||||||
op.createProcess(project, new Properties()).performImmediate();
|
op.createProcess(project, new Properties()).performImmediate();
|
||||||
|
|
||||||
assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id);
|
assertEquals("Q343", project.rows.get(0).cells.get(0).recon.match.id);
|
||||||
assertEquals("http://test.org/entities", project.rows.get(0).cells.get(0).recon.identifierSpace);
|
assertEquals("http://test.org/entities/", project.rows.get(0).cells.get(0).recon.identifierSpace);
|
||||||
assertNull(project.rows.get(1).cells.get(0));
|
assertNull(project.rows.get(1).cells.get(0));
|
||||||
assertEquals("Q31", project.rows.get(2).cells.get(0).recon.match.id);
|
assertEquals("Q31", project.rows.get(2).cells.get(0).recon.match.id);
|
||||||
assertEquals(2, project.columnModel.columns.get(0).getReconStats().matchedTopics);
|
assertEquals(2, project.columnModel.columns.get(0).getReconStats().matchedTopics);
|
||||||
assertEquals("http://test.org/schema", ((StandardReconConfig)project.columnModel.columns.get(0).getReconConfig()).schemaSpace);
|
assertEquals("http://test.org/schema/", ((StandardReconConfig)project.columnModel.columns.get(0).getReconConfig()).schemaSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1299,6 +1299,20 @@
|
|||||||
name.append($("<span></span>").text(data.description));
|
name.append($("<span></span>").text(data.description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we know of a view URL for this suggest service,
|
||||||
|
// clicking with the middle button sends the user to
|
||||||
|
// the view page.
|
||||||
|
if('view_url' in this.options && data.id) {
|
||||||
|
var view_url = this.options.view_url.replace('{{id}}', data.id).replace('${id}', data.id);
|
||||||
|
li.on('mousedown', function(e) {
|
||||||
|
if (e.which == 2) {
|
||||||
|
var win = window.open(view_url, '_blank');
|
||||||
|
win.focus();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//console.log("create_item", li);
|
//console.log("create_item", li);
|
||||||
return li;
|
return li;
|
||||||
},
|
},
|
||||||
|
@ -44,9 +44,6 @@ function ListFacet(div, config, options, selection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._selection = selection || [];
|
this._selection = selection || [];
|
||||||
this._numberChoice = (config.selectNumber) ? { s : true, c : 0 } : null;
|
|
||||||
this._datetimeChoice = (config.selectDateTime) ? { s : true, c : 0 } : null;
|
|
||||||
this._booleanChoice = (config.selecBoolean) ? { s : true, c : 0 } : null;
|
|
||||||
this._blankChoice = (config.selectBlank) ? { s : true, c : 0 } : null;
|
this._blankChoice = (config.selectBlank) ? { s : true, c : 0 } : null;
|
||||||
this._errorChoice = (config.selectError) ? { s : true, c : 0 } : null;
|
this._errorChoice = (config.selectError) ? { s : true, c : 0 } : null;
|
||||||
|
|
||||||
@ -65,9 +62,6 @@ ListFacet.prototype.dispose = function() {
|
|||||||
|
|
||||||
ListFacet.prototype.reset = function() {
|
ListFacet.prototype.reset = function() {
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
this._numberChoice = null;
|
|
||||||
this._datetimeChoice = null;
|
|
||||||
this._booleanChoice = null;
|
|
||||||
this._blankChoice = null;
|
this._blankChoice = null;
|
||||||
this._errorChoice = null;
|
this._errorChoice = null;
|
||||||
};
|
};
|
||||||
@ -91,14 +85,11 @@ ListFacet.prototype.getJSON = function() {
|
|||||||
columnName: this._config.columnName,
|
columnName: this._config.columnName,
|
||||||
expression: this._config.expression,
|
expression: this._config.expression,
|
||||||
omitBlank: "omitBlank" in this._config ? this._config.omitBlank : false,
|
omitBlank: "omitBlank" in this._config ? this._config.omitBlank : false,
|
||||||
omitError: "omitError" in this._config ? this._config.omitError : false,
|
omitError: "omitError" in this._config ? this._config.omitError : false,
|
||||||
selection: [],
|
selection: [],
|
||||||
selectNumber: this._numberChoice !== null && this._numberChoice.s,
|
selectBlank: this._blankChoice !== null && this._blankChoice.s,
|
||||||
selectDateTime: this._datetimeChoice !== null && this._datetimeChoice.s,
|
selectError: this._errorChoice !== null && this._errorChoice.s,
|
||||||
selectBoolean: this._booleanChoice !== null && this._booleanChoice.s,
|
invert: this._config.invert
|
||||||
selectBlank: this._blankChoice !== null && this._blankChoice.s,
|
|
||||||
selectError: this._errorChoice !== null && this._errorChoice.s,
|
|
||||||
invert: this._config.invert
|
|
||||||
};
|
};
|
||||||
for (var i = 0; i < this._selection.length; i++) {
|
for (var i = 0; i < this._selection.length; i++) {
|
||||||
var choice = {
|
var choice = {
|
||||||
@ -111,11 +102,8 @@ ListFacet.prototype.getJSON = function() {
|
|||||||
|
|
||||||
ListFacet.prototype.hasSelection = function() {
|
ListFacet.prototype.hasSelection = function() {
|
||||||
return this._selection.length > 0 ||
|
return this._selection.length > 0 ||
|
||||||
( this._numberChoice !== null && this._numberChoice.s ) ||
|
(this._blankChoice !== null && this._blankChoice.s) ||
|
||||||
( this._datetimeChoice !== null && this._datetimeChoice.s ) ||
|
(this._errorChoice !== null && this._errorChoice.s);
|
||||||
( this._booleanChoice !== null && this._booleanChoice.s ) ||
|
|
||||||
( this._blankChoice !== null && this._blankChoice.s ) ||
|
|
||||||
( this._errorChoice !== null && this._errorChoice.s );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype.updateState = function(data) {
|
ListFacet.prototype.updateState = function(data) {
|
||||||
@ -133,9 +121,6 @@ ListFacet.prototype.updateState = function(data) {
|
|||||||
this._selection = selection;
|
this._selection = selection;
|
||||||
this._reSortChoices();
|
this._reSortChoices();
|
||||||
|
|
||||||
this._numberChoice = data.numberChoice || null;
|
|
||||||
this._datetimeChoice = data.datetimeChoice || null;
|
|
||||||
this._booleanChoice = data.booleanChoice || null;
|
|
||||||
this._blankChoice = data.blankChoice || null;
|
this._blankChoice = data.blankChoice || null;
|
||||||
this._errorChoice = data.errorChoice || null;
|
this._errorChoice = data.errorChoice || null;
|
||||||
}
|
}
|
||||||
@ -254,15 +239,6 @@ ListFacet.prototype._copyChoices = function() {
|
|||||||
var choice = this._data.choices[i];
|
var choice = this._data.choices[i];
|
||||||
lines.push(choice.v.l + "\t" + choice.c);
|
lines.push(choice.v.l + "\t" + choice.c);
|
||||||
}
|
}
|
||||||
if (this._numberChoice) {
|
|
||||||
lines.push("(number)\t" + this._numberChoice.c);
|
|
||||||
}
|
|
||||||
if (this._datetimeChoice) {
|
|
||||||
lines.push("(date)\t" + this._datetimeChoice.c);
|
|
||||||
}
|
|
||||||
if (this._booleanChoice) {
|
|
||||||
lines.push("(boolean)\t" + this._booleanChoice.c);
|
|
||||||
}
|
|
||||||
if (this._blankChoice) {
|
if (this._blankChoice) {
|
||||||
lines.push("(blank)\t" + this._blankChoice.c);
|
lines.push("(blank)\t" + this._blankChoice.c);
|
||||||
}
|
}
|
||||||
@ -359,9 +335,6 @@ ListFacet.prototype._update = function(resetScroll) {
|
|||||||
|
|
||||||
var choices = this._data.choices;
|
var choices = this._data.choices;
|
||||||
var selectionCount = this._selection.length +
|
var selectionCount = this._selection.length +
|
||||||
(this._numberChoice !== null && this._numberChoice.s ? 1 : 0) +
|
|
||||||
(this._datetimeChoice !== null && this._datetimeChoice.s ? 1 : 0) +
|
|
||||||
(this._booleanChoice !== null && this._booleanChoice.s ? 1 : 0) +
|
|
||||||
(this._blankChoice !== null && this._blankChoice.s ? 1 : 0) +
|
(this._blankChoice !== null && this._blankChoice.s ? 1 : 0) +
|
||||||
(this._errorChoice !== null && this._errorChoice.s ? 1 : 0);
|
(this._errorChoice !== null && this._errorChoice.s ? 1 : 0);
|
||||||
|
|
||||||
@ -416,24 +389,10 @@ ListFacet.prototype._update = function(resetScroll) {
|
|||||||
for (var i = 0; i < choices.length; i++) {
|
for (var i = 0; i < choices.length; i++) {
|
||||||
renderChoice(i, choices[i]);
|
renderChoice(i, choices[i]);
|
||||||
}
|
}
|
||||||
if (this._numberChoice !== null) {
|
|
||||||
renderEdit = false;
|
|
||||||
renderChoice(-5, this._numberChoice, "(number)");
|
|
||||||
}
|
|
||||||
if (this._datetimeChoice !== null) {
|
|
||||||
renderEdit = false;
|
|
||||||
renderChoice(-4, this._datetimeChoice, "(date)");
|
|
||||||
}
|
|
||||||
if (this._booleanChoice !== null) {
|
|
||||||
renderEdit = false;
|
|
||||||
renderChoice(-3, this._booleanChoice, "(boolean)");
|
|
||||||
}
|
|
||||||
if (this._blankChoice !== null) {
|
if (this._blankChoice !== null) {
|
||||||
renderEdit = false;
|
|
||||||
renderChoice(-1, this._blankChoice, "(blank)");
|
renderChoice(-1, this._blankChoice, "(blank)");
|
||||||
}
|
}
|
||||||
if (this._errorChoice !== null) {
|
if (this._errorChoice !== null) {
|
||||||
renderEdit = false;
|
|
||||||
renderChoice(-2, this._errorChoice, "(error)");
|
renderChoice(-2, this._errorChoice, "(error)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,12 +406,6 @@ ListFacet.prototype._update = function(resetScroll) {
|
|||||||
return self._blankChoice;
|
return self._blankChoice;
|
||||||
} else if (index === -2) {
|
} else if (index === -2) {
|
||||||
return self._errorChoice;
|
return self._errorChoice;
|
||||||
} else if (index === -3) {
|
|
||||||
return self._booleanChoice;
|
|
||||||
} else if (index === -4) {
|
|
||||||
return self._datetimeChoice;
|
|
||||||
} else if (index === -5) {
|
|
||||||
return self._numberChoice;
|
|
||||||
} else {
|
} else {
|
||||||
return choices[index];
|
return choices[index];
|
||||||
}
|
}
|
||||||
@ -589,12 +542,6 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
|
|||||||
originalContent = "(blank)";
|
originalContent = "(blank)";
|
||||||
} else if (choice === this._errorChoice) {
|
} else if (choice === this._errorChoice) {
|
||||||
originalContent = "(error)";
|
originalContent = "(error)";
|
||||||
} else if (choice === this._booleanChoice) {
|
|
||||||
originalContent = "(boolean)";
|
|
||||||
} else if (choice === this._datetimeChoice) {
|
|
||||||
originalContent = "(date)";
|
|
||||||
} else if (choice === this._numberChoice) {
|
|
||||||
originalContent = "(number)";
|
|
||||||
} else {
|
} else {
|
||||||
originalContent = choice.v.v;
|
originalContent = choice.v.v;
|
||||||
}
|
}
|
||||||
@ -670,15 +617,6 @@ ListFacet.prototype._editChoice = function(choice, choiceDiv) {
|
|||||||
ListFacet.prototype._select = function(choice, only) {
|
ListFacet.prototype._select = function(choice, only) {
|
||||||
if (only) {
|
if (only) {
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
if (this._numberChoice !== null) {
|
|
||||||
this._numberChoice.s = false;
|
|
||||||
}
|
|
||||||
if (this._datetimeChoice !== null) {
|
|
||||||
this._datetimeChoice.s = false;
|
|
||||||
}
|
|
||||||
if (this._booleanChoice !== null) {
|
|
||||||
this._booleanChoice.s = false;
|
|
||||||
}
|
|
||||||
if (this._blankChoice !== null) {
|
if (this._blankChoice !== null) {
|
||||||
this._blankChoice.s = false;
|
this._blankChoice.s = false;
|
||||||
}
|
}
|
||||||
@ -688,11 +626,7 @@ ListFacet.prototype._select = function(choice, only) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
choice.s = true;
|
choice.s = true;
|
||||||
if (choice !== this._errorChoice &&
|
if (choice !== this._errorChoice && choice !== this._blankChoice) {
|
||||||
choice !== this._blankChoice &&
|
|
||||||
choice !== this._numberChoice &&
|
|
||||||
choice !== this._datetimeChoice &&
|
|
||||||
choice !== this._booleanChoice ) {
|
|
||||||
this._selection.push(choice);
|
this._selection.push(choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +634,7 @@ ListFacet.prototype._select = function(choice, only) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ListFacet.prototype._deselect = function(choice) {
|
ListFacet.prototype._deselect = function(choice) {
|
||||||
if (choice === this._errorChoice || choice === this._blankChoice || choice === this._numberChoice || choice === this._datetimeChoice || choice === this._booleanChoice) {
|
if (choice === this._errorChoice || choice === this._blankChoice) {
|
||||||
choice.s = false;
|
choice.s = false;
|
||||||
} else {
|
} else {
|
||||||
for (var i = this._selection.length - 1; i >= 0; i--) {
|
for (var i = this._selection.length - 1; i >= 0; i--) {
|
||||||
@ -715,9 +649,6 @@ ListFacet.prototype._deselect = function(choice) {
|
|||||||
|
|
||||||
ListFacet.prototype._reset = function() {
|
ListFacet.prototype._reset = function() {
|
||||||
this._selection = [];
|
this._selection = [];
|
||||||
this._numberChoice = null;
|
|
||||||
this._datetimeChoice = null;
|
|
||||||
this._booleanChoice = null;
|
|
||||||
this._blankChoice = null;
|
this._blankChoice = null;
|
||||||
this._errorChoice = null;
|
this._errorChoice = null;
|
||||||
this._config.invert = false;
|
this._config.invert = false;
|
||||||
@ -738,9 +669,6 @@ ListFacet.prototype._remove = function() {
|
|||||||
this._config = null;
|
this._config = null;
|
||||||
|
|
||||||
this._selection = null;
|
this._selection = null;
|
||||||
this._numberChoice = null;
|
|
||||||
this._datetimeChoice = null;
|
|
||||||
this._booleanChoice = null;
|
|
||||||
this._blankChoice = null;
|
this._blankChoice = null;
|
||||||
this._errorChoice = null;
|
this._errorChoice = null;
|
||||||
this._data = null;
|
this._data = null;
|
||||||
|
@ -41,6 +41,23 @@ function DataTableCellUI(dataTableView, cell, rowIndex, cellIndex, td) {
|
|||||||
this._render();
|
this._render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DataTableCellUI.previewMatchedCells = true;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "command/core/get-preference?" + $.param({
|
||||||
|
name: "cell-ui.previewMatchedCells"
|
||||||
|
}),
|
||||||
|
success: function(data) {
|
||||||
|
if (data.value && data.value == "false") {
|
||||||
|
DataTableCellUI.previewMatchedCells = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dataType: "json",
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
DataTableCellUI.prototype._render = function() {
|
DataTableCellUI.prototype._render = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var cell = this._cell;
|
var cell = this._cell;
|
||||||
@ -108,6 +125,10 @@ DataTableCellUI.prototype._render = function() {
|
|||||||
a.attr("href", encodeURI(service.view.url.replace("{{id}}", match.id)));
|
a.attr("href", encodeURI(service.view.url.replace("{{id}}", match.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DataTableCellUI.previewMatchedCells) {
|
||||||
|
self._previewOnHover(service, match, a, a, false);
|
||||||
|
}
|
||||||
|
|
||||||
$('<span> </span>').appendTo(divContent);
|
$('<span> </span>').appendTo(divContent);
|
||||||
$('<a href="javascript:{}"></a>')
|
$('<a href="javascript:{}"></a>')
|
||||||
.text($.i18n('core-views/choose-match'))
|
.text($.i18n('core-views/choose-match'))
|
||||||
@ -125,18 +146,19 @@ DataTableCellUI.prototype._render = function() {
|
|||||||
var candidates = r.c;
|
var candidates = r.c;
|
||||||
var renderCandidate = function(candidate, index) {
|
var renderCandidate = function(candidate, index) {
|
||||||
var li = $('<div></div>').addClass("data-table-recon-candidate").appendTo(ul);
|
var li = $('<div></div>').addClass("data-table-recon-candidate").appendTo(ul);
|
||||||
|
var liSpan = $('<span></span>').appendTo(li);
|
||||||
|
|
||||||
$('<a href="javascript:{}"> </a>')
|
$('<a href="javascript:{}"> </a>')
|
||||||
.addClass("data-table-recon-match-similar")
|
.addClass("data-table-recon-match-similar")
|
||||||
.attr("title", $.i18n('core-views/match-all-cells'))
|
.attr("title", $.i18n('core-views/match-all-cells'))
|
||||||
.appendTo(li).click(function(evt) {
|
.appendTo(liSpan).click(function(evt) {
|
||||||
self._doMatchTopicToSimilarCells(candidate);
|
self._doMatchTopicToSimilarCells(candidate);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<a href="javascript:{}"> </a>')
|
$('<a href="javascript:{}"> </a>')
|
||||||
.addClass("data-table-recon-match")
|
.addClass("data-table-recon-match")
|
||||||
.attr("title", $.i18n('core-views/match-this-cell') )
|
.attr("title", $.i18n('core-views/match-this-cell') )
|
||||||
.appendTo(li).click(function(evt) {
|
.appendTo(liSpan).click(function(evt) {
|
||||||
self._doMatchTopicToOneCell(candidate);
|
self._doMatchTopicToOneCell(candidate);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -144,26 +166,13 @@ DataTableCellUI.prototype._render = function() {
|
|||||||
.addClass("data-table-recon-topic")
|
.addClass("data-table-recon-topic")
|
||||||
.attr("target", "_blank")
|
.attr("target", "_blank")
|
||||||
.text(_.unescape(candidate.name)) // TODO: only use of _.unescape - consolidate
|
.text(_.unescape(candidate.name)) // TODO: only use of _.unescape - consolidate
|
||||||
.appendTo(li);
|
.appendTo(liSpan);
|
||||||
|
|
||||||
if ((service) && (service.view) && (service.view.url)) {
|
if ((service) && (service.view) && (service.view.url)) {
|
||||||
a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id)));
|
a.attr("href", encodeURI(service.view.url.replace("{{id}}", candidate.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
var preview = null;
|
self._previewOnHover(service, candidate, liSpan.parent(), liSpan, true);
|
||||||
if ((service) && (service.preview)) {
|
|
||||||
preview = service.preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preview) {
|
|
||||||
a.click(function(evt) {
|
|
||||||
if (!evt.metaKey && !evt.ctrlKey) {
|
|
||||||
self._previewCandidateTopic(candidate, this, preview);
|
|
||||||
evt.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var score;
|
var score;
|
||||||
if (candidate.score < 1) {
|
if (candidate.score < 1) {
|
||||||
@ -171,7 +180,7 @@ DataTableCellUI.prototype._render = function() {
|
|||||||
} else {
|
} else {
|
||||||
score = Math.round(candidate.score);
|
score = Math.round(candidate.score);
|
||||||
}
|
}
|
||||||
$('<span></span>').addClass("data-table-recon-score").text("(" + score + ")").appendTo(li);
|
$('<span></span>').addClass("data-table-recon-score").text("(" + score + ")").appendTo(liSpan);
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var i = 0; i < candidates.length; i++) {
|
for (var i = 0; i < candidates.length; i++) {
|
||||||
@ -200,6 +209,9 @@ DataTableCellUI.prototype._render = function() {
|
|||||||
var addSuggest = false;
|
var addSuggest = false;
|
||||||
if ((service) && (service.suggest) && (service.suggest.entity)) {
|
if ((service) && (service.suggest) && (service.suggest.entity)) {
|
||||||
suggestOptions = service.suggest.entity;
|
suggestOptions = service.suggest.entity;
|
||||||
|
if ('view' in service && 'url' in service.view && !('view_url' in suggestOptions)) {
|
||||||
|
suggestOptions.view_url = service.view.url;
|
||||||
|
}
|
||||||
addSuggest = true;
|
addSuggest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,24 +440,18 @@ DataTableCellUI.prototype._postProcessSeveralCells = function(command, params, b
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO delete this
|
DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview, showActions) {
|
||||||
DataTableCellUI.internalPreview = {
|
|
||||||
srchurl: 'https://www.googleapis.com/freebase/v1/search?filter=(all mid:${id})'
|
|
||||||
+ '&output=(notable:/client/summary (description citation provenance) type)'
|
|
||||||
+ '&key='+CustomSuggest.FREEBASE_API_KEY+'&callback=?',
|
|
||||||
imgurl : 'https://www.googleapis.com/freebase/v1/image${id}?maxwidth=75&errorid=/freebase/no_image_png&key='+CustomSuggest.FREEBASE_API_KEY,
|
|
||||||
width: 430,
|
|
||||||
height: 300
|
|
||||||
};
|
|
||||||
|
|
||||||
DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, preview) {
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var id = candidate.id;
|
var id = candidate.id;
|
||||||
var fakeMenu = MenuSystem.createMenu();
|
var fakeMenu = $('<div></div>')
|
||||||
|
.addClass("menu-container");
|
||||||
fakeMenu
|
fakeMenu
|
||||||
.width(preview.width?preview.width:414)
|
.width(preview.width?preview.width:414)
|
||||||
.addClass('data-table-topic-popup')
|
.addClass('data-table-topic-popup');
|
||||||
.html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html"));
|
if (showActions) {
|
||||||
|
fakeMenu
|
||||||
|
.html(DOM.loadHTML("core", "scripts/views/data-table/cell-recon-preview-popup-header.html"));
|
||||||
|
}
|
||||||
|
|
||||||
if (preview && preview.url) { // Service has a preview URL associated with it
|
if (preview && preview.url) { // Service has a preview URL associated with it
|
||||||
var url = encodeURI(preview.url.replace("{{id}}", id));
|
var url = encodeURI(preview.url.replace("{{id}}", id));
|
||||||
@ -454,37 +460,63 @@ DataTableCellUI.prototype._previewCandidateTopic = function(candidate, elmt, pre
|
|||||||
.height(preview.height)
|
.height(preview.height)
|
||||||
.attr("src", url)
|
.attr("src", url)
|
||||||
.appendTo(fakeMenu);
|
.appendTo(fakeMenu);
|
||||||
} else { // Otherwise use our internal preview
|
} else {
|
||||||
var url = encodeURI(DataTableCellUI.internalPreview.srchurl.replace("\${id}", id));
|
return; // no preview service available
|
||||||
$.ajax(url,{dataType:"jsonp"}).done(function(searchResponse) {
|
|
||||||
var data = searchResponse.result[0];
|
|
||||||
var html = $.suggest.suggest.create_flyout(data, preview.imgurl);
|
|
||||||
var container = $('<div></div>').css({fontSize:16}); // Suggest assumes this as a base font size
|
|
||||||
container.append(html);
|
|
||||||
fakeMenu.append(container);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSystem.showMenu(fakeMenu, function(){});
|
|
||||||
MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt));
|
MenuSystem.positionMenuLeftRight(fakeMenu, $(elmt));
|
||||||
|
fakeMenu.appendTo(elmt);
|
||||||
|
|
||||||
var elmts = DOM.bind(fakeMenu);
|
var dismissMenu = function() {
|
||||||
|
fakeMenu.remove();
|
||||||
elmts.matchButton.html($.i18n('core-views/match-cell'));
|
fakeMenu.unbind();
|
||||||
elmts.matchSimilarButton.html($.i18n('core-views/match-identical'));
|
};
|
||||||
elmts.cancelButton.html($.i18n('core-buttons/cancel'));
|
|
||||||
|
if (showActions) {
|
||||||
elmts.matchButton.click(function() {
|
var elmts = DOM.bind(fakeMenu);
|
||||||
self._doMatchTopicToOneCell(candidate);
|
|
||||||
MenuSystem.dismissAll();
|
elmts.matchButton.html($.i18n('core-views/match-cell'));
|
||||||
});
|
elmts.matchSimilarButton.html($.i18n('core-views/match-identical'));
|
||||||
elmts.matchSimilarButton.click(function() {
|
elmts.cancelButton.html($.i18n('core-buttons/cancel'));
|
||||||
self._doMatchTopicToSimilarCells(candidate);
|
|
||||||
MenuSystem.dismissAll();
|
elmts.matchButton.click(function() {
|
||||||
});
|
self._doMatchTopicToOneCell(candidate);
|
||||||
elmts.cancelButton.click(function() {
|
dismissMenu();
|
||||||
MenuSystem.dismissAll();
|
});
|
||||||
});
|
elmts.matchSimilarButton.click(function() {
|
||||||
|
self._doMatchTopicToSimilarCells(candidate);
|
||||||
|
dismissMenu();
|
||||||
|
});
|
||||||
|
elmts.cancelButton.click(function() {
|
||||||
|
dismissMenu();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return dismissMenu;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a preview widget to appear when hovering the given DOM element.
|
||||||
|
*/
|
||||||
|
DataTableCellUI.prototype._previewOnHover = function(service, candidate, hoverElement, coreElement, showActions) {
|
||||||
|
var self = this;
|
||||||
|
var preview = null;
|
||||||
|
if ((service) && (service.preview)) {
|
||||||
|
preview = service.preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preview) {
|
||||||
|
var dismissCallback = null;
|
||||||
|
hoverElement.hover(function(evt) {
|
||||||
|
if (!evt.metaKey && !evt.ctrlKey) {
|
||||||
|
dismissCallback = self._previewCandidateTopic(candidate, coreElement, preview, showActions);
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
|
}, function(evt) {
|
||||||
|
if(dismissCallback !== null) {
|
||||||
|
dismissCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DataTableCellUI.prototype._startEdit = function(elmt) {
|
DataTableCellUI.prototype._startEdit = function(elmt) {
|
||||||
|
@ -626,7 +626,7 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) {
|
|||||||
{
|
{
|
||||||
"name" : $.i18n('core-views/starred-rows'),
|
"name" : $.i18n('core-views/starred-rows'),
|
||||||
"columnName" : "",
|
"columnName" : "",
|
||||||
"expression" : "row.starred.toString()"
|
"expression" : "row.starred"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scroll" : false
|
"scroll" : false
|
||||||
@ -643,7 +643,7 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) {
|
|||||||
{
|
{
|
||||||
"name" : $.i18n('core-views/flagged-rows'),
|
"name" : $.i18n('core-views/flagged-rows'),
|
||||||
"columnName" : "",
|
"columnName" : "",
|
||||||
"expression" : "row.flagged.toString()"
|
"expression" : "row.flagged"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scroll" : false
|
"scroll" : false
|
||||||
|
@ -147,8 +147,8 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name": column.name,
|
"name": column.name,
|
||||||
"columnName": column.name,
|
"columnName": column.name,
|
||||||
"expression": "(facetCount(value, 'value', '" +
|
"expression": "facetCount(value, 'value', '" +
|
||||||
column.name + "') > 1).toString()"
|
column.name + "') > 1"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name": column.name,
|
"name": column.name,
|
||||||
"columnName": column.name,
|
"columnName": column.name,
|
||||||
"expression": "isError(value).toString()"
|
"expression": "isError(value)"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name": column.name,
|
"name": column.name,
|
||||||
"columnName": column.name,
|
"columnName": column.name,
|
||||||
"expression": "isNull(value).toString()"
|
"expression": "isNull(value)"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name": column.name,
|
"name": column.name,
|
||||||
"columnName": column.name,
|
"columnName": column.name,
|
||||||
"expression": "isEmptyString(value).toString()"
|
"expression": "isEmptyString(value)"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name": column.name,
|
"name": column.name,
|
||||||
"columnName": column.name,
|
"columnName": column.name,
|
||||||
"expression": "isBlank(value).toString()"
|
"expression": "isBlank(value)"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,9 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
if (service && service.suggest && service.suggest.entity) {
|
if (service && service.suggest && service.suggest.entity) {
|
||||||
suggestOptions = $.extend({}, service.suggest.entity);
|
suggestOptions = $.extend({}, service.suggest.entity);
|
||||||
suggestOptions.query_param_name = "prefix";
|
suggestOptions.query_param_name = "prefix";
|
||||||
|
if ('view' in service && 'url' in service.view && !('view_url' in suggestOptions)) {
|
||||||
|
suggestOptions.formatter_url = service.view.url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var frame = DialogSystem.createDialog();
|
var frame = DialogSystem.createDialog();
|
||||||
@ -294,7 +297,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name" : column.name + " "+$.i18n('core-views/hist-entries'),
|
"name" : column.name + " "+$.i18n('core-views/hist-entries'),
|
||||||
"columnName" : column.name,
|
"columnName" : column.name,
|
||||||
"expression" : "cell.recon.judgmentHistoryEntry.toString()"
|
"expression" : "cell.recon.judgmentHistoryEntry"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -326,7 +329,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name" : column.name + ": "+$.i18n('core-views/best-cand-type-match'),
|
"name" : column.name + ": "+$.i18n('core-views/best-cand-type-match'),
|
||||||
"columnName" : column.name,
|
"columnName" : column.name,
|
||||||
"expression" : 'forNonBlank(cell.recon.features.typeMatch, v, v, if(isNonBlank(value), if(cell.recon != null, "(no type)", "(unreconciled)"), "(blank)")).toString()'
|
"expression" : 'forNonBlank(cell.recon.features.typeMatch, v, v, if(isNonBlank(value), if(cell.recon != null, "(no type)", "(unreconciled)"), "(blank)"))'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scroll" : false
|
"scroll" : false
|
||||||
@ -343,7 +346,7 @@ DataTableColumnHeaderUI.extendMenu(function(column, columnHeaderUI, menu) {
|
|||||||
{
|
{
|
||||||
"name" : column.name + ": "+ $.i18n('core-views/best-cand-name'),
|
"name" : column.name + ": "+ $.i18n('core-views/best-cand-name'),
|
||||||
"columnName" : column.name,
|
"columnName" : column.name,
|
||||||
"expression" : 'forNonBlank(cell.recon.features.nameMatch, v, v, if(isNonBlank(value), if(cell.recon.new,"(new)","(unreconciled)"), "(blank)")).toString()'
|
"expression" : 'forNonBlank(cell.recon.features.nameMatch, v, v, if(isNonBlank(value), "(unreconciled)", "(blank)"))'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"scroll" : false
|
"scroll" : false
|
||||||
|
@ -298,6 +298,13 @@ a.data-table-flag-off {
|
|||||||
padding: @padding_tight;
|
padding: @padding_tight;
|
||||||
.rounded_corners();
|
.rounded_corners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.data-table-topic-popup {
|
||||||
|
z-index: 1010;
|
||||||
|
position: fixed;
|
||||||
|
line-height: 1;
|
||||||
|
white-space: initial;
|
||||||
|
}
|
||||||
|
|
||||||
.data-table-topic-popup-header {
|
.data-table-topic-popup-header {
|
||||||
padding: 0 0 5px;
|
padding: 0 0 5px;
|
||||||
@ -353,4 +360,4 @@ ul.sorting-dialog-blank-error-positions > li {
|
|||||||
margin: 2px;
|
margin: 2px;
|
||||||
cursor: move;
|
cursor: move;
|
||||||
.rounded_corners(3px);
|
.rounded_corners(3px);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user