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 org.apache.commons.lang3.Validate; 025 026public class WorkChunkMetadata implements IModelJson { 027 028 @JsonProperty("id") 029 private String myId; 030 031 @JsonProperty("sequence") 032 // TODO MB danger - these repeat with a job or even a single step. They start at 0 for every parent chunk. Review 033 // after merge. 034 private int mySequence; 035 036 @JsonProperty("status") 037 private WorkChunkStatusEnum myStatus; 038 039 @JsonProperty("jobDefinitionId") 040 private String myJobDefinitionId; 041 042 @JsonProperty("jobDefinitionVersion") 043 private int myJobDefinitionVersion; 044 045 @JsonProperty("targetStepId") 046 private String myTargetStepId; 047 048 @JsonProperty("instanceId") 049 private String myInstanceId; 050 051 public WorkChunkStatusEnum getStatus() { 052 return myStatus; 053 } 054 055 public WorkChunkMetadata setStatus(WorkChunkStatusEnum theStatus) { 056 myStatus = theStatus; 057 return this; 058 } 059 060 public String getJobDefinitionId() { 061 return myJobDefinitionId; 062 } 063 064 public WorkChunkMetadata setJobDefinitionId(String theJobDefinitionId) { 065 Validate.notBlank(theJobDefinitionId); 066 myJobDefinitionId = theJobDefinitionId; 067 return this; 068 } 069 070 public int getJobDefinitionVersion() { 071 return myJobDefinitionVersion; 072 } 073 074 public WorkChunkMetadata setJobDefinitionVersion(int theJobDefinitionVersion) { 075 Validate.isTrue(theJobDefinitionVersion >= 1); 076 myJobDefinitionVersion = theJobDefinitionVersion; 077 return this; 078 } 079 080 public String getTargetStepId() { 081 return myTargetStepId; 082 } 083 084 public WorkChunkMetadata setTargetStepId(String theTargetStepId) { 085 Validate.notBlank(theTargetStepId); 086 myTargetStepId = theTargetStepId; 087 return this; 088 } 089 090 public String getInstanceId() { 091 return myInstanceId; 092 } 093 094 public WorkChunkMetadata setInstanceId(String theInstanceId) { 095 myInstanceId = theInstanceId; 096 return this; 097 } 098 099 public String getId() { 100 return myId; 101 } 102 103 public WorkChunkMetadata setId(String theId) { 104 Validate.notBlank(theId); 105 myId = theId; 106 return this; 107 } 108 109 public int getSequence() { 110 return mySequence; 111 } 112 113 public void setSequence(int theSequence) { 114 mySequence = theSequence; 115 } 116 117 public WorkChunk toWorkChunk() { 118 WorkChunk workChunk = new WorkChunk(); 119 workChunk.setId(getId()); 120 workChunk.setStatus(getStatus()); 121 workChunk.setInstanceId(getInstanceId()); 122 workChunk.setJobDefinitionId(getJobDefinitionId()); 123 workChunk.setJobDefinitionVersion(getJobDefinitionVersion()); 124 workChunk.setSequence(getSequence()); 125 workChunk.setTargetStepId(getTargetStepId()); 126 return workChunk; 127 } 128}