
001/*- 002 * #%L 003 * HAPI FHIR Subscription Server 004 * %% 005 * Copyright (C) 2014 - 2025 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.subscription.match.registry; 021 022import ca.uhn.fhir.jpa.subscription.match.matcher.subscriber.SubscriptionCriteriaParser; 023import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscription; 024import ca.uhn.fhir.jpa.subscription.model.CanonicalSubscriptionChannelType; 025import ca.uhn.fhir.jpa.subscription.model.ChannelRetryConfiguration; 026import ca.uhn.fhir.model.primitive.IdDt; 027 028import java.util.concurrent.atomic.AtomicLong; 029 030public class ActiveSubscription { 031 032 private SubscriptionCriteriaParser.SubscriptionCriteria myCriteria; 033 034 private final String myChannelName; 035 private final String myId; 036 private CanonicalSubscription mySubscription; 037 private boolean flagForDeletion; 038 039 private ChannelRetryConfiguration myRetryConfigurationParameters; 040 private final AtomicLong myDeliveriesCount = new AtomicLong(); 041 042 public ActiveSubscription(CanonicalSubscription theSubscription, String theChannelName) { 043 myChannelName = theChannelName; 044 myId = theSubscription.getIdPart(); 045 setSubscription(theSubscription); 046 } 047 048 public SubscriptionCriteriaParser.SubscriptionCriteria getCriteria() { 049 return myCriteria; 050 } 051 052 public CanonicalSubscription getSubscription() { 053 return mySubscription; 054 } 055 056 public final void setSubscription(CanonicalSubscription theSubscription) { 057 mySubscription = theSubscription; 058 myCriteria = SubscriptionCriteriaParser.parse(theSubscription.getCriteriaString()); 059 } 060 061 public String getChannelName() { 062 return myChannelName; 063 } 064 065 public boolean isFlagForDeletion() { 066 return flagForDeletion; 067 } 068 069 public void setFlagForDeletion(boolean theFlagForDeletion) { 070 flagForDeletion = theFlagForDeletion; 071 } 072 073 public String getId() { 074 return myId; 075 } 076 077 public CanonicalSubscriptionChannelType getChannelType() { 078 return mySubscription.getChannelType(); 079 } 080 081 public void setRetryConfiguration(ChannelRetryConfiguration theParams) { 082 myRetryConfigurationParameters = theParams; 083 } 084 085 public ChannelRetryConfiguration getRetryConfigurationParameters() { 086 return myRetryConfigurationParameters; 087 } 088 089 public long getDeliveriesCount() { 090 return myDeliveriesCount.get(); 091 } 092 093 public long incrementDeliveriesCount() { 094 return myDeliveriesCount.incrementAndGet(); 095 } 096 097 public IdDt getIdDt() { 098 return new IdDt("Subscription", myId); 099 } 100}