001package org.kuali.ole.service.impl; 002 003import org.kuali.ole.docstore.common.document.content.bib.marc.BibMarcRecord; 004import org.kuali.ole.docstore.common.document.content.bib.marc.DataField; 005import org.kuali.ole.docstore.common.document.content.bib.marc.SubField; 006import org.kuali.ole.service.OverlayFileReaderService; 007 008import java.util.LinkedHashMap; 009import java.util.List; 010 011/** 012 * Created with IntelliJ IDEA. 013 * User: vivekb 014 * Date: 2/23/13 015 * Time: 1:02 PM 016 * To change this template use File | Settings | File Templates. 017 */ 018public class OverlayMrcFileReaderServiceImpl implements OverlayFileReaderService{ 019 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OverlayMrcFileReaderServiceImpl.class); 020 021 private Object object; 022 023 @Override 024 public void setObject(Object object) { 025 this.object = object; 026 } 027 028 @Override 029 public String getInputFieldValue(String incomingField) { 030 if(object!=null && object instanceof BibMarcRecord) { 031 BibMarcRecord bibMarcRecord = (BibMarcRecord) object; 032 List<DataField> dataFields = bibMarcRecord.getDataFields(); 033 OverlayLookupTableServiceImpl overlayLookupTableService = new OverlayLookupTableServiceImpl(); 034 try { 035 LinkedHashMap<String,SubField> subFieldMap = overlayLookupTableService.getOverlayDataFieldService().getSubFieldValueMap(dataFields); 036 String incomingFieldValue = overlayLookupTableService.getFieldValueFromSubField(incomingField, subFieldMap); 037 return incomingFieldValue!=null?incomingFieldValue:""; 038 } catch (Exception e) { 039 e.printStackTrace(); 040 LOG.error("Exception while getting input field value"+e.getMessage()); 041 } 042 } 043 return ""; 044 } 045}