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 org.apache.commons.lang3.builder.EqualsBuilder;
023import org.apache.commons.lang3.builder.HashCodeBuilder;
024
025/**
026 * Payload for the work-chunk completion event with the record and error counts.
027 */
028public class WorkChunkCompletionEvent extends BaseWorkChunkEvent {
029        int myRecordsProcessed;
030        int myRecoveredErrorCount;
031        String myRecoveredWarningMessage;
032
033        public WorkChunkCompletionEvent(String theChunkId, int theRecordsProcessed, int theRecoveredErrorCount) {
034                super(theChunkId);
035                myRecordsProcessed = theRecordsProcessed;
036                myRecoveredErrorCount = theRecoveredErrorCount;
037        }
038
039        public WorkChunkCompletionEvent(
040                        String theChunkId, int theRecordsProcessed, int theRecoveredErrorCount, String theRecoveredWarningMessage) {
041                this(theChunkId, theRecordsProcessed, theRecoveredErrorCount);
042                myRecoveredWarningMessage = theRecoveredWarningMessage;
043        }
044
045        public int getRecordsProcessed() {
046                return myRecordsProcessed;
047        }
048
049        public int getRecoveredErrorCount() {
050                return myRecoveredErrorCount;
051        }
052
053        public String getRecoveredWarningMessage() {
054                return myRecoveredWarningMessage;
055        }
056
057        @Override
058        public boolean equals(Object theO) {
059                if (this == theO) return true;
060
061                if (theO == null || getClass() != theO.getClass()) return false;
062
063                WorkChunkCompletionEvent that = (WorkChunkCompletionEvent) theO;
064
065                return new EqualsBuilder()
066                                .appendSuper(super.equals(theO))
067                                .append(myRecordsProcessed, that.myRecordsProcessed)
068                                .append(myRecoveredErrorCount, that.myRecoveredErrorCount)
069                                .append(myRecoveredWarningMessage, that.myRecoveredWarningMessage)
070                                .isEquals();
071        }
072
073        @Override
074        public int hashCode() {
075                return new HashCodeBuilder(17, 37)
076                                .appendSuper(super.hashCode())
077                                .append(myRecordsProcessed)
078                                .append(myRecoveredErrorCount)
079                                .append(myRecoveredWarningMessage)
080                                .toHashCode();
081        }
082}