View Javadoc
1   package ca.uhn.fhir.jpa.dao;
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.RuntimeResourceDefinition;
24  import ca.uhn.fhir.jpa.model.entity.BaseHasResource;
25  import ca.uhn.fhir.jpa.model.entity.ResourceTable;
26  import ca.uhn.fhir.jpa.model.entity.TagTypeEnum;
27  import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
28  import ca.uhn.fhir.jpa.util.DeleteConflict;
29  import ca.uhn.fhir.jpa.util.ExpungeOptions;
30  import ca.uhn.fhir.jpa.util.ExpungeOutcome;
31  import ca.uhn.fhir.model.api.IQueryParameterType;
32  import ca.uhn.fhir.model.api.TagList;
33  import ca.uhn.fhir.rest.api.EncodingEnum;
34  import ca.uhn.fhir.rest.api.MethodOutcome;
35  import ca.uhn.fhir.rest.api.PatchTypeEnum;
36  import ca.uhn.fhir.rest.api.ValidationModeEnum;
37  import ca.uhn.fhir.rest.api.server.IBundleProvider;
38  import ca.uhn.fhir.rest.api.server.RequestDetails;
39  import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
40  import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
41  import org.hl7.fhir.instance.model.api.IBaseMetaType;
42  import org.hl7.fhir.instance.model.api.IBaseResource;
43  import org.hl7.fhir.instance.model.api.IIdType;
44  import org.springframework.transaction.annotation.Propagation;
45  import org.springframework.transaction.annotation.Transactional;
46  
47  import javax.servlet.http.HttpServletResponse;
48  import java.util.Date;
49  import java.util.List;
50  import java.util.Map;
51  import java.util.Set;
52  
53  public interface IFhirResourceDao<T extends IBaseResource> extends IDao {
54  
55  	void addTag(IIdType theId, TagTypeEnum theTagType, String theScheme, String theTerm, String theLabel);
56  
57  	/**
58  	 * Create a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
59  	 * therefore can not fire any interceptors. Use only for internal system calls
60  	 */
61  	DaoMethodOutcome create(T theResource);
62  
63  	DaoMethodOutcome create(T theResource, RequestDetails theRequestDetails);
64  
65  	/**
66  	 * Create a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
67  	 * therefore can not fire any interceptors. Use only for internal system calls
68  	 */
69  	DaoMethodOutcome create(T theResource, String theIfNoneExist);
70  
71  	/**
72  	 * @param thePerformIndexing Use with caution! If you set this to false, you need to manually perform indexing or your resources
73  	 *                           won't be indexed and searches won't work.
74  	 * @param theUpdateTimestamp
75  	 * @param theRequestDetails  TODO
76  	 */
77  	DaoMethodOutcome create(T theResource, String theIfNoneExist, boolean thePerformIndexing, Date theUpdateTimestamp, RequestDetails theRequestDetails);
78  
79  	DaoMethodOutcome create(T theResource, String theIfNoneExist, RequestDetails theRequestDetails);
80  
81  	/**
82  	 * Delete a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
83  	 * therefore can not fire any interceptors. Use only for internal system calls
84  	 */
85  	DaoMethodOutcome delete(IIdType theResource);
86  
87  	/**
88  	 * This method does not throw an exception if there are delete conflicts, but populates them
89  	 * in the provided list
90  	 *
91  	 * @param theRequestDetails TODO
92  	 */
93  	DaoMethodOutcome delete(IIdType theResource, List<DeleteConflict> theDeleteConflictsListToPopulate, RequestDetails theRequestDetails);
94  
95  	/**
96  	 * This method throws an exception if there are delete conflicts
97  	 */
98  	DaoMethodOutcome delete(IIdType theResource, RequestDetails theRequestDetails);
99  
100 	/**
101 	 * This method does not throw an exception if there are delete conflicts, but populates them
102 	 * in the provided list
103 	 */
104 	DeleteMethodOutcome deleteByUrl(String theUrl, List<DeleteConflict> theDeleteConflictsListToPopulate, RequestDetails theRequestDetails);
105 
106 	/**
107 	 * This method throws an exception if there are delete conflicts
108 	 */
109 	DeleteMethodOutcome deleteByUrl(String theString, RequestDetails theRequestDetails);
110 
111 	ExpungeOutcome expunge(ExpungeOptions theExpungeOptions);
112 
113 	ExpungeOutcome expunge(IIdType theIIdType, ExpungeOptions theExpungeOptions);
114 
115 	TagList getAllResourceTags(RequestDetails theRequestDetails);
116 
117 	Class<T> getResourceType();
118 
119 	TagList getTags(IIdType theResourceId, RequestDetails theRequestDetails);
120 
121 	IBundleProvider history(Date theSince, Date theUntil, RequestDetails theRequestDetails);
122 
123 	IBundleProvider history(IIdType theId, Date theSince, Date theUntil, RequestDetails theRequestDetails);
124 
125 	/**
126 	 * Not supported in DSTU1!
127 	 *
128 	 * @param theRequestDetails TODO
129 	 */
130 	<MT extends IBaseMetaType> MT metaAddOperation(IIdType theId1, MT theMetaAdd, RequestDetails theRequestDetails);
131 
132 	/**
133 	 * Not supported in DSTU1!
134 	 *
135 	 * @param theRequestDetails TODO
136 	 */
137 	<MT extends IBaseMetaType> MT metaDeleteOperation(IIdType theId1, MT theMetaDel, RequestDetails theRequestDetails);
138 
139 	/**
140 	 * Not supported in DSTU1!
141 	 *
142 	 * @param theRequestDetails TODO
143 	 */
144 	<MT extends IBaseMetaType> MT metaGetOperation(Class<MT> theType, IIdType theId, RequestDetails theRequestDetails);
145 
146 	/**
147 	 * Not supported in DSTU1!
148 	 *
149 	 * @param theRequestDetails TODO
150 	 */
151 	<MT extends IBaseMetaType> MT metaGetOperation(Class<MT> theType, RequestDetails theRequestDetails);
152 
153 	DaoMethodOutcome patch(IIdType theId, PatchTypeEnum thePatchType, String thePatchBody, RequestDetails theRequestDetails);
154 
155 	Set<Long> processMatchUrl(String theMatchUrl);
156 
157 	/**
158 	 * Read a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
159 	 * therefore can not fire any interceptors. Use only for internal system calls
160 	 */
161 	T read(IIdType theId);
162 
163 	/**
164 	 * Read a resource by its internal PID
165 	 */
166 	IBaseResource readByPid(Long thePid);
167 
168 	/**
169 	 * @param theId
170 	 * @param theRequestDetails TODO
171 	 * @throws ResourceNotFoundException If the ID is not known to the server
172 	 */
173 	T read(IIdType theId, RequestDetails theRequestDetails);
174 
175 	/**
176 	 * Should deleted resources be returned successfully. This should be false for
177 	 * a normal FHIR read.
178 	 */
179 	T read(IIdType theId, RequestDetails theRequestDetails, boolean theDeletedOk);
180 
181 	BaseHasResource readEntity(IIdType theId);
182 
183 	/**
184 	 * @param theCheckForForcedId If true, this method should fail if the requested ID contains a numeric PID which exists, but is
185 	 *                            obscured by a "forced ID" so should not exist as far as the outside world is concerned.
186 	 */
187 	BaseHasResource readEntity(IIdType theId, boolean theCheckForForcedId);
188 
189 	/**
190 	 * Updates index tables associated with the given resource. Does not create a new
191 	 * version or update the resource's update time.
192 	 */
193 	void reindex(T theResource, ResourceTable theEntity);
194 
195 	void removeTag(IIdType theId, TagTypeEnum theTagType, String theSystem, String theCode, RequestDetails theRequestDetails);
196 
197 	void removeTag(IIdType theId, TagTypeEnum theTagType, String theSystem, String theCode);
198 
199 	IBundleProvider search(SearchParameterMap theParams);
200 
201 	IBundleProvider search(SearchParameterMap theParams, RequestDetails theRequestDetails);
202 
203 	@Transactional(propagation = Propagation.SUPPORTS)
204 	IBundleProvider search(SearchParameterMap theParams, RequestDetails theRequestDetails, HttpServletResponse theServletResponse);
205 
206 	Set<Long> searchForIds(SearchParameterMap theParams);
207 
208 	/**
209 	 * Takes a map of incoming raw search parameters and translates/parses them into
210 	 * appropriate {@link IQueryParameterType} instances of the appropriate type
211 	 * for the given param
212 	 *
213 	 * @throws InvalidRequestException If any of the parameters are not known
214 	 */
215 	void translateRawParameters(Map<String, List<String>> theSource, SearchParameterMap theTarget);
216 
217 	/**
218 	 * Update a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
219 	 * therefore can not fire any interceptors. Use only for internal system calls
220 	 */
221 	DaoMethodOutcome update(T theResource);
222 
223 	DaoMethodOutcome update(T theResource, RequestDetails theRequestDetails);
224 
225 	/**
226 	 * Update a resource - Note that this variant of the method does not take in a {@link RequestDetails} and
227 	 * therefore can not fire any interceptors. Use only for internal system calls
228 	 */
229 	DaoMethodOutcome update(T theResource, String theMatchUrl);
230 
231 	/**
232 	 * @param thePerformIndexing Use with caution! If you set this to false, you need to manually perform indexing or your resources
233 	 *                           won't be indexed and searches won't work.
234 	 * @param theRequestDetails  TODO
235 	 */
236 	DaoMethodOutcome update(T theResource, String theMatchUrl, boolean thePerformIndexing, RequestDetails theRequestDetails);
237 
238 	DaoMethodOutcome update(T theResource, String theMatchUrl, RequestDetails theRequestDetails);
239 
240 	/**
241 	 * @param theForceUpdateVersion Create a new version with the same contents as the current version even if the content hasn't changed (this is mostly useful for
242 	 *                              resources mapping to external content such as external code systems)
243 	 */
244 	DaoMethodOutcome update(T theResource, String theMatchUrl, boolean thePerformIndexing, boolean theForceUpdateVersion, RequestDetails theRequestDetails);
245 
246 	/**
247 	 * Not supported in DSTU1!
248 	 *
249 	 * @param theRequestDetails TODO
250 	 */
251 	MethodOutcome validate(T theResource, IIdType theId, String theRawResource, EncodingEnum theEncoding, ValidationModeEnum theMode, String theProfile, RequestDetails theRequestDetails);
252 
253 	RuntimeResourceDefinition validateCriteriaAndReturnResourceDefinition(String criteria);
254 
255 
256 	// /**
257 	// * Invoke the everything operation
258 	// */
259 	// IBundleProvider everything(IIdType theId);
260 
261 }