Revision 90046bc4
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/test/function/TestSpecimen.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
23 | 23 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.Language; |
25 | 25 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
26 |
import eu.etaxonomy.cdm.model.location.Country; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
27 | 28 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
28 |
import eu.etaxonomy.cdm.model.location.Country; |
|
29 | 29 |
import eu.etaxonomy.cdm.model.media.Media; |
30 | 30 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
31 | 31 |
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart; |
... | ... | |
50 | 50 |
*/ |
51 | 51 |
public class TestSpecimen { |
52 | 52 |
private static final Logger logger = Logger.getLogger(TestSpecimen.class); |
53 |
|
|
53 |
|
|
54 | 54 |
public void testSpecimen(){ |
55 | 55 |
logger.info("Create test taxon ..."); |
56 |
Reference<?> sec = ReferenceFactory.newDatabase();
|
|
56 |
Reference sec = ReferenceFactory.newDatabase(); |
|
57 | 57 |
String fullNameString = "Acanthostyles saucechicoensis (Hieron.) R.M. King & H. Rob."; |
58 | 58 |
BotanicalName botanicalName = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(fullNameString); |
59 | 59 |
Taxon taxon = Taxon.NewInstance(botanicalName, sec); |
60 |
|
|
60 |
|
|
61 | 61 |
Collection collection = Collection.NewInstance(); |
62 | 62 |
String collectionCode = "ABCDE"; |
63 | 63 |
collection.setCode(collectionCode); |
... | ... | |
65 | 65 |
String institutionCode = "Inst444"; |
66 | 66 |
institution.setCode(institutionCode); |
67 | 67 |
collection.setInstitute(institution); |
68 |
|
|
69 |
|
|
68 |
|
|
69 |
|
|
70 | 70 |
logger.info("Create determination event"); |
71 | 71 |
DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(); |
72 | 72 |
determinationEvent.setTaxon(taxon); |
73 | 73 |
Person actor = Person.NewTitledInstance("J. M�ller (JE)"); |
74 | 74 |
determinationEvent.setActor(actor); |
75 |
|
|
75 |
|
|
76 | 76 |
logger.info("Create gathering event"); |
77 | 77 |
GatheringEvent gatheringEvent = GatheringEvent.NewInstance(); |
78 | 78 |
AgentBase<?> gatherer = Person.NewTitledInstance("Lorentz,P.G. s.n."); |
... | ... | |
82 | 82 |
int month = 10; |
83 | 83 |
int date = 05; |
84 | 84 |
gatheringDate.set(year, month, date); |
85 |
|
|
85 |
|
|
86 | 86 |
gatheringEvent.setGatheringDate(gatheringDate); |
87 |
|
|
87 |
|
|
88 | 88 |
logger.info("Create locality"); |
89 | 89 |
NamedArea namedArea = NamedArea.NewInstance(); |
90 | 90 |
Country country = Country.ARGENTINAARGENTINEREPUBLIC(); |
91 | 91 |
namedArea.addCountry(country); |
92 | 92 |
namedArea.setType(NamedAreaType.ADMINISTRATION_AREA()); |
93 | 93 |
// XX |
94 |
|
|
94 |
|
|
95 | 95 |
gatheringEvent.addCollectingArea(namedArea); |
96 | 96 |
String localityString = "Sierras Pampeanas, Sauce Chico"; |
97 | 97 |
LanguageString locality = LanguageString.NewInstance(localityString, Language.DEFAULT()); |
98 | 98 |
gatheringEvent.setLocality(locality); |
99 |
|
|
100 |
|
|
99 |
|
|
100 |
|
|
101 | 101 |
logger.info("Create new specimen ..."); |
102 | 102 |
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
103 | 103 |
specimen.setCatalogNumber("JE 00004506"); |
... | ... | |
105 | 105 |
specimen.setCollection(collection); |
106 | 106 |
String annotation = "originally designated as type specimen 2000, but corrected 2005-11"; |
107 | 107 |
specimen.addAnnotation(Annotation.NewDefaultLanguageInstance(annotation)); |
108 |
|
|
109 |
|
|
108 |
|
|
109 |
|
|
110 | 110 |
Media media = Media.NewInstance(); |
111 | 111 |
URI uri = null; |
112 | 112 |
try { |
... | ... | |
118 | 118 |
Integer size = null; |
119 | 119 |
MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(mimeType, "jpg"); |
120 | 120 |
media.addRepresentation(mediaRepresentation); |
121 |
|
|
121 |
|
|
122 | 122 |
MediaRepresentationPart mediaRepresentationPart = MediaRepresentationPart.NewInstance(uri, size); |
123 | 123 |
mediaRepresentation.addRepresentationPart(mediaRepresentationPart); |
124 | 124 |
// specimen.addMedia(media); #3597 |
... | ... | |
127 | 127 |
String id = "22"; |
128 | 128 |
IdentifiableSource source = IdentifiableSource.NewDataImportInstance(id); |
129 | 129 |
specimen.addSource(source); |
130 |
|
|
130 |
|
|
131 | 131 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
132 | 132 |
DerivationEvent derivationEvent = DerivationEvent.NewInstance(DerivationEventType.GATHERING_IN_SITU()); |
133 | 133 |
derivationEvent.addDerivative(specimen); |
134 | 134 |
fieldUnit.addDerivationEvent(derivationEvent); |
135 | 135 |
fieldUnit.setGatheringEvent(gatheringEvent); |
136 |
|
|
137 |
|
|
136 |
|
|
137 |
|
|
138 | 138 |
//type information |
139 | 139 |
//typified by |
140 |
|
|
141 |
|
|
140 |
|
|
141 |
|
|
142 | 142 |
logger.warn("Specimen: " + specimen); |
143 | 143 |
DerivationEvent dEvent = specimen.getDerivedFrom(); |
144 | 144 |
logger.warn("DerivationEvent: " + dEvent); |
... | ... | |
155 | 155 |
} |
156 | 156 |
} |
157 | 157 |
} |
158 |
|
|
158 |
|
|
159 | 159 |
private void test(){ |
160 | 160 |
System.out.println("Start ..."); |
161 | 161 |
this.testSpecimen(); |
162 | 162 |
System.out.println("\nEnd ..."); |
163 | 163 |
} |
164 |
|
|
164 |
|
|
165 | 165 |
/** |
166 | 166 |
* @param args |
167 | 167 |
*/ |
Also available in: Unified diff
Remove generics from Reference in cdmlib-model #5830