View Javadoc
1   package ca.uhn.fhir.jpa.dao.dstu3;
2   
3   import ca.uhn.fhir.context.FhirContext;
4   import ca.uhn.fhir.jpa.dao.IFhirResourceDaoSearchParameter;
5   import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
6   import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
7   import ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoSearchParameterR4;
8   import ca.uhn.fhir.jpa.entity.ResourceTable;
9   import org.hl7.fhir.dstu3.model.*;
10  import org.springframework.beans.factory.annotation.Autowired;
11  
12  import java.util.List;
13  
14  /*
15   * #%L
16   * HAPI FHIR JPA Server
17   * %%
18   * Copyright (C) 2014 - 2018 University Health Network
19   * %%
20   * Licensed under the Apache License, Version 2.0 (the "License");
21   * you may not use this file except in compliance with the License.
22   * You may obtain a copy of the License at
23   * 
24   * http://www.apache.org/licenses/LICENSE-2.0
25   * 
26   * Unless required by applicable law or agreed to in writing, software
27   * distributed under the License is distributed on an "AS IS" BASIS,
28   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29   * See the License for the specific language governing permissions and
30   * limitations under the License.
31   * #L%
32   */
33  
34  public class FhirResourceDaoSearchParameterDstu3 extends FhirResourceDaoDstu3<SearchParameter> implements IFhirResourceDaoSearchParameter<SearchParameter> {
35  
36  	@Autowired
37  	private ISearchParamRegistry mySearchParamRegistry;
38  
39  	@Autowired
40  	private IFhirSystemDao<Bundle, Meta> mySystemDao;
41  
42  	protected void markAffectedResources(SearchParameter theResource) {
43  		Boolean reindex = theResource != null ? CURRENTLY_REINDEXING.get(theResource) : null;
44  		String expression = theResource != null ? theResource.getExpression() : null;
45  		markResourcesMatchingExpressionAsNeedingReindexing(reindex, expression);
46  	}
47  
48  
49  	@Override
50  	protected void postPersist(ResourceTable theEntity, SearchParameter theResource) {
51  		super.postPersist(theEntity, theResource);
52  		markAffectedResources(theResource);
53  	}
54  
55  	@Override
56  	protected void postUpdate(ResourceTable theEntity, SearchParameter theResource) {
57  		super.postUpdate(theEntity, theResource);
58  		markAffectedResources(theResource);
59  	}
60  
61  	@Override
62  	protected void preDelete(SearchParameter theResourceToDelete, ResourceTable theEntityToDelete) {
63  		super.preDelete(theResourceToDelete, theEntityToDelete);
64  		markAffectedResources(theResourceToDelete);
65  	}
66  
67  	@Override
68  	protected void validateResourceForStorage(SearchParameter theResource, ResourceTable theEntityToSave) {
69  		super.validateResourceForStorage(theResource, theEntityToSave);
70  
71  		Enum<?> status = theResource.getStatus();
72  		List<CodeType> base = theResource.getBase();
73  		String expression = theResource.getExpression();
74  		FhirContext context = getContext();
75  		Enumerations.SearchParamType type = theResource.getType();
76  
77  		FhirResourceDaoSearchParameterR4.validateSearchParam(type, status, base, expression, context);
78  	}
79  
80  }