| 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.media; |
|---|
| 11 | |
|---|
| 12 | import java.util.HashMap; |
|---|
| 13 | import java.util.Map; |
|---|
| 14 | import java.util.UUID; |
|---|
| 15 | |
|---|
| 16 | import javax.persistence.Entity; |
|---|
| 17 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 18 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 19 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 20 | import javax.xml.bind.annotation.XmlType; |
|---|
| 21 | |
|---|
| 22 | import org.apache.log4j.Logger; |
|---|
| 23 | import org.hibernate.envers.Audited; |
|---|
| 24 | import org.hibernate.search.annotations.Indexed; |
|---|
| 25 | |
|---|
| 26 | import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|---|
| 27 | import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * @author m.doering |
|---|
| 31 | * @version 1.0 |
|---|
| 32 | * @created 08-Nov-2007 13:06:50 |
|---|
| 33 | */ |
|---|
| 34 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 35 | @XmlType(name = "RightsTerm") |
|---|
| 36 | @XmlRootElement(name = "RightsTerm") |
|---|
| 37 | @Entity |
|---|
| 38 | @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase") |
|---|
| 39 | @Audited |
|---|
| 40 | public class RightsTerm extends DefinedTermBase<RightsTerm> { |
|---|
| 41 | private static final long serialVersionUID = -5823263624000932116L; |
|---|
| 42 | private static final Logger logger = Logger.getLogger(RightsTerm.class); |
|---|
| 43 | |
|---|
| 44 | protected static Map<UUID, RightsTerm> termMap = null; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | /** |
|---|
| 48 | * Factory method |
|---|
| 49 | * @return |
|---|
| 50 | */ |
|---|
| 51 | public static RightsTerm NewInstance(){ |
|---|
| 52 | logger.debug("NewInstance"); |
|---|
| 53 | return new RightsTerm(); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Factory method |
|---|
| 58 | * @return |
|---|
| 59 | */ |
|---|
| 60 | public static RightsTerm NewInstance(String text, String label, String labelAbbrev){ |
|---|
| 61 | return new RightsTerm(text, label, labelAbbrev); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | /** |
|---|
| 65 | * Default Constructor |
|---|
| 66 | */ |
|---|
| 67 | public RightsTerm() { |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | /** |
|---|
| 71 | * Constructor |
|---|
| 72 | */ |
|---|
| 73 | public RightsTerm(String term, String label, String labelAbbrev) { |
|---|
| 74 | super(term, label, labelAbbrev); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | // ************************************* MTEHODS ***************************************************/ |
|---|
| 80 | |
|---|
| 81 | /* (non-Javadoc) |
|---|
| 82 | * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms() |
|---|
| 83 | */ |
|---|
| 84 | @Override |
|---|
| 85 | public void resetTerms(){ |
|---|
| 86 | termMap = null; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | protected static RightsTerm getTermByUuid(UUID uuid){ |
|---|
| 90 | if (termMap == null){ |
|---|
| 91 | return null; //better return null then initialize the termMap in an unwanted way |
|---|
| 92 | } |
|---|
| 93 | return (RightsTerm)termMap.get(uuid); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | /** |
|---|
| 97 | * http://purl.org/dc/terms/accessRights |
|---|
| 98 | */ |
|---|
| 99 | public static final RightsTerm ACCESS_RIGHTS(){ |
|---|
| 100 | return getTermByUuid(uuidAccessRights); |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | public static final RightsTerm COPYRIGHT(){ |
|---|
| 104 | return getTermByUuid(uuidCopyright); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | public static final RightsTerm LICENSE(){ |
|---|
| 108 | return getTermByUuid(uuidLicense); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | private static final UUID uuidLicense = UUID.fromString("67c0d47e-8985-1014-8845-c84599f9992c"); |
|---|
| 112 | private static final UUID uuidCopyright = UUID.fromString("d1ef838e-b195-4f28-b8eb-0d3be080bd37"); |
|---|
| 113 | private static final UUID uuidAccessRights = UUID.fromString("a50b4def-b3ac-4508-b50a-e0f249e3a1d7"); |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | @Override |
|---|
| 117 | protected void setDefaultTerms(TermVocabulary<RightsTerm> termVocabulary) { |
|---|
| 118 | termMap = new HashMap<UUID, RightsTerm>(); |
|---|
| 119 | for (RightsTerm term : termVocabulary.getTerms()){ |
|---|
| 120 | termMap.put(term.getUuid(), (RightsTerm)term); |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | } |
|---|