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 index 9a9fa01391d98ac9e97b3594d51d7011dbf573c0..5c86a450a8d6e0c179504505ad6ba30916276a31 100644 --- 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 @@ -22,14 +22,28 @@ package ch.systemsx.cisd.openbis.generic.shared.api.v1.util; public class JsonPropertyUtil { + /* + * Unfortunately some of our API DTOs are not in the API packages or refer to classes that are + * not in the API packages (for instance classes in + * ch.systemsx.cisd.openbis.generic.shared.basic.dto package). To make things even worse these + * classes are reused in both the API and in GWT. Creating a utility class that is reused by all + * these DTOs is therefore impossible. If that utility class is located in the API package then + * it won't be available in GWT. On the other hand if it is located in a GWT module then is + * breaks the API code independence. Until we don't fix the DTOs the best we can do is to have + * two JsonPropertyUtil classes. Once we have all API DTOs is the API packages the other + * JsonPropertyUtil class can be removed. + */ + public static final String toStringOrNull(final Long longOrNull) { - return longOrNull == null ? null : longOrNull.toString(); + return ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil + .toStringOrNull(longOrNull); } public static final Long toLongOrNull(final String stringOrNull) { - return stringOrNull == null ? null : Long.valueOf(stringOrNull); + return ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil + .toLongOrNull(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 de3a659fd247f954bb411af3eef83d9c67436d5d..9815bebc76cb8e3ba9ef0a52f129449c40211813 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 @@ -25,8 +25,8 @@ 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; +import ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil; /** * Technical identifier of an entity. 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 e42a640697a143fea14832da12abc8f4b5fe4371..4e3c24b6c5bbd627e5fe3e725eeff5bcf12b4a19 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 @@ -20,7 +20,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.util.JsonPropertyUtil; /** * @author Franz-Josef Elmer 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 5db1d028ef85a6965c06c537b00bc612412c0b66..4d362e4ddea8d6cebae8d392eaa0b3e0d3bdfe6d 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 @@ -22,7 +22,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.util.JsonPropertyUtil; /** * @author Pawel Glyzewski 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 b72ceabe65f84b62231b77fb9b1e958fd6a36b5a..66ef8871cabc100d6b5de6b63b9ba92af7829fef 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 @@ -23,8 +23,8 @@ 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; +import ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil; /** * @author Pawel Glyzewski 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 d4151b159e783e2683ec565025a4fd2c9c92e956..94e12da583044c55561c889e3ddd0b0ad1155923 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 @@ -16,7 +16,7 @@ package ch.systemsx.cisd.openbis.generic.shared.basic.dto; -import java.util.ArrayList; + import java.util.ArrayList; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -24,7 +24,7 @@ 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; +import ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil; /** * Controlled vocabulary. 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 1a8b0272cbd162260c2892e1ade802630972f14c..5d7279161149d14724adf1702cbd489b580b5e46 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 @@ -21,7 +21,7 @@ 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; +import ch.systemsx.cisd.openbis.generic.shared.basic.util.JsonPropertyUtil; /** * A vocabulary term. diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/util/JsonPropertyUtil.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/util/JsonPropertyUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..c89ba067ba705c6bf7ccbc9f2cd1b4731fae63b1 --- /dev/null +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/util/JsonPropertyUtil.java @@ -0,0 +1,40 @@ +/* + * 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.basic.util; + +/** + * @author pkupczyk + */ +public class JsonPropertyUtil +{ + + /* + * This class should be removed once we clean our API DTOs - see comment in {@link + * ch.systemsx.cisd.openbis.generic.shared.api.v1.util.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); + } + +}