View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.select.service.impl;
17  
18  import org.kuali.ole.select.businessobject.BibInfoBean;
19  import org.kuali.ole.select.service.ItemMarcXMLGenerationService;
20  
21  import java.util.HashMap;
22  
23  public class ItemMarcXMLGenerationServiceImpl implements ItemMarcXMLGenerationService {
24  
25      private static ItemMarcXMLGenerationServiceImpl itemMarcXMLGenerationServiceImpl;
26      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ItemMarcXMLGenerationServiceImpl.class);
27  
28  
29      public String getMarcXML(BibInfoBean bibInfoBean, HashMap dataMap) throws Exception {
30          return buildXmlString(bibInfoBean, dataMap);
31      }
32  
33      private String buildXmlString(BibInfoBean bibInfoBean, HashMap dataMap) throws Exception {
34          StringBuilder xmlString = new StringBuilder();
35          xmlString.append("<collection xmlns=\"http://www.loc.gov/MARC21/slim\">");
36          xmlString.append("<record>");
37          xmlString.append("<leader></leader>");
38          xmlString.append("<controlfield tag=\"001\"></controlfield>");
39          xmlString.append("<datafield tag=\"999\" ind1=\"\" ind2=\"\" >");
40          xmlString.append("<subfield code=\"a\"></subfield>");
41          xmlString.append("<subfield code=\"b\">").append(bibInfoBean.getVolumeNumber() != null ? bibInfoBean.getVolumeNumber() : "").append("</subfield>");
42          xmlString.append("<subfield code=\"i\"></subfield>");
43          xmlString.append("<subfield code=\"l\">").append(bibInfoBean.getLocation() != null ? bibInfoBean.getLocation() : "").append("</subfield>");
44          xmlString.append("<subfield code=\"m\"></subfield>");
45          xmlString.append("<subfield code=\"p\">").append(bibInfoBean.getListprice() != null ? bibInfoBean.getListprice() : "").append("</subfield>");
46          xmlString.append("</datafield>");
47          xmlString.append("</record>");
48          xmlString.append("</collection>");
49          if (LOG.isDebugEnabled())
50              LOG.debug("itemxmlString----------->" + xmlString.toString());
51          return xmlString.toString();
52      }
53  }