4 package eu
.etaxonomy
.cdm
.functiontest
;
6 import org
.springframework
.context
.support
.ClassPathXmlApplicationContext
;
7 import org
.apache
.log4j
.Logger
;
8 import org
.springframework
.beans
.factory
.xml
.XmlBeanFactory
;
9 import org
.springframework
.core
.io
.*;
11 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
12 import eu
.etaxonomy
.cdm
.aspectj
.PropertyChangeTest
;
13 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
14 import eu
.etaxonomy
.cdm
.model
.name
.*;
15 import eu
.etaxonomy
.cdm
.persistence
.dao
.*;
21 public class SpringControl
{
22 static Logger logger
= Logger
.getLogger(SpringControl
.class);
24 public void testBeanFactory (){
25 String fileName
= "editCdm.spring.cfg.xml";
26 ClassPathResource cpr
= new ClassPathResource(fileName
);
28 XmlBeanFactory bf
= new XmlBeanFactory(cpr
);
29 ITaxonNameDao tnDao
= (ITaxonNameDao
)bf
.getBean("tnDao");
30 NonViralName tn
= tnDao
.findById(1);
31 List
<NonViralName
> tnList
= tnDao
.getAllNames();
33 logger
.warn(tn
.getUuid());
36 public void testAppContext(){
37 String fileName
= "editCdm.spring.cfg.xml";
39 ClassPathXmlApplicationContext appContext
= new ClassPathXmlApplicationContext(fileName
);
40 appContext
.registerShutdownHook();
42 String
[] o
= appContext
.getBeanDefinitionNames();
43 for (int i
= 0; i
<o
.length
;i
++){
44 System
.out
.println(o
[i
]);
47 ITaxonNameDao tnDao
= (ITaxonNameDao
) appContext
.getBean( "tnDao" );
48 NonViralName tn
= tnDao
.findById(1);
49 List
<NonViralName
> tnList
= tnDao
.getNamesByName(tn
.getName());
50 for (NonViralName tn2
: tnList
){
51 System
.out
.print(tn2
.getUuid()+";");
56 public void testAppController(){
57 CdmApplicationController appCtr
= new CdmApplicationController();
58 logger
.info("Create name objects...");
59 NonViralName tn
= appCtr
.getNameService().createTaxonName(Rank
.SPECIES
);
60 NonViralName tn3
= appCtr
.getNameService().createTaxonName(Rank
.SPECIES
);
63 PropertyChangeTest listener
= new PropertyChangeTest();
64 tn
.addPropertyChangeListener(listener
);
65 tn3
.addPropertyChangeListener(listener
);
68 tn
.setUninomial("tn1-Genus1");
69 tn3
.setUninomial("tn3-genus");
72 logger
.info("Create new Author team...");
73 Team team
= new Team();
74 team
.addPropertyChangeListener(listener
);
75 team
.setShortName("AuthorTeam1");
76 tn
.setAuthorTeam(team
);
78 logger
.info("Save objects ...");
79 appCtr
.getAgentService().saveTeam(team
);
80 appCtr
.getNameService().saveTaxonName(tn
);
81 appCtr
.getNameService().saveTaxonName(tn3
);
84 logger
.info("Load existing names from db...");
85 List
<NonViralName
> tnList
= appCtr
.getNameService().getAllNames();
86 for (NonViralName tn2
: tnList
){
87 logger
.info("Genus: "+ tn2
.getUninomial() + " UUID: " + tn2
.getUuid()+";");
93 System
.out
.println("Start");
94 SpringControl sc
= new SpringControl();
98 System
.out
.println("\nEnd");
104 public static void main(String
[] args
) {
105 SpringControl sc
= new SpringControl();