001package ca.uhn.fhir.jpa.subscription.model; 002 003/*- 004 * #%L 005 * HAPI FHIR Storage api 006 * %% 007 * Copyright (C) 2014 - 2022 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.interceptor.model.RequestPartitionId; 025import ca.uhn.fhir.rest.api.server.RequestDetails; 026import ca.uhn.fhir.rest.server.messaging.BaseResourceModifiedMessage; 027import com.fasterxml.jackson.annotation.JsonProperty; 028import org.apache.commons.lang3.builder.ToStringBuilder; 029import org.hl7.fhir.instance.model.api.IBaseResource; 030 031/** 032 * Most of this class has been moved to ResourceModifiedMessage in the hapi-fhir-server project, for a reusable channel ResourceModifiedMessage 033 * that doesn't require knowledge of subscriptions. 034 */ 035public class ResourceModifiedMessage extends BaseResourceModifiedMessage { 036 037 /** 038 * This will only be set if the resource is being triggered for a specific 039 * subscription 040 */ 041 @JsonProperty(value = "subscriptionId", required = false) 042 private String mySubscriptionId; 043 044 @JsonProperty(value = "partitionId", required = false) 045 private RequestPartitionId myPartitionId; 046 047 048 /** 049 * Constructor 050 */ 051 public ResourceModifiedMessage() { 052 super(); 053 } 054 055 public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theResource, OperationTypeEnum theOperationType) { 056 super(theFhirContext, theResource, theOperationType); 057 myPartitionId = RequestPartitionId.defaultPartition(); 058 } 059 060 public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest) { 061 super(theFhirContext, theNewResource, theOperationType, theRequest); 062 myPartitionId = RequestPartitionId.defaultPartition(); 063 } 064 065 public ResourceModifiedMessage(FhirContext theFhirContext, IBaseResource theNewResource, OperationTypeEnum theOperationType, RequestDetails theRequest, RequestPartitionId theRequestPartitionId) { 066 super(theFhirContext, theNewResource, theOperationType, theRequest); 067 myPartitionId = theRequestPartitionId; 068 } 069 070 071 public String getSubscriptionId() { 072 return mySubscriptionId; 073 } 074 075 public void setSubscriptionId(String theSubscriptionId) { 076 mySubscriptionId = theSubscriptionId; 077 } 078 079 public RequestPartitionId getPartitionId() { 080 return myPartitionId; 081 } 082 083 public void setPartitionId(RequestPartitionId thePartitionId) { 084 myPartitionId = thePartitionId; 085 } 086 087 088 @Override 089 public String toString() { 090 return new ToStringBuilder(this) 091 .append("operationType", myOperationType) 092 .append("subscriptionId", mySubscriptionId) 093 .append("payloadId", myPayloadId) 094 .append("partitionId", myPartitionId) 095 .toString(); 096 } 097}