diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java index d74a19163af..1615e41ea10 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java @@ -454,6 +454,7 @@ public class FhirContext { * * @deprecated Support for DEV resources will be removed, you should use DSTU2 resources instead */ + @Deprecated public static FhirContext forDev() { return new FhirContext(FhirVersionEnum.DEV); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseIdentifiableElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseIdentifiableElement.java index c424343dd70..1e6bbe6dcf9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseIdentifiableElement.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseIdentifiableElement.java @@ -36,6 +36,7 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId * @deprecated Use {@link #getElementSpecificId()} instead. This method will be removed because it is easily * confused with other ID methods (such as patient#getIdentifier) */ + @Deprecated @Override public IdDt getId() { if (myElementSpecificId == null) { @@ -54,6 +55,7 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId * @deprecated Use {@link #setElementSpecificId(String)} instead. This method will be removed because it is easily * confused with other ID methods (such as patient#getIdentifier) */ + @Deprecated @Override public void setId(IdDt theId) { if (theId == null) { @@ -68,6 +70,7 @@ public abstract class BaseIdentifiableElement extends BaseElement implements IId * confused with other ID methods (such as patient#getIdentifier) */ @Override + @Deprecated public void setId(String theId) { myElementSpecificId = theId; } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Bundle.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Bundle.java index fca80f95643..a57b1f79c96 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Bundle.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Bundle.java @@ -68,6 +68,7 @@ public class Bundle extends BaseBundle /* implements IElement */{ * @deprecated Tags wil become immutable in a future release of HAPI, so * {@link #addCategory(String, String, String)} should be used instead */ + @Deprecated public Tag addCategory() { Tag retVal = new Tag(); getCategories().add(retVal); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BundleEntry.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BundleEntry.java index ebd1c926c2e..5818dc148c1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BundleEntry.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BundleEntry.java @@ -67,6 +67,7 @@ public class BundleEntry extends BaseBundle { * @deprecated Tags wil become immutable in a future release of HAPI, so * {@link #addCategory(String, String, String)} should be used instead */ + @Deprecated public Tag addCategory() { Tag retVal = new Tag(); getCategories().add(retVal); @@ -146,6 +147,7 @@ public class BundleEntry extends BaseBundle { * if this entry represents a deleted resource, use {@link #setDeletedResourceId(IdDt)}. */ @Override + @Deprecated public IdDt getId() { return super.getId(); } @@ -160,6 +162,7 @@ public class BundleEntry extends BaseBundle { /** * @deprecated Use resource ID to determine base URL */ + @Deprecated public StringDt getLinkBase() { if (myLinkBase == null) { myLinkBase = new StringDt(); @@ -220,6 +223,7 @@ public class BundleEntry extends BaseBundle { * DSTU2, it is recommended that you migrate code away from using this method and over to using resource * metadata instead. */ + @Deprecated public InstantDt getUpdated() { if (myUpdated == null) { myUpdated = new InstantDt(); @@ -283,6 +287,7 @@ public class BundleEntry extends BaseBundle { * @deprecated Bundle entries no longer have an ID in DSTU2, as ID is explicitly stated in the resource itself. */ @Override + @Deprecated public void setId(IdDt theId) { super.setId(theId); } @@ -294,6 +299,7 @@ public class BundleEntry extends BaseBundle { /** * @deprecated Use resource ID to determine base URL */ + @Deprecated public void setLinkBase(StringDt theLinkBase) { myLinkBase = theLinkBase; } @@ -329,6 +335,7 @@ public class BundleEntry extends BaseBundle { * DSTU2, it is recommended that you migrate code away from using this method and over to using resource * metadata instead. */ + @Deprecated public void setUpdated(InstantDt theUpdated) { Validate.notNull(theUpdated, "Updated may not be null"); myUpdated = theUpdated; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IIdentifiableElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IIdentifiableElement.java index 63ff217c52d..691f260f38f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IIdentifiableElement.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IIdentifiableElement.java @@ -34,6 +34,7 @@ public interface IIdentifiableElement extends IElement { * @deprecated Use {@link #getElementSpecificId()} instead. This method will be removed because it is easily * confused with other ID methods (such as patient#getIdentifier) */ + @Deprecated IdDt getId(); /** @@ -46,12 +47,14 @@ public interface IIdentifiableElement extends IElement { * @deprecated Use {@link #setElementSpecificId(String)} instead. This method will be removed because it is easily * confused with other ID methods (such as patient#getIdentifier) */ + @Deprecated void setId(IdDt theId); /** * @deprecated Use {@link #setElementSpecificId(String)} instead. This method will be removed because it is easily * confused with other ID methods (such as patient#getIdentifier) */ + @Deprecated void setId(String theId); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/PathSpecification.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/PathSpecification.java index a18ca5bbc35..cd4dc5a70d1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/PathSpecification.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/PathSpecification.java @@ -31,6 +31,7 @@ package ca.uhn.fhir.model.api; * * @deprecated {@link Include} should be used instead */ +@Deprecated public class PathSpecification extends Include { public PathSpecification(String theInclude) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Tag.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Tag.java index 7ae7284b3a0..1098dfbce47 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Tag.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/Tag.java @@ -61,12 +61,14 @@ public class Tag extends BaseElement implements IElement { /** * @deprecated Tags will become immutable in a future release, so this constructor should not be used. */ + @Deprecated public Tag() { } /** * @deprecated There is no reason to create a tag with a term and not a scheme, so this constructor will be removed */ + @Deprecated public Tag(String theTerm) { this((String) null, theTerm, null); } @@ -148,6 +150,7 @@ public class Tag extends BaseElement implements IElement { * ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new * tag object */ + @Deprecated public Tag setLabel(String theLabel) { myLabel = theLabel; return this; @@ -160,6 +163,7 @@ public class Tag extends BaseElement implements IElement { * ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new * tag object */ + @Deprecated public Tag setScheme(String theScheme) { myScheme = theScheme; return this; @@ -172,6 +176,7 @@ public class Tag extends BaseElement implements IElement { * ensuring that the TagList acts as an unordered set. Use the constructor to set this field when creating a new * tag object */ + @Deprecated public Tag setTerm(String theTerm) { myTerm = theTerm; return this; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java index a0ae718023d..2a38ca0c088 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/TagList.java @@ -79,6 +79,7 @@ public class TagList implements Set, Serializable, IBase { /** * @deprecated Tags wil become immutable in a future release of HAPI, so {@link #addTag(String, String, String)} should be used instead */ + @Deprecated public Tag addTag() { myOrderedTags = null; return addTag(null, null, null); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java index c7b646ddeb0..2d3a0bf8558 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/IdDt.java @@ -181,6 +181,7 @@ public class IdDt extends UriDt implements IPrimitiveDatatype { /** * @deprecated Use {@link #getIdPartAsBigDecimal()} instead (this method was deprocated because its name is ambiguous) */ + @Deprecated public BigDecimal asBigDecimal() { return getIdPartAsBigDecimal(); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionIdParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionIdParam.java index 82f2793ad05..185873a30ab 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionIdParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionIdParam.java @@ -28,6 +28,7 @@ import java.lang.annotation.Target; /** * @deprecated IdDt can now hold both an ID and a version ID, so a single parameter with the {@link IdParam} annotation may be used */ +@Deprecated @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) public @interface VersionIdParam { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java index 4716262608c..63e58755f95 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java @@ -97,6 +97,7 @@ public class MethodOutcome { /** * @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance */ + @Deprecated public MethodOutcome(IdDt theId, IdDt theVersionId) { myId = theId; myVersionId = theVersionId; @@ -105,6 +106,7 @@ public class MethodOutcome { /** * @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance */ + @Deprecated public MethodOutcome(IdDt theId, IdDt theVersionId, BaseOperationOutcome theBaseOperationOutcome) { myId = theId; myVersionId = theVersionId; @@ -127,6 +129,7 @@ public class MethodOutcome { /** * @deprecated {@link MethodOutcome#getId()} should return the complete ID including version if it is available */ + @Deprecated public IdDt getVersionId() { return myVersionId; } @@ -173,6 +176,7 @@ public class MethodOutcome { /** * @deprecated Put the ID and version ID into the same IdDt instance and pass it to {@link #setId(IdDt)} */ + @Deprecated public void setVersionId(IdDt theVersionId) { myVersionId = theVersionId; } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/HttpBasicAuthInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/HttpBasicAuthInterceptor.java index 3ae60801c14..7075a70fe14 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/HttpBasicAuthInterceptor.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/HttpBasicAuthInterceptor.java @@ -38,6 +38,7 @@ import ca.uhn.fhir.rest.client.api.IBasicClient; /** * @deprecated Use {@link ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor} instead. Note that BasicAuthInterceptor class is a HAPI client interceptor instead of being a commons-httpclient interceptor, so you register it to your client instance once it's created using {@link IGenericClient#registerInterceptor(IClientInterceptor)} or {@link IBasicClient#registerInterceptor(IClientInterceptor)} instead */ +@Deprecated public class HttpBasicAuthInterceptor implements HttpRequestInterceptor { private String myUsername; diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java index fb36b5dc1ef..eabef4c4ed0 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IGenericClient.java @@ -66,6 +66,7 @@ public interface IGenericClient extends IRestfulClient { * @deprecated Use {@link #create() fluent method instead}. This method will be removed. * */ + @Deprecated MethodOutcome create(IResource theResource); /** @@ -83,6 +84,7 @@ public interface IGenericClient extends IRestfulClient { * @return An outcome * @deprecated Use {@link #delete()} instead */ + @Deprecated MethodOutcome delete(Class theType, IdDt theId); /** @@ -95,6 +97,7 @@ public interface IGenericClient extends IRestfulClient { * @return An outcome * @deprecated Use {@link #delete()} instead */ + @Deprecated MethodOutcome delete(Class theType, String theId); /** @@ -125,6 +128,7 @@ public interface IGenericClient extends IRestfulClient { * @return A bundle containing returned resources * @deprecated As of 0.9, use the fluent {@link #history()} method instead */ + @Deprecated Bundle history(Class theType, IdDt theId, DateTimeDt theSince, Integer theLimit); /** @@ -145,6 +149,7 @@ public interface IGenericClient extends IRestfulClient { * @return A bundle containing returned resources * @deprecated As of 0.9, use the fluent {@link #history()} method instead */ + @Deprecated Bundle history(Class theType, String theId, DateTimeDt theSince, Integer theLimit); /** @@ -268,6 +273,7 @@ public interface IGenericClient extends IRestfulClient { * @deprecated Use {@link #transaction()} * */ + @Deprecated List transaction(List theResources); /** @@ -341,6 +347,7 @@ public interface IGenericClient extends IRestfulClient { * @return The resource * @deprecated Deprecated in 0.7 - IdDt can contain an ID and a version, so this class doesn't make a lot of sense */ + @Deprecated T vread(Class theType, IdDt theId, IdDt theVersionId); /** diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/CompositeParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/CompositeParam.java index 55dbf9e59d7..b5f0f8607c2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/CompositeParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/CompositeParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link CompositeClientParam} instead. That class is identical to this one but was renamed to reduce * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class CompositeParam extends CompositeClientParam { public CompositeParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/DateParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/DateParam.java index de2abbfa75f..2623c4493fc 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/DateParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/DateParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link DateClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class DateParam extends DateClientParam { public DateParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IClientExecutable.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IClientExecutable.java index 3530ef7635f..99f20c0913f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IClientExecutable.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/IClientExecutable.java @@ -35,6 +35,7 @@ public interface IClientExecutable, Y> { * * @deprecated Use the client logging interceptor to log requests and responses instead. See here for more information. */ + @Deprecated T andLogRequestAndResponse(boolean theLogRequestAndResponse); T prettyPrint(); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/NumberParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/NumberParam.java index 0b7b9ac0e12..32edde136f4 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/NumberParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/NumberParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link NumberClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class NumberParam extends NumberClientParam { public NumberParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityParam.java index 20c5cf38e1f..05920ac81e9 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/QuantityParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link QuantityClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class QuantityParam extends QuantityClientParam { public QuantityParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ReferenceParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ReferenceParam.java index 89e7d4967d0..e0f53b377a6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ReferenceParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ReferenceParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link ReferenceClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class ReferenceParam extends ReferenceClientParam { public ReferenceParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/StringParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/StringParam.java index c9df9eeeb0d..81261ff54ce 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/StringParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/StringParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link StringClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class StringParam extends StringClientParam { public StringParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/TokenParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/TokenParam.java index d0fc95e03ba..994341b8ee3 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/TokenParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/TokenParam.java @@ -25,6 +25,7 @@ package ca.uhn.fhir.rest.gclient; * @deprecated Use {@link TokenClientParam} instead. That class is identical to this one but was renamed to reduct * confusing duplicate names in the API. This class will be removed in a future release. */ +@Deprecated public class TokenParam extends TokenClientParam { public TokenParam(String theParamName) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/QualifiedDateParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/QualifiedDateParam.java index 15ac41c3a4b..9277775927d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/QualifiedDateParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/QualifiedDateParam.java @@ -27,6 +27,7 @@ import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum; /** * @deprecated Use {@link DateParam} instead (this class is identical, but was renamed to be less confusing) */ +@Deprecated public class QualifiedDateParam extends DateParam { /** * Constructor diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java index f577fb869b2..600cdd4d0c0 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java @@ -57,6 +57,7 @@ public class ResourceNotFoundException extends BaseServerResponseException { /** * @deprecated This doesn't make sense, since an identifier is not a resource ID and shouldn't generate a 404 if it isn't found - Should be removed */ + @Deprecated public ResourceNotFoundException(Class theClass, BaseIdentifierDt theId) { super(STATUS_CODE, "Resource of type " + theClass.getSimpleName() + " with ID " + theId + " is not known"); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java index 92a1c056849..7758c4611a6 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java @@ -21,13 +21,13 @@ package ca.uhn.fhir.rest.server.exceptions; */ import ca.uhn.fhir.model.base.resource.BaseOperationOutcome; -import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.server.Constants; /** * @deprecated Use {@link PreconditionFailedException} instead - This exception is * strangely named and will be removed at some point. */ +@Deprecated public class ResourceVersionNotSpecifiedException extends BaseServerResponseException { public static final int STATUS_CODE = Constants.STATUS_HTTP_412_PRECONDITION_FAILED; private static final long serialVersionUID = 1L; diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java index af4c49d0387..5c5078dc6e3 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java @@ -6,6 +6,7 @@ import static org.junit.Assert.*; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Observable; import net.sf.json.JSON; import net.sf.json.JSONSerializer; @@ -26,9 +27,9 @@ import ca.uhn.fhir.model.api.TagList; import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt; import ca.uhn.fhir.model.dstu2.composite.HumanNameDt; -import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt; import ca.uhn.fhir.model.dstu2.resource.Binary; import ca.uhn.fhir.model.dstu2.resource.MedicationPrescription; +import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.resource.QuestionnaireAnswers; import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum; @@ -53,11 +54,48 @@ public class JsonParserTest { assertEquals("{\"resourceType\":\"Binary\",\"id\":\"11\",\"meta\":{\"versionId\":\"22\"},\"contentType\":\"foo\",\"content\":\"AQIDBA==\"}", val); } + /** + * see #144 and #146 + */ + @Test + public void testParseContained() { + + FhirContext c = FhirContext.forDstu2(); + IParser parser = c.newJsonParser().setPrettyPrint(true); + + Observation o = new Observation(); + o.getCode().setText("obs text"); + + Patient p = new Patient(); + p.addName().addFamily("patient family"); + o.getSubject().setResource(p); + + String enc = parser.encodeResourceToString(o); + ourLog.info(enc); + + //@formatter:off + assertThat(enc, stringContainsInOrder( + "\"resourceType\":\"Observation\"", + "\"contained\":[", + "\"resourceType\":\"Patient\",", + "\"id\":\"1\"", + "\"reference\":\"#1\"" + )); + //@formatter:on + + o = parser.parseResource(Observation.class, enc); + assertEquals("obs text", o.getCode().getText()); + + assertNotNull(o.getSubject().getResource()); + p = (Patient) o.getSubject().getResource(); + assertEquals("patient family", p.getNameFirstRep().getFamilyAsSingleString()); + } + @Test public void testEncodeAndParseMetaProfileAndTags() { Patient p = new Patient(); p.addName().addFamily("FAMILY"); - + List profiles = new ArrayList(); profiles.add(new IdDt("http://foo/Profile1")); profiles.add(new IdDt("http://foo/Profile2")); @@ -67,10 +105,10 @@ public class JsonParserTest { tagList.addTag("scheme1", "term1", "label1"); tagList.addTag("scheme2", "term2", "label2"); ResourceMetadataKeyEnum.TAG_LIST.put(p, tagList); - + String enc = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info(enc); - + //@formatter:off assertThat(enc, stringContainsInOrder("\"meta\":{", "\"profile\":[", @@ -91,39 +129,38 @@ public class JsonParserTest { "]", "},")); //@formatter:on - + Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, enc); List gotLabels = ResourceMetadataKeyEnum.PROFILES.get(parsed); - - assertEquals(2,gotLabels.size()); + + assertEquals(2, gotLabels.size()); IdDt label = (IdDt) gotLabels.get(0); assertEquals("http://foo/Profile1", label.getValue()); label = (IdDt) gotLabels.get(1); assertEquals("http://foo/Profile2", label.getValue()); - + tagList = ResourceMetadataKeyEnum.TAG_LIST.get(parsed); assertEquals(2, tagList.size()); - + assertEquals(new Tag("scheme1", "term1", "label1"), tagList.get(0)); assertEquals(new Tag("scheme2", "term2", "label2"), tagList.get(1)); } - @Test public void testEncodeAndParseSecurityLabels() { Patient p = new Patient(); p.addName().addFamily("FAMILY"); - + List labels = new ArrayList(); labels.add(new CodingDt().setSystem("SYSTEM1").setCode("CODE1").setDisplay("DISPLAY1").setPrimary(true).setVersion("VERSION1")); labels.add(new CodingDt().setSystem("SYSTEM2").setCode("CODE2").setDisplay("DISPLAY2").setPrimary(false).setVersion("VERSION2")); - + ResourceMetadataKeyEnum.SECURITY_LABELS.put(p, labels); String enc = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(p); ourLog.info(enc); - + //@formatter:off assertEquals("{\n" + " \"resourceType\":\"Patient\",\n" + @@ -154,11 +191,11 @@ public class JsonParserTest { " ]\n" + "}", enc.trim()); //@formatter:on - + Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, enc); List gotLabels = ResourceMetadataKeyEnum.SECURITY_LABELS.get(parsed); - - assertEquals(2,gotLabels.size()); + + assertEquals(2, gotLabels.size()); CodingDt label = (CodingDt) gotLabels.get(0); assertEquals("SYSTEM1", label.getSystem()); @@ -175,7 +212,6 @@ public class JsonParserTest { assertEquals("VERSION2", label.getVersion()); } - /** * Fixing #89 */ @@ -183,9 +219,9 @@ public class JsonParserTest { public void testEncodeBundleWithDeletedEntry() throws ConfigurationException, DataFormatException, IOException { Bundle b = ourCtx.newXmlParser().parseBundle(IOUtils.toString(JsonParserTest.class.getResourceAsStream("/xml-bundle.xml"))); String val = ourCtx.newJsonParser().encodeBundleToString(b); - + ourLog.info(val); - + //@formatter:off assertThat(val, containsString("\"deleted\":{" + "\"type\":\"Patient\"," + @@ -236,39 +272,12 @@ public class JsonParserTest { ourLog.info(output); String enc = ourCtx.newJsonParser().encodeResourceToString(patient); - assertThat(enc, Matchers.stringContainsInOrder("{\"resourceType\":\"Patient\",", - "\"extension\":[{\"url\":\"http://example.com/extensions#someext\",\"valueDateTime\":\"2011-01-02T11:13:15\"}", - "{\"url\":\"http://example.com#parent\",\"extension\":[{\"url\":\"http://example.com#child\",\"valueString\":\"value1\"},{\"url\":\"http://example.com#child\",\"valueString\":\"value2\"}]}" - )); - assertThat(enc, Matchers.stringContainsInOrder("\"modifierExtension\":[" + - "{" + - "\"url\":\"http://example.com/extensions#modext\"," + - "\"valueDate\":\"1995-01-02\"" + - "}" + - "],")); - assertThat(enc, containsString("\"_given\":[" + - "{" + - "\"extension\":[" + - "{" + - "\"url\":\"http://examples.com#givenext\"," + - "\"valueString\":\"given\"" + - "}" + - "]" + - "}," + - "{" + - "\"extension\":[" + - "{" + - "\"url\":\"http://examples.com#givenext_parent\"," + - "\"extension\":[" + - "{" + - "\"url\":\"http://examples.com#givenext_child\"," + - "\"valueString\":\"CHILD\"" + - "}" + - "]" + - "}" + - "]" + - "}")); - + assertThat(enc, Matchers.stringContainsInOrder("{\"resourceType\":\"Patient\",", "\"extension\":[{\"url\":\"http://example.com/extensions#someext\",\"valueDateTime\":\"2011-01-02T11:13:15\"}", + "{\"url\":\"http://example.com#parent\",\"extension\":[{\"url\":\"http://example.com#child\",\"valueString\":\"value1\"},{\"url\":\"http://example.com#child\",\"valueString\":\"value2\"}]}")); + assertThat(enc, Matchers.stringContainsInOrder("\"modifierExtension\":[" + "{" + "\"url\":\"http://example.com/extensions#modext\"," + "\"valueDate\":\"1995-01-02\"" + "}" + "],")); + assertThat(enc, containsString("\"_given\":[" + "{" + "\"extension\":[" + "{" + "\"url\":\"http://examples.com#givenext\"," + "\"valueString\":\"given\"" + "}" + "]" + "}," + "{" + "\"extension\":[" + "{" + "\"url\":\"http://examples.com#givenext_parent\"," + "\"extension\":[" + "{" + + "\"url\":\"http://examples.com#givenext_child\"," + "\"valueString\":\"CHILD\"" + "}" + "]" + "}" + "]" + "}")); + /* * Now parse this back */ @@ -307,22 +316,20 @@ public class JsonParserTest { } - - /** * #65 */ @Test public void testJsonPrimitiveWithExtensionEncoding() { - + QuestionnaireAnswers parsed = new QuestionnaireAnswers(); parsed.getGroup().setLinkId("value123"); parsed.getGroup().getLinkIdElement().addUndeclaredExtension(false, "http://123", new StringDt("HELLO")); - + String encoded = ourCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(parsed); ourLog.info(encoded); assertThat(encoded, containsString("{\"linkId\":\"value123\",\"_linkId\":{\"extension\":[{\"url\":\"http://123\",\"valueString\":\"HELLO\"}]}}")); - + } @Test @@ -358,10 +365,10 @@ public class JsonParserTest { " }]\n" + "}"; //@formatter:on - + Bundle b = ourCtx.newJsonParser().parseBundle(bundle); assertEquals(1, b.getEntries().size()); - + Patient pt = (Patient) b.getEntries().get(0).getResource(); assertEquals("http://foo/fhirBase2/Patient/1/_history/2", pt.getId().getValue()); assertEquals("2012-01-02", pt.getBirthDateElement().getValueAsString()); @@ -370,12 +377,12 @@ public class JsonParserTest { assertEquals("POST", ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(pt).getCode()); assertEquals("http://foo/Patient?identifier=value", ResourceMetadataKeyEnum.LINK_SEARCH.get(pt)); assertEquals("2001-02-22T11:22:33-05:00", ResourceMetadataKeyEnum.UPDATED.get(pt).getValueAsString()); - + Bundle toBundle = new Bundle(); toBundle.getLinkBase().setValue("http://foo/fhirBase1"); toBundle.getTotalResults().setValue(1); toBundle.getLinkSelf().setValue("http://localhost:52788/Binary?_pretty=true"); - + toBundle.addResource(pt, ourCtx, "http://foo/fhirBase1"); String reEncoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeBundleToString(toBundle); @@ -394,22 +401,20 @@ public class JsonParserTest { } - - @Test public void testParsePatientInBundle() { - + String text = "{\"resourceType\":\"Bundle\",\"id\":null,\"base\":\"http://localhost:57931/fhir/contextDev\",\"total\":1,\"link\":[{\"relation\":\"self\",\"url\":\"http://localhost:57931/fhir/contextDev/Patient?identifier=urn%3AMultiFhirVersionTest%7CtestSubmitPatient01&_format=json\"}],\"entry\":[{\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2014-12-20T18:41:29.706-05:00\"},\"identifier\":[{\"system\":\"urn:MultiFhirVersionTest\",\"value\":\"testSubmitPatient01\"}]}}]}"; FhirContext ctx = FhirContext.forDstu2(); Bundle b = ctx.newJsonParser().parseBundle(text); - + IResource patient = b.getEntries().get(0).getResource(); assertEquals(Patient.class, patient.getClass()); - + assertNull(ResourceMetadataKeyEnum.TAG_LIST.get(patient)); assertNull(ResourceMetadataKeyEnum.PROFILES.get(patient)); } - + @Test public void testParseAndEncodeBundle() throws Exception { String content = IOUtils.toString(JsonParserTest.class.getResourceAsStream("/bundle-example.json")); @@ -455,22 +460,25 @@ public class JsonParserTest { String content = IOUtils.toString(JsonParserTest.class.getResourceAsStream("/bundle-transaction.json")); Bundle parsed = ourCtx.newJsonParser().parseBundle(content); -// assertEquals("http://example.com/base/Bundle/example/_history/1", parsed.getId().getValue()); -// assertEquals("1", parsed.getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION)); -// assertEquals("1", parsed.getId().getVersionIdPart()); -// assertEquals(new InstantDt("2014-08-18T01:43:30Z"), parsed.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED)); -// assertEquals("searchset", parsed.getType().getValue()); -// assertEquals(3, parsed.getTotalResults().getValue().intValue()); -// assertEquals("http://example.com/base", parsed.getLinkBase().getValue()); -// assertEquals("https://example.com/base/MedicationPrescription?patient=347&searchId=ff15fd40-ff71-4b48-b366-09c706bed9d0&page=2", parsed.getLinkNext().getValue()); -// assertEquals("https://example.com/base/MedicationPrescription?patient=347&_include=MedicationPrescription.medication", parsed.getLinkSelf().getValue()); -// -// assertEquals(2, parsed.getEntries().size()); -// -// MedicationPrescription p = (MedicationPrescription) parsed.getEntries().get(0).getResource(); -// assertEquals("Patient/347", p.getPatient().getReference().getValue()); -// assertEquals("2014-08-16T05:31:17Z", ResourceMetadataKeyEnum.UPDATED.get(p).getValueAsString()); -// assertEquals("http://example.com/base/MedicationPrescription/3123/_history/1", p.getId().getValue()); + // assertEquals("http://example.com/base/Bundle/example/_history/1", parsed.getId().getValue()); + // assertEquals("1", parsed.getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION)); + // assertEquals("1", parsed.getId().getVersionIdPart()); + // assertEquals(new InstantDt("2014-08-18T01:43:30Z"), + // parsed.getResourceMetadata().get(ResourceMetadataKeyEnum.UPDATED)); + // assertEquals("searchset", parsed.getType().getValue()); + // assertEquals(3, parsed.getTotalResults().getValue().intValue()); + // assertEquals("http://example.com/base", parsed.getLinkBase().getValue()); + // assertEquals("https://example.com/base/MedicationPrescription?patient=347&searchId=ff15fd40-ff71-4b48-b366-09c706bed9d0&page=2", + // parsed.getLinkNext().getValue()); + // assertEquals("https://example.com/base/MedicationPrescription?patient=347&_include=MedicationPrescription.medication", + // parsed.getLinkSelf().getValue()); + // + // assertEquals(2, parsed.getEntries().size()); + // + // MedicationPrescription p = (MedicationPrescription) parsed.getEntries().get(0).getResource(); + // assertEquals("Patient/347", p.getPatient().getReference().getValue()); + // assertEquals("2014-08-16T05:31:17Z", ResourceMetadataKeyEnum.UPDATED.get(p).getValueAsString()); + // assertEquals("http://example.com/base/MedicationPrescription/3123/_history/1", p.getId().getValue()); String reencoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeBundleToString(parsed); ourLog.info(reencoded); @@ -483,15 +491,15 @@ public class JsonParserTest { String exp = expected.toString().replace("\\r\\n", "\\n"); // .replace("§", "ยง"); String act = actual.toString().replace("\\r\\n", "\\n"); - exp=exp.replace(",\"ifNoneExist\":\"Patient?identifier=234234\"", ""); - + exp = exp.replace(",\"ifNoneExist\":\"Patient?identifier=234234\"", ""); + ourLog.info("Expected: {}", exp); ourLog.info("Actual : {}", act); assertEquals(exp, act); } - + @Test public void testParseAndEncodeBundleNewStyle() throws Exception { String content = IOUtils.toString(JsonParserTest.class.getResourceAsStream("/bundle-example.json")); @@ -532,24 +540,22 @@ public class JsonParserTest { } - - @Test public void testParseAndEncodeBundleWithDeletedEntry() { - + Patient res = new Patient(); res.setId(new IdDt("Patient", "111", "222")); ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt("2011-01-01T12:12:22Z")); - + Bundle bundle = new Bundle(); bundle.addResource(res, ourCtx, "http://foo/base"); - + String actual = ourCtx.newJsonParser().encodeBundleToString(bundle); ourLog.info(actual); - + String expected = "{\"resourceType\":\"Bundle\",\"entry\":[{\"deleted\":{\"type\":\"Patient\",\"resourceId\":\"111\",\"versionId\":\"222\",\"instant\":\"2011-01-01T12:12:22Z\"}}]}"; assertEquals(expected, actual); - + } } diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java index 1e03a19cfe2..dff3393cd66 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java @@ -1,11 +1,7 @@ package ca.uhn.fhir.parser; import static org.hamcrest.Matchers.*; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.io.StringReader; import java.util.ArrayList; @@ -37,6 +33,7 @@ import ca.uhn.fhir.model.dstu2.resource.Composition; import ca.uhn.fhir.model.dstu2.resource.Encounter; import ca.uhn.fhir.model.dstu2.resource.Medication; import ca.uhn.fhir.model.dstu2.resource.MedicationPrescription; +import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Organization; import ca.uhn.fhir.model.dstu2.resource.Patient; import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum; @@ -57,6 +54,44 @@ public class XmlParserTest { XMLUnit.setIgnoreWhitespace(true); } + /** + * see #144 and #146 + */ + @Test + public void testParseContained() { + + FhirContext c = FhirContext.forDstu2(); + IParser parser = c.newXmlParser().setPrettyPrint(true); + + Observation o = new Observation(); + o.getCode().setText("obs text"); + + Patient p = new Patient(); + p.addName().addFamily("patient family"); + o.getSubject().setResource(p); + + String enc = parser.encodeResourceToString(o); + ourLog.info(enc); + + //@formatter:off + assertThat(enc, stringContainsInOrder( + "", + "", + "", + "", + "", + "" + )); + //@formatter:on + + o = parser.parseResource(Observation.class, enc); + assertEquals("obs text", o.getCode().getText()); + + assertNotNull(o.getSubject().getResource()); + p = (Patient) o.getSubject().getResource(); + assertEquals("patient family", p.getNameFirstRep().getFamilyAsSingleString()); + } + /** * See #113 */ diff --git a/pom.xml b/pom.xml index 7abf996f2f0..c35ab4ecb0e 100644 --- a/pom.xml +++ b/pom.xml @@ -217,11 +217,30 @@ org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.3 1.6 1.6 + javac-with-errorprone + true + + + com.google.errorprone + error_prone_core + 2.0.1 + + + org.codehaus.plexus + plexus-compiler-javac + 2.5 + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.5 + + org.apache.maven.plugins @@ -374,6 +393,26 @@ + + + + org.apache.maven.plugins + + + maven-compiler-plugin + + + [3.3,) + + + compile + testCompile + + + + + +