diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java index 49eeac4544ae0fe225ee2e6b3c217db22168069a..9c56946df5a22c97f6d8d804fa65f02d9ca376e6 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java @@ -21,10 +21,12 @@ import java.io.Serializable; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; import ch.systemsx.cisd.common.io.IOUtilities; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * Represents information about a file stored in DSS. @@ -92,6 +94,7 @@ public class FileInfoDssDTO implements Serializable * Return the file size if this FileInfo represents a file. If this FileInfo represents a * folder, the return value is negative. */ + @JsonIgnore public long getFileSize() { return fileSize; @@ -147,10 +150,23 @@ public class FileInfoDssDTO implements Serializable this.isDirectory = isDirectory; } + @JsonIgnore private void setFileSize(long fileSize) { this.fileSize = fileSize; } + + @JsonProperty("fileSize") + private String getFileSizeAsString() + { + return JsonPropertyUtil.toStringOrNull(fileSize); + } + + private void setFileSizeAsString(String fileSize) + { + this.fileSize = JsonPropertyUtil.toLongOrNull(fileSize); + } + private void setCrc32Checksum(int crc32Checksum) { diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/ShareInfo.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/ShareInfo.java index 67be121f09166b4d8885f8fabf4a85d7d4a738d7..2ccc9993a1b481dfd30009d9f9102f3a4258cb0f 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/ShareInfo.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/ShareInfo.java @@ -18,7 +18,11 @@ package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * Information about a share. @@ -44,6 +48,7 @@ public class ShareInfo implements Serializable return shareId; } + @JsonIgnore public long getFreeSpace() { return freeSpace; @@ -62,9 +67,21 @@ public class ShareInfo implements Serializable this.shareId = shareId; } + @JsonIgnore private void setFreeSpace(long freeSpace) { this.freeSpace = freeSpace; } + @JsonProperty("freeSpace") + private String getFreeSpaceAsString() + { + return JsonPropertyUtil.toStringOrNull(freeSpace); + } + + private void setFreeSpaceAsString(String freeSpace) + { + this.freeSpace = JsonPropertyUtil.toLongOrNull(freeSpace); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/dto/QueryDescription.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/dto/QueryDescription.java index a1879725ee67f8285e8175f8bfc5e8b007628b98..bac747fbfe474b16d0fa9c4bca1231d13e37eb69 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/dto/QueryDescription.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/shared/api/v1/dto/QueryDescription.java @@ -19,7 +19,11 @@ package ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto; import java.io.Serializable; import java.util.List; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * Description of a query. Contains everything needed on client side to show to the user what @@ -27,6 +31,7 @@ import ch.systemsx.cisd.base.annotation.JsonObject; * * @author Franz-Josef Elmer */ +@SuppressWarnings("unused") @JsonObject("QueryDescription") public class QueryDescription implements Serializable { @@ -43,11 +48,13 @@ public class QueryDescription implements Serializable /** * Returns the ID of the query. Will be used to identify the query to be executed. */ + @JsonIgnore public long getId() { return id; } + @JsonIgnore public void setId(long id) { this.id = id; @@ -130,4 +137,20 @@ public class QueryDescription implements Serializable { return name; } + + // + // JSON-RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js index 8ed25dcd20a196738a9913add7f9d336637774aa..aa7c6d118e6161defc8a79549869411a135d452a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js @@ -90,63 +90,99 @@ _openbisInternal.prototype.eraseCookie = function(name) { this.createCookie(name,"",-1); } -_openbisInternal.prototype.getDataStoreUrlForDataStoreCode = function(dataStoreCodeOrNull) { - if(this.dataStores.length == 0){ - throw "Couldn't get a data store url as there are no data stores configured."; - }else{ - if(dataStoreCodeOrNull){ - var dataStoreUrl = null; - $.each(this.dataStores, function(index, dataStore){ - if(dataStore.code == dataStoreCodeOrNull){ - dataStoreUrl = dataStore.downloadUrl; - } - }); - if(dataStoreUrl){ - return dataStoreUrl; +_openbisInternal.prototype.listDataStores = function(action){ + this.ajaxRequest({ + url: this.generalInfoServiceUrl, + data: { "method" : "listDataStores", + "params" : [ this.sessionToken ] + }, + success: action + }); +} + +_openbisInternal.prototype.initDataStores = function(action){ + var openbisInternal = this; + + if(typeof this.dataStores === "undefined"){ + this.listDataStores(function(response){ + if(response.result){ + openbisInternal.dataStores = response.result; }else{ - throw "Couldn't get a data store url because data store with " + dataStoreCodeOrNull + " code does not exist."; + openbisInternal.dataStores = []; } + action(); + }); + }else{ + action(); + } +} + +_openbisInternal.prototype.getDataStoreUrlForDataStoreCode = function(dataStoreCodeOrNull, action) { + var openbisInternal = this; + + this.initDataStores(function(){ + if(openbisInternal.dataStores.length == 0){ + throw "Couldn't get a data store url as there are no data stores configured."; }else{ - if(this.dataStores.length == 1){ - return this.dataStores[0].downloadUrl; + if(dataStoreCodeOrNull){ + var dataStoreUrl = null; + $.each(openbisInternal.dataStores, function(index, dataStore){ + if(dataStore.code == dataStoreCodeOrNull){ + dataStoreUrl = dataStore.downloadUrl; + } + }); + if(dataStoreUrl){ + action(dataStoreUrl); + }else{ + throw "Couldn't get a data store url because data store with " + dataStoreCodeOrNull + " code does not exist."; + } }else{ - throw "There is more than one data store configured. Please specify a data store code to get a data store url."; + if(openbisInternal.dataStores.length == 1){ + action(openbisInternal.dataStores[0].downloadUrl); + }else{ + throw "There is more than one data store configured. Please specify a data store code to get a data store url."; + } } } - } + }); } _openbisInternal.prototype.getDataStoreUrlForDataSetCode = function(dataSetCode, action) { - if(this.dataStores.length == 0){ - throw "Couldn't get a data store url as there are no data stores configured."; - }else if(this.dataStores.length == 1){ - action(this.dataStores[0].downloadUrl); - }else{ - this.ajaxRequest({ - url: this.generalInfoServiceUrl, - data: { "method" : "tryGetDataStoreBaseURL", - "params" : [ this.sessionToken, dataSetCode ] - }, - success: function(response){ - var hostUrl = response.result; - - if(hostUrl){ - action(hostUrl + "/datastore_server"); - }else{ - action(null); + var openbisInternal = this; + + this.initDataStores(function(){ + if(openbisInternal.dataStores.length == 0){ + throw "Couldn't get a data store url as there are no data stores configured."; + }else if(openbisInternal.dataStores.length == 1){ + action(openbisInternal.dataStores[0].downloadUrl); + }else{ + openbisInternal.ajaxRequest({ + url: openbisInternal.generalInfoServiceUrl, + data: { "method" : "tryGetDataStoreBaseURL", + "params" : [ openbisInternal.sessionToken, dataSetCode ] + }, + success: function(response){ + var hostUrl = response.result; + + if(hostUrl){ + action(hostUrl + "/datastore_server"); + }else{ + action(null); + } } - } - }); - } + }); + } + }); } -_openbisInternal.prototype.getDataStoreApiUrlForDataStoreCode = function(dataStoreCodeOrNull) { - var dataStoreUrl = this.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull); - if(dataStoreUrl){ - return dataStoreUrl + "/rmi-dss-api-v1.json"; - }else{ - return null; - } +_openbisInternal.prototype.getDataStoreApiUrlForDataStoreCode = function(dataStoreCodeOrNull, action) { + this.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){ + if(dataStoreUrl){ + action(dataStoreUrl + "/rmi-dss-api-v1.json"); + }else{ + action(null); + } + }); } _openbisInternal.prototype.getDataStoreApiUrlForDataSetCode = function(dataSetCode, action) { @@ -203,15 +239,11 @@ openbis.prototype.login = function(userId, userPassword, action) { function(loginResponse) { if(loginResponse.error){ alert("Login failed"); - action(loginResponse); }else{ openbisObj._internal.sessionToken = loginResponse.result; openbisObj.rememberSession(); - openbisObj.listDataStores(function(storesResponse){ - openbisObj._internal.dataStores = storesResponse.result; - action(loginResponse) - }); } + action(loginResponse); } }); } @@ -530,13 +562,7 @@ openbis.prototype.listDataSetsForSample = function(sample, restrictToDirectlyCon * @method */ openbis.prototype.listDataStores = function(action) { - this._internal.ajaxRequest({ - url: this._internal.generalInfoServiceUrl, - data: { "method" : "listDataStores", - "params" : [ this.getSession() ] - }, - success: action - }); + this._internal.listDataStores(action); } /** @@ -1244,24 +1270,24 @@ openbis.prototype.createSessionWorkspaceUploaderForDataStore = function(uploader } var $this = this; - var dataStoreUrl = this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull); + this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){ + // figure out what is the location of the openbis.js script and assume that uploader resources are served by the same server + var openbisScriptLocation = $('script[src*=openbis\\.js]').attr('src'); + var uploaderDirectoryLocation = jsFileLocation = openbisScriptLocation.replace(/js\/openbis\.js/g, 'uploader'); - // figure out what is the location of the openbis.js script and assume that uploader resources are served by the same server - var openbisScriptLocation = $('script[src*=openbis\\.js]').attr('src'); - var uploaderDirectoryLocation = jsFileLocation = openbisScriptLocation.replace(/js\/openbis\.js/g, 'uploader'); - - $('head').append('<link rel="stylesheet" media="screen" type="text/css" href="' + uploaderDirectoryLocation + '/css/src/upload.css" />'); - $('head').append('<script charset="utf-8" type="text/javascript" src="' + uploaderDirectoryLocation + '/js/src/upload.js" />'); - - $(uploaderContainer).load(uploaderDirectoryLocation + "/index.html", function(){ - Uploader.init({ - smart_mode: true, - chunk_size: 1000*1024, - file_upload_url: dataStoreUrl + "/session_workspace_file_upload", - form_upload_url: dataStoreUrl + "/session_workspace_form_upload", - file_download_url: dataStoreUrl + "/session_workspace_file_download", - oncomplete: oncomplete, - sessionID: $this.getSession() + $('head').append('<link rel="stylesheet" media="screen" type="text/css" href="' + uploaderDirectoryLocation + '/css/src/upload.css" />'); + $('head').append('<script charset="utf-8" type="text/javascript" src="' + uploaderDirectoryLocation + '/js/src/upload.js" />'); + + $(uploaderContainer).load(uploaderDirectoryLocation + "/index.html", function(){ + Uploader.init({ + smart_mode: true, + chunk_size: 1000*1024, + file_upload_url: dataStoreUrl + "/session_workspace_file_upload", + form_upload_url: dataStoreUrl + "/session_workspace_form_upload", + file_download_url: dataStoreUrl + "/session_workspace_file_download", + oncomplete: oncomplete, + sessionID: $this.getSession() + }); }); }); } @@ -1270,33 +1296,40 @@ openbis.prototype.createSessionWorkspaceUploaderForDataStore = function(uploader * Creates a session workspace download url for a file with the specified filePath and for the default data store. * @method */ -openbis.prototype.createSessionWorkspaceDownloadUrl = function(filePath){ - return this.createSessionWorkspaceDownloadUrlForDataStore(filePath, null); +openbis.prototype.createSessionWorkspaceDownloadUrl = function(filePath, action){ + return this.createSessionWorkspaceDownloadUrlForDataStore(filePath, null, action); } /** * Creates a session workspace download url for a file with the specified filePath and for the specified data store. * @method */ -openbis.prototype.createSessionWorkspaceDownloadUrlForDataStore = function(filePath, dataStoreCodeOrNull){ - var dataStoreUrl = this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull); - return dataStoreUrl + "/session_workspace_file_download?sessionID=" + this.getSession() + "&filePath=" + filePath; +openbis.prototype.createSessionWorkspaceDownloadUrlForDataStore = function(filePath, dataStoreCodeOrNull, action){ + var openbisObj = this; + + this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){ + var downloadUrl = dataStoreUrl + "/session_workspace_file_download?sessionID=" + openbisObj.getSession() + "&filePath=" + filePath; + action(downloadUrl); + }); } /** * Create a session workspace download link for a file with the specified filePath at the default data store. * @method */ -openbis.prototype.createSessionWorkspaceDownloadLink = function(filePath, linkText){ - return this.createSessionWorkspaceDownloadLinkForDataStore(filePath, linkText, null); +openbis.prototype.createSessionWorkspaceDownloadLink = function(filePath, linkText, action){ + return this.createSessionWorkspaceDownloadLinkForDataStore(filePath, linkText, null, action); } /** * Create a session workspace download link for a file with the specified filePath at the specified data store. * @method */ -openbis.prototype.createSessionWorkspaceDownloadLinkForDataStore = function(filePath, linkText, dataStoreCodeOrNull){ - return $("<a href='" + this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull) + "'>" + (linkText ? linkText : filePath) + "</a>"); +openbis.prototype.createSessionWorkspaceDownloadLinkForDataStore = function(filePath, linkText, dataStoreCodeOrNull, action){ + this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull, function(downloadUrl){ + var link = $("<a href='" + downloadUrl + "'>" + (linkText ? linkText : filePath) + "</a>"); + action(link); + }); } /** @@ -1312,12 +1345,16 @@ openbis.prototype.downloadSessionWorkspaceFile = function(filePath, action) { * @method */ openbis.prototype.downloadSessionWorkspaceFileForDataStore = function(filePath, dataStoreCodeOrNull, action) { - $.ajax({ - type: "GET", - dataType: "text", - url: this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull), - success: this._internal.ajaxRequestSuccess(action), - error: this._internal.ajaxRequestError(action) + var openbisObj = this; + + this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull, function(downloadUrl){ + $.ajax({ + type: "GET", + dataType: "text", + url: downloadUrl, + success: openbisObj._internal.ajaxRequestSuccess(action), + error: openbisObj._internal.ajaxRequestError(action) + }); }); } @@ -1334,13 +1371,17 @@ openbis.prototype.deleteSessionWorkspaceFile = function(filePath, action) { * @method */ openbis.prototype.deleteSessionWorkspaceFileForDataStore = function(filePath, dataStoreCodeOrNull, action) { - this._internal.ajaxRequest({ - url: this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull), - data: { - "method" : "deleteSessionWorkspaceFile", - "params" : [ this.getSession(), filePath ] - }, - success: action + var openbisObj = this; + + this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){ + openbisObj._internal.ajaxRequest({ + url: dataStoreApiUrl, + data: { + "method" : "deleteSessionWorkspaceFile", + "params" : [ openbisObj.getSession(), filePath ] + }, + success: action + }); }); } @@ -1377,13 +1418,17 @@ openbis.prototype.listAllShares = function(action) { * @method */ openbis.prototype.listAllSharesForDataStore = function(dataStoreCodeOrNull, action) { - this._internal.ajaxRequest({ - url: this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull), - data: { - "method" : "listAllShares", - "params" : [ this.getSession() ] - }, - success: action + var openbisObj = this; + + this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){ + openbisObj._internal.ajaxRequest({ + url: dataStoreApiUrl, + data: { + "method" : "listAllShares", + "params" : [ openbisObj.getSession() ] + }, + success: action + }); }); } @@ -1420,13 +1465,17 @@ openbis.prototype.getValidationScript = function(dataSetTypeOrNull, action) { * @method */ openbis.prototype.getValidationScriptForDataStore = function(dataSetTypeOrNull, dataStoreCodeOrNull, action) { - this._internal.ajaxRequest({ - url: this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull), - data: { - "method" : "getValidationScript", - "params" : [ this.getSession(), dataSetTypeOrNull ] - }, - success: action + var openbisObj = this; + + this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){ + openbisObj._internal.ajaxRequest({ + url: dataStoreApiUrl, + data: { + "method" : "getValidationScript", + "params" : [ openbisObj.getSession(), dataSetTypeOrNull ] + }, + success: action + }); }); } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSet.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSet.java index afc637eab6e1b0cad5eeaa966ee5969c7c8e3839..33e23867809c4371eff946d511abf148d04a9657 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSet.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataSet.java @@ -34,6 +34,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalDataManagementSystem; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; @@ -74,7 +75,7 @@ public final class DataSet implements Serializable, IIdHolder private String dataSetTypeCode; private boolean containerDataSet; - + private boolean linkDataSet; private String externalDataSetCode; @@ -337,7 +338,7 @@ public final class DataSet implements Serializable, IIdHolder private List<String> childrenCodes = Collections.emptyList(); private List<DataSet> containedDataSets = Collections.emptyList(); - + private DataSet containerOrNull; private EntityRegistrationDetails registrationDetails; @@ -397,6 +398,7 @@ public final class DataSet implements Serializable, IIdHolder * Returns tech id of the data set. */ @Override + @JsonIgnore public Long getId() { return id; @@ -609,6 +611,17 @@ public final class DataSet implements Serializable, IIdHolder { } + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + private void setCode(String code) { this.code = code; diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Experiment.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Experiment.java index 082f355a7b84bd75ef2a71a1a6f1e280da0b143e..50120685b7b218bc44b8d012c69d03b7f8176e48 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Experiment.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Experiment.java @@ -28,9 +28,11 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; @@ -223,6 +225,7 @@ public final class Experiment implements Serializable, IIdentifierHolder, IIdHol * Returns the experiment id. */ @Override + @JsonIgnore public Long getId() { return id; @@ -335,10 +338,22 @@ public final class Experiment implements Serializable, IIdentifierHolder, IIdHol { } + @JsonIgnore private void setId(Long id) { this.id = id; } + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } private void setPermId(String permId) { diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Material.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Material.java index 470ad0bdd0b09097eb5679415fcea1d09ba523d6..91c87f945ab7bc024cb5dc17fd94ab64e83b1fce 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Material.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Material.java @@ -21,7 +21,11 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; @@ -143,6 +147,7 @@ public class Material extends MaterialIdentifier implements IIdHolder } @Override + @JsonIgnore public Long getId() { return id; @@ -183,6 +188,17 @@ public class Material extends MaterialIdentifier implements IIdHolder { super(null, null); } + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } private void setProperties(Map<String, String> properties) { diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/NewVocabularyTerm.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/NewVocabularyTerm.java index 3006c706ebe39cb8d3d12d43147b818b1d872140..9732dfb6e4c83afa8e80a8c8358fc98cd5583595 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/NewVocabularyTerm.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/NewVocabularyTerm.java @@ -18,13 +18,18 @@ package ch.systemsx.cisd.openbis.generic.shared.api.v1.dto; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * A value object representing a new vocabulary term to be created by the openBIS backend. * * @author Kaloyan Enimanev */ +@SuppressWarnings("unused") @JsonObject("NewVocabularyTerm") public class NewVocabularyTerm implements Serializable { @@ -89,6 +94,7 @@ public class NewVocabularyTerm implements Serializable /** * Return the position of predecessor term in the vocabulary. */ + @JsonIgnore public Long getPreviousTermOrdinal() { return previousTermOrdinal; @@ -97,6 +103,7 @@ public class NewVocabularyTerm implements Serializable /** * Set the position of predecessor term in the vocabulary. */ + @JsonIgnore public void setPreviousTermOrdinal(Long previousTermOrdinal) { this.previousTermOrdinal = previousTermOrdinal; @@ -109,4 +116,19 @@ public class NewVocabularyTerm implements Serializable + description + ", previousTermOrdinal=" + previousTermOrdinal + "]"; } + // + // JSON-RPC + // + + @JsonProperty("previousTermOrdinal") + private String getPreviousTermOrdinalAsString() + { + return JsonPropertyUtil.toStringOrNull(previousTermOrdinal); + } + + private void setPreviousTermOrdinalAsString(String previousTermOrdinal) + { + this.previousTermOrdinal = JsonPropertyUtil.toLongOrNull(previousTermOrdinal); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Project.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Project.java index 7847b2737a6ef795aed5f88fe4341f6c40d23829..6def9e150f35209e1c8926900dd434cd47177c6d 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Project.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Project.java @@ -19,8 +19,10 @@ package ch.systemsx.cisd.openbis.generic.shared.api.v1.dto; import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder; /** @@ -78,14 +80,15 @@ public final class Project implements Serializable, IIdentifierHolder checkAndSetCodes(spaceCode, code); this.registrationDetails = registrationDetails; } - + /** * Creates a new instance for the specified space code and project code. * * @throws IllegalArgumentException if either the code or the space code is <code>null</code> or * an empty string. */ - public Project(Long id, String permId, String spaceCode, String code, EntityRegistrationDetails registrationDetails) + public Project(Long id, String permId, String spaceCode, String code, + EntityRegistrationDetails registrationDetails) { if (id == null || id == 0) { @@ -121,6 +124,7 @@ public final class Project implements Serializable, IIdentifierHolder * * @since 1.22 */ + @JsonIgnore public Long getId() { return id; @@ -151,7 +155,7 @@ public final class Project implements Serializable, IIdentifierHolder { return code; } - + @Override @JsonIgnore public String getIdentifier() @@ -281,11 +285,23 @@ public final class Project implements Serializable, IIdentifierHolder { } + @JsonIgnore private void setId(Long id) { this.id = id; } + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + private void setPermId(String permId) { this.permId = permId; diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Sample.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Sample.java index 90fe02f3fc2df1f489a60640262c3fac868f9032..13cb2a52babede08b7c6bd34e5f41f9b965717d7 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Sample.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Sample.java @@ -33,6 +33,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; @@ -380,6 +381,7 @@ public final class Sample implements Serializable, IIdentifierHolder, IIdHolder * Returns the sample id. */ @Override + @JsonIgnore public Long getId() { return id; @@ -426,6 +428,7 @@ public final class Sample implements Serializable, IIdentifierHolder, IIdHolder /** * Returns the sample type id. */ + @JsonIgnore public Long getSampleTypeId() { return sampleTypeId; @@ -616,11 +619,23 @@ public final class Sample implements Serializable, IIdentifierHolder, IIdHolder { } + @JsonIgnore private void setId(Long id) { this.id = id; } + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + private void setSpaceCode(String spaceCode) { this.spaceCode = spaceCode; @@ -646,11 +661,23 @@ public final class Sample implements Serializable, IIdentifierHolder, IIdHolder this.experimentIdentifierOrNull = experimentIdentifierOrNull; } + @JsonIgnore private void setSampleTypeId(Long sampleTypeId) { this.sampleTypeId = sampleTypeId; } + @JsonProperty("sampleTypeId") + private String getSampleTypeIdAsString() + { + return JsonPropertyUtil.toStringOrNull(sampleTypeId); + } + + private void setSampleTypeIdAsString(String sampleTypeId) + { + this.sampleTypeId = JsonPropertyUtil.toLongOrNull(sampleTypeId); + } + private void setSampleTypeCode(String sampleTypeCode) { this.sampleTypeCode = sampleTypeCode; diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Vocabulary.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Vocabulary.java index a7243b091021819539f26f61790773951e1d4e60..c570e0fe84c0cb45e379a4c007a62bb0e4da1b24 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Vocabulary.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/Vocabulary.java @@ -25,7 +25,11 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * Immutable value object representing an openBIS vocabulary. @@ -144,6 +148,7 @@ public class Vocabulary implements Serializable /** * Returns the vocabulary id. */ + @JsonIgnore public Long getId() { return id; @@ -249,11 +254,23 @@ public class Vocabulary implements Serializable } + @JsonIgnore private void setId(Long id) { this.id = id; } + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + private void setCode(String code) { this.code = code; diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/VocabularyTerm.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/VocabularyTerm.java index 908e4ceba8f8949f7377849bb564c8c23e6c83fd..0b8b61968129a57d5b6eca9fd2afbc5164f1e612 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/VocabularyTerm.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/VocabularyTerm.java @@ -23,8 +23,12 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * @since {@link IGeneralInformationService} version 1.13 @@ -66,6 +70,7 @@ public class VocabularyTerm implements Serializable return label; } + @JsonIgnore public Long getOrdinal() { return ordinal; @@ -143,10 +148,22 @@ public class VocabularyTerm implements Serializable this.label = label; } + @JsonIgnore private void setOrdinal(Long ordinal) { this.ordinal = ordinal; } + + @JsonProperty("ordinal") + private String getOrdinalAsString() + { + return JsonPropertyUtil.toStringOrNull(ordinal); + } + + private void setOrdinalAsString(String ordinal) + { + this.ordinal = JsonPropertyUtil.toLongOrNull(ordinal); + } private void setRegistrationDetails(EntityRegistrationDetails registrationDetails) { diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/id/ObjectTechIdId.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/id/ObjectTechIdId.java index e143f02c2d034f8f4b686728a68086396ae3c396..db81053cac3c9d8e7c22216aba164e431f0fbbdf 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/id/ObjectTechIdId.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/id/ObjectTechIdId.java @@ -16,7 +16,11 @@ package ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; /** @@ -24,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; * * @author pkupczyk */ +@SuppressWarnings("unused") @JsonObject("ObjectTechIdId") public abstract class ObjectTechIdId implements IObjectId { @@ -37,6 +42,7 @@ public abstract class ObjectTechIdId implements IObjectId setTechId(techId); } + @JsonIgnore public Long getTechId() { return techId; @@ -50,6 +56,7 @@ public abstract class ObjectTechIdId implements IObjectId { } + @JsonIgnore private void setTechId(Long techId) { if (techId == null) @@ -59,6 +66,17 @@ public abstract class ObjectTechIdId implements IObjectId this.techId = techId; } + @JsonProperty("techId") + private String getTechIdAsString() + { + return JsonPropertyUtil.toStringOrNull(getTechId()); + } + + private void setTechIdAsString(String techId) + { + setTechId(JsonPropertyUtil.toLongOrNull(techId)); + } + @Override public String toString() { @@ -68,7 +86,7 @@ public abstract class ObjectTechIdId implements IObjectId @Override public int hashCode() { - return ((techId == null) ? 0 : techId.hashCode()); + return ((techId == null) ? 0 : techId.hashCode()); } @Override diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/util/JsonPropertyUtil.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/util/JsonPropertyUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..9a9fa01391d98ac9e97b3594d51d7011dbf573c0 --- /dev/null +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/util/JsonPropertyUtil.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.api.v1.util; + +/** + * @author pkupczyk + */ +public class JsonPropertyUtil +{ + + public static final String toStringOrNull(final Long longOrNull) + { + return longOrNull == null ? null : longOrNull.toString(); + } + + public static final Long toLongOrNull(final String stringOrNull) + { + return stringOrNull == null ? null : Long.valueOf(stringOrNull); + } + +} diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/TechId.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/TechId.java index 5c0efd2acc88a0ec7bf1acd2d094f54990931b0e..de3a659fd247f954bb411af3eef83d9c67436d5d 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/TechId.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/TechId.java @@ -21,7 +21,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; /** @@ -29,6 +33,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; * * @author Piotr Buczek */ +@SuppressWarnings("unused") @JsonObject("TechId") public class TechId implements IIdHolder, Serializable { @@ -131,6 +136,7 @@ public class TechId implements IIdHolder, Serializable } @Override + @JsonIgnore public Long getId() { return id; @@ -194,4 +200,19 @@ public class TechId implements IIdHolder, Serializable } } + // + // JSON=RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DatabaseInstance.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DatabaseInstance.java index ffa4c58038b13861d92ea6084832d1aea380bc99..e42a640697a143fea14832da12abc8f4b5fe4371 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DatabaseInstance.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DatabaseInstance.java @@ -16,11 +16,16 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * @author Franz-Josef Elmer */ +@SuppressWarnings("unused") @JsonObject("DatabaseInstance") public class DatabaseInstance extends Code<DatabaseInstance> { @@ -54,11 +59,13 @@ public class DatabaseInstance extends Code<DatabaseInstance> this.identifier = identifier; } + @JsonIgnore public Long getId() { return id; } + @JsonIgnore public void setId(Long id) { this.id = id; @@ -73,4 +80,20 @@ public class DatabaseInstance extends Code<DatabaseInstance> { this.isHomeDatabase = isHomeDatabase; } + + // + // JSON-RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExternalDataManagementSystem.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExternalDataManagementSystem.java index 372be096d712175f7aace78e816f7d3bb084a67f..5db1d028ef85a6965c06c537b00bc612412c0b66 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExternalDataManagementSystem.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ExternalDataManagementSystem.java @@ -18,11 +18,16 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * @author Pawel Glyzewski */ +@SuppressWarnings("unused") @JsonObject("ExternalDataManagementSystem") public class ExternalDataManagementSystem extends Code<ExternalDataManagementSystem> implements Serializable @@ -39,11 +44,13 @@ public class ExternalDataManagementSystem extends Code<ExternalDataManagementSys private boolean openBIS; + @JsonIgnore public Long getId() { return id; } + @JsonIgnore public void setId(Long id) { this.id = id; @@ -88,4 +95,16 @@ public class ExternalDataManagementSystem extends Code<ExternalDataManagementSys { this.openBIS = openBIS; } + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Metaproject.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Metaproject.java index b6ee3af9b0777473cad858a706dbe4221b6d6e4f..b72ceabe65f84b62231b77fb9b1e958fd6a36b5a 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Metaproject.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Metaproject.java @@ -20,13 +20,16 @@ import java.io.Serializable; import java.util.Date; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdAndCodeHolder; /** * @author Pawel Glyzewski */ +@SuppressWarnings("unused") @JsonObject("Metaproject") public class Metaproject implements Serializable, IIdAndCodeHolder, IMetaprojectRegistration, IMetaprojectUpdates @@ -46,11 +49,13 @@ public class Metaproject implements Serializable, IIdAndCodeHolder, IMetaproject private Date creationDate; @Override + @JsonIgnore public Long getId() { return id; } + @JsonIgnore public void setId(Long id) { this.id = id; @@ -138,4 +143,20 @@ public class Metaproject implements Serializable, IIdAndCodeHolder, IMetaproject { return serialVersionUID; } + + // + // JSON-RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Vocabulary.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Vocabulary.java index 9e04acb13571db7c9d0f3b81f889cddadbf9e713..d4151b159e783e2683ec565025a4fd2c9c92e956 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Vocabulary.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/Vocabulary.java @@ -19,14 +19,19 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import java.util.ArrayList; import java.util.List; -import ch.systemsx.cisd.common.reflection.CollectionMapping; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.common.reflection.CollectionMapping; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * Controlled vocabulary. * * @author Izabela Adamczyk */ +@SuppressWarnings("unused") @JsonObject("VocabularyBasic") public class Vocabulary extends CodeWithRegistration<Vocabulary> implements IVocabularyUpdates { @@ -51,11 +56,13 @@ public class Vocabulary extends CodeWithRegistration<Vocabulary> implements IVoc } @Override + @JsonIgnore public Long getId() { return id; } + @JsonIgnore public void setId(Long id) { this.id = id; @@ -174,4 +181,19 @@ public class Vocabulary extends CodeWithRegistration<Vocabulary> implements IVoc return true; } + // + // JSON-RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java index 415cd9347dbe7a70bf7d99c96e408e7da24f67c5..1a8b0272cbd162260c2892e1ade802630972f14c 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/VocabularyTerm.java @@ -17,15 +17,18 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import ch.systemsx.cisd.base.annotation.JsonObject; import ch.systemsx.cisd.common.parser.BeanProperty; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * A vocabulary term. * * @author Izabela Adamczyk */ +@SuppressWarnings("unused") @JsonObject("VocabularyTermBasic") public class VocabularyTerm extends CodeWithRegistration<Vocabulary> implements IVocabularyTermUpdates @@ -55,11 +58,13 @@ public class VocabularyTerm extends CodeWithRegistration<Vocabulary> implements } @Override + @JsonIgnore public Long getId() { return id; } + @JsonIgnore public void setId(Long id) { this.id = id; @@ -121,11 +126,13 @@ public class VocabularyTerm extends CodeWithRegistration<Vocabulary> implements } @Override + @JsonIgnore public Long getOrdinal() { return ordinal; } + @JsonIgnore public void setOrdinal(Long ordinal) { this.ordinal = ordinal; @@ -140,4 +147,31 @@ public class VocabularyTerm extends CodeWithRegistration<Vocabulary> implements { this.isOfficial = isOfficial; } + + // + // JSON-RPC + // + + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + + @JsonProperty("ordinal") + private String getOrdinalAsString() + { + return JsonPropertyUtil.toStringOrNull(ordinal); + } + + private void setOrdinalAsString(String ordinal) + { + this.ordinal = JsonPropertyUtil.toLongOrNull(ordinal); + } + } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/dto/ImageRepresentationFormat.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/dto/ImageRepresentationFormat.java index 790989645e6f0a56e5ee672c907bfc99c60a4657..bd6aed5a23ac23f2b9aab7ffcc56187fdf30599d 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/dto/ImageRepresentationFormat.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/api/v1/dto/ImageRepresentationFormat.java @@ -25,9 +25,11 @@ import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; -import ch.systemsx.cisd.base.annotation.JsonObject; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import ch.systemsx.cisd.base.annotation.JsonObject; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.util.JsonPropertyUtil; /** * An image representation format is made up of its dimensions, bit depth, and file format. @@ -58,6 +60,7 @@ public class ImageRepresentationFormat implements Serializable this.channelCode = channelCode; } + @JsonIgnore public long getTransformationId() { return transformationId; @@ -112,11 +115,23 @@ public class ImageRepresentationFormat implements Serializable { } + @JsonIgnore private void setTransformationId(long transformationId) { this.transformationId = transformationId; } + @JsonProperty("transformationId") + private String getTransformationIdAsString() + { + return JsonPropertyUtil.toStringOrNull(transformationId); + } + + private void setTransformationIdAsString(String transformationId) + { + this.transformationId = JsonPropertyUtil.toLongOrNull(transformationId); + } + private void setTransformationCode(String transformationCode) { this.transformationCode = transformationCode; @@ -189,6 +204,7 @@ public class ImageRepresentationFormat implements Serializable /** * Return the ID of this image representation format. */ + @JsonIgnore public long getId() { return id; @@ -305,11 +321,23 @@ public class ImageRepresentationFormat implements Serializable this.dataSetCode = dataSetCode; } + @JsonIgnore private void setId(long id) { this.id = id; } + @JsonProperty("id") + private String getIdAsString() + { + return JsonPropertyUtil.toStringOrNull(id); + } + + private void setIdAsString(String id) + { + this.id = JsonPropertyUtil.toLongOrNull(id); + } + private void setOriginal(boolean original) { this.original = original; diff --git a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js index 0c351750e3e5b111d744dcf99ef18f570c103b4c..426717e12d92b988ba0488af31a1ff67a6afe85e 100644 --- a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js +++ b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js @@ -34,10 +34,6 @@ var createFacade = function(action, timeoutOrNull){ var createFacadeAndLoginForUserAndPassword = function(user, password, action, timeoutOrNull){ createFacade(function(facade){ - // IDEA we need separate users for: - // - entering web UI - // - running generic tests - // - running screening tests facade.login(user, password, function(){ action(facade); }); diff --git a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js index 35558d7c8deb1fdf3448d4f0b97b3f32b2790331..4ebbca0a6a779058abc2ef758e238a66cdd43f56 100644 --- a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js +++ b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js @@ -151,22 +151,23 @@ var downloadFile = function(url, action){ } var uploadFileToSessionWorkspace = function(facade, fileName, fileContent, dataStoreCode, action){ - var dataStoreUrl = facade._internal.getDataStoreUrlForDataStoreCode(dataStoreCode); - var uploadUrl = dataStoreUrl + "/session_workspace_file_upload" + + facade._internal.getDataStoreUrlForDataStoreCode(dataStoreCode, function(dataStoreUrl){ + var uploadUrl = dataStoreUrl + "/session_workspace_file_upload" + "?filename=" + fileName + "&id=0" + "&startByte=0" + "&endByte=0" + "&sessionID=" + facade.getSession(); - $.ajax({ - url : uploadUrl, - type : "POST", - data : fileContent, - contentType : "multipart/form-data" - }).done(function(response){ - action(response); - }); + $.ajax({ + url : uploadUrl, + type : "POST", + data : fileContent, + contentType : "multipart/form-data" + }).done(function(response){ + action(response); + }); + }); } var generateRandomString = function(){ @@ -963,7 +964,7 @@ test("createReportFromDataSets()", function(){ test("listAggregationServices()", function(){ createFacadeAndLogin(function(facade){ facade.listAggregationServices(function(response){ - assertObjectsCount(response.result, 3); + assertObjectsCount(response.result, 4); facade.close(); }); }); @@ -1094,10 +1095,11 @@ test("createSessionWorkspaceDownloadUrl()", function(){ var dataStoreCode = null; uploadFileToSessionWorkspace(facade, fileName, fileContent, dataStoreCode, function(){ - var downloadUrl = facade.createSessionWorkspaceDownloadUrl(fileName); - downloadFile(downloadUrl, function(response){ - equal(response, fileContent, "Download url is correct"); - facade.close(); + facade.createSessionWorkspaceDownloadUrl(fileName, function(downloadUrl){ + downloadFile(downloadUrl, function(response){ + equal(response, fileContent, "Download url is correct"); + facade.close(); + }); }); }); }); @@ -1110,10 +1112,11 @@ test("createSessionWorkspaceDownloadUrlForDataStore()", function(){ var dataStoreCode = "DSS-SCREENING"; uploadFileToSessionWorkspace(facade, fileName, fileContent, dataStoreCode, function(){ - var downloadUrl = facade.createSessionWorkspaceDownloadUrlForDataStore(fileName, dataStoreCode); - downloadFile(downloadUrl, function(response){ - equal(response, fileContent, "Download url is correct"); - facade.close(); + facade.createSessionWorkspaceDownloadUrlForDataStore(fileName, dataStoreCode, function(downloadUrl){ + downloadFile(downloadUrl, function(response){ + equal(response, fileContent, "Download url is correct"); + facade.close(); + }); }); }); }); @@ -1124,11 +1127,13 @@ test("createSessionWorkspaceDownloadLink()", function(){ var fileName = generateRandomString(); var linkText = generateRandomString(); - var link = facade.createSessionWorkspaceDownloadLink(fileName, linkText); - - equal($(link).attr("href"), facade.createSessionWorkspaceDownloadUrl(fileName), "Link has correct url"); - equal($(link).text(), linkText, "Link has correct text"); - facade.close(); + facade.createSessionWorkspaceDownloadUrl(fileName, function(downloadUrl){ + facade.createSessionWorkspaceDownloadLink(fileName, linkText, function(link){ + equal($(link).attr("href"), downloadUrl, "Link has correct url"); + equal($(link).text(), linkText, "Link has correct text"); + facade.close(); + }); + }); }); }); @@ -1138,11 +1143,13 @@ test("createSessionWorkspaceDownloadLinkForDataStore()", function(){ var linkText = generateRandomString(); var dataStoreCode = "DSS-SCREENING"; - var link = facade.createSessionWorkspaceDownloadLinkForDataStore(fileName, linkText, dataStoreCode); - - equal($(link).attr("href"), facade.createSessionWorkspaceDownloadUrlForDataStore(fileName, dataStoreCode), "Link has correct url"); - equal($(link).text(), linkText, "Link has correct text"); - facade.close(); + facade.createSessionWorkspaceDownloadUrlForDataStore(fileName, dataStoreCode, function(downloadUrl){ + facade.createSessionWorkspaceDownloadLinkForDataStore(fileName, linkText, dataStoreCode, function(link){ + equal($(link).attr("href"), downloadUrl, "Link has correct url"); + equal($(link).text(), linkText, "Link has correct text"); + facade.close(); + }); + }); }); }); diff --git a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/JsonAnnotationTest.java b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/JsonAnnotationTest.java index 946c257a50ca24f82cd0a23eb819d81db4d36a81..075bbcc80860f3e930b6fda942c7a1fa58c1f783 100644 --- a/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/JsonAnnotationTest.java +++ b/screening/sourceTest/java/ch/systemsx/cisd/openbis/screening/systemtests/JsonAnnotationTest.java @@ -24,20 +24,28 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.fasterxml.jackson.databind.BeanDescription; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; +import com.fasterxml.jackson.databind.type.SimpleType; import com.google.common.base.Predicate; import ch.systemsx.cisd.base.annotation.JsonObject; import ch.systemsx.cisd.openbis.common.api.server.json.util.ClassReferences; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric; import ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.IDssServiceRpcScreening; +import ch.systemsx.cisd.openbis.generic.shared.api.json.GenericObjectMapper; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IWebInformationService; import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer; +import ch.systemsx.cisd.openbis.plugin.screening.shared.api.json.ScreeningObjectMapper; import ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer; /** @@ -61,10 +69,10 @@ public class JsonAnnotationTest private void findAllClassesUsedByJsonRpcApi() { Class<?>[] jsonRpcInterfaces = - { IDssServiceRpcGeneric.class, IScreeningApiServer.class, - IGeneralInformationChangingService.class, - IGeneralInformationService.class, IWebInformationService.class, - IQueryApiServer.class, IDssServiceRpcScreening.class }; + { IDssServiceRpcGeneric.class, IScreeningApiServer.class, + IGeneralInformationChangingService.class, + IGeneralInformationService.class, IWebInformationService.class, + IQueryApiServer.class, IDssServiceRpcScreening.class }; for (Class<?> jsonClass : jsonRpcInterfaces) { @@ -73,8 +81,8 @@ public class JsonAnnotationTest @Override public boolean apply(Class<?> clazz) { - return (clazz.getPackage().getName().startsWith( - "ch.systemsx.sybit.imageviewer") == false); + return (clazz.getPackage().getName() + .startsWith("ch.systemsx.sybit.imageviewer") == false); } })); } @@ -110,6 +118,111 @@ public class JsonAnnotationTest assertThat(duplicatedValuesIn(names), is(emptyMap)); } + @Test + public void jsonClassesDoNotContainLongProperties() + { + IPropertyFilter longFilter = new IPropertyFilter() + { + @Override + public boolean accept(BeanDescription bean, BeanPropertyDefinition property) + { + if (property.getField() != null + && isLongClass(property.getField().getRawType())) + { + return true; + } + if (property.getGetter() != null + && isLongClass(property.getGetter().getRawType())) + { + return true; + } + if (property.getSetter() != null + && property.getSetter().getParameterCount() == 1 + && isLongClass(property.getSetter().getParameter(0).getRawType())) + { + return true; + } + + return false; + } + + private boolean isLongClass(Class<?> clazz) + { + return long.class.equals(clazz) || Long.class.equals(clazz); + } + + }; + + Set<String> longProperties = getProperties(longFilter); + Set<String> emptySet = new TreeSet<String>(); + assertThat(longProperties, is(emptySet)); + } + + @Test + public void jsonClassesDoNotContainAsStringProperties() + { + IPropertyFilter asStringFilter = new IPropertyFilter() + { + @Override + public boolean accept(BeanDescription bean, BeanPropertyDefinition property) + { + return property.getName().endsWith("AsString"); + } + }; + + Set<String> asStringProperties = getProperties(asStringFilter); + Set<String> emptySet = new TreeSet<String>(); + assertThat(asStringProperties, is(emptySet)); + } + + private static interface IPropertyFilter + { + + boolean accept(BeanDescription bean, BeanPropertyDefinition property); + + } + + private Set<String> getProperties(IPropertyFilter filter) + { + GenericObjectMapper genericMapper = new GenericObjectMapper(); + ScreeningObjectMapper screeningMapper = new ScreeningObjectMapper(); + + Set<String> properties = new TreeSet<String>(); + + for (Class<?> jsonClass : allJsonClasses) + { + JavaType jsonJavaType = SimpleType.construct(jsonClass); + + BeanDescription genericSerializationBean = + genericMapper.getSerializationConfig().introspect(jsonJavaType); + BeanDescription genericDeserializationBean = + genericMapper.getDeserializationConfig().introspect(jsonJavaType); + BeanDescription screeningSerializationBean = + screeningMapper.getSerializationConfig().introspect(jsonJavaType); + BeanDescription screeningDeserializationBean = + screeningMapper.getDeserializationConfig().introspect(jsonJavaType); + + addProperties(genericSerializationBean, filter, properties); + addProperties(genericDeserializationBean, filter, properties); + addProperties(screeningSerializationBean, filter, properties); + addProperties(screeningDeserializationBean, filter, properties); + } + + return properties; + } + + private static void addProperties(BeanDescription bean, IPropertyFilter propertyFilter, + Set<String> acceptedProperties) + { + for (BeanPropertyDefinition property : bean.findProperties()) + { + if (propertyFilter.accept(bean, property)) + { + acceptedProperties.add(bean.getBeanClass().getName() + "#" + property.getName()); + } + } + } + private static class PrettyPrintingCollectionMap<K, V extends Collection<?>> extends HashMap<K, V> { @@ -169,4 +282,5 @@ public class JsonAnnotationTest } return map; } + }