Moving editor sources back into trunk
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / store / model / ReferenceUtil.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.taxeditor.store.model;
12
13 import org.apache.log4j.Logger;
14
15 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
16 import eu.etaxonomy.cdm.model.reference.Generic;
17 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
18
19 /**
20 * @author p.ciardelli
21 * @created 02.04.2009
22 * @version 1.0
23 */
24 public class ReferenceUtil {
25 private static final Logger logger = Logger
26 .getLogger(ReferenceUtil.class);
27
28 /**
29 * Returns the entity's citation. If none exists, gives the
30 * entity a Generic citation.
31 *
32 * @param entity
33 * @return
34 */
35 public static ReferenceBase getOrCreateCitation(ReferencedEntityBase entity) {
36 ReferenceBase citation = entity.getCitation();
37 if (citation == null) {
38 citation = Generic.NewInstance();
39 entity.setCitation(citation);
40 }
41 return citation;
42 }
43 }