001package ca.uhn.fhir.jpa.subscription.model;
002
003/*-
004 * #%L
005 * HAPI FHIR Subscription Server
006 * %%
007 * Copyright (C) 2014 - 2021 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.context.FhirContext;
024import ca.uhn.fhir.rest.api.server.RequestDetails;
025import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage;
026import com.fasterxml.jackson.annotation.JsonProperty;
027import org.apache.commons.lang3.builder.ToStringBuilder;
028import org.hl7.fhir.instance.model.api.IBaseResource;
029
030/**
031 * Most of this class has been moved to ResourceModifiedMessage in the hapi-fhir-server project, for a reusable channel ResourceModifiedMessage
032 * that doesn't require knowledge of subscriptions.
033 */
034public class ResourceModifiedMessage extends BaseResourceModifiedMessage {
035
036        /**
037         * This will only be set if the resource is being triggered for a specific
038         * subscription
039         */
040        @JsonProperty(value = "subscriptionId", required = false)
041        private String mySubscriptionId;
042
043        /**
044         * Constructor
045         */
046        public ResourceModifiedMessage() {
047                super();
048        }
049
050        public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) {
051                super(theFhirContext, theResource, theOperationType);
052        }
053
054        public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) {
055                super(theFhirContext, theNewResource, theOperationType, theRequest);
056        }
057
058
059        public String getSubscriptionId() {
060                return mySubscriptionId;
061        }
062
063        public void setSubscriptionId(String theSubscriptionId) {
064                mySubscriptionId = theSubscriptionId;
065        }
066
067        @Override
068        public String toString() {
069                return new ToStringBuilder(this)
070                        .append("myId", myId)
071                        .append("myOperationType", myOperationType)
072                        .append("mySubscriptionId", mySubscriptionId)
073//                      .append("myPayload", myPayload)
074                        .append("myPayloadId", myPayloadId)
075//                      .append("myPayloadDecoded", myPayloadDecoded)
076                        .toString();
077        }
078}