
001package ca.uhn.fhir.jpa.term.job; 002 003/*- 004 * #%L 005 * HAPI FHIR JPA Server 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import org.slf4j.Logger; 024import org.slf4j.LoggerFactory; 025import org.springframework.batch.item.ItemReader; 026import org.springframework.beans.factory.annotation.Value; 027 028import static ca.uhn.fhir.jpa.batch.config.BatchConstants.JOB_PARAM_CODE_SYSTEM_VERSION_ID; 029 030/** 031 * This reader works as a pass-through by passing the received parameter once to the writer, 032 * in order to share the writer functionality between two jobs 033 */ 034public class BatchTermCodeSystemUniqueVersionDeleteReader implements ItemReader<Long> { 035 private static final Logger ourLog = LoggerFactory.getLogger(BatchTermCodeSystemUniqueVersionDeleteReader.class); 036 037 @Value("#{jobParameters['" + JOB_PARAM_CODE_SYSTEM_VERSION_ID + "']}") 038 private Long myTermCodeSystemVersionPid; 039 040 // indicates if the parameter was already passed once to the writer, which indicates end of task 041 private boolean myParameterPassed; 042 043 044 @Override 045 public Long read() throws Exception { 046 if ( ! myParameterPassed) { 047 myParameterPassed = true; 048 return myTermCodeSystemVersionPid; 049 } 050 051 return null; 052 } 053 054}