AT: committing CDMLIB to Branch post Merge
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / editor / CdmTypePropertyEditor.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 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.cdm.remote.editor;
12
13 import java.beans.PropertyEditorSupport;
14
15 import org.apache.log4j.Logger;
16 import org.springframework.stereotype.Component;
17
18 import eu.etaxonomy.cdm.model.location.TdwgArea;
19
20 /**
21 * @author a.kohlbecker
22 * @date 30.06.2009
23 * TODO only TDWG areas supported for now
24 */
25 @Component
26 public class CdmTypePropertyEditor extends PropertyEditorSupport {
27
28 public static final Logger logger = Logger.getLogger(CdmTypePropertyEditor.class);
29
30 public void setAsText(String text) {
31
32 Class clazz = null;
33 try {
34 clazz = Class.forName(text);
35 } catch (ClassNotFoundException e) { /* IGNORE */ }
36 try {
37 clazz = Class.forName("eu.etaxonomy.cdm.model.agent."+text);
38 } catch (ClassNotFoundException e) { /* IGNORE */ }
39 try {
40 clazz = Class.forName("eu.etaxonomy.cdm.model.common."+text);
41 } catch (ClassNotFoundException e) { /* IGNORE */ }
42 try {
43 clazz = Class.forName("eu.etaxonomy.cdm.model.description."+text);
44 } catch (ClassNotFoundException e) { /* IGNORE */ }
45 try {
46 clazz = Class.forName("eu.etaxonomy.cdm.model.location."+text);
47 } catch (ClassNotFoundException e) { /* IGNORE */ }
48 try {
49 clazz = Class.forName("eu.etaxonomy.cdm.model.media."+text);
50 } catch (ClassNotFoundException e) { /* IGNORE */ }
51 try {
52 clazz = Class.forName("eu.etaxonomy.cdm.model.molecular."+text);
53 } catch (ClassNotFoundException e) { /* IGNORE */ }
54 try {
55 clazz = Class.forName("eu.etaxonomy.cdm.model.name"+text);
56 } catch (ClassNotFoundException e) { /* IGNORE */ }
57 try {
58 clazz = Class.forName("eu.etaxonomy.cdm.model.occurrence."+text);
59 } catch (ClassNotFoundException e) { /* IGNORE */ }
60 try {
61 clazz = Class.forName("eu.etaxonomy.cdm.model.reference."+text);
62 } catch (ClassNotFoundException e) { /* IGNORE */ }
63 try {
64 clazz = Class.forName("eu.etaxonomy.cdm.model.taxon."+text);
65 } catch (ClassNotFoundException e) { /* IGNORE */ }
66
67 if(clazz != null){
68 setValue(clazz);
69 } else {
70 logger.error("Cannot find class for " + text);
71 }
72 }
73 }