View Javadoc
1   package ca.uhn.fhir.jpa.provider;
2   
3   /*-
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2019 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.context.FhirContext;
24  import ca.uhn.fhir.jpa.subscription.ISubscriptionTriggeringSvc;
25  import ca.uhn.fhir.jpa.util.JpaConstants;
26  import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum;
27  import ca.uhn.fhir.rest.annotation.IdParam;
28  import ca.uhn.fhir.rest.annotation.Operation;
29  import ca.uhn.fhir.rest.annotation.OperationParam;
30  import ca.uhn.fhir.rest.param.StringParam;
31  import ca.uhn.fhir.rest.param.UriParam;
32  import ca.uhn.fhir.rest.server.IResourceProvider;
33  import org.hl7.fhir.instance.model.api.IBaseParameters;
34  import org.hl7.fhir.instance.model.api.IBaseResource;
35  import org.hl7.fhir.instance.model.api.IIdType;
36  import org.springframework.beans.factory.annotation.Autowired;
37  
38  import java.util.List;
39  
40  public class SubscriptionTriggeringProvider implements IResourceProvider {
41  	public static final String RESOURCE_ID = "resourceId";
42  	public static final String SEARCH_URL = "searchUrl";
43  	@Autowired
44  	private FhirContext myFhirContext;
45  	@Autowired
46  	private ISubscriptionTriggeringSvc mySubscriptionTriggeringSvc;
47  
48  
49  	@Operation(name = JpaConstants.OPERATION_TRIGGER_SUBSCRIPTION)
50  	public IBaseParameters triggerSubscription(
51  		@OperationParam(name = RESOURCE_ID, min = 0, max = OperationParam.MAX_UNLIMITED) List<UriParam> theResourceIds,
52  		@OperationParam(name = SEARCH_URL, min = 0, max = OperationParam.MAX_UNLIMITED) List<StringParam> theSearchUrls
53  	) {
54  		return mySubscriptionTriggeringSvc.triggerSubscription(theResourceIds, theSearchUrls, null);
55  	}
56  
57  	@Operation(name = JpaConstants.OPERATION_TRIGGER_SUBSCRIPTION)
58  	public IBaseParameters triggerSubscription(
59  		@IdParam IIdType theSubscriptionId,
60  		@OperationParam(name = RESOURCE_ID, min = 0, max = OperationParam.MAX_UNLIMITED) List<UriParam> theResourceIds,
61  		@OperationParam(name = SEARCH_URL, min = 0, max = OperationParam.MAX_UNLIMITED) List<StringParam> theSearchUrls
62  	) {
63  		return mySubscriptionTriggeringSvc.triggerSubscription(theResourceIds, theSearchUrls, theSubscriptionId);
64  	}
65  
66  
67  	@Override
68  	public Class<? extends IBaseResource> getResourceType() {
69  		return myFhirContext.getResourceDefinition(ResourceTypeEnum.SUBSCRIPTION.getCode()).getImplementingClass();
70  	}
71  
72  }