001package org.kuali.ole.batch.bo;
002
003import org.kuali.ole.docstore.common.document.Holdings;
004import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord;
005import org.slf4j.Logger;
006import org.slf4j.LoggerFactory;
007
008import java.util.ArrayList;
009import java.util.List;
010
011/**
012 * Created with IntelliJ IDEA.
013 * User: rajeshbabuk
014 * Date: 7/2/14
015 * Time: 10:49 AM
016 * To change this template use File | Settings | File Templates.
017 */
018public class OLEBatchBibImportStatistics {
019    private static final Logger LOG = LoggerFactory.getLogger(OLEBatchBibImportStatistics.class);
020
021    private int chunkCount = 0;
022    private int totalCount = 0;
023    private int successRecord = 0;
024    private int noOfEinstanceAdded = 0;
025    private int noOfEinstanceDeleted = 0;
026    private int noOfEinstanceCreatedWithOutLink = 0;
027    private int noOfbibsHaveMoreThanOneEinstance = 0;
028    private StringBuffer misMatchMarcRecords = new StringBuffer("");
029    private List<BibMarcRecord> mismatchRecordList = new ArrayList<BibMarcRecord>();
030    private List<BibMarcRecord> recordsCreatedWithOutLink = new ArrayList<BibMarcRecord>();
031    private List<BibMarcRecord> recordsCreatedWithMoreThanOneLink = new ArrayList<BibMarcRecord>();
032    private List<Holdings> totalRecordsCreated = new ArrayList<Holdings>();
033    private List<Holdings> totalRecordsDeleted = new ArrayList<Holdings>();
034    private List<String> invalidLeaderField = new ArrayList<>();
035    private List<BibMarcRecord> bibMarcRecordList = new ArrayList<BibMarcRecord>();
036    private List bibImportChunkRecordsList = new ArrayList(0);
037    private StringBuilder errorBuilder = new StringBuilder();
038
039    private List<BibMarcRecord> moreThanOneHoldingsMatched = new ArrayList<BibMarcRecord>();
040    private List<BibMarcRecord> moreThanOneItemMatched = new ArrayList<BibMarcRecord>();
041
042    public int getChunkCount() {
043        return chunkCount;
044    }
045
046    public void setChunkCount(int chunkCount) {
047        this.chunkCount = chunkCount;
048    }
049
050    public int getTotalCount() {
051        return totalCount;
052    }
053
054    public void setTotalCount(int totalCount) {
055        this.totalCount = totalCount;
056    }
057
058    public int getSuccessRecord() {
059        return successRecord;
060    }
061
062    public void setSuccessRecord(int successRecord) {
063        this.successRecord = successRecord;
064    }
065
066    public int getNoOfEinstanceAdded() {
067        return noOfEinstanceAdded;
068    }
069
070    public void setNoOfEinstanceAdded(int noOfEinstanceAdded) {
071        this.noOfEinstanceAdded = noOfEinstanceAdded;
072    }
073
074    public int getNoOfEinstanceDeleted() {
075        return noOfEinstanceDeleted;
076    }
077
078    public void setNoOfEinstanceDeleted(int noOfEinstanceDeleted) {
079        this.noOfEinstanceDeleted = noOfEinstanceDeleted;
080    }
081
082    public int getNoOfEinstanceCreatedWithOutLink() {
083        return noOfEinstanceCreatedWithOutLink;
084    }
085
086    public void setNoOfEinstanceCreatedWithOutLink(int noOfEinstanceCreatedWithOutLink) {
087        this.noOfEinstanceCreatedWithOutLink = noOfEinstanceCreatedWithOutLink;
088    }
089
090    public int getNoOfbibsHaveMoreThanOneEinstance() {
091        return noOfbibsHaveMoreThanOneEinstance;
092    }
093
094    public void setNoOfbibsHaveMoreThanOneEinstance(int noOfbibsHaveMoreThanOneEinstance) {
095        this.noOfbibsHaveMoreThanOneEinstance = noOfbibsHaveMoreThanOneEinstance;
096    }
097
098    public void addChunkCount(int chunkCount) {
099        this.chunkCount = this.chunkCount + chunkCount;
100    }
101
102    public void addTotalCount(int totalCount) {
103        this.totalCount = this.totalCount + totalCount;
104    }
105
106    public void addSuccessRecord(int successRecord) {
107        this.successRecord = this.successRecord + successRecord;
108    }
109
110    public void addNoOfEinstanceAdded(int noOfEinstanceAdded) {
111        this.noOfEinstanceAdded = this.noOfEinstanceAdded + noOfEinstanceAdded;
112    }
113
114    public void addNoOfEinstanceDeleted(int noOfEinstanceDeleted) {
115        this.noOfEinstanceDeleted = this.noOfEinstanceDeleted + noOfEinstanceDeleted;
116    }
117
118    public void addNoOfEinstanceCreatedWithOutLink(int noOfEinstanceCreatedWithOutLink) {
119        this.noOfEinstanceCreatedWithOutLink = this.noOfEinstanceCreatedWithOutLink + noOfEinstanceCreatedWithOutLink;
120    }
121
122    public void addNoOfbibsHaveMoreThanOneEinstance(int noOfbibsHaveMoreThanOneEinstance) {
123        this.noOfbibsHaveMoreThanOneEinstance = this.noOfbibsHaveMoreThanOneEinstance + noOfbibsHaveMoreThanOneEinstance;
124    }
125
126    public StringBuffer getMisMatchMarcRecords() {
127        return misMatchMarcRecords;
128    }
129
130    public void setMisMatchMarcRecords(StringBuffer misMatchMarcRecords) {
131        this.misMatchMarcRecords = misMatchMarcRecords;
132    }
133
134    public void appendMisMatchMarcRecords(String misMatchMarcRecords) {
135        this.misMatchMarcRecords.append(misMatchMarcRecords);
136    }
137
138    public List<BibMarcRecord> getMismatchRecordList() {
139        return mismatchRecordList;
140    }
141
142    public void setMismatchRecordList(List<BibMarcRecord> mismatchRecordList) {
143        this.mismatchRecordList = mismatchRecordList;
144    }
145
146    public List<BibMarcRecord> getRecordsCreatedWithOutLink() {
147        return recordsCreatedWithOutLink;
148    }
149
150    public void setRecordsCreatedWithOutLink(List<BibMarcRecord> recordsCreatedWithOutLink) {
151        this.recordsCreatedWithOutLink = recordsCreatedWithOutLink;
152    }
153
154    public List<BibMarcRecord> getRecordsCreatedWithMoreThanOneLink() {
155        return recordsCreatedWithMoreThanOneLink;
156    }
157
158    public void setRecordsCreatedWithMoreThanOneLink(List<BibMarcRecord> recordsCreatedWithMoreThanOneLink) {
159        this.recordsCreatedWithMoreThanOneLink = recordsCreatedWithMoreThanOneLink;
160    }
161
162    public List<Holdings> getTotalRecordsCreated() {
163        return totalRecordsCreated;
164    }
165
166    public void setTotalRecordsCreated(List<Holdings> totalRecordsCreated) {
167        this.totalRecordsCreated = totalRecordsCreated;
168    }
169
170    public List<Holdings> getTotalRecordsDeleted() {
171        return totalRecordsDeleted;
172    }
173
174    public void setTotalRecordsDeleted(List<Holdings> totalRecordsDeleted) {
175        this.totalRecordsDeleted = totalRecordsDeleted;
176    }
177
178    public List<String> getInvalidLeaderField() {
179        return invalidLeaderField;
180    }
181
182    public void setInvalidLeaderField(List<String> invalidLeaderField) {
183        this.invalidLeaderField = invalidLeaderField;
184    }
185
186    public List<BibMarcRecord> getBibMarcRecordList() {
187        return bibMarcRecordList;
188    }
189
190    public void setBibMarcRecordList(List<BibMarcRecord> bibMarcRecordList) {
191        this.bibMarcRecordList = bibMarcRecordList;
192    }
193
194    public List getBibImportChunkRecordsList() {
195        return bibImportChunkRecordsList;
196    }
197
198    public void setBibImportChunkRecordsList(List bibImportChunkRecordsList) {
199        this.bibImportChunkRecordsList = bibImportChunkRecordsList;
200    }
201
202    public List<BibMarcRecord> getMoreThanOneHoldingsMatched() {
203        return moreThanOneHoldingsMatched;
204    }
205
206    public void setMoreThanOneHoldingsMatched(List<BibMarcRecord> moreThanOneHoldingsMatched) {
207        this.moreThanOneHoldingsMatched = moreThanOneHoldingsMatched;
208    }
209
210    public List<BibMarcRecord> getMoreThanOneItemMatched() {
211        return moreThanOneItemMatched;
212    }
213
214    public void setMoreThanOneItemMatched(List<BibMarcRecord> moreThanOneItemMatched) {
215        this.moreThanOneItemMatched = moreThanOneItemMatched;
216    }
217
218    public StringBuilder getErrorBuilder() {
219        return errorBuilder;
220    }
221
222    public void setErrorBuilder(StringBuilder errorBuilder) {
223        this.errorBuilder = errorBuilder;
224    }
225
226    @Override
227    public String toString() {
228        return "OLEBatchBibImportStatistics {" + "chunkCount" + chunkCount
229                + "totalCount" + totalCount
230                + "successRecord" + successRecord
231                + "noOfEinstanceAdded" + noOfEinstanceAdded
232                + "noOfEinstanceDeleted" + noOfEinstanceDeleted
233                + "noOfEinstanceCreatedWithOutLink" + noOfEinstanceCreatedWithOutLink
234                + "noOfbibsHaveMoreThanOneEinstance" + noOfbibsHaveMoreThanOneEinstance
235                + "}";
236    }
237
238    public void setInstanceStatistics(List<BibMarcRecord> mismatchRecordList) {
239        setMismatchRecordList(mismatchRecordList);
240        setNoOfEinstanceCreatedWithOutLink(getRecordsCreatedWithOutLink().size());
241        setNoOfbibsHaveMoreThanOneEinstance(getRecordsCreatedWithMoreThanOneLink().size());
242        setNoOfEinstanceAdded(getTotalRecordsCreated().size());
243        setNoOfEinstanceDeleted(getTotalRecordsDeleted().size());
244
245    }
246}