From 1a93dd886a19c2e3dcfa1a2d2485827b41766bbc Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 19 Feb 2019 16:03:34 +0100 Subject: [PATCH] field common name is used --- frontend-js/src/main/js/Configuration.js | 26 ++++++++++ .../js/gui/admin/ChooseAnnotatorsDialog.js | 8 ++-- .../src/main/js/map/data/BioEntityField.js | 48 +++++++++++++++++++ frontend-js/src/test/js/Configuration-test.js | 6 ++- 4 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 frontend-js/src/main/js/map/data/BioEntityField.js diff --git a/frontend-js/src/main/js/Configuration.js b/frontend-js/src/main/js/Configuration.js index d94274b67a..77a65042bb 100644 --- a/frontend-js/src/main/js/Configuration.js +++ b/frontend-js/src/main/js/Configuration.js @@ -6,6 +6,7 @@ var logger = require('./logger'); var Annotator = require('./map/data/Annotator'); +var BioEntityField = require('./map/data/BioEntityField'); var ConfigurationType = require('./ConfigurationType'); var ConfigurationOption = require('./ConfigurationOption'); var MiriamType = require('./map/data/MiriamType'); @@ -106,6 +107,7 @@ function Configuration(json) { self.setVersion(json.version); self.setBuildDate(json.buildDate); self.setGitHash(json.gitHash); + self.setBioEntityFields(json.bioEntityFields); } } @@ -527,6 +529,30 @@ Configuration.prototype.setAnnotators = function (annotators) { } }; +/** + * + * @param {Object[]} bioEntityFields + */ +Configuration.prototype.setBioEntityFields = function (bioEntityFields) { + this._bioEntityFields = []; + for (var i = 0; i < bioEntityFields.length; i++) { + this._bioEntityFields.push(new BioEntityField(bioEntityFields[i])); + } +}; + +/** + * + * @param {string} name + */ +Configuration.prototype.getBioEntityFieldByName = function (name) { + for (var i = 0; i < this._bioEntityFields.length; i++) { + if (this._bioEntityFields[i].getName() === name) { + return this._bioEntityFields[i]; + } + } + return null; +}; + /** * * @returns {Annotator[]} diff --git a/frontend-js/src/main/js/gui/admin/ChooseAnnotatorsDialog.js b/frontend-js/src/main/js/gui/admin/ChooseAnnotatorsDialog.js index 14d1bd07cb..add98150ad 100644 --- a/frontend-js/src/main/js/gui/admin/ChooseAnnotatorsDialog.js +++ b/frontend-js/src/main/js/gui/admin/ChooseAnnotatorsDialog.js @@ -48,7 +48,7 @@ ChooseAnnotatorsDialog.prototype.createGui = function () { content.appendChild(Functions.createElement({ type: "div", style: "display:table-cell;height:100%", - content: "<div name='elementList' style='height:100%'/>", + content: "<div name='elementList' style='height:100%;padding:10px'/>", xss: false })); @@ -436,6 +436,7 @@ ChooseAnnotatorsDialog.prototype.init = function () { var element = $('[name="elementList"]', self.getElement())[0]; var select = Functions.createElement({ type: "select", + style: "height:100%", onchange: function () { var className = $(this).find(":selected").attr("data"); var type; @@ -522,13 +523,14 @@ ChooseAnnotatorsDialog.prototype.open = function () { */ ChooseAnnotatorsDialog.prototype.getParameterName = function (parameter) { var result; + var field = this.getConfiguration().getBioEntityFieldByName(parameter.getField()); if (parameter.getType() === "CONFIG") { result = parameter.getCommonName(); } else if (parameter.getField() !== undefined && parameter.getField() !== '' && parameter.getAnnotationType() !== undefined && parameter.getAnnotationType() !== '') { - result = "Element '" + parameter.getField() + "' as " + this.getConfiguration().getMiriamTypeByName(parameter.getAnnotationType()).getCommonName(); + result = "Element '" + field.getCommonName() + "' as " + this.getConfiguration().getMiriamTypeByName(parameter.getAnnotationType()).getCommonName(); } else if (parameter.getField() !== undefined && parameter.getField() !== '') { - result = "Element '" + parameter.getField() + "'"; + result = "Element '" + field.getCommonName() + "'"; } else if (parameter.getAnnotationType() !== undefined && parameter.getAnnotationType() !== '') { result = this.getConfiguration().getMiriamTypeByName(parameter.getAnnotationType()).getCommonName(); } else { diff --git a/frontend-js/src/main/js/map/data/BioEntityField.js b/frontend-js/src/main/js/map/data/BioEntityField.js new file mode 100644 index 0000000000..976c217cc7 --- /dev/null +++ b/frontend-js/src/main/js/map/data/BioEntityField.js @@ -0,0 +1,48 @@ +"use strict"; + +/** + * + * @param javaObject + * @constructor + */ +function BioEntityField(javaObject) { + this.setName(javaObject.name); + this.setCommonName(javaObject.commonName); +} + +BioEntityField.prototype = Object.create(Object.prototype); +BioEntityField.prototype.constructor = BioEntityField; + +/** + * + * @param {string} name + */ +BioEntityField.prototype.setName = function (name) { + this._name = name; +}; + +/** + * + * @returns {string} + */ +BioEntityField.prototype.getName = function () { + return this._name; +}; + +/** + * + * @param {string} commonName + */ +BioEntityField.prototype.setCommonName = function (commonName) { + this._commonName = commonName; +}; + +/** + * + * @returns {string} + */ +BioEntityField.prototype.getCommonName = function () { + return this._commonName; +}; + +module.exports = BioEntityField; diff --git a/frontend-js/src/test/js/Configuration-test.js b/frontend-js/src/test/js/Configuration-test.js index 7061e036c4..2398e8fd37 100644 --- a/frontend-js/src/test/js/Configuration-test.js +++ b/frontend-js/src/test/js/Configuration-test.js @@ -25,7 +25,8 @@ describe('Configuration', function () { mapTypes: {}, modificationStateTypes: {}, privilegeTypes: {}, - annotators: {} + annotators: {}, + bioEntityFields: [] }); assert.ok(configuration); assert.equal(0, logger.getWarnings().length); @@ -140,7 +141,8 @@ describe('Configuration', function () { mapTypes: {}, modificationStateTypes: {}, privilegeTypes: {}, - annotators: {} + annotators: {}, + bioEntityFields: [] }); it('for valid value', function () { assert.ok(conf.getBooleanValue("BOOLEAN_OPTION_OK")); -- GitLab