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