1 package org.kuali.ole.service.impl;
2
3 import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord;
4 import org.kuali.ole.docstore.common.document.content.bib.marc.DataField;
5 import org.kuali.ole.docstore.common.document.content.bib.marc.SubField;
6 import org.kuali.ole.service.OverlayFileReaderService;
7
8 import java.util.LinkedHashMap;
9 import java.util.List;
10
11
12
13
14
15
16
17
18 public class OverlayMrcFileReaderServiceImpl implements OverlayFileReaderService{
19 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OverlayMrcFileReaderServiceImpl.class);
20
21 private Object object;
22
23 @Override
24 public void setObject(Object object) {
25 this.object = object;
26 }
27
28 @Override
29 public String getInputFieldValue(String incomingField) {
30 if(object!=null && object instanceof BibMarcRecord) {
31 BibMarcRecord bibMarcRecord = (BibMarcRecord) object;
32 List<DataField> dataFields = bibMarcRecord.getDataFields();
33 OverlayLookupTableServiceImpl overlayLookupTableService = new OverlayLookupTableServiceImpl();
34 try {
35 LinkedHashMap<String,SubField> subFieldMap = overlayLookupTableService.getOverlayDataFieldService().getSubFieldValueMap(dataFields);
36 String incomingFieldValue = overlayLookupTableService.getFieldValueFromSubField(incomingField, subFieldMap);
37 return incomingFieldValue!=null?incomingFieldValue:"";
38 } catch (Exception e) {
39 e.printStackTrace();
40 LOG.error("Exception while getting input field value"+e.getMessage());
41 }
42 }
43 return "";
44 }
45 }