diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js index bf6861d2c1539b70371e2c4f8c00d3a27b02550d..b883dc17fe80edd1afaaeffc89483e087538bed2 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-search.js @@ -667,5 +667,26 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common', 'test/naturalsort' ], testSearch(c, fSearch, fCheck); }); + QUnit.test("searchVocabularyTerms()", function(assert) { + var c = new common(assert); + + var fSearch = function(facade) { + var criteria = new c.VocabularyTermSearchCriteria(); + criteria.withCode().thatEquals("BDS_DIRECTORY"); + return facade.searchVocabularyTerms(criteria, c.createVocabularyTermFetchOptions()); + } + + var fCheck = function(facade, terms) { + c.assertEqual(terms.length, 1); + var term = terms[0]; + c.assertEqual(term.getCode(), "BDS_DIRECTORY", "Code"); + c.assertEqual(term.getVocabulary().getCode(), "$STORAGE_FORMAT", "Vocabulary code"); + c.assertEqual(term.getOrdinal(), 2, "Ordinal"); + c.assertEqual(term.isOfficial(), true, "Official"); + } + + testSearch(c, fSearch, fCheck); + }); + } }); diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js index 83f4ddea5f15a73249b99dc41e64212a163c4010..a48032a5a43164c020a35f0edfc150de6e319986 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-update.js @@ -6,11 +6,10 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open c.start(); var ctx = { - facade: null, - permIds: null + facade : null, + permIds : null }; - c.createFacadeAndLogin() - .then(function(facade) { + c.createFacadeAndLogin().then(function(facade) { ctx.facade = facade; return fCreate(facade) }).then(function(permIds) { @@ -362,5 +361,33 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open testUpdate(c, fCreate, fUpdate, c.findMaterial, fCheck); }); + QUnit.test("updateVocabularyTerms()", function(assert) { + var c = new common(assert); + var code = c.generateId("VOCABULARY_TERM"); + var description = "Description of " + code; + + var fCreate = function(facade) { + var termCreation = new c.VocabularyTermCreation(); + termCreation.setVocabularyId(new c.VocabularyPermId("TEST-VOCABULARY")); + termCreation.setCode(code); + return facade.createVocabularyTerms([ termCreation ]); + } + + var fUpdate = function(facade, permId) { + var termUpdate = new c.VocabularyTermUpdate(); + termUpdate.setVocabularyTermId(permId); + termUpdate.setDescription(description); + return facade.updateVocabularyTerms([ termUpdate ]); + } + + var fCheck = function(term) { + c.assertEqual(term.getCode(), code, "Term code"); + c.assertEqual(term.getVocabulary().getCode(), "TEST-VOCABULARY", "Term vocabulary code"); + c.assertEqual(term.getDescription(), description, "Term description"); + } + + testUpdate(c, fCreate, fUpdate, c.findVocabularyTerm, fCheck); + }); + } }); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/vocabulary/search/VocabularyTermSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/vocabulary/search/VocabularyTermSearchCriteria.js index b5cb217cfffc5a99cfd8e4c10076b23a95126b79..29140664876ba3c9998032c6d90550bc5831bf84 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/vocabulary/search/VocabularyTermSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/vocabulary/search/VocabularyTermSearchCriteria.js @@ -1,29 +1,32 @@ /** * @author pkupczyk */ -define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria"], - function(require, stjs, AbstractObjectSearchCriteria) { +define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", "as/dto/common/search/CodeSearchCriteria", "as/dto/common/search/PermIdSearchCriteria", + "as/dto/vocabulary/search/VocabularySearchCriteria" ], function(require, stjs, AbstractObjectSearchCriteria) { var VocabularyTermSearchCriteria = function() { AbstractObjectSearchCriteria.call(this); }; stjs.extend(VocabularyTermSearchCriteria, AbstractObjectSearchCriteria, [ AbstractObjectSearchCriteria ], function(constructor, prototype) { prototype['@type'] = 'as.dto.vocabulary.search.VocabularyTermSearchCriteria'; constructor.serialVersionUID = 1; - + prototype.withPermId = function() { - return this.with(new require("as/dto/common/search/PermIdSearchCriteria")()); + var PermIdSearchCriteria = require("as/dto/common/search/PermIdSearchCriteria"); + return this.addCriteria(new PermIdSearchCriteria()); }; prototype.withCode = function() { - return this.addCriteria(new require("as/dto/common/search/CodeSearchCriteria")()); + var CodeSearchCriteria = require("as/dto/common/search/CodeSearchCriteria"); + return this.addCriteria(new CodeSearchCriteria()); }; prototype.withVocabulary = function() { - return this.with(new require("as/dto/vocabulary/search/VocabularySearchCriteria")()); + var VocabularySearchCriteria = require("as/dto/vocabulary/search/VocabularySearchCriteria"); + return this.addCriteria(new VocabularySearchCriteria()); }; }, { -// criteria : { -// name : "Collection", -// arguments : [ "ISearchCriteria" ] -// } + criteria : { + name : "Collection", + arguments : [ "ISearchCriteria" ] + } }); return VocabularyTermSearchCriteria; }) \ No newline at end of file