View Javadoc
1   package ca.uhn.fhir.jpa.search;
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 javax.persistence.EntityManager;
24  
25  import org.springframework.beans.factory.annotation.Autowired;
26  import org.springframework.transaction.PlatformTransactionManager;
27  
28  import ca.uhn.fhir.context.FhirContext;
29  import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
30  import ca.uhn.fhir.jpa.dao.data.ISearchResultDao;
31  import ca.uhn.fhir.rest.api.server.IBundleProvider;
32  import ca.uhn.fhir.rest.server.BasePagingProvider;
33  import ca.uhn.fhir.rest.server.IPagingProvider;
34  
35  public class DatabaseBackedPagingProvider extends BasePagingProvider implements IPagingProvider {
36  
37  	@Autowired
38  	private FhirContext myContext;
39  	@Autowired
40  	private IFhirSystemDao<?, ?> myDao;
41  	@Autowired
42  	private EntityManager myEntityManager;
43  	@Autowired
44  	private PlatformTransactionManager myPlatformTransactionManager;
45  	@Autowired
46  	private ISearchResultDao mySearchResultDao;
47  
48  	/**
49  	 * Constructor
50  	 */
51  	public DatabaseBackedPagingProvider() {
52  		super();
53  	}
54  
55  	/**
56  	 * Constructor
57  	 * @deprecated Use {@link DatabaseBackedPagingProvider} as this constructor has no purpose
58  	 */
59  	@Deprecated
60  	public DatabaseBackedPagingProvider(int theSize) {
61  		this();
62  	}
63  
64  	@Override
65  	public synchronized IBundleProvider retrieveResultList(String theId) {
66  		PersistedJpaBundleProvider provider = new PersistedJpaBundleProvider(theId, myDao);
67  		if (!provider.ensureSearchEntityLoaded()) {
68  			return null;
69  		}
70  		return provider;
71  	}
72  
73  	@Override
74  	public synchronized String storeResultList(IBundleProvider theList) {
75  		String uuid = theList.getUuid();
76  		return uuid;
77  	}
78  
79  }