View Javadoc
1   package ca.uhn.fhir.jpa.provider;
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.rest.annotation.Operation;
24  import ca.uhn.fhir.rest.annotation.OperationParam;
25  import ca.uhn.fhir.util.ParametersUtil;
26  import org.hl7.fhir.instance.model.api.IBaseParameters;
27  import org.hl7.fhir.instance.model.api.IBaseResource;
28  import org.hl7.fhir.instance.model.api.IPrimitiveType;
29  
30  public abstract class BaseJpaSystemProviderDstu2Plus<T, MT> extends BaseJpaSystemProvider<T, MT> {
31  
32  
33  	@Operation(name = MARK_ALL_RESOURCES_FOR_REINDEXING, idempotent = true, returnParameters = {
34  		@OperationParam(name = "status")
35  	})
36  	public IBaseResource markAllResourcesForReindexing() {
37  		Integer count = getDao().markAllResourcesForReindexing();
38  
39  		IBaseParameters retVal = ParametersUtil.newInstance(getContext());
40  
41  		IPrimitiveType<?> string = ParametersUtil.createString(getContext(), "Marked " + count + " resources");
42  		ParametersUtil.addParameterToParameters(getContext(), retVal, "status", string);
43  
44  		return retVal;
45  	}
46  
47  	@Operation(name = PERFORM_REINDEXING_PASS, idempotent = true, returnParameters = {
48  		@OperationParam(name = "status")
49  	})
50  	public IBaseResource performReindexingPass() {
51  		Integer count = getDao().performReindexingPass(1000);
52  
53  		IBaseParameters retVal = ParametersUtil.newInstance(getContext());
54  
55  		IPrimitiveType<?> string;
56  		if (count == null) {
57  			string = ParametersUtil.createString(getContext(), "Index pass already proceeding");
58  		} else {
59  			string = ParametersUtil.createString(getContext(), "Indexed " + count + " resources");
60  		}
61  		ParametersUtil.addParameterToParameters(getContext(), retVal, "status", string);
62  
63  		return retVal;
64  	}
65  
66  }