commit debug code for test not running in jenkins
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / markup / handler / PublicationHandler.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.io.markup.handler;
11
12 import org.apache.log4j.Logger;
13 import org.xml.sax.Attributes;
14 import org.xml.sax.SAXException;
15
16 import eu.etaxonomy.cdm.io.common.ImportHandlerBase;
17 import eu.etaxonomy.cdm.io.common.XmlImportBase;
18
19
20
21 /**
22 * Sax2 handler for the MarkupImport publication element
23 * @author a.mueller
24 * @date 28.06.2011
25 *
26 */
27 public class PublicationHandler extends ImportHandlerBase{
28 @SuppressWarnings("unused")
29 private static final Logger logger = Logger.getLogger(PublicationHandler.class);
30
31 private boolean isInPublication;
32 private ImportHandlerBase currentHandler = null;
33
34 public PublicationHandler(XmlImportBase importBase) {
35 super(importBase);
36 }
37
38 /* (non-Javadoc)
39 * @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
40 */
41 @Override
42 public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
43 super.startElement(uri, localName, qName, attributes);
44 if (currentHandler != null){
45 currentHandler.startElement(uri, localName, qName, attributes);
46 }else{
47 //publication
48 if ("publication".equalsIgnoreCase(qName)){
49 this.isInPublication = true;
50 //TODO check attributes
51 return;
52 }else if (this.isInPublication == false){
53 handleUnexpectedStartElement(uri, localName, qName);
54 return;
55 }
56 //children
57 if ("metaData".equalsIgnoreCase(qName)){
58 handleNotYetImplementedElement(uri, localName, qName);
59 }else if ("treatment".equalsIgnoreCase(qName)){
60 currentHandler = new TreatmentHandler(this);
61 }else if ("biographies".equalsIgnoreCase(qName)){
62 handleNotYetImplementedElement(uri, localName, qName);
63 }else if ("references".equalsIgnoreCase(qName)){
64 handleNotYetImplementedElement(uri, localName, qName);
65 }else if ("textSection".equalsIgnoreCase(qName)){
66 handleNotYetImplementedElement(uri, localName, qName);
67 }else if ("addenda".equalsIgnoreCase(qName)){
68 handleNotYetImplementedElement(uri, localName, qName);
69 }else{
70 handleUnexpectedStartElement(uri, localName, qName);
71 }
72 if (attributes.getLength() > 0){
73 handleUnexpectedAttributes(attributes);
74 }
75 }
76 }
77
78 /* (non-Javadoc)
79 * @see eu.etaxonomy.cdm.io.markup.handler.ImportHandlerBase#endElement(java.lang.String, java.lang.String, java.lang.String)
80 */
81 @Override
82 public void endElement(String uri, String localName, String qName) throws SAXException {
83 // super.endElement(uri, localName, qName);
84 if (currentHandler != null){
85 currentHandler.endElement(uri, localName, qName);
86 }else{
87 if ("publication".equalsIgnoreCase(qName)){
88 if (this.isInPublication == true){
89 this.isInPublication = false;
90 return;
91 }else{
92 fireUnexpectedEndElement(uri, localName, qName, 1);
93 }
94 }else{
95 if ("metaData".equalsIgnoreCase(qName)){
96 System.out.println("Hallo");
97 }else if ("treatment".equalsIgnoreCase(qName)){
98
99
100 }else if ("biographies".equalsIgnoreCase(qName)){
101
102 }else if ("references".equalsIgnoreCase(qName)){
103 }else if ("textSection".equalsIgnoreCase(qName)){
104 }else if ("addenda".equalsIgnoreCase(qName)){
105 }else{
106 handleUnexpectedEndElement(uri, localName, qName);
107 }
108 }
109 }
110 }
111
112
113
114
115 }