1
|
/**
|
2
|
* Copyright (C) 2020 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
|
package eu.etaxonomy.cdm.database.data;
|
10
|
|
11
|
import java.math.BigDecimal;
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.hibernate.Session;
|
17
|
import org.joda.time.DateTime;
|
18
|
|
19
|
import com.ibm.lsid.MalformedLSIDException;
|
20
|
|
21
|
import eu.etaxonomy.cdm.common.DOI;
|
22
|
import eu.etaxonomy.cdm.common.URI;
|
23
|
import eu.etaxonomy.cdm.model.agent.Address;
|
24
|
import eu.etaxonomy.cdm.model.agent.Contact;
|
25
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
26
|
import eu.etaxonomy.cdm.model.agent.ORCID;
|
27
|
import eu.etaxonomy.cdm.model.agent.Person;
|
28
|
import eu.etaxonomy.cdm.model.agent.Team;
|
29
|
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
|
30
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
31
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
32
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
33
|
import eu.etaxonomy.cdm.model.common.Credit;
|
34
|
import eu.etaxonomy.cdm.model.common.EventBase;
|
35
|
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
|
36
|
import eu.etaxonomy.cdm.model.common.Extension;
|
37
|
import eu.etaxonomy.cdm.model.common.ExtensionType;
|
38
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
39
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
40
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
41
|
import eu.etaxonomy.cdm.model.common.IntextReference;
|
42
|
import eu.etaxonomy.cdm.model.common.LSID;
|
43
|
import eu.etaxonomy.cdm.model.common.LSIDAuthority;
|
44
|
import eu.etaxonomy.cdm.model.common.Language;
|
45
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
46
|
import eu.etaxonomy.cdm.model.common.Marker;
|
47
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
48
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
49
|
import eu.etaxonomy.cdm.model.description.CategoricalData;
|
50
|
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
|
51
|
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
|
52
|
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
|
53
|
import eu.etaxonomy.cdm.model.description.Distribution;
|
54
|
import eu.etaxonomy.cdm.model.description.Feature;
|
55
|
import eu.etaxonomy.cdm.model.description.IIdentificationKey;
|
56
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
57
|
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
|
58
|
import eu.etaxonomy.cdm.model.description.MediaKey;
|
59
|
import eu.etaxonomy.cdm.model.description.MultiAccessKey;
|
60
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
61
|
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
|
62
|
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
|
63
|
import eu.etaxonomy.cdm.model.description.QuantitativeData;
|
64
|
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
|
65
|
import eu.etaxonomy.cdm.model.description.State;
|
66
|
import eu.etaxonomy.cdm.model.description.StateData;
|
67
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
68
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
|
69
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
70
|
import eu.etaxonomy.cdm.model.description.TaxonInteraction;
|
71
|
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
|
72
|
import eu.etaxonomy.cdm.model.description.TemporalData;
|
73
|
import eu.etaxonomy.cdm.model.description.TextData;
|
74
|
import eu.etaxonomy.cdm.model.description.TextFormat;
|
75
|
import eu.etaxonomy.cdm.model.location.Country;
|
76
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
77
|
import eu.etaxonomy.cdm.model.location.Point;
|
78
|
import eu.etaxonomy.cdm.model.location.ReferenceSystem;
|
79
|
import eu.etaxonomy.cdm.model.media.AudioFile;
|
80
|
import eu.etaxonomy.cdm.model.media.ExternalLink;
|
81
|
import eu.etaxonomy.cdm.model.media.ExternalLinkType;
|
82
|
import eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity;
|
83
|
import eu.etaxonomy.cdm.model.media.ImageFile;
|
84
|
import eu.etaxonomy.cdm.model.media.Media;
|
85
|
import eu.etaxonomy.cdm.model.media.MediaMetaData;
|
86
|
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
|
87
|
import eu.etaxonomy.cdm.model.media.MovieFile;
|
88
|
import eu.etaxonomy.cdm.model.media.Rights;
|
89
|
import eu.etaxonomy.cdm.model.media.RightsType;
|
90
|
import eu.etaxonomy.cdm.model.molecular.Amplification;
|
91
|
import eu.etaxonomy.cdm.model.molecular.AmplificationResult;
|
92
|
import eu.etaxonomy.cdm.model.molecular.Cloning;
|
93
|
import eu.etaxonomy.cdm.model.molecular.DnaQuality;
|
94
|
import eu.etaxonomy.cdm.model.molecular.DnaSample;
|
95
|
import eu.etaxonomy.cdm.model.molecular.PhylogeneticTree;
|
96
|
import eu.etaxonomy.cdm.model.molecular.Primer;
|
97
|
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
98
|
import eu.etaxonomy.cdm.model.molecular.SequenceDirection;
|
99
|
import eu.etaxonomy.cdm.model.molecular.SequenceString;
|
100
|
import eu.etaxonomy.cdm.model.molecular.SingleRead;
|
101
|
import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment;
|
102
|
import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment.Shift;
|
103
|
import eu.etaxonomy.cdm.model.name.HybridRelationship;
|
104
|
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
|
105
|
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
106
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
107
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
|
108
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
109
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCodeEdition;
|
110
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
111
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
112
|
import eu.etaxonomy.cdm.model.name.Rank;
|
113
|
import eu.etaxonomy.cdm.model.name.Registration;
|
114
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
|
115
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
116
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
117
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
118
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
119
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
|
120
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEventType;
|
121
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
122
|
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
|
123
|
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
|
124
|
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
|
125
|
import eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent;
|
126
|
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
|
127
|
import eu.etaxonomy.cdm.model.occurrence.PreservationMethod;
|
128
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
129
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
130
|
import eu.etaxonomy.cdm.model.permission.CdmAuthority;
|
131
|
import eu.etaxonomy.cdm.model.permission.Group;
|
132
|
import eu.etaxonomy.cdm.model.permission.Operation;
|
133
|
import eu.etaxonomy.cdm.model.permission.PermissionClass;
|
134
|
import eu.etaxonomy.cdm.model.permission.Role;
|
135
|
import eu.etaxonomy.cdm.model.permission.User;
|
136
|
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
|
137
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
138
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
139
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
140
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
141
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
142
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
143
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
144
|
import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
|
145
|
import eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus;
|
146
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
|
147
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
148
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
149
|
import eu.etaxonomy.cdm.model.term.Representation;
|
150
|
import eu.etaxonomy.cdm.model.term.TermNode;
|
151
|
import eu.etaxonomy.cdm.model.term.TermTree;
|
152
|
import eu.etaxonomy.cdm.model.term.TermType;
|
153
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
154
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
155
|
|
156
|
/**
|
157
|
* This class tries to create a database that has
|
158
|
* at least one record in each table.
|
159
|
* It is meant to test update scripts as well as imports
|
160
|
* and exports.
|
161
|
*
|
162
|
* ATTENTION: As the content of the created database may change
|
163
|
* over time due to model changes and other requirements test using
|
164
|
* this class should be written in a way that they do rather
|
165
|
* depend on general parameter than concrete data values.
|
166
|
*
|
167
|
* @author a.mueller
|
168
|
* @since 2013-12-02
|
169
|
*/
|
170
|
public class FullCoverageDataGenerator {
|
171
|
|
172
|
public void fillWithData(Session session){
|
173
|
List<CdmBase> cdmBases = new ArrayList<>();
|
174
|
|
175
|
createAgents(cdmBases);
|
176
|
|
177
|
createDescriptions(cdmBases);
|
178
|
|
179
|
createMedia(cdmBases);
|
180
|
|
181
|
createMolecular(cdmBases);
|
182
|
|
183
|
createTaxonName(cdmBases);
|
184
|
|
185
|
createOccurrence(cdmBases);
|
186
|
|
187
|
createReference(cdmBases);
|
188
|
|
189
|
createTaxon(cdmBases);
|
190
|
|
191
|
createSupplemental(cdmBases);
|
192
|
|
193
|
createUserAuthority(cdmBases);
|
194
|
|
195
|
for (CdmBase cdmBase: cdmBases){
|
196
|
session.save(cdmBase);
|
197
|
}
|
198
|
}
|
199
|
|
200
|
private void createUserAuthority(List<CdmBase> cdmBases) {
|
201
|
// TODO Auto-generated method stub
|
202
|
}
|
203
|
|
204
|
private void createSupplemental(List<CdmBase> cdmBases) {
|
205
|
|
206
|
Reference ref = ReferenceFactory.newBook();
|
207
|
|
208
|
Annotation annotation = Annotation.NewDefaultLanguageInstance("annotation");
|
209
|
ref.addAnnotation(annotation);
|
210
|
handleAnnotatableEntity(annotation);
|
211
|
|
212
|
Credit credit = Credit.NewInstance(Person.NewInstance(), "refCredit", "rc", Language.DEFAULT());
|
213
|
ref.addCredit(credit);
|
214
|
handleAnnotatableEntity(credit);
|
215
|
|
216
|
Rights rights = Rights.NewInstance("My rights", Language.GERMAN());
|
217
|
ref.addRights(rights);
|
218
|
handleAnnotatableEntity(rights);
|
219
|
|
220
|
//Others
|
221
|
try {
|
222
|
LSIDAuthority lsidAuthority = new LSIDAuthority("My authority");
|
223
|
lsidAuthority.addNamespace("lsidNamespace", TaxonName.class);
|
224
|
cdmBases.add(lsidAuthority);
|
225
|
} catch (MalformedLSIDException e) {
|
226
|
e.printStackTrace();
|
227
|
}
|
228
|
|
229
|
User user = User.NewInstance("myUser", "12345");
|
230
|
Group group = Group.NewInstance("MyGroup");
|
231
|
group.addMember(user);
|
232
|
CdmAuthority authority = CdmAuthority.NewInstance(PermissionClass.TAXONNAME,
|
233
|
"a property", Operation.CREATE, UUID.fromString("f1653cb8-5956-429e-852a-4a3b57893f49"));
|
234
|
group.addAuthority(authority);
|
235
|
Role role = Role.NewInstance("my role");
|
236
|
user.addAuthority(role);
|
237
|
|
238
|
cdmBases.add(user);
|
239
|
cdmBases.add(group);
|
240
|
cdmBases.add(authority);
|
241
|
|
242
|
cdmBases.add(ref);
|
243
|
}
|
244
|
|
245
|
private void createAgents(List<CdmBase> cdmBases) {
|
246
|
//Person
|
247
|
Person person = Person.NewTitledInstance("Person Title");
|
248
|
person.setGivenName("first name");
|
249
|
person.setFamilyName("last name");
|
250
|
person.setCollectorTitle("C. collector");
|
251
|
person.setLifespan(TimePeriodParser.parseString("1905-1995"));
|
252
|
person.setPrefix("prefix");
|
253
|
person.setSuffix("suffix");
|
254
|
person.setOrcid(ORCID.fromString("0000-0001-5000-0007"));
|
255
|
|
256
|
handleIdentifiableEntity(person);
|
257
|
|
258
|
//Contact
|
259
|
Contact contact = Contact.NewInstance();
|
260
|
person.setContact(contact);
|
261
|
Point locality = Point.NewInstance(45.12, -38.69, ReferenceSystem.WGS84(), 22);
|
262
|
contact.addEmailAddress("a@b.de");
|
263
|
contact.addFaxNumber("f:010-123456");
|
264
|
contact.addPhoneNumber("p:090-987654");
|
265
|
contact.addUrl(URI.create("http://www.abc.de"));
|
266
|
|
267
|
//Address
|
268
|
Address address = Address.NewInstance(Country.GERMANY(), "locality", "pobox", "12345", "region", "street", locality);
|
269
|
contact.addAddress(address);
|
270
|
|
271
|
//Team
|
272
|
Team team = Team.NewTitledInstance("Team title", "Team abbrev title");
|
273
|
team.addTeamMember(person);
|
274
|
handleIdentifiableEntity(team);
|
275
|
|
276
|
//Institution
|
277
|
Institution institution = Institution.NewInstance();
|
278
|
institution.setCode("institution code");
|
279
|
institution.setName("institution name");
|
280
|
handleIdentifiableEntity(institution);
|
281
|
|
282
|
|
283
|
//TODO vocabulary
|
284
|
// voc = "29ad808b-3126-4274-be81-4561e7afc76f"
|
285
|
DefinedTerm instType = DefinedTerm.NewInstitutionTypeInstance("Description forthis instition type", "institution type", "inst. t.");
|
286
|
cdmBases.add(instType);
|
287
|
institution.addType(instType);
|
288
|
person.addInstitutionalMembership(institution, TimePeriodParser.parseString("1955-1956"), "department", "role");
|
289
|
|
290
|
Institution subInstitution = Institution.NewInstance();
|
291
|
subInstitution.setCode("sub institution code");
|
292
|
subInstitution.setName("sub institution name");
|
293
|
subInstitution.setIsPartOf(institution);
|
294
|
|
295
|
cdmBases.add(person);
|
296
|
cdmBases.add(team);
|
297
|
cdmBases.add(institution);
|
298
|
}
|
299
|
|
300
|
private void createDescriptions(List<CdmBase> cdmBases) {
|
301
|
|
302
|
TermVocabulary<AnnotationType> voc = TermVocabulary.NewInstance(TermType.AnnotationType, AnnotationType.class,
|
303
|
"my termVoc desc", "myTerm voc", "mtv", URI.create("http://www.abc.de"));
|
304
|
handleIdentifiableEntity(voc);
|
305
|
cdmBases.add(voc);
|
306
|
|
307
|
Representation rep = voc.getRepresentations().iterator().next();
|
308
|
handleAnnotatableEntity(rep);
|
309
|
// Representation engRep = Language.ENGLISH().getRepresentations().iterator().next();
|
310
|
// handleAnnotatableEntity(engRep);
|
311
|
// cdmBases.add(engRep); //needed?
|
312
|
|
313
|
//Categorical data
|
314
|
State state = State.NewInstance("Test state", "state", "st.");
|
315
|
state.addMedia(Media.NewInstance());
|
316
|
cdmBases.add(state);
|
317
|
CategoricalData categoricalData = CategoricalData.NewInstance(state, Feature.CONSERVATION());
|
318
|
StateData stateData = categoricalData.getStateData().get(0);
|
319
|
stateData.addModifier(DefinedTerm.SEX_FEMALE());
|
320
|
handleAnnotatableEntity(categoricalData);
|
321
|
|
322
|
State nextState = State.NewInstance();
|
323
|
cdmBases.add(nextState);
|
324
|
StateData stateData2 = StateData.NewInstance(nextState);
|
325
|
stateData2.setCount(3);
|
326
|
stateData2.putModifyingText(Language.ENGLISH(), "State2 modifying text");
|
327
|
categoricalData.addStateData(stateData2);
|
328
|
categoricalData.setOrderRelevant(true);
|
329
|
|
330
|
//Quantitative data
|
331
|
Feature leaveLength = Feature.NewInstance("Leave length description", "leave length", "l.l.");
|
332
|
cdmBases.add(leaveLength);
|
333
|
leaveLength.setSupportsQuantitativeData(true);
|
334
|
QuantitativeData quantitativeData = QuantitativeData.NewInstance(leaveLength);
|
335
|
MeasurementUnit measurementUnit = MeasurementUnit.NewInstance("Measurement Unit", "munit", null);
|
336
|
cdmBases.add(measurementUnit);
|
337
|
quantitativeData.setUnit(measurementUnit);
|
338
|
quantitativeData.setUuid(UUID.fromString("920fce5e-4913-4a3f-89bf-1611f5081869"));
|
339
|
StatisticalMeasurementValue statisticalMeasurementValue = quantitativeData.setAverage(
|
340
|
new BigDecimal("22.9215"), null);
|
341
|
handleAnnotatableEntity(quantitativeData);
|
342
|
handleIdentifiableEntity(measurementUnit);
|
343
|
DefinedTerm valueModifier = DefinedTerm.NewModifierInstance("about", "about", null);
|
344
|
statisticalMeasurementValue.addModifier(valueModifier);
|
345
|
cdmBases.add(valueModifier);
|
346
|
|
347
|
//Feature
|
348
|
TermVocabulary<DefinedTerm> recommendedModifierEnumeration = TermVocabulary.NewInstance(TermType.Modifier, DefinedTerm.class);
|
349
|
leaveLength.addRecommendedModifierEnumeration(recommendedModifierEnumeration);
|
350
|
cdmBases.add(recommendedModifierEnumeration);
|
351
|
TermVocabulary<State> supportedCategoricalEnumeration = TermVocabulary.NewInstance(TermType.State, State.class);
|
352
|
leaveLength.addSupportedCategoricalEnumeration(supportedCategoricalEnumeration);
|
353
|
cdmBases.add(supportedCategoricalEnumeration);
|
354
|
leaveLength.addRecommendedMeasurementUnit(measurementUnit);
|
355
|
leaveLength.addRecommendedStatisticalMeasure(StatisticalMeasure.AVERAGE());
|
356
|
|
357
|
//CommonTaxonName
|
358
|
CommonTaxonName commonTaxonName = CommonTaxonName.NewInstance("common name", Language.ENGLISH(), Country.UNITEDSTATESOFAMERICA());
|
359
|
handleAnnotatableEntity(commonTaxonName);
|
360
|
|
361
|
//TextData
|
362
|
TextData textData = TextData.NewInstance(Feature.DIAGNOSIS());
|
363
|
Language eng = Language.ENGLISH();
|
364
|
textData.putText(eng, "My text data");
|
365
|
LanguageString languageString = textData.getLanguageText(eng);
|
366
|
|
367
|
Taxon referencedTaxon = getTaxon();
|
368
|
cdmBases.add(referencedTaxon);
|
369
|
languageString.addIntextReference(IntextReference.NewInstance(referencedTaxon, languageString, 2, 5));
|
370
|
textData.putModifyingText(eng, "nice diagnosis");
|
371
|
handleAnnotatableEntity(textData);
|
372
|
handleAnnotatableEntity(languageString);
|
373
|
|
374
|
TextFormat format = TextFormat.NewInstance("format", "format", null);
|
375
|
textData.setFormat(format);
|
376
|
cdmBases.add(format);
|
377
|
handleAnnotatableEntity(format);
|
378
|
|
379
|
//IndividualsAssociation
|
380
|
DerivedUnit specimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
381
|
IndividualsAssociation indAssoc = IndividualsAssociation.NewInstance(specimen);
|
382
|
indAssoc.putDescription(Language.ENGLISH(), "description for individuals association");
|
383
|
handleAnnotatableEntity(indAssoc);
|
384
|
|
385
|
//TaxonInteraction
|
386
|
TaxonInteraction taxonInteraction = TaxonInteraction.NewInstance(Feature.HOSTPLANT());
|
387
|
taxonInteraction.putDescription(Language.ENGLISH(), "interaction description");
|
388
|
handleAnnotatableEntity(taxonInteraction);
|
389
|
|
390
|
//Distribution
|
391
|
NamedArea inCountryArea = NamedArea.NewInstance("My area in a country", "my area", "ma");
|
392
|
inCountryArea.addCountry(Country.TURKEYREPUBLICOF());
|
393
|
cdmBases.add(inCountryArea);
|
394
|
Distribution distribution = Distribution.NewInstance(inCountryArea, PresenceAbsenceTerm.CULTIVATED());
|
395
|
handleAnnotatableEntity(distribution);
|
396
|
|
397
|
//TemporalData
|
398
|
Feature floweringSeason = Feature.FLOWERING_PERIOD();
|
399
|
TemporalData temporalData = TemporalData.NewInstance(ExtendedTimePeriod.NewExtendedMonthInstance(5, 8, 4, 9));
|
400
|
temporalData.setFeature(floweringSeason);
|
401
|
temporalData.getPeriod().setFreeText("My temporal text");
|
402
|
handleAnnotatableEntity(temporalData);
|
403
|
temporalData.setUuid(UUID.fromString("9a1c91c0-fc58-4310-94cb-8c26115985d3"));
|
404
|
|
405
|
Taxon taxon = getTaxon();
|
406
|
TaxonDescription taxonDescription = TaxonDescription.NewInstance(taxon);
|
407
|
taxonDescription.addElements(categoricalData, quantitativeData,
|
408
|
textData, commonTaxonName, taxonInteraction, indAssoc, distribution, temporalData);
|
409
|
|
410
|
DerivedUnit describedSpecimenOrObservation = DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit);
|
411
|
taxonDescription.setDescribedSpecimenOrObservation(describedSpecimenOrObservation);
|
412
|
|
413
|
taxonDescription.addScope(DefinedTerm.SEX_FEMALE());
|
414
|
taxonDescription.addGeoScope(Country.GERMANY());
|
415
|
handleIdentifiableEntity(taxonDescription);
|
416
|
|
417
|
taxon.addAggregationSource(taxonDescription);
|
418
|
|
419
|
cdmBases.add(taxon);
|
420
|
|
421
|
//DescriptionElmenetBase + source
|
422
|
textData.addMedia(Media.NewInstance());
|
423
|
textData.addModifier(DefinedTerm.SEX_HERMAPHRODITE());
|
424
|
textData.putModifyingText(Language.ENGLISH(), "no modification");
|
425
|
textData.setTimeperiod(TimePeriodParser.parseString("1970-1980"));
|
426
|
Reference ref = ReferenceFactory.newArticle();
|
427
|
DescriptionElementSource source = textData.addSource(OriginalSourceType.Import, "22", "taxon description table", ref, "detail");
|
428
|
source.setNameUsedInSource(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()));
|
429
|
ExternalLink link = ExternalLink.NewInstance(ExternalLinkType.WebSite,
|
430
|
URI.create("http://wwww.abd.de"), "Somehow useful link", 445);
|
431
|
source.addLink(link);
|
432
|
handleAnnotatableEntity(source);
|
433
|
|
434
|
taxonDescription.addDescriptionSource(ref); //as long as it still exists
|
435
|
|
436
|
|
437
|
//Specimen description
|
438
|
SpecimenOrObservationBase<?> describedSpecimen = getSpecimen();
|
439
|
SpecimenDescription specDesc = SpecimenDescription.NewInstance(specimen);
|
440
|
cdmBases.add(describedSpecimen);
|
441
|
handleAnnotatableEntity(specDesc);
|
442
|
|
443
|
//Name description
|
444
|
TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
445
|
TaxonNameDescription nameDesc = TaxonNameDescription.NewInstance(name);
|
446
|
cdmBases.add(name);
|
447
|
handleAnnotatableEntity(nameDesc);
|
448
|
|
449
|
|
450
|
//Feature Tree
|
451
|
TermTree<Feature> featureTree = TermTree.NewFeatureInstance();
|
452
|
// featureTree
|
453
|
TermNode<Feature> descriptionTermNode = featureTree.getRoot().addChild(Feature.DESCRIPTION());
|
454
|
TermNode<Feature> leaveLengthNode = descriptionTermNode.addChild(leaveLength);
|
455
|
handleIdentifiableEntity(featureTree);
|
456
|
|
457
|
State inapplicableState = State.NewInstance("inapplicableState", "inapplicableState", null);
|
458
|
State applicableState = State.NewInstance("only applicable state", "only applicable state", null);
|
459
|
cdmBases.add(applicableState);
|
460
|
cdmBases.add(inapplicableState);
|
461
|
leaveLengthNode.addInapplicableState(leaveLength, inapplicableState); //this is semantically not correct, should be a parent feature
|
462
|
leaveLengthNode.addApplicableState(leaveLength, applicableState);
|
463
|
cdmBases.add(featureTree);
|
464
|
cdmBases.add(leaveLengthNode);
|
465
|
|
466
|
|
467
|
//DescriptiveDataSet
|
468
|
DescriptiveDataSet descriptiveDataSet = DescriptiveDataSet.NewInstance();
|
469
|
descriptiveDataSet.addDescription(taxonDescription);
|
470
|
descriptiveDataSet.setLabel("My Descriptive Dataset");
|
471
|
descriptiveDataSet.getDescriptiveSystem();
|
472
|
handleAnnotatableEntity(descriptiveDataSet);
|
473
|
descriptiveDataSet.addGeoFilterArea(Country.GERMANY());
|
474
|
Classification classification = Classification.NewInstance("DescriptiveDataSet subtree classification");
|
475
|
Taxon subTreeTaxon = getTaxon();
|
476
|
TaxonNode subtree = classification.addChildTaxon(subTreeTaxon, null, null);
|
477
|
descriptiveDataSet.addTaxonSubtree(subtree);
|
478
|
|
479
|
cdmBases.add(classification);
|
480
|
cdmBases.add(subtree);
|
481
|
|
482
|
|
483
|
//polytomous keys
|
484
|
Taxon coveredTaxon = Taxon.NewInstance(name, null);
|
485
|
PolytomousKey key = PolytomousKey.NewTitledInstance("My Polykey");
|
486
|
handleIdentificationKey(key, taxon, coveredTaxon);
|
487
|
key.setStartNumber(10);
|
488
|
|
489
|
|
490
|
PolytomousKeyNode firstChildNode = PolytomousKeyNode.NewInstance("Green", "What is the leave length?", coveredTaxon, leaveLength);
|
491
|
key.getRoot().addChild(firstChildNode);
|
492
|
PolytomousKeyNode secondChildNode = PolytomousKeyNode.NewInstance("234");
|
493
|
firstChildNode.addChild(secondChildNode);
|
494
|
|
495
|
PolytomousKey subkey = PolytomousKey.NewTitledInstance("Sub-key");
|
496
|
firstChildNode.setSubkey(subkey);
|
497
|
|
498
|
PolytomousKeyNode subKeyNode = PolytomousKeyNode.NewInstance("sub key couplet");
|
499
|
subkey.getRoot().addChild(subKeyNode);
|
500
|
secondChildNode.setOtherNode(subKeyNode);
|
501
|
|
502
|
secondChildNode.putModifyingText(Language.GERMAN(), "manchmal");
|
503
|
|
504
|
cdmBases.add(key);
|
505
|
cdmBases.add(subkey);
|
506
|
|
507
|
MediaKey mediaKey = MediaKey.NewInstance();
|
508
|
mediaKey.addKeyRepresentation(Representation.NewInstance("Media Key Representation", "media key", null, Language.ENGLISH()));
|
509
|
handleIdentificationKey(mediaKey, taxon, coveredTaxon);
|
510
|
|
511
|
MultiAccessKey multiAccessKey = MultiAccessKey.NewInstance();
|
512
|
handleIdentificationKey(multiAccessKey, taxon, coveredTaxon);
|
513
|
|
514
|
cdmBases.add(mediaKey);
|
515
|
cdmBases.add(multiAccessKey);
|
516
|
|
517
|
}
|
518
|
|
519
|
|
520
|
|
521
|
private void handleIdentificationKey(IIdentificationKey key, Taxon taxon, Taxon coveredTaxon){
|
522
|
key.addCoveredTaxon(coveredTaxon);
|
523
|
key.addGeographicalScope(Country.GERMANY());
|
524
|
key.addScopeRestriction(DefinedTerm.SEX_FEMALE());
|
525
|
key.addTaxonomicScope(taxon);
|
526
|
if (key instanceof IdentifiableEntity<?>){
|
527
|
handleIdentifiableEntity((IdentifiableEntity<?>)key);
|
528
|
}else{
|
529
|
handleAnnotatableEntity((AnnotatableEntity)key);
|
530
|
}
|
531
|
|
532
|
|
533
|
}
|
534
|
|
535
|
|
536
|
private void createMedia(List<CdmBase> cdmBases){
|
537
|
AudioFile audioFile = AudioFile.NewInstance(URI.create("http://a.b.de"), 22);
|
538
|
ImageFile imageFile = ImageFile.NewInstance(URI.create("http://b.c.de"), 44, 467, 55);
|
539
|
MovieFile movieFile = MovieFile.NewInstance(URI.create("http://b.c.de"), 67);
|
540
|
MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance("mime", "media");
|
541
|
|
542
|
mediaRepresentation.addRepresentationPart(movieFile);
|
543
|
mediaRepresentation.addRepresentationPart(imageFile);
|
544
|
mediaRepresentation.addRepresentationPart(audioFile);
|
545
|
Media media = Media.NewInstance();
|
546
|
media.addRepresentation(mediaRepresentation);
|
547
|
|
548
|
media.putTitle(Language.ENGLISH(), "Media title");
|
549
|
media.setMediaCreated(TimePeriod.NewInstance(DateTime.now()));
|
550
|
media.putDescription(Language.ENGLISH(), "Media description");
|
551
|
handleIdentifiableEntity(media);
|
552
|
|
553
|
|
554
|
Person artist = Person.NewTitledInstance("artist");
|
555
|
media.setArtist(artist);
|
556
|
cdmBases.add(media);
|
557
|
cdmBases.add(artist);
|
558
|
|
559
|
MediaMetaData.NewInstance(imageFile, "Key", "Value");
|
560
|
}
|
561
|
|
562
|
|
563
|
private void createMolecular(List<CdmBase> cdmBases) {
|
564
|
DnaSample dnaSample = DnaSample.NewInstance();
|
565
|
|
566
|
//Amplification
|
567
|
Amplification amplification = Amplification.NewInstance();
|
568
|
|
569
|
DefinedTerm dnaMarker = DefinedTerm.NewDnaMarkerInstance("My dna marker", "dna marker", null);
|
570
|
cdmBases.add(dnaMarker);
|
571
|
amplification.setDnaMarker(dnaMarker);
|
572
|
Institution inst = Institution.NewInstance();
|
573
|
amplification.setInstitution(inst);
|
574
|
handleEventBase(amplification);
|
575
|
handleAnnotatableEntity(amplification);
|
576
|
|
577
|
Primer forwardPrimer = Primer.NewInstance("forward primer");
|
578
|
forwardPrimer.setPublishedIn(getReference());
|
579
|
forwardPrimer.setSequence(SequenceString.NewInstance("my sequence"));
|
580
|
handleAnnotatableEntity(forwardPrimer);
|
581
|
|
582
|
Primer reversePrimer = Primer.NewInstance("reverse primer");
|
583
|
handleAnnotatableEntity(reversePrimer);
|
584
|
|
585
|
amplification.setForwardPrimer(forwardPrimer);
|
586
|
amplification.setReversePrimer(reversePrimer);
|
587
|
|
588
|
DefinedTerm purificationMethod = DefinedTerm.NewInstance(TermType.MaterialOrMethod, "purification method", "purification method", null);
|
589
|
cdmBases.add(purificationMethod);
|
590
|
MaterialOrMethodEvent purification = MaterialOrMethodEvent.NewInstance(purificationMethod, "purification method");
|
591
|
amplification.setPurification(purification);
|
592
|
handleAnnotatableEntity(purification);
|
593
|
handleAnnotatableEntity(purificationMethod);
|
594
|
|
595
|
amplification.setLadderUsed("ladder");
|
596
|
amplification.setElectrophoresisVoltage(5.5);
|
597
|
amplification.setGelConcentration(2.4);
|
598
|
amplification.setGelRunningTime(3.6);
|
599
|
|
600
|
//Amplification result
|
601
|
AmplificationResult amplificationResult = AmplificationResult.NewInstance(dnaSample, amplification);
|
602
|
amplificationResult.setSuccessful(true);
|
603
|
amplificationResult.setSuccessText("Very successful");
|
604
|
handleAnnotatableEntity(amplificationResult);
|
605
|
|
606
|
DefinedTerm cloningMethod = DefinedTerm.NewInstance(TermType.MaterialOrMethod, "cloning method", "cloning method", null);
|
607
|
cdmBases.add(cloningMethod);
|
608
|
Cloning cloning = Cloning.NewInstance(cloningMethod, "My cloning method", "my strain", forwardPrimer, reversePrimer);
|
609
|
amplificationResult.setCloning(cloning);
|
610
|
handleAnnotatableEntity(cloningMethod);
|
611
|
handleAnnotatableEntity(cloning);
|
612
|
|
613
|
Media gelPhoto = Media.NewInstance();
|
614
|
amplificationResult.setGelPhoto(gelPhoto);
|
615
|
|
616
|
//SingleRead
|
617
|
SingleRead singleRead = SingleRead.NewInstance();
|
618
|
handleAnnotatableEntity(singleRead);
|
619
|
amplificationResult.addSingleRead(singleRead);
|
620
|
MaterialOrMethodEvent readMethod = MaterialOrMethodEvent.NewInstance(null, "read method");
|
621
|
singleRead.setMaterialOrMethod(readMethod);
|
622
|
handleAnnotatableEntity(readMethod);
|
623
|
|
624
|
Media pherogram = Media.NewInstance();
|
625
|
singleRead.setPherogram(pherogram);
|
626
|
|
627
|
singleRead.setPrimer(forwardPrimer);
|
628
|
singleRead.setSequence(SequenceString.NewInstance("ABTC"));
|
629
|
singleRead.setDirection(SequenceDirection.Forward);
|
630
|
|
631
|
//Sequence
|
632
|
Sequence sequence = Sequence.NewInstance("ADDT");
|
633
|
dnaSample.addSequence(sequence);
|
634
|
|
635
|
// SequenceString alignedSequence = SequenceString.NewInstance("AGTC");
|
636
|
Shift[] shifts = new Shift[]{new Shift(66,1),new Shift(103,-2)};
|
637
|
SingleReadAlignment.NewInstance(sequence, singleRead, shifts, "AGTC");
|
638
|
|
639
|
Media contigFile = Media.NewInstance();
|
640
|
sequence.setContigFile(contigFile);
|
641
|
sequence.setIsBarcode(true);
|
642
|
sequence.setDnaMarker(dnaMarker);
|
643
|
sequence.setBarcodeSequencePart(SequenceString.NewInstance("ADTA"));
|
644
|
sequence.setGeneticAccessionNumber("GenNO12345");
|
645
|
sequence.setBoldProcessId("boldId");
|
646
|
sequence.setHaplotype("haplotype");
|
647
|
Reference sequenceCitation = getReference();
|
648
|
sequence.addCitation(sequenceCitation);
|
649
|
handleAnnotatableEntity(sequence);
|
650
|
|
651
|
//DnaQuality
|
652
|
DnaQuality dnaQuality = DnaQuality.NewInstance();
|
653
|
dnaQuality.setConcentration(2.0);
|
654
|
MeasurementUnit mu = MeasurementUnit.NewInstance("mg/ml", "mg/ml","mg/ml");
|
655
|
cdmBases.add(mu);
|
656
|
dnaQuality.setConcentrationUnit(mu);
|
657
|
dnaQuality.setPurificationMethod("purification method");
|
658
|
dnaQuality.setQualityCheckDate(DateTime.now());
|
659
|
dnaQuality.setQualityTerm(null); //TODO
|
660
|
dnaQuality.setRatioOfAbsorbance260_230(22.0);
|
661
|
dnaQuality.setRatioOfAbsorbance260_280(3.9);
|
662
|
dnaSample.setDnaQuality(dnaQuality);
|
663
|
|
664
|
//Phylogenetic Tree
|
665
|
PhylogeneticTree phyloTree = PhylogeneticTree.NewInstance();
|
666
|
phyloTree.addUsedSequences(sequence);
|
667
|
handleIdentifiableEntity(phyloTree);
|
668
|
|
669
|
cdmBases.add(dnaSample);
|
670
|
cdmBases.add(phyloTree);
|
671
|
}
|
672
|
|
673
|
private void createTaxon(List<CdmBase> cdmBases) {
|
674
|
|
675
|
Reference sec = getReference();
|
676
|
TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
677
|
Taxon taxon = Taxon.NewInstance(name, sec);
|
678
|
taxon.getSecSource().addLink(ExternalLink.NewInstance(ExternalLinkType.WebSite, URI.create("https://www.abc.de"),
|
679
|
"link description", Language.GERMAN(), 44));
|
680
|
handleIdentifiableEntity(taxon);
|
681
|
|
682
|
TaxonName synName = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
683
|
Synonym syn = Synonym.NewInstance(synName, sec, "123");
|
684
|
taxon.addSynonym(syn, SynonymType.HETEROTYPIC_SYNONYM_OF());
|
685
|
taxon.setDoubtful(true);
|
686
|
handleIdentifiableEntity(syn);
|
687
|
|
688
|
Taxon concept = Taxon.NewInstance(name, getReference());
|
689
|
TaxonRelationship taxRel = taxon.addTaxonRelation(concept, TaxonRelationshipType.CONGRUENT_TO(),
|
690
|
sec, "444");
|
691
|
taxon.setTaxonStatusUnknown(true);
|
692
|
handleAnnotatableEntity(taxRel);
|
693
|
concept.setConcept(true);
|
694
|
concept.setNameUsage(true);
|
695
|
concept.setHomotypicGroups(true);
|
696
|
concept.setConceptId("euromed123");
|
697
|
concept.setPersistent(true);
|
698
|
concept.setCurrentConceptPeriod(TimePeriod.NewInstance(1999, 2019));
|
699
|
concept.setSupportsProvenance(true);
|
700
|
|
701
|
//Classification
|
702
|
Classification classification = Classification.NewInstance("My classification", sec);
|
703
|
classification.setMicroReference("p. 123");
|
704
|
classification.setTimeperiod(TimePeriodParser.parseString("1.1.2012-4.8.2013"));
|
705
|
classification.addGeoScope(Country.GERMANY());
|
706
|
classification.putDescription(Language.ENGLISH(), "An interesting classification");
|
707
|
|
708
|
TaxonNode node = classification.addChildTaxon(taxon, sec,"22");
|
709
|
handleIdentifiableEntity(classification);
|
710
|
handleAnnotatableEntity(node);
|
711
|
node.putStatusNote(Language.DEFAULT(), "Status note");
|
712
|
DefinedTerm agentRelationType = DefinedTerm.NewTaxonNodeAgentRelationTypeInstance(null, "agentRelation", "ar");
|
713
|
Person agent = Person.NewTitledInstance("Related agent");
|
714
|
TaxonNodeAgentRelation agentRelation = node.addAgentRelation(agentRelationType, agent);
|
715
|
handleAnnotatableEntity(agentRelation);
|
716
|
|
717
|
Taxon childTaxon = Taxon.NewInstance(synName, sec);
|
718
|
node.addChildTaxon(childTaxon, sec, "44");
|
719
|
node.setStatus(TaxonNodeStatus.EXCLUDED);
|
720
|
|
721
|
cdmBases.add(taxon);
|
722
|
cdmBases.add(concept);
|
723
|
cdmBases.add(childTaxon);
|
724
|
cdmBases.add(classification);
|
725
|
cdmBases.add(agentRelationType);
|
726
|
|
727
|
|
728
|
}
|
729
|
|
730
|
|
731
|
|
732
|
|
733
|
private void createReference(List<CdmBase> cdmBases) {
|
734
|
Reference reference = ReferenceFactory.newArticle();
|
735
|
Person author = Person.NewTitledInstance("Author team");
|
736
|
reference.setAuthorship(author);
|
737
|
reference.setTitle("ref title");
|
738
|
reference.setAbbrevTitle("abbrev title");
|
739
|
reference.setDatePublished(TimePeriodParser.parseStringVerbatim("1999"));
|
740
|
reference.setEdition("edition");
|
741
|
reference.setEditor("editor");
|
742
|
Institution institution = Institution.NewInstance();
|
743
|
reference.setInstitution(institution);
|
744
|
reference.setIsbn("1234556");
|
745
|
reference.setIssn("issn");
|
746
|
reference.setDoi(DOI.fromRegistrantCodeAndSuffix("14356", "suffix"));
|
747
|
reference.setReferenceAbstract("referenceAbstract");
|
748
|
reference.setOrganization("organization");
|
749
|
reference.setPages("123-134");
|
750
|
reference.setPlacePublished("place Published");
|
751
|
reference.setPublisher("publisher");
|
752
|
Institution school = Institution.NewInstance();
|
753
|
reference.setSchool(school);
|
754
|
// reference.setSeriesPart("series");
|
755
|
reference.setSeriesPart("seriesPart");
|
756
|
reference.setVolume("vol. 3");
|
757
|
reference.setUri(URI.create("http://rer.abc.de"));
|
758
|
|
759
|
Reference journal = ReferenceFactory.newJournal();
|
760
|
reference.setInJournal(journal);
|
761
|
|
762
|
handleIdentifiableEntity(reference);
|
763
|
|
764
|
cdmBases.add(reference);
|
765
|
|
766
|
}
|
767
|
|
768
|
|
769
|
|
770
|
|
771
|
private void createOccurrence(List<CdmBase> cdmBases) {
|
772
|
//Collection
|
773
|
Collection collection = Collection.NewInstance();
|
774
|
Collection subCollection = Collection.NewInstance();
|
775
|
subCollection.setSuperCollection(collection);
|
776
|
handleIdentifiableEntity(collection);
|
777
|
handleIdentifiableEntity(subCollection);
|
778
|
cdmBases.add(subCollection);
|
779
|
|
780
|
collection.setCode("coll code");
|
781
|
collection.setCodeStandard("codeStandard");
|
782
|
collection.setName("coll name");
|
783
|
collection.setTownOrLocation("townOrLocation");
|
784
|
Institution institution = Institution.NewInstance();
|
785
|
collection.setInstitute(institution);
|
786
|
|
787
|
//FieldUnit
|
788
|
FieldUnit fieldUnit = FieldUnit.NewInstance();
|
789
|
fieldUnit.setFieldNumber("fieldNumber");
|
790
|
fieldUnit.setFieldNotes("fieldNotes");
|
791
|
Person primaryCollector = Person.NewInstance();
|
792
|
fieldUnit.setPrimaryCollector(primaryCollector);
|
793
|
handleIdentifiableEntity(fieldUnit);
|
794
|
|
795
|
GatheringEvent gatheringEvent = GatheringEvent.NewInstance();
|
796
|
fieldUnit.setGatheringEvent(gatheringEvent);
|
797
|
gatheringEvent.putLocality(Language.ENGLISH(), "locality");
|
798
|
gatheringEvent.setExactLocation(Point.NewInstance(22.4, -34.2,
|
799
|
ReferenceSystem.WGS84(), 33));
|
800
|
gatheringEvent.setCountry(Country.GERMANY());
|
801
|
gatheringEvent.addCollectingArea(NamedArea.EUROPE());
|
802
|
gatheringEvent.setCollectingMethod("collectingMethod");
|
803
|
gatheringEvent.setAbsoluteElevation(10);
|
804
|
gatheringEvent.setAbsoluteElevationMax(100);
|
805
|
gatheringEvent.setAbsoluteElevationText("elevation text");
|
806
|
|
807
|
gatheringEvent.setDistanceToGround(10.4);
|
808
|
gatheringEvent.setDistanceToGroundMax(100.3);
|
809
|
gatheringEvent.setDistanceToGroundText("distance to ground text");
|
810
|
|
811
|
gatheringEvent.setDistanceToWaterSurface(10.4);
|
812
|
gatheringEvent.setDistanceToWaterSurfaceMax(100.3);
|
813
|
gatheringEvent.setDistanceToWaterSurfaceText("distance to water text");
|
814
|
handleAnnotatableEntity(gatheringEvent);
|
815
|
handleEventBase(gatheringEvent);
|
816
|
|
817
|
|
818
|
//Derived Unit
|
819
|
MediaSpecimen mediaSpecimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.StillImage);
|
820
|
mediaSpecimen.setCollection(collection);
|
821
|
mediaSpecimen.setCatalogNumber("catalogNumber");
|
822
|
mediaSpecimen.setAccessionNumber("accessionNumber");
|
823
|
// mediaSpecimen.setCollectorsNumber("collectorsNumber");
|
824
|
mediaSpecimen.setBarcode("barcode");
|
825
|
TaxonName storedUnder = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
826
|
storedUnder.setTitleCache("Stored under", true);
|
827
|
mediaSpecimen.setStoredUnder(storedUnder);
|
828
|
mediaSpecimen.setExsiccatum("exsiccatum");
|
829
|
PreservationMethod preservation = PreservationMethod.NewInstance(null, "My preservation");
|
830
|
preservation.setTemperature(22.4);
|
831
|
mediaSpecimen.setPreservation(preservation);
|
832
|
mediaSpecimen.setOriginalLabelInfo("Original Label Info");
|
833
|
handleIdentifiableEntity(mediaSpecimen);
|
834
|
|
835
|
//DerivationEvent
|
836
|
DerivationEvent event = DerivationEvent.NewInstance(DerivationEventType.ACCESSIONING());
|
837
|
event.addOriginal(fieldUnit);
|
838
|
event.addDerivative(mediaSpecimen);
|
839
|
Institution inst = Institution.NewInstance();
|
840
|
event.setInstitution(inst);
|
841
|
handleAnnotatableEntity(event);
|
842
|
handleEventBase(event);
|
843
|
|
844
|
//SpecOrObservationBase
|
845
|
fieldUnit.setSex(DefinedTerm.SEX_FEMALE());
|
846
|
DefinedTerm lifeStage = DefinedTerm.NewStageInstance("Live stage", "stage", null);
|
847
|
cdmBases.add(lifeStage);
|
848
|
fieldUnit.setLifeStage(lifeStage);
|
849
|
DefinedTerm kindOfUnit = DefinedTerm.NewKindOfUnitInstance("Kind of unit", "Kind of unit", null);
|
850
|
cdmBases.add(kindOfUnit);
|
851
|
fieldUnit.setKindOfUnit(kindOfUnit);
|
852
|
fieldUnit.setIndividualCount("3");
|
853
|
fieldUnit.putDefinition(Language.ENGLISH(), "definition");
|
854
|
fieldUnit.setPublish(true);
|
855
|
handleIdentifiableEntity(fieldUnit);
|
856
|
|
857
|
//Determination
|
858
|
DeterminationEvent determinationEvent = DeterminationEvent.NewInstance(getTaxon(), mediaSpecimen);
|
859
|
determinationEvent.setModifier(DefinedTerm.DETERMINATION_MODIFIER_AFFINIS());
|
860
|
determinationEvent.setPreferredFlag(true);
|
861
|
determinationEvent.addReference(getReference());
|
862
|
handleAnnotatableEntity(determinationEvent);
|
863
|
handleEventBase(determinationEvent);
|
864
|
|
865
|
cdmBases.add(fieldUnit);
|
866
|
cdmBases.add(mediaSpecimen);
|
867
|
cdmBases.add(collection);
|
868
|
}
|
869
|
|
870
|
|
871
|
private void createTaxonName(List<CdmBase> cdmBases) {
|
872
|
TaxonName bacName = TaxonNameFactory.NewBacterialInstance(Rank.GENUS());
|
873
|
bacName.setSubGenusAuthorship("sub Genus author");
|
874
|
bacName.setNameApprobation("nameApprobation");
|
875
|
handleIdentifiableEntity(bacName);
|
876
|
|
877
|
TaxonName botName = TaxonNameFactory.NewCultivarInstance(Rank.SUBSPECIES());
|
878
|
botName.setAnamorphic(true);
|
879
|
botName.setCultivarName("cultivarName");
|
880
|
botName.setGenusOrUninomial("Genus");
|
881
|
botName.setInfraGenericEpithet("InfraGeneric");
|
882
|
botName.setSpecificEpithet("specificEpithet");
|
883
|
botName.setInfraSpecificEpithet("infraSpecificEpithet");
|
884
|
Person combinationAuthorship = Person.NewInstance();
|
885
|
botName.setCombinationAuthorship(combinationAuthorship);
|
886
|
Person exCombinationAuthorship = Person.NewInstance();
|
887
|
botName.setExCombinationAuthorship(exCombinationAuthorship);
|
888
|
Person basionymAuthorship = Person.NewInstance();
|
889
|
botName.setBasionymAuthorship(basionymAuthorship);
|
890
|
Person exBasionymAuthorship = Person.NewInstance();
|
891
|
botName.setExBasionymAuthorship(exBasionymAuthorship);
|
892
|
handleIdentifiableEntity(botName);
|
893
|
handleAnnotatableEntity(botName.getHomotypicalGroup());
|
894
|
TaxonName botName2 = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
|
895
|
HybridRelationship hybridRel = botName2.addHybridChild(botName, HybridRelationshipType.FIRST_PARENT(), "Rule 1.2.3");
|
896
|
hybridRel.setCitation(ReferenceFactory.newBook());
|
897
|
hybridRel.setCitationMicroReference("p. 123");
|
898
|
handleAnnotatableEntity(hybridRel);
|
899
|
|
900
|
TaxonName zooName = TaxonNameFactory.NewZoologicalInstance(Rank.GENUS());
|
901
|
zooName.setBreed("breed");
|
902
|
zooName.setPublicationYear(1922);
|
903
|
zooName.setOriginalPublicationYear(1987);
|
904
|
zooName.setAppendedPhrase("appended phrase");
|
905
|
zooName.addDescription(TaxonNameDescription.NewInstance());
|
906
|
zooName.setNomenclaturalMicroReference("p. 123");
|
907
|
zooName.setNomenclaturalReference(getReference());
|
908
|
NameRelationship rel = zooName.addRelationshipFromName(botName, NameRelationshipType.LATER_HOMONYM() , "ruleConsidered", NomenclaturalCodeEdition.ICN_2017_SHENZHEN);
|
909
|
NomenclaturalStatus status = NomenclaturalStatus.NewInstance(NomenclaturalStatusType.CONSERVED(), getReference(), "p. 222");
|
910
|
zooName.addStatus(status);
|
911
|
handleAnnotatableEntity(rel);
|
912
|
handleAnnotatableEntity(status);
|
913
|
handleIdentifiableEntity(zooName);
|
914
|
|
915
|
//TypeDesignation
|
916
|
TaxonName speciesZooName = TaxonNameFactory.NewZoologicalInstance(Rank.SPECIES());
|
917
|
NameTypeDesignation nameDesig = zooName.addNameTypeDesignation(speciesZooName, getReference(), "111", "original name",
|
918
|
NameTypeDesignationStatus.AUTOMATIC(), true, true, true, true);
|
919
|
handleAnnotatableEntity(nameDesig);
|
920
|
SpecimenTypeDesignation specimenDesig = speciesZooName.addSpecimenTypeDesignation(getSpecimen(), SpecimenTypeDesignationStatus.HOLOTYPE(),
|
921
|
getReference(), "p,22", "original name", false, true);
|
922
|
handleAnnotatableEntity(specimenDesig);
|
923
|
speciesZooName.addTextualTypeDesignation("A textual type designation", Language.ENGLISH(), true,
|
924
|
getReference(), "123", "Species orginalus", false);
|
925
|
|
926
|
|
927
|
TaxonName viralName = TaxonNameFactory.NewViralInstance(Rank.GENUS());
|
928
|
viralName.setAcronym("acronym");
|
929
|
handleIdentifiableEntity(viralName);
|
930
|
|
931
|
//Registration
|
932
|
Registration registration = Registration.NewInstance("registration identifier",
|
933
|
"specificIdentifier", speciesZooName, null);
|
934
|
registration.addTypeDesignation(specimenDesig);
|
935
|
registration.setRegistrationDate(DateTime.now());
|
936
|
Registration blockingRegistration = Registration.NewInstance();
|
937
|
registration.addBlockedBy(blockingRegistration);
|
938
|
registration.setInstitution(Institution.NewInstance());
|
939
|
User submitter = User.NewInstance("submitter", "12345");
|
940
|
registration.setSubmitter(submitter);
|
941
|
handleAnnotatableEntity(registration);;
|
942
|
|
943
|
cdmBases.add(submitter);
|
944
|
cdmBases.add(bacName);
|
945
|
cdmBases.add(botName);
|
946
|
cdmBases.add(viralName);
|
947
|
cdmBases.add(zooName);
|
948
|
cdmBases.add(botName2);
|
949
|
}
|
950
|
|
951
|
private void handleEventBase(EventBase event){
|
952
|
event.setTimeperiod(TimePeriodParser.parseString("1.4.1975-2.5.1980"));
|
953
|
event.setActor(Person.NewTitledInstance("EventActor"));
|
954
|
event.setDescription("Some interesing event");
|
955
|
}
|
956
|
|
957
|
private void handleAnnotatableEntity(AnnotatableEntity entity){
|
958
|
Annotation annotation = Annotation.NewDefaultLanguageInstance("annotation");
|
959
|
entity.addAnnotation(annotation);
|
960
|
Marker marker = Marker.NewInstance(MarkerType.COMPLETE(), true);
|
961
|
entity.addMarker(marker);
|
962
|
}
|
963
|
|
964
|
private void handleIdentifiableEntity(IdentifiableEntity<?> identifiableEntity){
|
965
|
handleAnnotatableEntity(identifiableEntity);
|
966
|
|
967
|
//Credits
|
968
|
Person creditor = Person.NewTitledInstance("Creditor");
|
969
|
Credit credit = Credit.NewInstance(creditor, "credit");
|
970
|
identifiableEntity.addCredit(credit);
|
971
|
|
972
|
//Extension
|
973
|
Extension.NewInstance(identifiableEntity, "extension", ExtensionType.INFORMAL_CATEGORY());
|
974
|
|
975
|
//Identifier
|
976
|
Identifier identifier = identifiableEntity.addIdentifier("ident23", DefinedTerm.SEX_FEMALE());
|
977
|
handleAnnotatableEntity(identifier);
|
978
|
|
979
|
//Links
|
980
|
identifiableEntity.addLinkWebsite(URI.create("http://a.bc.de"), "Description", Language.ENGLISH());
|
981
|
|
982
|
//Rights
|
983
|
Rights rights = Rights.NewInstance("right", Language.ENGLISH());
|
984
|
rights.setUri(URI.create("http://rights.abc.de"));
|
985
|
rights.setAbbreviatedText("abbrev");
|
986
|
rights.setType(RightsType.COPYRIGHT());
|
987
|
Person owner = Person.NewTitledInstance("Owner");
|
988
|
rights.setAgent(owner);
|
989
|
identifiableEntity.addRights(rights);
|
990
|
|
991
|
if (identifiableEntity.isInstanceOf(IdentifiableMediaEntity.class)){
|
992
|
Media media = Media.NewInstance(URI.create("http://www.identifiableMedia.de"), 22, "img/jpg", "jpg");
|
993
|
((IdentifiableMediaEntity<?>)identifiableEntity).addMedia(media);
|
994
|
}
|
995
|
|
996
|
//source
|
997
|
IdentifiableSource source = identifiableEntity.addSource(OriginalSourceType.Import, "id", "idNamespace",
|
998
|
getReference(), "123");
|
999
|
source.setOriginalNameString("original name");
|
1000
|
|
1001
|
//LSID
|
1002
|
try {
|
1003
|
LSID lsid = new LSID("urn:lsid:a.b.de:namespace:1234");
|
1004
|
identifiableEntity.setLsid(lsid);
|
1005
|
} catch (MalformedLSIDException e) {
|
1006
|
e.printStackTrace();
|
1007
|
}
|
1008
|
}
|
1009
|
|
1010
|
private Reference getReference() {
|
1011
|
Reference result = ReferenceFactory.newGeneric();
|
1012
|
result.setTitle("some generic reference");
|
1013
|
return result;
|
1014
|
}
|
1015
|
|
1016
|
private DerivedUnit getSpecimen() {
|
1017
|
DerivedUnit derivedUnit = DerivedUnit.NewPreservedSpecimenInstance();
|
1018
|
return derivedUnit;
|
1019
|
}
|
1020
|
|
1021
|
private Taxon getTaxon() {
|
1022
|
Reference sec = getReference();
|
1023
|
TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
|
1024
|
Taxon taxon = Taxon.NewInstance(name, sec);
|
1025
|
return taxon;
|
1026
|
}
|
1027
|
}
|