1    /*
2     * Copyright 2009 :torweg free software group
3     *
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.site.map;
19   
20   import javax.persistence.Entity;
21   import javax.persistence.Table;
22   import javax.persistence.UniqueConstraint;
23   import javax.xml.bind.annotation.XmlAccessOrder;
24   import javax.xml.bind.annotation.XmlAccessType;
25   import javax.xml.bind.annotation.XmlAccessorOrder;
26   import javax.xml.bind.annotation.XmlAccessorType;
27   import javax.xml.bind.annotation.XmlRootElement;
28   
29   import org.jdom.Element;
30   import org.torweg.pulse.bundle.JDOMable;
31   import org.torweg.pulse.util.INameable;
32   import org.torweg.pulse.util.entity.AbstractNamableEntity;
33   
34   /**
35    * Used to tag a {@code SitemapNode} to be part of a specific section of
36    * the {@code Sitemap}.
37    * 
38    * @author Daniel Dietz
39    * @version $Revision: 1404 $
40    */
41   @Entity
42   @XmlRootElement(name = "sitemap-section-tag")
43   @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
44   @XmlAccessorType(XmlAccessType.FIELD)
45   @Table(uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
46   public class SitemapSectionTag extends AbstractNamableEntity implements
47           INameable, JDOMable {
48   
49       /**
50        * The serialVersionUID.
51        */
52       private static final long serialVersionUID = -7055007237858087858L;
53   
54       /**
55        * Default constructor.
56        */
57       protected SitemapSectionTag() {
58           super();
59       }
60   
61       /**
62        * Creates a new {@code SitemapSectionTag} with the given name.
63        * 
64        * @param n
65        *            the name to be set
66        */
67       public SitemapSectionTag(final String n) {
68           super();
69           setName(n);
70       }
71   
72       /**
73        * Return a JDom-representation of the {@code SitemapSectionTag}.
74        * 
75        * @return {@code null}
76        * 
77        */
78       public final Element deserializeToJDOM() {
79           Element element = new Element("SitemapSectionTag").setAttribute(
80                   "class", getClass().getCanonicalName());
81           if (getId() != null) {
82               element.setAttribute("id", getId().toString());
83           }
84           element.addContent(new Element("name").setText(getName()));
85           return element;
86       }
87   
88   }
89