| 1 | /** |
|---|
| 2 | * Copyright (C) 2007 EDIT |
|---|
| 3 | * European Distributed Institute of Taxonomy |
|---|
| 4 | * http://www.e-taxonomy.eu |
|---|
| 5 | * |
|---|
| 6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 |
|---|
| 7 | * See LICENSE.TXT at the top of this package for the full license terms. |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | package eu.etaxonomy.cdm.model.common; |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | import javax.persistence.FetchType; |
|---|
| 14 | import javax.persistence.ManyToOne; |
|---|
| 15 | import javax.persistence.MappedSuperclass; |
|---|
| 16 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 17 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 18 | import javax.xml.bind.annotation.XmlElement; |
|---|
| 19 | import javax.xml.bind.annotation.XmlIDREF; |
|---|
| 20 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 21 | import javax.xml.bind.annotation.XmlSchemaType; |
|---|
| 22 | import javax.xml.bind.annotation.XmlType; |
|---|
| 23 | |
|---|
| 24 | import org.apache.log4j.Logger; |
|---|
| 25 | import org.hibernate.annotations.Cascade; |
|---|
| 26 | import org.hibernate.annotations.CascadeType; |
|---|
| 27 | |
|---|
| 28 | import eu.etaxonomy.cdm.model.reference.Reference; |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * abstract class for all objects that may have a reference |
|---|
| 32 | * @author m.doering |
|---|
| 33 | * @version 1.0 |
|---|
| 34 | * @created 08-Nov-2007 13:06:47 |
|---|
| 35 | */ |
|---|
| 36 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 37 | @XmlType(name = "ReferencedEntityBase", propOrder = { |
|---|
| 38 | "citationMicroReference", |
|---|
| 39 | "originalNameString", |
|---|
| 40 | "citation" |
|---|
| 41 | }) |
|---|
| 42 | @XmlRootElement(name = "ReferencedEntityBase") |
|---|
| 43 | @MappedSuperclass |
|---|
| 44 | public abstract class ReferencedEntityBase extends AnnotatableEntity implements IReferencedEntity { |
|---|
| 45 | private static final long serialVersionUID = -5614669050360359126L; |
|---|
| 46 | @SuppressWarnings("unused") |
|---|
| 47 | private static final Logger logger = Logger.getLogger(ReferencedEntityBase.class); |
|---|
| 48 | |
|---|
| 49 | //Details of the reference. These are mostly (implicitly) pages but can also be tables or any other element of a |
|---|
| 50 | //publication. {if the citationMicroReference exists then there must be also a reference} |
|---|
| 51 | @XmlElement(name = "Citation") |
|---|
| 52 | @XmlIDREF |
|---|
| 53 | @XmlSchemaType(name = "IDREF") |
|---|
| 54 | @ManyToOne(fetch = FetchType.LAZY) |
|---|
| 55 | @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE}) |
|---|
| 56 | private Reference citation; |
|---|
| 57 | |
|---|
| 58 | @XmlElement(name = "CitationMicroReference") |
|---|
| 59 | private String citationMicroReference; |
|---|
| 60 | |
|---|
| 61 | @XmlElement(name = "OriginalNameString") |
|---|
| 62 | private String originalNameString; |
|---|
| 63 | |
|---|
| 64 | public ReferencedEntityBase() { |
|---|
| 65 | super(); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | public ReferencedEntityBase(Reference citation, String citationMicroReference, |
|---|
| 70 | String originalNameString) { |
|---|
| 71 | super(); |
|---|
| 72 | this.citationMicroReference = citationMicroReference; |
|---|
| 73 | this.originalNameString = originalNameString; |
|---|
| 74 | this.citation = citation; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | public String getCitationMicroReference(){ |
|---|
| 78 | return this.citationMicroReference; |
|---|
| 79 | } |
|---|
| 80 | public void setCitationMicroReference(String citationMicroReference){ |
|---|
| 81 | this.citationMicroReference = citationMicroReference; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | public String getOriginalNameString(){ |
|---|
| 86 | return this.originalNameString; |
|---|
| 87 | } |
|---|
| 88 | public void setOriginalNameString(String originalNameString){ |
|---|
| 89 | this.originalNameString = originalNameString; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | public Reference getCitation(){ |
|---|
| 93 | return this.citation; |
|---|
| 94 | } |
|---|
| 95 | public void setCitation(Reference citation) { |
|---|
| 96 | this.citation = citation; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | //****************** CLONE ************************************************/ |
|---|
| 100 | |
|---|
| 101 | /* (non-Javadoc) |
|---|
| 102 | * @see java.lang.Object#clone() |
|---|
| 103 | */ |
|---|
| 104 | @Override |
|---|
| 105 | public Object clone() throws CloneNotSupportedException{ |
|---|
| 106 | ReferencedEntityBase result = (ReferencedEntityBase)super.clone(); |
|---|
| 107 | |
|---|
| 108 | //no changes to: citation, citationMicroReference, originalNameString |
|---|
| 109 | return result; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | } |
|---|