Revision 7b567c03
Added by Anahit Babadshanjan over 15 years ago
.gitattributes | ||
---|---|---|
1341 | 1341 |
cdmlib-services/src/main/resources/eu/etaxonomy/cdm/defaultSecurityContext.xml -text |
1342 | 1342 |
cdmlib-services/src/main/resources/eu/etaxonomy/cdm/services.xml -text |
1343 | 1343 |
cdmlib-services/src/site/site.xml -text |
1344 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImplTest.java -text |
|
1344 | 1345 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest2.java -text |
1345 | 1346 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java -text |
1347 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceSearchTest.java -text |
|
1346 | 1348 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TermServiceImplTest.java -text |
1347 | 1349 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/Datasource.java -text |
1348 | 1350 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestDatabase.java -text |
... | ... | |
1355 | 1357 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/suite/CdmTestSuite.java -text |
1356 | 1358 |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/unit/CdmUnitTestBase.java -text |
1357 | 1359 |
cdmlib-services/src/test/resources/dbscripts/001_cdm.ddl -text |
1360 |
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.xml -text |
|
1358 | 1361 |
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/applicationContext-test.xml -text |
1359 | 1362 |
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/applicationContext.xml -text |
1360 | 1363 |
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/cdm.datasources.xml -text |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationController.java | ||
---|---|---|
162 | 162 |
appContext.refresh(); |
163 | 163 |
appContext.start(); |
164 | 164 |
|
165 |
// CdmTermInitializer.omit = false; |
|
166 |
|
|
167 | 165 |
} catch (BeanCreationException e) { |
168 | 166 |
// create new schema |
169 | 167 |
if (dbSchemaValidation == DbSchemaValidation.VALIDATE) { |
... | ... | |
178 | 176 |
return false; |
179 | 177 |
} |
180 | 178 |
setApplicationContext(appContext); |
181 |
// load defined terms if necessary |
|
182 |
//TODO not necessary any more |
|
183 |
// if (CdmTermInitializer.omit == false) { |
|
184 |
// if (testDefinedTermsAreMissing()){ |
|
185 |
// throw new TermNotFoundException("Some needed Terms are Missing."); |
|
186 |
// } |
|
187 |
// } |
|
188 |
// |
|
189 |
// CdmTermInitializer.omit = false; |
|
190 | 179 |
return true; |
191 | 180 |
} |
192 | 181 |
|
... | ... | |
354 | 343 |
TransactionDefinition txDef = defaultTxDef; |
355 | 344 |
|
356 | 345 |
// Log some transaction-related debug information. |
357 |
logger.debug("Transaction name = " + txDef.getName()); |
|
358 |
logger.debug("Transaction facets:"); |
|
359 |
logger.debug("Propagation behavior = " + txDef.getPropagationBehavior()); |
|
360 |
logger.debug("Isolation level = " + txDef.getIsolationLevel()); |
|
361 |
logger.debug("Timeout = " + txDef.getTimeout()); |
|
362 |
logger.debug("Read Only = " + txDef.isReadOnly()); |
|
363 |
// org.springframework.orm.hibernate3.HibernateTransactionManager |
|
364 |
// provides more transaction/session-related debug information. |
|
346 |
if (logger.isDebugEnabled()) { |
|
347 |
logger.debug("Transaction name = " + txDef.getName()); |
|
348 |
logger.debug("Transaction facets:"); |
|
349 |
logger.debug("Propagation behavior = " + txDef.getPropagationBehavior()); |
|
350 |
logger.debug("Isolation level = " + txDef.getIsolationLevel()); |
|
351 |
logger.debug("Timeout = " + txDef.getTimeout()); |
|
352 |
logger.debug("Read Only = " + txDef.isReadOnly()); |
|
353 |
// org.springframework.orm.hibernate3.HibernateTransactionManager |
|
354 |
// provides more transaction/session-related debug information. |
|
355 |
} |
|
365 | 356 |
|
366 | 357 |
TransactionStatus txStatus = txManager.getTransaction(txDef); |
367 | 358 |
return txStatus; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationDefaultConfiguration.java | ||
---|---|---|
72 | 72 |
//@Qualifier("commonService") |
73 | 73 |
private ICommonService commonService; |
74 | 74 |
//@Autowired |
75 |
//@Qualifier("mainService")
|
|
75 |
@Qualifier("mainService") |
|
76 | 76 |
private IService<CdmBase> mainService; |
77 | 77 |
|
78 | 78 |
|
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java | ||
---|---|---|
56 | 56 |
@Service |
57 | 57 |
@Transactional(readOnly = true) |
58 | 58 |
public class DescriptionServiceImpl extends IdentifiableServiceBase<DescriptionBase,IDescriptionDao> implements IDescriptionService { |
59 |
|
|
59 |
|
|
60 | 60 |
private static final Logger logger = Logger.getLogger(DescriptionServiceImpl.class); |
61 | 61 |
|
62 | 62 |
protected IDescriptionElementDao descriptionElementDao; |
... | ... | |
174 | 174 |
return featureVocabulary; |
175 | 175 |
} |
176 | 176 |
|
177 |
// public TermVocabulary<Feature> getFeatureVocabulary(){ |
|
178 |
// TermVocabulary<Feature> featureVocabulary; |
|
179 |
// try { |
|
180 |
// featureVocabulary = (TermVocabulary)vocabularyDao.findByUuid(uuid); |
|
181 |
// } catch (ClassCastException e) { |
|
182 |
// return null; |
|
183 |
// } |
|
184 |
// return featureVocabulary; |
|
185 |
// } |
|
186 |
|
|
177 | 187 |
public TermVocabulary<Feature> getDefaultFeatureVocabulary(){ |
178 | 188 |
String uuidFeature = "b187d555-f06f-4d65-9e53-da7c93f8eaa8"; |
179 | 189 |
UUID featureUuid = UUID.fromString(uuidFeature); |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java | ||
---|---|---|
39 | 39 |
* @param uuid |
40 | 40 |
* @return |
41 | 41 |
*/ |
42 |
public abstract DescriptionBase getDescriptionBaseByUuid(UUID uuid);
|
|
42 |
public DescriptionBase getDescriptionBaseByUuid(UUID uuid); |
|
43 | 43 |
|
44 | 44 |
/** |
45 | 45 |
* Persists a <code>Description</code> |
46 | 46 |
* @param description |
47 | 47 |
* @return |
48 | 48 |
*/ |
49 |
public abstract UUID saveDescription(DescriptionBase description);
|
|
49 |
public UUID saveDescription(DescriptionBase description); |
|
50 | 50 |
|
51 | 51 |
/** |
52 | 52 |
* Persists a <code>FeatureTree</code> |
53 | 53 |
* @param tree |
54 | 54 |
* @return |
55 | 55 |
*/ |
56 |
public abstract UUID saveFeatureTree(FeatureTree tree);
|
|
56 |
public UUID saveFeatureTree(FeatureTree tree); |
|
57 | 57 |
// FIXME could you handle the feature data elements using @Cascade? |
58 |
public abstract void saveFeatureDataAll(Collection<VersionableEntity> featureData);
|
|
59 |
public abstract Map<UUID, FeatureTree> saveFeatureTreeAll(Collection<FeatureTree> trees);
|
|
60 |
public abstract Map<UUID, FeatureNode> saveFeatureNodeAll(Collection<FeatureNode> nodes);
|
|
58 |
public void saveFeatureDataAll(Collection<VersionableEntity> featureData); |
|
59 |
public Map<UUID, FeatureTree> saveFeatureTreeAll(Collection<FeatureTree> trees); |
|
60 |
public Map<UUID, FeatureNode> saveFeatureNodeAll(Collection<FeatureNode> nodes); |
|
61 | 61 |
|
62 |
public abstract List<FeatureTree> getFeatureTreesAll();
|
|
63 |
public abstract List<FeatureNode> getFeatureNodesAll();
|
|
62 |
public List<FeatureTree> getFeatureTreesAll(); |
|
63 |
public List<FeatureNode> getFeatureNodesAll(); |
|
64 | 64 |
|
65 |
public abstract TermVocabulary<Feature> getDefaultFeatureVocabulary(); |
|
66 |
public abstract TermVocabulary<Feature> getFeatureVocabulary(UUID uuid); |
|
65 |
public TermVocabulary<Feature> getDefaultFeatureVocabulary(); |
|
66 |
//public TermVocabulary<Feature> getFeatureVocabulary(); |
|
67 |
public TermVocabulary<Feature> getFeatureVocabulary(UUID uuid); |
|
67 | 68 |
|
68 | 69 |
/** |
69 | 70 |
* List the descriptions of type <TYPE>, filtered using the following parameters |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImplTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2009 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.api.service; |
|
11 |
|
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.junit.Test; |
|
14 |
import org.unitils.spring.annotation.SpringBeanByType; |
|
15 |
|
|
16 |
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest; |
|
17 |
|
|
18 |
/** |
|
19 |
* @author a.babadshanjan |
|
20 |
* @created 09.02.2009 |
|
21 |
* @version 1.0 |
|
22 |
*/ |
|
23 |
public class DescriptionServiceImplTest extends CdmIntegrationTest { |
|
24 |
private static Logger logger = Logger |
|
25 |
.getLogger(DescriptionServiceImplTest.class); |
|
26 |
|
|
27 |
@SpringBeanByType |
|
28 |
private IDescriptionService service; |
|
29 |
|
|
30 |
@Test |
|
31 |
public void testGetDefaultFeatureVocabulary() { |
|
32 |
|
|
33 |
service.getDefaultFeatureVocabulary(); |
|
34 |
} |
|
35 |
} |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java | ||
---|---|---|
6 | 6 |
import static org.junit.Assert.assertEquals; |
7 | 7 |
import static org.junit.Assert.assertNull; |
8 | 8 |
|
9 |
import java.util.List; |
|
9 | 10 |
import java.util.UUID; |
10 | 11 |
|
11 | 12 |
import org.apache.log4j.Logger; |
13 |
import org.junit.Ignore; |
|
12 | 14 |
import org.junit.Test; |
15 |
import org.unitils.dbunit.annotation.DataSet; |
|
16 |
import org.unitils.dbunit.annotation.ExpectedDataSet; |
|
13 | 17 |
import org.unitils.spring.annotation.SpringBeanByType; |
14 | 18 |
|
19 |
import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator; |
|
20 |
import eu.etaxonomy.cdm.api.service.config.impl.TaxonServiceConfiguratorImpl; |
|
21 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
22 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
23 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
24 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
15 | 25 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
26 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
|
27 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
28 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
16 | 29 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
17 | 30 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
18 | 31 |
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest; |
... | ... | |
27 | 40 |
@SpringBeanByType |
28 | 41 |
private ITaxonService service; |
29 | 42 |
|
43 |
@SpringBeanByType |
|
44 |
private INameService nameService; |
|
45 |
|
|
30 | 46 |
/****************** TESTS *****************************/ |
31 | 47 |
|
32 | 48 |
/** |
... | ... | |
86 | 102 |
public final void testGetRootTaxa() { |
87 | 103 |
logger.warn("Not yet implemented"); // TODO |
88 | 104 |
} |
105 |
|
|
106 |
/** |
|
107 |
* Test method for {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator)}. |
|
108 |
*/ |
|
109 |
@Ignore |
|
110 |
@Test |
|
111 |
@DataSet("TaxonServiceImplTest.xml") |
|
112 |
//@ExpectedDataSet |
|
113 |
public final void testFindTaxaAndNames() { |
|
114 |
|
|
115 |
ITaxonServiceConfigurator configurator = new TaxonServiceConfiguratorImpl(); |
|
116 |
configurator.setDoSynonyms(true); |
|
117 |
configurator.setDoNamesWithoutTaxa(true); |
|
118 |
Pager<IdentifiableEntity> pager = service.findTaxaAndNames(configurator); |
|
119 |
List<IdentifiableEntity> list = pager.getRecords(); |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
@Test |
|
124 |
public final void testBuildDataSet() { |
|
125 |
|
|
126 |
BotanicalName abies_Mill, abiesAlba_Michx, abiesAlba_Mill; |
|
127 |
// BotanicalName abies, abies_Mill, abiesAlba, abiesAlba_Michx, abiesAlba_Mill; |
|
128 |
// Synonym s_abiesAlba_Michx; |
|
129 |
// Taxon t_abies_Mill, t_abiesAlba_Mill; |
|
130 |
|
|
131 |
Person mill = Person.NewInstance(); |
|
132 |
mill.setTitleCache("Mill."); |
|
133 |
Person michx = Person.NewInstance(); |
|
134 |
michx.setTitleCache("Michx."); |
|
135 |
|
|
136 |
nameService.saveTaxonName(BotanicalName.NewInstance(Rank.GENUS(), "Abies", null, null, null, null, null, null, null)); |
|
137 |
abies_Mill = BotanicalName.NewInstance(Rank.GENUS(), "Abies", null, null, null, mill, null, null, null); |
|
138 |
nameService.saveTaxonName(BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, null, null, null, null)); |
|
139 |
abiesAlba_Michx = BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, michx, null, null, null); |
|
140 |
abiesAlba_Mill = BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, mill, null, null, null); |
|
141 |
|
|
142 |
service.saveTaxon(Taxon.NewInstance(abies_Mill, null)); |
|
143 |
service.saveTaxon(Taxon.NewInstance(abiesAlba_Mill, null)); |
|
144 |
service.saveTaxon(Synonym.NewInstance(abiesAlba_Michx, null)); |
|
89 | 145 |
|
146 |
} |
|
147 |
|
|
148 |
@Test |
|
149 |
public final void testPrintDataSet() { |
|
150 |
|
|
151 |
printDataSet(System.out); |
|
152 |
} |
|
153 |
|
|
90 | 154 |
} |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceSearchTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2009 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.cdm.api.service; |
|
11 |
|
|
12 |
import static org.junit.Assert.assertNotNull; |
|
13 |
|
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.junit.Ignore; |
|
18 |
import org.junit.Test; |
|
19 |
import org.unitils.dbunit.annotation.DataSet; |
|
20 |
import org.unitils.spring.annotation.SpringBeanByType; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator; |
|
23 |
import eu.etaxonomy.cdm.api.service.config.impl.TaxonServiceConfiguratorImpl; |
|
24 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
|
25 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
26 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
27 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
28 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
29 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
30 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
31 |
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBaseTestClass; |
|
32 |
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author a.babadshanjan |
|
36 |
* @created 04.02.2009 |
|
37 |
* @version 1.0 |
|
38 |
*/ |
|
39 |
public class TaxonServiceSearchTest extends CdmIntegrationTest { |
|
40 |
private static Logger logger = Logger.getLogger(TaxonServiceSearchTest.class); |
|
41 |
|
|
42 |
@SpringBeanByType |
|
43 |
private ITaxonService service; |
|
44 |
|
|
45 |
@SpringBeanByType |
|
46 |
private INameService nameService; |
|
47 |
|
|
48 |
@SpringBeanByType |
|
49 |
private CdmEntityDaoBaseTestClass cdmEntityDaoBase; |
|
50 |
|
|
51 |
@Test |
|
52 |
public void testDbUnitUsageTest() throws Exception { |
|
53 |
assertNotNull("service should exist", service); |
|
54 |
assertNotNull("nameService should exist", nameService); |
|
55 |
assertNotNull("cdmEntityDaoBase should exist", cdmEntityDaoBase); |
|
56 |
} |
|
57 |
|
|
58 |
@Test |
|
59 |
public final void testBuildDataSet() { |
|
60 |
|
|
61 |
BotanicalName abies_Mill, abiesAlba_Michx, abiesAlba_Mill; |
|
62 |
|
|
63 |
Person mill = Person.NewInstance(); |
|
64 |
mill.setTitleCache("Mill."); |
|
65 |
Person michx = Person.NewInstance(); |
|
66 |
michx.setTitleCache("Michx."); |
|
67 |
|
|
68 |
nameService.saveTaxonName(BotanicalName.NewInstance(Rank.GENUS(), "Abies", null, null, null, null, null, null, null)); |
|
69 |
abies_Mill = BotanicalName.NewInstance(Rank.GENUS(), "Abies", null, null, null, mill, null, null, null); |
|
70 |
nameService.saveTaxonName(BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, null, null, null, null)); |
|
71 |
abiesAlba_Michx = BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, michx, null, null, null); |
|
72 |
abiesAlba_Mill = BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, mill, null, null, null); |
|
73 |
|
|
74 |
service.saveTaxon(Taxon.NewInstance(abies_Mill, null)); |
|
75 |
service.saveTaxon(Taxon.NewInstance(abiesAlba_Mill, null)); |
|
76 |
service.saveTaxon(Synonym.NewInstance(abiesAlba_Michx, null)); |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* Test method for {@link eu.etaxonomy.cdm.api.service.TaxonServiceImpl#findTaxaAndNames(eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator)}. |
|
82 |
*/ |
|
83 |
@Test |
|
84 |
//@DataSet("TaxonServiceImplTest.xml") |
|
85 |
//@ExpectedDataSet |
|
86 |
public final void testFindTaxaAndNames() { |
|
87 |
|
|
88 |
ITaxonServiceConfigurator configurator = new TaxonServiceConfiguratorImpl(); |
|
89 |
configurator.setDoSynonyms(true); |
|
90 |
configurator.setDoNamesWithoutTaxa(true); |
|
91 |
Pager<IdentifiableEntity> pager = service.findTaxaAndNames(configurator); |
|
92 |
List<IdentifiableEntity> list = pager.getRecords(); |
|
93 |
for (int i = 0; i > list.size(); i++) { |
|
94 |
logger.error(i + " = " + list.get(i).getTitleCache()); |
|
95 |
//System.out.println(i + " = " + list.get(i).getTitleCache()); |
|
96 |
} |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
@Ignore |
|
101 |
@Test |
|
102 |
public final void testPrintDataSet() { |
|
103 |
|
|
104 |
printDataSet(System.out); |
|
105 |
} |
|
106 |
|
|
107 |
} |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestDatabase.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
package eu.etaxonomy.cdm.test.function; |
4 | 4 |
|
5 |
import java.util.HashSet; |
|
6 |
import java.util.Set; |
|
5 | 7 |
import java.util.UUID; |
6 | 8 |
|
7 | 9 |
import org.apache.log4j.Logger; |
... | ... | |
9 | 11 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
10 | 12 |
import eu.etaxonomy.cdm.api.service.IDatabaseService; |
11 | 13 |
import eu.etaxonomy.cdm.api.service.INameService; |
14 |
import eu.etaxonomy.cdm.common.AccountStore; |
|
12 | 15 |
import eu.etaxonomy.cdm.common.CdmUtils; |
13 | 16 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
14 | 17 |
import eu.etaxonomy.cdm.database.DataSourceNotFoundException; |
18 |
import eu.etaxonomy.cdm.database.DatabaseTypeEnum; |
|
15 | 19 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
16 | 20 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
21 |
import eu.etaxonomy.cdm.model.agent.Agent; |
|
22 |
import eu.etaxonomy.cdm.model.agent.Contact; |
|
23 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
17 | 24 |
import eu.etaxonomy.cdm.model.common.Language; |
18 | 25 |
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException; |
19 | 26 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
... | ... | |
226 | 233 |
} |
227 | 234 |
} |
228 | 235 |
|
236 |
|
|
237 |
public void testContact(){ |
|
238 |
try { |
|
239 |
// String server = "192.168.2.10"; |
|
240 |
// String database = "cdm_test_andreasM"; |
|
241 |
// String username = "edit"; |
|
242 |
// String password = CdmUtils.readInputLine("Password: "); |
|
243 |
DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE; |
|
244 |
|
|
245 |
// ICdmDataSource datasource = CdmDataSource.NewMySqlInstance(server, database, username, password); |
|
246 |
//ICdmDataSource datasource = CdmDataSource.NewH2EmbeddedInstance("CDM", "sa", ""); |
|
247 |
ICdmDataSource datasource = cdm_test_anahit2(); |
|
248 |
CdmApplicationController appCtr = CdmApplicationController.NewInstance(datasource, dbSchemaValidation); |
|
249 |
Agent person = Person.NewTitledInstance("TestPerson"); |
|
250 |
Contact contact1 = new Contact(); |
|
251 |
Set<String> set = new HashSet<String>(); |
|
252 |
set.add("email1"); |
|
253 |
set.add("c@d.org"); |
|
254 |
// contact1.setEmail(set); |
|
255 |
// person.setContact(contact1); |
|
256 |
appCtr.getAgentService().save(person); |
|
257 |
appCtr.close(); |
|
258 |
System.out.println("End"); |
|
259 |
} catch (DataSourceNotFoundException e) { |
|
260 |
logger.error("datasource error"); |
|
261 |
} catch (TermNotFoundException e) { |
|
262 |
logger.error("defined terms not found"); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
|
|
267 |
public static ICdmDataSource cdm_test_anahit2(){ |
|
268 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
|
269 |
String cdmServer = "192.168.2.10"; |
|
270 |
String cdmDB = "cdm_test_anahit2"; |
|
271 |
String cdmUserName = "edit"; |
|
272 |
return makeDestination(cdmServer, cdmDB, -1, cdmUserName, null); |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* initializes source |
|
277 |
* @return true, if connection establisehd |
|
278 |
*/ |
|
279 |
private static ICdmDataSource makeDestination(String cdmServer, String cdmDB, int port, String cdmUserName, String pwd ){ |
|
280 |
//establish connection |
|
281 |
pwd = AccountStore.readOrStorePassword(cdmServer, cdmDB, cdmUserName, pwd); |
|
282 |
//TODO not MySQL |
|
283 |
ICdmDataSource destination = CdmDataSource.NewMySqlInstance(cdmServer, cdmDB, port, cdmUserName, pwd); |
|
284 |
return destination; |
|
285 |
|
|
286 |
} |
|
229 | 287 |
|
230 | 288 |
|
231 | 289 |
/** |
... | ... | |
233 | 291 |
*/ |
234 | 292 |
public static void main(String[] args) { |
235 | 293 |
TestDatabase sc = new TestDatabase(); |
236 |
sc.test(); |
|
294 |
sc.testContact();
|
|
237 | 295 |
} |
238 | 296 |
|
239 | 297 |
} |
cdmlib-services/src/test/resources/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='UTF-8'?> |
|
2 |
<dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../dataset.xsd"> |
|
3 |
<TAXONBASE DTYPE="Taxon" ID="4" CREATED="2009-02-03 17:52:26.0" UUID="aafce7fe-0c5f-42ed-814b-4c7c2c715660" TITLECACHE="Abies sec. ???" PROTECTEDTITLECACHE="false" DOUBTFUL="false" TAXONOMICCHILDRENCOUNT="0" TAXONNAME_FK="4"/> |
|
4 |
<TAXONBASE DTYPE="Taxon" ID="5" CREATED="2009-02-03 17:52:26.0" UUID="5c1a3d10-3a32-45d1-a5ae-1e982533b79f" TITLECACHE="Abies alba sec. ???" PROTECTEDTITLECACHE="false" DOUBTFUL="false" TAXONOMICCHILDRENCOUNT="0" TAXONNAME_FK="5"/> |
|
5 |
<TAXONBASE DTYPE="Synonym" ID="6" CREATED="2009-02-03 17:52:26.0" UUID="4de9d002-d68c-49af-84f1-7f9eddaa1226" TITLECACHE="Abies alba sec. ???" PROTECTEDTITLECACHE="false" DOUBTFUL="false" TAXONNAME_FK="6"/> |
|
6 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="1" CREATED="2009-02-03 17:52:26.0" UUID="88fab5b3-0d9a-42c3-9915-71fc17266116" TITLECACHE="" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" NAMECACHE="" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="1"/> |
|
7 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="2" CREATED="2009-02-03 17:52:26.0" UUID="984e4304-57b0-4ce8-8f94-7c39be7396d9" TITLECACHE="Abies" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="Abies" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" GENUSORUNINOMIAL="Abies" NAMECACHE="Abies" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="2" RANK_ID="774"/> |
|
8 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="3" CREATED="2009-02-03 17:52:26.0" UUID="a7e666e7-0d96-4284-9cc4-8e5ccc3b9a36" TITLECACHE="Abies alba" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="Abies alba" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" GENUSORUNINOMIAL="Abies" NAMECACHE="Abies alba" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" SPECIFICEPITHET="alba" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="3" RANK_ID="765"/> |
|
9 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="4" CREATED="2009-02-03 17:52:26.0" UUID="ebd459a6-52ec-4f7c-a520-32c82aa31011" TITLECACHE="Abies" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="Abies" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" GENUSORUNINOMIAL="Abies" NAMECACHE="Abies" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="4" RANK_ID="774" COMBINATIONAUTHORTEAM_ID="1"/> |
|
10 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="5" CREATED="2009-02-03 17:52:26.0" UUID="5d74500b-9fd5-4d18-b9cd-cc1c8a372fec" TITLECACHE="Abies alba" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="Abies alba" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" GENUSORUNINOMIAL="Abies" NAMECACHE="Abies alba" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" SPECIFICEPITHET="alba" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="5" RANK_ID="765" COMBINATIONAUTHORTEAM_ID="1"/> |
|
11 |
<TAXONNAMEBASE DTYPE="BotanicalName" ID="6" CREATED="2009-02-03 17:52:26.0" UUID="55e6ee55-371e-418e-8775-d885d28453c4" TITLECACHE="Abies alba" PROTECTEDTITLECACHE="false" HASPROBLEM="false" FULLTITLECACHE="Abies alba" PROBLEMENDS="-1" PROBLEMSTARTS="-1" PROTECTEDFULLTITLECACHE="false" AUTHORSHIPCACHE="" GENUSORUNINOMIAL="Abies" NAMECACHE="Abies alba" PROTECTEDAUTHORSHIPCACHE="false" PROTECTEDNAMECACHE="false" SPECIFICEPITHET="alba" ANAMORPHIC="false" BINOMHYBRID="false" HYBRIDFORMULA="false" MONOMHYBRID="false" TRINOMHYBRID="false" HOMOTYPICALGROUP_ID="6" RANK_ID="765" COMBINATIONAUTHORTEAM_ID="2"/> |
|
12 |
</dataset> |
Also available in: Unified diff
Added some tests