3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.model
;
13 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
14 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
15 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
16 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
19 * Utility class for handling of authorship related elements.
22 * @created Sep 8, 2010
25 public class AuthorHelper
{
28 * If the given {@link TeamOrPersonBase} is a {@link Person} this methods
29 * creates a new {@link Team} with this person. If it already a team the
34 * @return the given team or a newly created team with the given person
36 public static Team
getAuthor(TeamOrPersonBase
<?
> teamOrPerson
){
37 if(teamOrPerson
== null){
40 Object deproxiedObject
= HibernateProxyHelper
.deproxy(teamOrPerson
);
41 if(deproxiedObject
instanceof Person
){
42 Person person
= (Person
) deproxiedObject
;
43 Team team
= Team
.NewInstance();
44 team
.addTeamMember(person
);
47 else if(deproxiedObject
instanceof Team
){
48 return (Team
) deproxiedObject
;
50 throw new IllegalArgumentException("Given object os of the wrong type");