Project

General

Profile

Download (1.21 KB) Statistics
| Branch: | Tag: | Revision:
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.model;
12

    
13
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
14
import eu.etaxonomy.cdm.model.agent.Person;
15
import eu.etaxonomy.cdm.model.agent.Team;
16

    
17
/**
18
 * <p>AuthorHelper class.</p>
19
 *
20
 * @author n.hoffmann
21
 * @created Sep 8, 2010
22
 * @version 1.0
23
 */
24
public class AuthorHelper {
25
	
26
	/**
27
	 * <p>getAuthor</p>
28
	 *
29
	 * @param object a {@link java.lang.Object} object.
30
	 * @return a {@link eu.etaxonomy.cdm.model.agent.Team} object.
31
	 */
32
	public static Team getAuthor(Object object){
33
		if(object == null){
34
			return null;
35
		}
36
		Object deproxiedObject = HibernateProxyHelper.deproxy(object);
37
		if(deproxiedObject instanceof Person){
38
			Person person = (Person) deproxiedObject;
39
			Team team = Team.NewInstance();
40
			team.addTeamMember(person);
41
			return team;
42
		}
43
		else if(deproxiedObject instanceof Team){
44
			return (Team) deproxiedObject;
45
		}else{
46
			throw new IllegalArgumentException("Given object os of the wrong type");
47
		}
48
	}
49
}
(3-3/33)