From 2ced47176a6fa9dd318f59cbde96df5ad6d30a78 Mon Sep 17 00:00:00 2001 From: fedoreno <fedoreno> Date: Thu, 10 Mar 2016 10:41:02 +0000 Subject: [PATCH] SSDM-3284: fixed remaining mistakenly generated string builders, JSON can now create objects with no default constructors SVN: 35862 --- .../search/AbstractCompositeSearchCriteria.js | 11 ---- .../search/AbstractEntitySearchCriteria.js | 6 -- .../search/SearchCriteriaToStringBuilder.js | 58 ------------------- .../dataset/search/DataSetSearchCriteria.js | 5 -- .../deletion/search/DeletionSearchCriteria.js | 6 -- .../search/EntityTypeSearchCriteria.js | 6 -- .../search/ExperimentSearchCriteria.js | 5 -- .../dto/global/search/GlobalSearchCriteria.js | 6 -- .../material/search/MaterialSearchCriteria.js | 5 -- .../project/search/ProjectSearchCriteria.js | 6 -- .../dto/sample/search/SampleSearchCriteria.js | 5 -- .../search/CustomASServiceSearchCriteria.js | 6 -- .../dto/space/search/SpaceSearchCriteria.js | 6 -- .../v3/as/dto/tag/search/TagSearchCriteria.js | 6 -- .../public/resources/api/v3/util/Json.js | 8 ++- 15 files changed, 6 insertions(+), 139 deletions(-) delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/SearchCriteriaToStringBuilder.js diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractCompositeSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractCompositeSearchCriteria.js index 02d2df10501..0a4e7d033ff 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractCompositeSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractCompositeSearchCriteria.js @@ -29,17 +29,6 @@ define([ "stjs", "as/dto/common/search/AbstractSearchCriteria", "as/dto/common/s prototype.withAndOperator = function() { this.operator = SearchOperator.AND; } - prototype.toString = function() { - return this.toString(""); - }; - prototype.toString = function(indentation) { - return this.createBuilder().toString(indentation); - }; - prototype.createBuilder = function() { - var builder = new SearchCriteriaToStringBuilder(); - builder.setCriteria(this.criteria); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractEntitySearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractEntitySearchCriteria.js index aaf12115e27..005fa13634e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractEntitySearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/AbstractEntitySearchCriteria.js @@ -65,12 +65,6 @@ define( var AnyFieldSearchCriteria = require("as/dto/common/search/AnyFieldSearchCriteria"); return this.addCriteria(new AnyFieldSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setOperator(this.operator); - return builder; - }; }, { operator : { name : "Enum", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/SearchCriteriaToStringBuilder.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/SearchCriteriaToStringBuilder.js deleted file mode 100644 index 8e5c82ceb17..00000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/common/search/SearchCriteriaToStringBuilder.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @author pkupczyk - */ -define([ "stjs", "as/dto/common/search/AbstractCompositeSearchCriteria" ], function(stjs, AbstractCompositeSearchCriteria) { - var SearchCriteriaToStringBuilder = function() { - }; - stjs.extend(SearchCriteriaToStringBuilder, null, [], function(constructor, prototype) { - prototype['@type'] = 'as.dto.common.search.SearchCriteriaToStringBuilder'; - prototype.name = null; - prototype.operator = null; - prototype.criteria = null; - prototype.setName = function(name) { - this.name = name; - return this; - }; - prototype.setOperator = function(operator) { - this.operator = operator; - return this; - }; - prototype.setCriteria = function(criteria) { - this.criteria = criteria; - return this; - }; - prototype.toString = function(anIndentation) { - // TODO rewrite to JS version - var sb = new StringBuilder(); - var indentation = anIndentation; - if (indentation.isEmpty()) { - sb.append(this.name.toUpperCase() + "\n"); - } else { - sb.append(indentation + "with " + this.name.toLowerCase() + ":\n"); - } - indentation += " "; - if (this.operator != null) { - sb.append(indentation + "with operator '" + this.operator + "'\n"); - } - for ( var criterion in this.criteria) { - if (stjs.isInstanceOf(criterion.constructor, AbstractCompositeSearchCriteria)) { - var compositeCriteria = criterion; - sb.append(compositeCriteria.toString(indentation)); - } else { - sb.append(indentation + criterion.toString() + "\n"); - } - } - return sb.toString(); - }; - }, { - operator : { - name : "Enum", - arguments : [ "SearchOperator" ] - }, - criteria : { - name : "Collection", - arguments : [ "ISearchCriteria" ] - } - }); - return SearchCriteriaToStringBuilder; -}) \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/dataset/search/DataSetSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/dataset/search/DataSetSearchCriteria.js index b2361796ce8..140ef89a188 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/dataset/search/DataSetSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/dataset/search/DataSetSearchCriteria.js @@ -46,11 +46,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractEntitySearchCriteria", prototype.getRelation = function() { return this.relation; }; - prototype.createBuilder = function() { - var builder = AbstractEntitySearchCriteria.prototype.createBuilder.call(this); - builder.setName(this.relation.name()); - return builder; - }; }, { relation : { name : "Enum", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/deletion/search/DeletionSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/deletion/search/DeletionSearchCriteria.js index 0a4c8421eba..1e15697c751 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/deletion/search/DeletionSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/deletion/search/DeletionSearchCriteria.js @@ -5,12 +5,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria" stjs.extend(DeletionSearchCriteria, AbstractObjectSearchCriteria, [ AbstractObjectSearchCriteria ], function(constructor, prototype) { prototype['@type'] = 'as.dto.deletion.search.DeletionSearchCriteria'; constructor.serialVersionUID = 1; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("DELETION"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/entitytype/search/EntityTypeSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/entitytype/search/EntityTypeSearchCriteria.js index ea2692a48ea..b8660825597 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/entitytype/search/EntityTypeSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/entitytype/search/EntityTypeSearchCriteria.js @@ -17,12 +17,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", var PermIdSearchCriteria = require("as/dto/common/search/PermIdSearchCriteria"); return this.addCriteria(new PermIdSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("TYPE"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/experiment/search/ExperimentSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/experiment/search/ExperimentSearchCriteria.js index 1ecb1b0bac2..6e31f502b88 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/experiment/search/ExperimentSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/experiment/search/ExperimentSearchCriteria.js @@ -19,11 +19,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractEntitySearchCriteria", prototype.withAndOperator = function() { return this.withOperator(SearchOperator.AND); }; - prototype.createBuilder = function() { - var builder = AbstractEntitySearchCriteria.prototype.createBuilder.call(this); - builder.setName("EXPERIMENT"); - return builder; - }; }, { operator : { name : "Enum", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/global/search/GlobalSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/global/search/GlobalSearchCriteria.js index e139c9d599a..b875e7ffa5d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/global/search/GlobalSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/global/search/GlobalSearchCriteria.js @@ -21,12 +21,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractCompositeSearchCriteri var GlobalSearchWildCardsCriteria = require("as/dto/global/search/GlobalSearchWildCardsCriteria"); return this.addCriteria(new GlobalSearchWildCardsCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("GLOBAL_SEARCH"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/material/search/MaterialSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/material/search/MaterialSearchCriteria.js index 8edef0f1420..886538bc231 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/material/search/MaterialSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/material/search/MaterialSearchCriteria.js @@ -14,11 +14,6 @@ define([ "stjs", "as/dto/common/search/AbstractEntitySearchCriteria", "as/dto/co prototype.withAndOperator = function() { return this.withOperator(SearchOperator.AND); }; - prototype.createBuilder = function() { - var builder = AbstractEntitySearchCriteria.prototype.createBuilder.call(this); - builder.setName("MATERIAL"); - return builder; - }; }, { operator : { name : "Enum", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/project/search/ProjectSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/project/search/ProjectSearchCriteria.js index 0bbb3ce3215..35cf131ef82 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/project/search/ProjectSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/project/search/ProjectSearchCriteria.js @@ -21,12 +21,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", var SpaceSearchCriteria = require("as/dto/space/search/SpaceSearchCriteria"); return this.addCriteria(new SpaceSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("PROJECT"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/sample/search/SampleSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/sample/search/SampleSearchCriteria.js index 714bf8daa59..62fcd50caf5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/sample/search/SampleSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/sample/search/SampleSearchCriteria.js @@ -47,11 +47,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractEntitySearchCriteria", prototype.getRelation = function() { return this.relation; }; - prototype.createBuilder = function() { - var builder = AbstractEntitySearchCriteria.prototype.createBuilder.call(this); - builder.setName(this.relation.name()); - return builder; - }; }, { relation : { name : "Enum", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/service/search/CustomASServiceSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/service/search/CustomASServiceSearchCriteria.js index 3dcfff41ab0..323b2f20562 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/service/search/CustomASServiceSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/service/search/CustomASServiceSearchCriteria.js @@ -10,12 +10,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", var CodeSearchCriteria = require("as/dto/common/search/CodeSearchCriteria"); return this.addCriteria(new CodeSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("CUSTOM_AS_SERVICE"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/space/search/SpaceSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/space/search/SpaceSearchCriteria.js index 04ceb951c99..69f39e1c921 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/space/search/SpaceSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/space/search/SpaceSearchCriteria.js @@ -17,12 +17,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", var PermIdSearchCriteria = require("as/dto/common/search/PermIdSearchCriteria"); return this.addCriteria(new PermIdSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("SPACE"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/tag/search/TagSearchCriteria.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/tag/search/TagSearchCriteria.js index 4aa7f9032ce..9ebf822eb06 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/tag/search/TagSearchCriteria.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/as/dto/tag/search/TagSearchCriteria.js @@ -17,12 +17,6 @@ define([ "require", "stjs", "as/dto/common/search/AbstractObjectSearchCriteria", var PermIdSearchCriteria = require("as/dto/common/search/PermIdSearchCriteria"); return this.addCriteria(new PermIdSearchCriteria()); }; - prototype.createBuilder = function() { - var AbstractCompositeSearchCriteria = require("as/dto/common/search/AbstractCompositeSearchCriteria"); - var builder = AbstractCompositeSearchCriteria.prototype.createBuilder.call(this); - builder.setName("TAG"); - return builder; - }; }, { criteria : { name : "Collection", diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/util/Json.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/util/Json.js index 340b53d5cbc..82b676a177b 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/util/Json.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/api/v3/util/Json.js @@ -87,7 +87,7 @@ define([ "underscore" ], function(_) { if (jsonObject in hashedObjects) { return hashedObjects[jsonObject]; } else { - throw "Object with id: " + jsonObject + " and type: " + jsonType + " haven't been found in cache"; + throw "Object with id: " + JSON.stringify(jsonObject) + " and type: " + jsonType + " haven't been found in cache"; } } else { return jsonObject; @@ -102,7 +102,11 @@ define([ "underscore" ], function(_) { var moduleName = typeToModuleName(jsonType); var module = modulesMap[moduleName]; var moduleFieldTypeMap = module.$typeDescription || {}; - var object = new module; + try { + var object = new module(""); // some entities have a mandatory non-null constructor parameters + } catch(e) { + throw "Failed deserializing object " + JSON.stringify(jsonObject) + " into type " + jsonType + " with error " + e.message; + } if (jsonId) { if (jsonId in hashedObjects) { -- GitLab