001/*- 002 * #%L 003 * HAPI FHIR JPA Server - Batch2 Task Processor 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.batch2.model; 021 022import ca.uhn.fhir.model.api.IModelJson; 023import com.fasterxml.jackson.annotation.JsonProperty; 024import jakarta.annotation.Nonnull; 025 026public class JobWorkNotification implements IModelJson { 027 028 @JsonProperty(value = "jobDefinitionId") 029 private String myJobDefinitionId; 030 031 @JsonProperty(value = "jobDefinitionVersion") 032 private int myJobDefinitionVersion; 033 034 @JsonProperty(value = "targetStepId") 035 private String myTargetStepId; 036 037 @JsonProperty(value = "chunkId") 038 private String myChunkId; 039 040 @JsonProperty(value = "instanceId") 041 private String myInstanceId; 042 043 public JobWorkNotification() {} 044 045 public JobWorkNotification( 046 @Nonnull String theJobDefinitionId, 047 int jobDefinitionVersion, 048 @Nonnull String theInstanceId, 049 @Nonnull String theTargetStepId, 050 @Nonnull String theChunkId) { 051 setJobDefinitionId(theJobDefinitionId); 052 setJobDefinitionVersion(jobDefinitionVersion); 053 setChunkId(theChunkId); 054 setInstanceId(theInstanceId); 055 setTargetStepId(theTargetStepId); 056 } 057 058 public JobWorkNotification(JobInstance theInstance, String theNextStepId, String theNextChunkId) { 059 this( 060 theInstance.getJobDefinitionId(), 061 theInstance.getJobDefinitionVersion(), 062 theInstance.getInstanceId(), 063 theNextStepId, 064 theNextChunkId); 065 } 066 067 public static JobWorkNotification firstStepNotification( 068 JobDefinition<?> theJobDefinition, String theInstanceId, String theChunkId) { 069 String firstStepId = theJobDefinition.getFirstStepId(); 070 String jobDefinitionId = theJobDefinition.getJobDefinitionId(); 071 int jobDefinitionVersion = theJobDefinition.getJobDefinitionVersion(); 072 return new JobWorkNotification(jobDefinitionId, jobDefinitionVersion, theInstanceId, firstStepId, theChunkId); 073 } 074 075 public String getJobDefinitionId() { 076 return myJobDefinitionId; 077 } 078 079 public void setJobDefinitionId(String theJobDefinitionId) { 080 myJobDefinitionId = theJobDefinitionId; 081 } 082 083 public int getJobDefinitionVersion() { 084 return myJobDefinitionVersion; 085 } 086 087 public void setJobDefinitionVersion(int theJobDefinitionVersion) { 088 myJobDefinitionVersion = theJobDefinitionVersion; 089 } 090 091 public String getTargetStepId() { 092 return myTargetStepId; 093 } 094 095 public void setTargetStepId(String theTargetStepId) { 096 myTargetStepId = theTargetStepId; 097 } 098 099 public String getChunkId() { 100 return myChunkId; 101 } 102 103 public void setChunkId(String theChunkId) { 104 myChunkId = theChunkId; 105 } 106 107 public void setInstanceId(String theInstanceId) { 108 myInstanceId = theInstanceId; 109 } 110 111 public String getInstanceId() { 112 return myInstanceId; 113 } 114 115 @Override 116 public String toString() { 117 return String.format( 118 "job[%s] instance[%s] step[%s] chunk[%s]", myJobDefinitionId, myInstanceId, myTargetStepId, myChunkId); 119 } 120}