2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.sdd
.in
;
13 import java
.io
.IOException
;
14 import java
.net
.MalformedURLException
;
17 import java
.text
.SimpleDateFormat
;
18 import java
.util
.ArrayList
;
19 import java
.util
.Date
;
20 import java
.util
.HashMap
;
21 import java
.util
.HashSet
;
22 import java
.util
.List
;
25 import java
.util
.UUID
;
27 import org
.apache
.commons
.lang
.StringUtils
;
28 import org
.apache
.log4j
.Logger
;
29 import org
.jdom
.Element
;
30 import org
.jdom
.Namespace
;
31 import org
.joda
.time
.DateTime
;
32 import org
.springframework
.stereotype
.Component
;
33 import org
.springframework
.transaction
.TransactionStatus
;
35 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
36 import eu
.etaxonomy
.cdm
.common
.media
.ImageInfo
;
37 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
38 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ICdmImport
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
41 import eu
.etaxonomy
.cdm
.io
.common
.XmlImportBase
;
42 import eu
.etaxonomy
.cdm
.io
.sdd
.SDDTransformer
;
43 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
44 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
45 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
46 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
47 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
48 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
49 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
50 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
51 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
52 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
53 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
54 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
55 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
56 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceType
;
57 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
58 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
59 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
60 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
61 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
62 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
63 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
64 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
65 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
66 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
67 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
68 import eu
.etaxonomy
.cdm
.model
.description
.State
;
69 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
70 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
71 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
72 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
73 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
74 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
75 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
76 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
77 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
78 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
79 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
80 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentationPart
;
81 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
82 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
83 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
84 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
85 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
86 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
87 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
88 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
89 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
90 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
91 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
98 @Component("sddImport")
99 public class SDDImport
extends XmlImportBase
<SDDImportConfigurator
, SDDImportState
> implements ICdmImport
<SDDImportConfigurator
, SDDImportState
> {
100 private static final Logger logger
= Logger
.getLogger(SDDImport
.class);
102 private static int modCount
= 1000;
104 private UUID uuidAnnotationTypeLocation
= UUID
.fromString("a3737e07-72e3-46d2-986d-fa4cf5de0b63");
107 private Map
<String
,Person
> authors
= new HashMap
<String
,Person
>();
108 private Map
<String
,String
> citations
= new HashMap
<String
,String
>();
109 private Map
<String
,String
> defaultUnitPrefixes
= new HashMap
<String
,String
>();
110 private Map
<String
,Person
> editors
= new HashMap
<String
,Person
>();
111 private Map
<String
,FeatureNode
> featureNodes
= new HashMap
<String
,FeatureNode
>();
112 private Map
<String
,Feature
> features
= new HashMap
<String
,Feature
>();
113 private Map
<String
,String
> locations
= new HashMap
<String
,String
>();
114 private Map
<String
,List
<CdmBase
>> mediaObject_ListCdmBase
= new HashMap
<String
,List
<CdmBase
>>();
115 private Map
<String
,String
> mediaObject_Role
= new HashMap
<String
,String
>();
116 private Map
<String
,Reference
<?
>> publications
= new HashMap
<String
,Reference
<?
>>();
117 private Map
<String
,State
> states
= new HashMap
<String
,State
>();
118 private Map
<String
,TaxonDescription
> taxonDescriptions
= new HashMap
<String
,TaxonDescription
>();
119 private Map
<String
,NonViralName
<?
>> taxonNameBases
= new HashMap
<String
,NonViralName
<?
>>();
120 private Map
<String
,MeasurementUnit
> units
= new HashMap
<String
,MeasurementUnit
>();
121 private Map
<String
,TaxonNode
> taxonNodes
= new HashMap
<String
,TaxonNode
>();
122 private Map
<String
,NamedArea
> namedAreas
= new HashMap
<String
,NamedArea
>();
123 private Map
<String
,DerivedUnit
> specimens
= new HashMap
<String
,DerivedUnit
>();
124 private Map
<String
,DefinedTerm
> modifiers
= new HashMap
<String
,DefinedTerm
>();
126 private Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
127 private Set
<TermVocabulary
<?
>> vocabularies
= new HashSet
<TermVocabulary
<?
>>();
129 private Set
<Feature
> descriptiveConcepts
= new HashSet
<Feature
>();
130 private Set
<AnnotationType
> annotationTypes
= new HashSet
<AnnotationType
>();
131 // private Set<Feature> featureSet = new HashSet<Feature>();
132 private Set
<Reference
<?
>> sources
= new HashSet
<Reference
<?
>>();
133 private Reference
<?
> sec
= ReferenceFactory
.newDatabase();
134 private Reference
<?
> sourceReference
= null;
136 private Language datasetLanguage
= null;
137 private WorkingSet workingSet
= null;
139 private Namespace xmlNamespace
= Namespace
.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
141 private String generatorName
= "";
142 private String generatorVersion
= "";
145 private Set
<StatisticalMeasure
> statisticalMeasures
= new HashSet
<StatisticalMeasure
>();
146 private Set
<VersionableEntity
> featureData
= new HashSet
<VersionableEntity
>();
147 private Set
<FeatureTree
> featureTrees
= new HashSet
<FeatureTree
>();
148 private Set
<Classification
> classifications
= new HashSet
<Classification
>();
150 private Rights copyright
= null;
152 private int taxonNamesCount
= 0;
159 public boolean doCheck(SDDImportState state
){
160 boolean result
= true;
161 logger
.warn("No check implemented for SDD");
166 // public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){
168 public void doInvoke(SDDImportState state
){
170 TransactionStatus ts
= startTransaction();
171 SDDImportConfigurator sddConfig
= state
.getConfig();
172 IProgressMonitor progressMonitor
= sddConfig
.getProgressMonitor();
174 logger
.info("start Datasets ...");
176 // <Datasets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://rs.tdwg.org/UBIF/2006/" xsi:schemaLocation="http://rs.tdwg.org/UBIF/2006/ ../SDD.xsd">
177 Element root
= sddConfig
.getSourceRoot();
178 Namespace sddNamespace
= sddConfig
.getSddNamespace();
180 logger
.info("start TechnicalMetadata ...");
181 // <TechnicalMetadata created="2006-04-20T10:00:00">
182 importTechnicalMetadata(root
, sddNamespace
, sddConfig
);
183 List
<Element
> elDatasets
= root
.getChildren("Dataset",sddNamespace
);
187 logger
.info("start Dataset ...");
188 progressMonitor
.beginTask("Importing SDD data", elDatasets
.size());
189 for (Element elDataset
: elDatasets
){
190 importDataset(elDataset
, sddNamespace
, state
);
191 // if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);}
192 // logger.info(i + " dataset(s) handled");
193 progressMonitor
.worked(1);
195 commitTransaction(ts
);
196 progressMonitor
.done();
197 logger
.info("End of transaction");
202 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
204 protected boolean isIgnore(SDDImportState state
){
209 // associates the reference of a media object in SDD with a CdmBase Object
210 protected void associateImageWithCdmBase(String refMO
, CdmBase cb
){
211 if ((refMO
!= null) && (cb
!=null)) {
212 if (! refMO
.equals("")) {
213 if (! mediaObject_ListCdmBase
.containsKey(refMO
)) {
214 List
<CdmBase
> lcb
= new ArrayList
<CdmBase
>();
216 mediaObject_ListCdmBase
.put(refMO
,lcb
);
218 List
<CdmBase
> lcb
= mediaObject_ListCdmBase
.get(refMO
);
220 mediaObject_ListCdmBase
.put(refMO
,lcb
);
226 // imports information about the Dataset
227 protected void importDatasetRepresentation(Element parent
, Namespace sddNamespace
){
228 logger
.info("start Representation ...");
230 <Label>The Genus Viola</Label>
231 <Detail>This is an example for a very simple SDD file, representing a single description with categorical, quantitative, and text character. Compare also the "Fragment*" examples, which contain more complex examples in the form of document fragments. Intended for version="SDD 1.1".</Detail>
237 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
238 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
);
239 String detail
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Detail",sddNamespace
);
242 Representation representation
= Representation
.NewInstance(detail
, label
, null, datasetLanguage
);
243 workingSet
.addRepresentation(representation
);
247 // sec.setTitleCache(label, true);
249 // if (detail != null) {
250 // Annotation annotation = Annotation.NewInstance(detail, datasetLanguage);
251 // annotation.setAnnotationType(AnnotationType.EDITORIAL());
252 // sec.addAnnotation(annotation);
256 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject",sddNamespace
);
258 for (Element elMediaObject
: listMediaObjects
) {
261 if (elMediaObject
!= null) {
262 ref
= elMediaObject
.getAttributeValue("ref");
263 role
= elMediaObject
.getAttributeValue("role");
266 if (!ref
.equals("")) {
267 this.associateImageWithCdmBase(ref
,sourceReference
);
268 this.associateImageWithCdmBase(ref
,sec
);
269 mediaObject_Role
.put(ref
,role
);
275 // imports the representation (label, detail, lang) of a particular SDD element
276 protected void importRepresentation(Element parent
, Namespace sddNamespace
, VersionableEntity ve
, String id
, SDDImportState state
){
277 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
279 Map
<Language
,List
<String
>> langLabDet
= new HashMap
<Language
,List
<String
>>();
281 handleRepresentationLabels(sddNamespace
, elRepresentation
, langLabDet
);
282 handleRepresentationDetails(sddNamespace
, elRepresentation
, langLabDet
);
284 if (ve
instanceof TermBase
) {
285 makeRepresentationForTerms((TermBase
)ve
, langLabDet
);
286 }else if (ve
instanceof Media
) {
287 makeRepresentationForMedia((Media
)ve
, langLabDet
);
288 }else if (ve
instanceof IdentifiableEntity
<?
>) {
289 IdentifiableEntity
<?
> ie
= (IdentifiableEntity
<?
>)ve
;
290 makeRepresentationForIdentifiableEntity(sddNamespace
, ie
, elRepresentation
, langLabDet
);
291 if (ve
instanceof IdentifiableMediaEntity
<?
>){
292 makeRepresentationForIdentifiableMediaEntity(parent
, sddNamespace
, (IdentifiableMediaEntity
<?
>)ve
);
296 makeRepresentationMediaObjects(sddNamespace
, ve
, elRepresentation
);//FIXME
302 * Handles the "Detail" children of representations. Adds the result to the langLabDet.
303 * @param sddNamespace
304 * @param elRepresentation
307 private void handleRepresentationDetails(Namespace sddNamespace
,
308 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
309 List
<Element
> listDetails
= elRepresentation
.getChildren("Detail",sddNamespace
);
310 for (Element elDetail
: listDetails
){
311 Language language
= getLanguage(elDetail
);
312 String role
= elDetail
.getAttributeValue("role");
313 String detail
= elDetail
.getText();
314 List
<String
> labDet
= langLabDet
.get(language
);
317 langLabDet
.put(language
, labDet
);
322 * Handles the "Label" children of representations. Adds the result to the langLabDet.
323 * @param sddNamespace
324 * @param elRepresentation
327 private void handleRepresentationLabels(Namespace sddNamespace
,
328 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
329 // <Label xml:lang="la">Viola hederacea Labill.</Label>
330 List
<Element
> listLabels
= elRepresentation
.getChildren("Label",sddNamespace
);
331 for (Element elLabel
: listLabels
){
332 Language language
= getLanguage(elLabel
);
333 String label
= elLabel
.getText();
334 List
<String
> labDet
= new ArrayList
<String
>(3);
336 langLabDet
.put(language
, labDet
);
345 private void makeRepresentationForMedia(Media media
, Map
<Language
, List
<String
>> langLabDet
) {
346 for (Language lang
: langLabDet
.keySet()){
347 List
<String
> labDet
= langLabDet
.get(lang
);
348 if (labDet
.get(0) != null){
349 media
.putTitle(LanguageString
.NewInstance(labDet
.get(0), lang
));
351 if (labDet
.size()>1) {
352 media
.putDescription(lang
, labDet
.get(1));
358 * Handles representations for terms. Adds one representation per language in langLabDet.
363 private void makeRepresentationForTerms(TermBase tb
, Map
<Language
, List
<String
>> langLabDet
) {
364 for (Language lang
: langLabDet
.keySet()){
365 List
<String
> labDet
= langLabDet
.get(lang
);
366 if (labDet
.size()>0){
367 if (labDet
.size()>1) {
368 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(1), labDet
.get(0), labDet
.get(0), lang
));
370 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(0), labDet
.get(0), labDet
.get(0), lang
));
378 * Handles the "MediaObject" children of representations.
379 * @param sddNamespace
381 * @param elRepresentation
383 private void makeRepresentationMediaObjects(Namespace sddNamespace
, VersionableEntity ve
, Element elRepresentation
) {
384 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject", sddNamespace
);
385 for (Element elMediaObject
: listMediaObjects
) {
389 if (elMediaObject
!= null) {
390 ref
= elMediaObject
.getAttributeValue("ref");
391 role
= elMediaObject
.getAttributeValue("role");
393 if (StringUtils
.isNotBlank(ref
)) {
394 if (ve
instanceof TaxonDescription
) {
395 TaxonDescription td
= (TaxonDescription
) ve
;
396 if (td
.getSources().size() > 0) {
397 this.associateImageWithCdmBase(ref
, td
.getSources().iterator().next().getCitation());
399 Reference
<?
> descriptionSource
= ReferenceFactory
.newGeneric();
400 sources
.add(descriptionSource
);
402 td
.addSource(OriginalSourceType
.Unknown
, null, null, descriptionSource
, null);
403 this.associateImageWithCdmBase(ref
,descriptionSource
);
406 this.associateImageWithCdmBase(ref
,ve
);
413 * Handles the "Links" element
415 * @param sddNamespace
418 private void makeRepresentationForIdentifiableMediaEntity(Element parent
,
419 Namespace sddNamespace
, IdentifiableMediaEntity ime
) {
420 Element elLinks
= parent
.getChild("Links",sddNamespace
);
422 if (elLinks
!= null) {
424 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
425 List
<Element
> listLinks
= elLinks
.getChildren("Link", sddNamespace
);
426 Media link
= Media
.NewInstance();
427 MediaRepresentation mr
= MediaRepresentation
.NewInstance();
430 for (Element elLink
: listLinks
){
434 String rel
= elLink
.getAttributeValue("rel");
435 String href
= elLink
.getAttributeValue("href");
436 URI uri
= new URI(href
);
437 mr
.addRepresentationPart(MediaRepresentationPart
.NewInstance(uri
, null));
438 link
.addRepresentation(mr
);
441 } catch (Exception e
) {
443 logger
.warn("Import of Link " + k
+ " failed.");
446 if ((++k
% modCount
) == 0){ logger
.info("Links handled: " + k
);}
453 * @param sddNamespace
455 * @param elRepresentation
459 private void makeRepresentationForIdentifiableEntity(Namespace sddNamespace
, IdentifiableEntity
<?
> ie
,
460 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
461 List
<String
> labDet
= null;
463 if (ie
instanceof TaxonNameBase
) {
464 if (langLabDet
.keySet().contains(getTermService().getLanguageByIso("la"))) {
465 labDet
= langLabDet
.get(getTermService().getLanguageByIso("la"));
466 } else if (langLabDet
.keySet().contains(datasetLanguage
)) {
467 labDet
= langLabDet
.get(datasetLanguage
);
468 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
470 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
471 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
474 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
477 //FIXME labDet is != null only for TaxonNameBase
478 ie
.setTitleCache(labDet
.get(0), true);
480 if (labDet
.size()>1) {
481 Annotation annotation
= null;
482 if (labDet
.get(1) != null) {
483 if (labDet
.get(2) != null) {
484 annotation
= Annotation
.NewInstance(labDet
.get(2) + " - " + labDet
.get(1), datasetLanguage
);
486 annotation
= Annotation
.NewInstance(labDet
.get(1), datasetLanguage
);
489 ie
.addAnnotation(annotation
);
498 private Language
getLanguage(Element elLanguage
) {
499 String lang
= elLanguage
.getAttributeValue("lang",xmlNamespace
);
500 Language language
= null;
501 if (StringUtils
.isNotBlank(lang
)) {
502 language
= getTermService().getLanguageByIso(lang
.substring(0, 2));
504 language
= datasetLanguage
;
510 // imports the representation (label, detail, lang) of a particular SDD element
511 protected void importTechnicalMetadata(Element root
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
512 Element elTechnicalMetadata
= root
.getChild("TechnicalMetadata", sddNamespace
);
513 String nameCreated
= elTechnicalMetadata
.getAttributeValue("created");
514 sourceReference
= sddConfig
.getSourceReference();
516 if (nameCreated
!= null) {
517 if (!nameCreated
.equals("")) {
518 int year
= Integer
.parseInt(nameCreated
.substring(0,4));
519 int monthOfYear
= Integer
.parseInt(nameCreated
.substring(5,7));
520 int dayOfMonth
= Integer
.parseInt(nameCreated
.substring(8,10));
521 int hourOfDay
= Integer
.parseInt(nameCreated
.substring(11,13));
522 int minuteOfHour
= Integer
.parseInt(nameCreated
.substring(14,16));
523 int secondOfMinute
= Integer
.parseInt(nameCreated
.substring(17,19));
524 DateTime created
= new DateTime(year
,monthOfYear
,dayOfMonth
,hourOfDay
,minuteOfHour
,secondOfMinute
,0);
525 sourceReference
.setCreated(created
);
526 sec
.setCreated(created
);
530 // <Generator name="n/a, handcrafted instance document" version="n/a"/>
531 Element elGenerator
= elTechnicalMetadata
.getChild("Generator", sddNamespace
);
532 generatorName
= elGenerator
.getAttributeValue("name");
533 generatorVersion
= elGenerator
.getAttributeValue("version");
535 sec
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
536 sourceReference
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
540 // imports the complete dataset information
541 protected void importDataset(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){ // <Dataset xml:lang="en-us">
543 workingSet
= WorkingSet
.NewInstance();
544 importDatasetLanguage(elDataset
,state
);
545 importDatasetRepresentation(elDataset
, sddNamespace
);
546 importRevisionData(elDataset
, sddNamespace
);
547 importIPRStatements(elDataset
, sddNamespace
, state
);
548 importTaxonNames(elDataset
, sddNamespace
, state
);
550 importDescriptiveConcepts(elDataset
, sddNamespace
, state
);
551 importCharacters(elDataset
, sddNamespace
, state
);
552 importCharacterTrees(elDataset
, sddNamespace
, state
);
554 MarkerType editorMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerEditor
, "editor", "Editor", "edt");
555 MarkerType geographicAreaMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerSDDGeographicArea
, "SDDGeographicArea", "SDDGeographicArea", "ga");
556 MarkerType descriptiveConceptMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerDescriptiveConcept
, "DescriptiveConcept", "Descriptive Concept", "DC");
557 markerTypes
.add(editorMarkerType
);
558 markerTypes
.add(geographicAreaMarkerType
);
559 markerTypes
.add(descriptiveConceptMarkerType
);
561 //saving of all imported data into the CDM db
567 saveAreas(geographicAreaMarkerType
);
569 saveStatisticalMeasure();
570 saveAnnotationType();
572 importCodedDescriptions(elDataset
, sddNamespace
, state
);
573 importAgents(elDataset
, sddNamespace
, state
);
574 importPublications(elDataset
, sddNamespace
, state
);
575 importMediaObjects(elDataset
, sddNamespace
, state
);
576 importTaxonHierarchies(elDataset
, sddNamespace
, state
);
577 importGeographicAreas(elDataset
, sddNamespace
, state
);
578 importSpecimens(elDataset
,sddNamespace
, state
);
581 if ((authors
!= null)||(editors
!= null)) {
582 Team team
= Team
.NewInstance();
583 if (authors
!= null) {
584 for (Person author
: authors
.values()){
585 team
.addTeamMember(author
);
588 if (editors
!= null) {
589 Marker marker
= Marker
.NewInstance();
590 marker
.setMarkerType(editorMarkerType
);
591 for (Person editor
: editors
.values()){
592 Person edit
= editor
;
593 edit
.addMarker(marker
);
594 team
.addTeamMember(edit
);
597 sec
.setAuthorTeam(team
);
598 sourceReference
.setAuthorTeam(team
);
601 if (copyright
!= null) {
602 sourceReference
.addRights(copyright
);
603 sec
.addRights(copyright
);
606 // Returns a CdmApplicationController created by the values of this configuration.
607 IDescriptionService descriptionService
= getDescriptionService();
609 for (TaxonDescription taxonDescription
: taxonDescriptions
.values()){
610 // Persists a Description
611 descriptionService
.save(taxonDescription
);
614 for (String ref
: taxonDescriptions
.keySet()){
615 TaxonDescription td
= taxonDescriptions
.get(ref
);
616 if (citations
.containsKey(ref
)) {
617 Reference
<?
> publication
= publications
.get(citations
.get(ref
));
618 if (locations
.containsKey(ref
)) {
619 Annotation location
= Annotation
.NewInstance(locations
.get(ref
), datasetLanguage
);
620 //TODO move to a generic place (implemented in hurry therefore dirty)
621 AnnotationType annotationType
= getAnnotationType(state
, uuidAnnotationTypeLocation
, "location", "location", "location", null);
622 // annotationTypes.add(annotationType); TODO necessary??
623 location
.setAnnotationType(annotationType
);
624 (publication
).addAnnotation(location
);
626 td
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, null, null,publication
, null);
629 logger
.info("end makeTaxonDescriptions ...");
631 if (descriptiveConcepts
!= null) {
632 for (Feature feature
: descriptiveConcepts
) {
633 Marker marker
= Marker
.NewInstance();
634 marker
.setMarkerType(descriptiveConceptMarkerType
);
635 feature
.addMarker(marker
);
640 for (Reference
<?
> publication
: publications
.values()){
641 getReferenceService().save(publication
);
644 for (Reference
<?
> source
: sources
){
645 getReferenceService().save(source
);
648 for (FeatureTree featureTree
: featureTrees
) {
649 getFeatureTreeService().save(featureTree
);
651 getWorkingSetService().save(workingSet
);
652 for (Classification classification
: classifications
) {
653 getClassificationService().save(classification
);
655 for (DerivedUnit specimen
: specimens
.values()) {
656 getOccurrenceService().save(specimen
);
658 logger
.info("end of persistence ...");
666 private void saveVocabularies() {
667 for (TermVocabulary
<?
> vocabulary
: vocabularies
){
668 getVocabularyService().save(vocabulary
);
673 private void saveAnnotationType() {
674 for (AnnotationType annotationType
: annotationTypes
){
675 getTermService().saveOrUpdate(annotationType
);
679 private void saveStatisticalMeasure() {
680 for (StatisticalMeasure sm
: statisticalMeasures
){
681 getTermService().save(sm
);
685 private void saveUnits() {
687 for (MeasurementUnit unit
: units
.values()){
689 getTermService().save(unit
);
695 private void saveAreas(MarkerType geographicAreaMarkerType
) {
696 for (NamedArea area
: namedAreas
.values() ){
697 Marker marker
= Marker
.NewInstance();
698 marker
.setMarkerType(geographicAreaMarkerType
);
699 area
.addMarker(marker
);
700 getTermService().save(area
);
704 private void saveStates() {
705 for (State state
: states
.values() ){
706 getTermService().save(state
);
710 private void saveMarkerType() {
711 for (MarkerType markerType
: markerTypes
){
712 getTermService().save(markerType
);
716 private void saveModifiers() {
717 for (DefinedTerm modifier
: modifiers
.values() ){
718 getTermService().save(modifier
);
722 private void saveFeatures() {
723 for (Feature feature
: features
.values() ){
724 getTermService().save(feature
);
728 // imports the default language of the dataset
729 protected void importDatasetLanguage(Element elDataset
, SDDImportState state
){
730 String nameLang
= elDataset
.getAttributeValue("lang",xmlNamespace
);
732 if (StringUtils
.isNotBlank(nameLang
)) {
733 String iso
= nameLang
.substring(0, 2);
734 datasetLanguage
= getTermService().getLanguageByIso(iso
);
736 datasetLanguage
= Language
.DEFAULT();
738 if (datasetLanguage
== null) {
739 datasetLanguage
= Language
.DEFAULT();
743 // imports the specimens
744 protected void importSpecimens(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
745 logger
.info("start Specimens ...");
749 <Label>TJM45337</Label>
754 Element elSpecimens
= elDataset
.getChild("Specimens",sddNamespace
);
755 if (elSpecimens
!= null){
756 List
<Element
> listSpecimens
= elSpecimens
.getChildren("Specimen", sddNamespace
);
757 for (Element elSpecimen
: listSpecimens
) {
758 String id
= elSpecimen
.getAttributeValue("id");
759 DerivedUnit specimen
= null;
760 if (!id
.equals("")) {
761 specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
762 specimens
.put(id
,specimen
);
763 importRepresentation(elSpecimen
, sddNamespace
, specimen
, id
, cdmState
);
770 // imports the revision data associated with the Dataset (authors, modifications)
771 protected void importRevisionData(Element elDataset
, Namespace sddNamespace
){
773 logger
.info("start RevisionData ...");
774 Element elRevisionData
= elDataset
.getChild("RevisionData",sddNamespace
);
775 if (elRevisionData
!= null){
777 Element elCreators
= elRevisionData
.getChild("Creators",sddNamespace
);
779 // <Agent role="aut" ref="a1"/>
780 List
<Element
> listAgents
= elCreators
.getChildren("Agent", sddNamespace
);
784 for (Element elAgent
: listAgents
){
786 String role
= elAgent
.getAttributeValue("role");
787 String ref
= elAgent
.getAttributeValue("ref");
788 if (role
.equals("aut")) {
789 if(!ref
.equals("")) {
790 authors
.put(ref
, null);
793 if (role
.equals("edt")) {
794 if(!ref
.equals("")) {
795 editors
.put(ref
, null);
798 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
802 // <DateModified>2006-04-08T00:00:00</DateModified>
803 String stringDateModified
= (String
)ImportHelper
.getXmlInputValue(elRevisionData
, "DateModified",sddNamespace
);
805 if (stringDateModified
!= null) {
806 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
809 d
= sdf
.parse(stringDateModified
);
810 } catch(Exception e
) {
811 System
.err
.println("Exception :");
815 DateTime updated
= null;
817 updated
= new DateTime(d
);
818 sourceReference
.setUpdated(updated
);
819 sec
.setUpdated(updated
);
825 // imports ipr statements associated with a dataset
826 protected void importIPRStatements(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
828 logger
.info("start IPRStatements ...");
829 Element elIPRStatements
= elDataset
.getChild("IPRStatements",sddNamespace
);
830 // <IPRStatement role="Copyright">
831 if (elIPRStatements
!= null) {
832 List
<Element
> listIPRStatements
= elIPRStatements
.getChildren("IPRStatement", sddNamespace
);
834 //for each IPRStatement
836 for (Element elIPRStatement
: listIPRStatements
){
838 String role
= elIPRStatement
.getAttributeValue("role");
839 // <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
840 Element elLabel
= elIPRStatement
.getChild("Label",sddNamespace
);
842 if (elLabel
!= null) {
843 lang
= elLabel
.getAttributeValue("lang",xmlNamespace
);
845 String label
= (String
)ImportHelper
.getXmlInputValue(elIPRStatement
, "Label",sddNamespace
);
847 if (role
.equals("Copyright")) {
848 Language iprLanguage
= null;
850 if (!lang
.equals("")) {
851 iprLanguage
= getTermService().getLanguageByIso(lang
.substring(0, 2));
853 iprLanguage
= datasetLanguage
;
856 if (iprLanguage
== null) {
857 iprLanguage
= datasetLanguage
;
859 copyright
= Rights
.NewInstance(label
, iprLanguage
);
862 if (copyright
!= null) {
863 sourceReference
.addRights(copyright
);
864 sec
.addRights(copyright
);
867 if ((++j
% modCount
) == 0){ logger
.info("IPRStatements handled: " + j
);}
873 // imports the taxon names
874 protected void importTaxonNames(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
876 logger
.info("start TaxonNames ...");
877 Element elTaxonNames
= elDataset
.getChild("TaxonNames",sddNamespace
);
878 // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
879 if (elTaxonNames
!= null) {
880 List
<Element
> listTaxonNames
= elTaxonNames
.getChildren("TaxonName", sddNamespace
);
883 for (Element elTaxonName
: listTaxonNames
){
885 String id
= elTaxonName
.getAttributeValue("id");
886 String uri
= elTaxonName
.getAttributeValue("uri");
888 NonViralName
<?
> tnb
= null;
889 if (!id
.equals("")) {
890 tnb
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
891 IdentifiableSource source
= null;
893 if (! isNotBlank(uri
)) {
895 source
= IdentifiableSource
.NewInstance(OriginalSourceType
.Unknown
, id
, "TaxonName", ReferenceFactory
.newGeneric(), uri
);
898 source
= IdentifiableSource
.NewDataImportInstance(id
, "TaxonName");
900 tnb
.addSource(source
);
901 taxonNameBases
.put(id
,tnb
);
905 // <Label xml:lang="la">Viola hederacea Labill.</Label>
906 importRepresentation(elTaxonName
, sddNamespace
, tnb
, id
, state
);
908 if ((++j
% modCount
) == 0){ logger
.info("TaxonNames handled: " + j
);}
914 // imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features
915 protected void importCharacters(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
917 logger
.info("start Characters ...");
918 Element elCharacters
= elDataset
.getChild("Characters", sddNamespace
);
920 // <CategoricalCharacter id="c1">
921 if (elCharacters
!= null) {
922 handleCategoricalData(sddNamespace
, cdmState
, elCharacters
);
923 handleQuantitativeData(sddNamespace
, cdmState
, elCharacters
);
924 handleTextCharacters(sddNamespace
, cdmState
, elCharacters
);
927 /*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){
928 featureSet.add(f.next()); //XIM Why this line ?
936 * @param sddNamespace
938 * @param elCharacters
941 private void handleCategoricalData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
942 List
<Element
> elCategoricalCharacters
= elCharacters
.getChildren("CategoricalCharacter", sddNamespace
);
944 for (Element elCategoricalCharacter
: elCategoricalCharacters
){
947 String idCC
= elCategoricalCharacter
.getAttributeValue("id");
948 Feature categoricalCharacter
= Feature
.NewInstance();
949 categoricalCharacter
.setKindOf(Feature
.DESCRIPTION());
950 importRepresentation(elCategoricalCharacter
, sddNamespace
, categoricalCharacter
, idCC
, cdmState
);
951 categoricalCharacter
.setSupportsCategoricalData(true);
954 Element elStates
= elCategoricalCharacter
.getChild("States",sddNamespace
);
956 // <StateDefinition id="s1">
957 List
<Element
> elStateDefinitions
= elStates
.getChildren("StateDefinition",sddNamespace
);
958 TermVocabulary
<State
> termVocabularyState
= TermVocabulary
.NewInstance(TermType
.State
, null, null, null, null);
960 vocabularies
.add(termVocabularyState
);
963 //for each StateDefinition
964 for (Element elStateDefinition
: elStateDefinitions
){
966 if ((++k
% modCount
) == 0){ logger
.info("StateDefinitions handled: " + (k
-1));}
968 String idS
= elStateDefinition
.getAttributeValue("id");
969 State state
= states
.get(idS
);
971 state
= State
.NewInstance();
973 logger
.debug("State duplicate found");
975 importRepresentation(elStateDefinition
, sddNamespace
, state
, idS
, cdmState
);
977 termVocabularyState
.addTerm(state
);
978 states
.put(idS
,state
);
980 categoricalCharacter
.addSupportedCategoricalEnumeration(termVocabularyState
);
981 features
.put(idCC
, categoricalCharacter
);
983 } catch (Exception e
) {
984 logger
.warn("Import of CategoricalCharacter " + j
+ " failed.");
985 cdmState
.setUnsuccessfull();
988 if ((++j
% modCount
) == 0){ logger
.info("CategoricalCharacters handled: " + j
);}
995 * @param sddNamespace
997 * @param elCharacters
999 private void handleQuantitativeData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1001 // <QuantitativeCharacter id="c2">
1002 List
<Element
> elQuantitativeCharacters
= elCharacters
.getChildren("QuantitativeCharacter", sddNamespace
);
1004 //for each QuantitativeCharacter
1005 for (Element elQuantitativeCharacter
: elQuantitativeCharacters
){
1009 String idQC
= elQuantitativeCharacter
.getAttributeValue("id");
1012 // <Label>Leaf length</Label>
1013 // </Representation>
1014 Feature quantitativeCharacter
= Feature
.NewInstance();
1015 quantitativeCharacter
.setKindOf(Feature
.DESCRIPTION());
1016 importRepresentation(elQuantitativeCharacter
, sddNamespace
, quantitativeCharacter
, idQC
, cdmState
);
1018 quantitativeCharacter
.setSupportsQuantitativeData(true);
1020 // <MeasurementUnit>
1021 // <Label role="Abbrev">m</Label>
1022 // </MeasurementUnit>
1023 Element elMeasurementUnit
= elQuantitativeCharacter
.getChild("MeasurementUnit",sddNamespace
);
1026 if (elMeasurementUnit
!= null) {
1027 Element elLabel
= elMeasurementUnit
.getChild("Label",sddNamespace
);
1028 role
= elLabel
.getAttributeValue("role");
1029 label
= (String
)ImportHelper
.getXmlInputValue(elMeasurementUnit
, "Label",sddNamespace
);
1032 MeasurementUnit unit
= null;
1033 if (!label
.equals("")){
1035 if (role
.equals("Abbrev")){
1036 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1039 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1044 units
.put(idQC
, unit
);
1048 // <MeasurementUnitPrefix>milli</MeasurementUnitPrefix>
1050 Element elDefault
= elQuantitativeCharacter
.getChild("Default",sddNamespace
);
1051 if (elDefault
!= null) {
1052 String measurementUnitPrefix
= (String
)ImportHelper
.getXmlInputValue(elDefault
, "MeasurementUnitPrefix",sddNamespace
);
1053 if (! measurementUnitPrefix
.equals("")){
1054 defaultUnitPrefixes
.put(idQC
, measurementUnitPrefix
);
1058 features
.put(idQC
, quantitativeCharacter
);
1060 } catch (Exception e
) {
1062 logger
.warn("Import of QuantitativeCharacter " + j
+ " failed.");
1063 cdmState
.setUnsuccessfull();
1066 if ((++j
% modCount
) == 0){ logger
.info("QuantitativeCharacters handled: " + j
);}
1072 private void handleTextCharacters(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1074 // <TextCharacter id="c3">
1075 List
<Element
> elTextCharacters
= elCharacters
.getChildren("TextCharacter", sddNamespace
);
1077 //for each TextCharacter
1078 for (Element elTextCharacter
: elTextCharacters
){
1082 String idTC
= elTextCharacter
.getAttributeValue("id");
1085 // <Label xml:lang="en">Leaf features not covered by other characters</Label>
1086 // </Representation>
1087 Feature textCharacter
= Feature
.NewInstance();
1088 textCharacter
.setKindOf(Feature
.DESCRIPTION());
1089 importRepresentation(elTextCharacter
, sddNamespace
, textCharacter
, idTC
, cdmState
);
1091 textCharacter
.setSupportsTextData(true);
1093 features
.put(idTC
, textCharacter
);
1095 } catch (Exception e
) {
1097 logger
.warn("Import of TextCharacter " + j
+ " failed.");
1098 cdmState
.setUnsuccessfull();
1101 if ((++j
% modCount
) == 0){ logger
.info("TextCharacters handled: " + j
);}
1107 // imports the descriptions of taxa
1108 protected void importCodedDescriptions(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1110 // <CodedDescriptions>
1111 logger
.info("start CodedDescriptions ...");
1112 Element elCodedDescriptions
= elDataset
.getChild("CodedDescriptions",sddNamespace
);
1114 // <CodedDescription id="D101">
1115 if (elCodedDescriptions
!= null) {
1116 List
<Element
> listCodedDescriptions
= elCodedDescriptions
.getChildren("CodedDescription", sddNamespace
);
1118 //for each CodedDescription
1119 for (Element elCodedDescription
: listCodedDescriptions
){
1120 handleCodedDescription(sddNamespace
, cdmState
, elCodedDescription
, j
);
1121 if ((++j
% modCount
) == 0){ logger
.info("CodedDescriptions handled: " + j
);}
1128 * @param sddNamespace
1131 * @param elCodedDescription
1134 private void handleCodedDescription(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
, int j
) {
1137 String idCD
= elCodedDescription
.getAttributeValue("id");
1140 // <Label><i>Viola hederacea</i> Labill. as revised by R. Morris April 8, 2006</Label>
1141 // </Representation>
1142 TaxonDescription taxonDescription
= TaxonDescription
.NewInstance();
1143 if (!generatorName
.isEmpty()){
1144 Annotation annotation
= Annotation
.NewInstance(generatorName
, AnnotationType
.TECHNICAL(),Language
.DEFAULT());
1145 taxonDescription
.addAnnotation(annotation
);
1147 importRepresentation(elCodedDescription
, sddNamespace
, taxonDescription
, idCD
, cdmState
);
1150 // <TaxonName ref="t1"/>
1151 // <Citation ref="p1" location="p. 30"/>
1153 Element elScope
= elCodedDescription
.getChild("Scope", sddNamespace
);
1155 if (elScope
!= null) {
1156 taxon
= handleCDScope(sddNamespace
, cdmState
, idCD
, elScope
);
1157 } else {//in case no taxon is linked to the description, a new one is created
1158 taxon
= handleCDNoScope(sddNamespace
, cdmState
, elCodedDescription
);
1162 Element elSummaryData
= elCodedDescription
.getChild("SummaryData",sddNamespace
);
1163 if (elSummaryData
!= null) {
1164 handleSummaryCategoricalData(sddNamespace
, taxonDescription
, elSummaryData
);
1165 handleSummaryQuantitativeData(sddNamespace
, taxonDescription
, elSummaryData
);
1166 handleSummaryTextData(sddNamespace
, taxonDescription
, elSummaryData
);
1169 if (taxon
!= null) {
1170 taxon
.addDescription(taxonDescription
);
1173 workingSet
.addDescription(taxonDescription
);
1175 //OLD taxonDescription.setDescriptiveSystem(featureSet);
1177 taxonDescriptions
.put(idCD
, taxonDescription
);//FIXME
1179 } catch (Exception e
) {
1181 logger
.warn("Import of CodedDescription " + j
+ " failed.", e
);
1182 cdmState
.setUnsuccessfull();
1188 * @param sddNamespace
1190 * @param elCodedDescription
1194 private Taxon
handleCDNoScope(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
) {
1196 NonViralName
<?
> nonViralName
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
1197 String id
= new String("" + taxonNamesCount
);
1198 IdentifiableSource source
= IdentifiableSource
.NewDataImportInstance(id
, "TaxonName");
1199 importRepresentation(elCodedDescription
, sddNamespace
, nonViralName
, id
, cdmState
);
1201 if(cdmState
.getConfig().isDoMatchTaxa()){
1202 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1206 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1207 // taxonNameBases.put(id ,tnb);
1208 // taxonNamesCount++;
1209 logger
.info("using existing Taxon " + taxon
.getTitleCache());
1211 nonViralName
.addSource(source
);
1212 taxonNameBases
.put(id
,nonViralName
);
1214 logger
.info("creating new Taxon from TaxonName " + nonViralName
.getTitleCache());
1215 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1221 * @param sddNamespace
1228 private Taxon
handleCDScope(Namespace sddNamespace
, SDDImportState cdmState
,
1229 String idCD
, Element elScope
) {
1231 Element elTaxonName
= elScope
.getChild("TaxonName", sddNamespace
);
1232 String ref
= elTaxonName
.getAttributeValue("ref");
1233 NonViralName
<?
> nonViralName
= taxonNameBases
.get(ref
);
1235 if(cdmState
.getConfig().isDoMatchTaxa()){
1236 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1240 logger
.info("using existing Taxon" + taxon
.getTitleCache());
1241 if(!nonViralName
.getUuid().equals(taxon
.getName().getUuid())){
1242 logger
.warn("TaxonNameBase entity of existing taxon does not match Name in list -> replacing Name in list");
1243 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1246 logger
.info("creating new Taxon from TaxonName '" + nonViralName
.getTitleCache()+"'");
1247 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1251 Element elCitation
= elScope
.getChild("Citation",sddNamespace
);
1252 if (elCitation
!= null) {
1253 String refCitation
= elCitation
.getAttributeValue("ref");
1254 if (! refCitation
.equals("")){
1255 citations
.put(idCD
, refCitation
);
1257 String location
= elCitation
.getAttributeValue("location");
1258 if (! location
.equals("")){
1259 locations
.put(idCD
, location
);
1266 * @param sddNamespace
1267 * @param taxonDescription
1268 * @param elSummaryData
1270 private void handleSummaryTextData(Namespace sddNamespace
,
1271 TaxonDescription taxonDescription
, Element elSummaryData
) {
1274 // <TextChar ref="c3">
1275 List
<Element
> elTextChars
= elSummaryData
.getChildren("TextChar", sddNamespace
);
1278 for (Element elTextChar
: elTextChars
){
1279 if ((++k
% modCount
) == 0){ logger
.info("TextChar handled: " + (k
-1));}
1280 ref
= elTextChar
.getAttributeValue("ref");
1281 Feature feature
= features
.get(ref
);
1282 TextData textData
= TextData
.NewInstance();
1283 textData
.setFeature(feature
);
1285 // <Content>Free form text</Content>
1286 String content
= (String
)ImportHelper
.getXmlInputValue(elTextChar
, "Content",sddNamespace
);
1287 textData
.putText(datasetLanguage
, content
);
1288 taxonDescription
.addElement(textData
);
1293 * @param sddNamespace
1294 * @param taxonDescription
1295 * @param elSummaryData
1297 private void handleSummaryQuantitativeData(Namespace sddNamespace
,
1298 TaxonDescription taxonDescription
, Element elSummaryData
) {
1301 // <Quantitative ref="c2">
1302 List
<Element
> elQuantitatives
= elSummaryData
.getChildren("Quantitative", sddNamespace
);
1304 //for each Quantitative
1305 for (Element elQuantitative
: elQuantitatives
){
1306 if ((++k
% modCount
) == 0){ logger
.warn("Quantitative handled: " + (k
-1));}
1307 ref
= elQuantitative
.getAttributeValue("ref");
1308 Feature feature
= features
.get(ref
);
1309 QuantitativeData quantitativeData
= QuantitativeData
.NewInstance();
1310 quantitativeData
.setFeature(feature
);
1312 MeasurementUnit unit
= units
.get(ref
);
1313 String prefix
= defaultUnitPrefixes
.get(ref
);
1315 String u
= unit
.getLabel();
1316 if (prefix
!= null) {
1320 quantitativeData
.setUnit(unit
);
1323 // <Measure type="Min" value="2.3"/>
1324 List
<Element
> elMeasures
= elQuantitative
.getChildren("Measure", sddNamespace
);
1328 for (Element elMeasure
: elMeasures
){
1329 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1330 String type
= elMeasure
.getAttributeValue("type");
1331 String value
= elMeasure
.getAttributeValue("value");
1332 if (value
.contains(",")) {
1333 value
= value
.replace(',', '.');
1335 Float v
= Float
.parseFloat(value
);
1336 //Float v = new Float(0);
1337 StatisticalMeasure t
= null;
1338 if (type
.equals("Min")) {
1339 t
= StatisticalMeasure
.MIN();
1340 } else if (type
.equals("Mean")) {
1341 t
= StatisticalMeasure
.AVERAGE();
1342 } else if (type
.equals("Max")) {
1343 t
= StatisticalMeasure
.MAX();
1344 } else if (type
.equals("SD")) {
1345 t
= StatisticalMeasure
.STANDARD_DEVIATION();
1346 } else if (type
.equals("N")) {
1347 t
= StatisticalMeasure
.SAMPLE_SIZE();
1348 } else if (type
.equals("UMethLower")) {
1349 t
= StatisticalMeasure
.TYPICAL_LOWER_BOUNDARY();
1350 } else if (type
.equals("UMethUpper")) {
1351 t
= StatisticalMeasure
.TYPICAL_UPPER_BOUNDARY();
1352 } else if (type
.equals("Var")) {
1353 t
= StatisticalMeasure
.VARIANCE();
1355 t
= StatisticalMeasure
.NewInstance(type
,type
,type
);
1356 statisticalMeasures
.add(t
);
1359 StatisticalMeasurementValue statisticalValue
= StatisticalMeasurementValue
.NewInstance();
1360 statisticalValue
.setValue(v
);
1361 statisticalValue
.setType(t
);
1362 quantitativeData
.addStatisticalValue(statisticalValue
);
1363 featureData
.add(statisticalValue
);
1365 taxonDescription
.addElement(quantitativeData
);
1370 * @param sddNamespace
1371 * @param taxonDescription
1372 * @param elSummaryData
1374 private void handleSummaryCategoricalData(Namespace sddNamespace
,
1375 TaxonDescription taxonDescription
, Element elSummaryData
) {
1377 // <Categorical ref="c4">
1378 List
<Element
> elCategoricals
= elSummaryData
.getChildren("Categorical", sddNamespace
);
1380 //for each Categorical
1381 for (Element elCategorical
: elCategoricals
){
1382 if ((++k
% modCount
) == 0){ logger
.warn("Categorical handled: " + (k
-1));}
1383 ref
= elCategorical
.getAttributeValue("ref");
1384 Feature feature
= features
.get(ref
);
1385 CategoricalData categoricalData
= CategoricalData
.NewInstance();
1386 categoricalData
.setFeature(feature
);
1388 // <State ref="s3"/>
1389 List
<Element
> elStates
= elCategorical
.getChildren("State", sddNamespace
);
1393 for (Element elState
: elStates
){
1394 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1395 ref
= elState
.getAttributeValue("ref");
1396 State state
= states
.get(ref
);
1397 if (state
!= null) {
1398 StateData stateData
= StateData
.NewInstance();
1399 stateData
.setState(state
);
1400 List
<Element
> elModifiers
= elState
.getChildren("Modifier", sddNamespace
);
1401 for (Element elModifier
: elModifiers
){
1402 ref
= elModifier
.getAttributeValue("ref");
1403 DefinedTerm modifier
= modifiers
.get(ref
);
1404 if (modifier
!= null) {
1405 stateData
.addModifier(modifier
);
1408 categoricalData
.addStateData(stateData
);
1410 taxonDescription
.addElement(categoricalData
);
1415 // imports the persons associated with the dataset creation, modification, related publications
1416 protected void importAgents(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1418 logger
.info("start Agents ...");
1419 Element elAgents
= elDataset
.getChild("Agents",sddNamespace
);
1420 if (elAgents
!= null) {
1422 List
<Element
> listAgents
= elAgents
.getChildren("Agent", sddNamespace
);
1425 for (Element elAgent
: listAgents
){
1429 String idA
= elAgent
.getAttributeValue("id");
1432 // <Label>Kevin Thiele</Label>
1433 // <Detail role="Description">Ali Baba is also known as r.a.m.</Detail>
1434 // </Representation>
1435 Person person
= Person
.NewInstance();
1436 importRepresentation(elAgent
, sddNamespace
, person
, idA
, cdmState
);
1437 person
.addSource(IdentifiableSource
.NewDataImportInstance(idA
, "Agent"));
1440 Element elLinks = elAgent.getChild("Links",sddNamespace);
1442 if (elLinks != null) {
1444 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
1445 List<Element> listLinks = elLinks.getChildren("Link", sddNamespace);
1448 for (Element elLink : listLinks){
1452 String rel = elLink.getAttributeValue("rel");
1453 String href = elLink.getAttributeValue("href");
1455 Media link = Media.NewInstance();
1456 MediaRepresentation mr = MediaRepresentation.NewInstance();
1457 mr.addRepresentationPart(MediaRepresentationPart.NewInstance(href, null));
1458 link.addRepresentation(mr);
1459 person.addMedia(link);
1461 } catch (Exception e) {
1463 logger.warn("Import of Link " + k + " failed.");
1467 if ((++k % modCount) == 0){ logger.info("Links handled: " + k);}
1472 if (authors
.containsKey(idA
)) {
1473 authors
.put(idA
,person
);
1476 if (editors
.containsKey(idA
)) {
1477 editors
.put(idA
, person
);
1480 } catch (Exception e
) {
1482 logger
.warn("Import of Agent " + j
+ " failed.");
1483 cdmState
.setUnsuccessfull();
1486 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
1492 // imports publications related with the data set
1493 protected void importPublications(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1495 <Publication id="p112">
1497 <Label>Gee, X. & Haa, Y. (2003). How to be happy in five minutes. Instant Gratifications, Palm Beach.</Label>
1500 <Link rel="BasedOn" href="doi:10.1992/32311"/>
1501 <Link rel="Alternate" href="http://some.service.net/providing/bibliographic.data"/>
1505 logger
.info("start Publications ...");
1506 Element elPublications
= elDataset
.getChild("Publications",sddNamespace
);
1508 if (elPublications
!= null) {
1509 List
<Element
> listPublications
= elPublications
.getChildren("Publication", sddNamespace
);
1511 for (Element elPublication
: listPublications
){
1515 String idP
= elPublication
.getAttributeValue("id");
1516 Reference
<?
> publication
= ReferenceFactory
.newArticle();
1517 importRepresentation(elPublication
, sddNamespace
, publication
, idP
, cdmState
);
1519 publications
.put(idP
,publication
);
1521 } catch (Exception e
) {
1522 logger
.warn("Import of Publication " + j
+ " failed.");
1523 cdmState
.setUnsuccessfull();
1526 if ((++j
% modCount
) == 0){ logger
.info("Publications handled: " + j
);}
1532 // imports media objects such as images //FIXME check mediaobj
1533 protected void importMediaObjects(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1535 logger
.info("start MediaObjects ...");
1536 Element elMediaObjects
= elDataset
.getChild("MediaObjects",sddNamespace
);
1538 if (elMediaObjects
!= null) {
1539 // <MediaObject id="m1">
1540 List
<Element
> listMediaObjects
= elMediaObjects
.getChildren("MediaObject", sddNamespace
);
1542 for (Element elMO
: listMediaObjects
){
1547 String idMO
= elMO
.getAttributeValue("id");
1551 // <Label>Image description, e.g. to be used for alt-attribute in html.</Label>
1552 // </Representation>
1553 Media media
= Media
.NewInstance();
1554 importRepresentation(elMO
, sddNamespace
, media
, idMO
, cdmState
);
1556 // <Type>Image</Type>
1557 // <Source href="http://test.edu/test.jpg"/>
1558 String type
= (String
)ImportHelper
.getXmlInputValue(elMO
,"Type",sddNamespace
);
1560 if ((type
!= null) && (type
.equals("Image"))) {
1561 Element elSource
= elMO
.getChild("Source",sddNamespace
);
1562 String href
= elSource
.getAttributeValue("href");
1564 ImageInfo imageMetaData
= null;
1565 ImageFile image
= null;
1567 if (href
.substring(0,7).equals("http://")) {
1569 URL url
= new URL(href
);
1571 imageMetaData
= ImageInfo
.NewInstance(url
.toURI(), 0);
1572 image
= ImageFile
.NewInstance(url
.toURI(), null, imageMetaData
);
1573 } catch (MalformedURLException e
) {
1574 logger
.error("Malformed URL", e
);
1575 } catch (IOException ioe
) {
1576 logger
.warn("(IO ex: " + id
+ "): " + ioe
.getMessage());
1580 String sns
= cdmState
.getConfig().getSourceNameString();
1581 File f
= new File(sns
);
1582 File parent
= f
.getParentFile();
1583 String fi
= parent
.toString() + File
.separator
+ href
;
1584 File file
= new File(fi
);
1585 imageMetaData
= ImageInfo
.NewInstance(new URI(fi
), 0); //file
1586 image
= ImageFile
.NewInstance(file
.toURI(), null, imageMetaData
);
1588 MediaRepresentation representation
= MediaRepresentation
.NewInstance(imageMetaData
.getMimeType(), null);
1589 representation
.addRepresentationPart(image
);
1591 media
.addRepresentation(representation
);
1593 ArrayList
<CdmBase
> lcb
= (ArrayList
<CdmBase
>) mediaObject_ListCdmBase
.get(idMO
);
1595 for (int k
= 0; k
< lcb
.size(); k
++) {
1596 if (lcb
.get(k
) instanceof DefinedTermBase
) {
1597 DefinedTermBase
<?
> dtb
= (DefinedTermBase
<?
>) lcb
.get(k
);
1598 // if (lcb.get(0) instanceof DefinedTermBase) {
1599 // DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1602 dtb
.addMedia(media
);
1603 //System.out.println(dtb.getLabel());
1605 // Media me = (Media) media.clone();
1606 // dtb.addMedia(me);
1609 } else if (lcb
.get(k
) instanceof Reference
) {
1610 Reference
<?
> rb
= (Reference
<?
>) lcb
.get(k
);
1611 //} else if (lcb.get(0) instanceof Reference) {
1612 //Reference rb = (Reference) lcb.get(0);
1613 // rb.setTitleCache(label);
1617 //System.out.println(rb.getTitle());
1619 // Media me = (Media) media.clone();
1623 // else if (lcb.get(k) instanceof TaxonNameBase){
1624 // TaxonNameBase tb = (TaxonNameBase) lcb.get(k);
1625 // tb.addMedia(media);
1627 logger
.warn("Can't handle associated media for " + lcb
.get(k
).getId() + "(" + lcb
.get(k
).getClass().getSimpleName()+")" );
1633 } catch (Exception e
) {
1635 logger
.warn("Could not attach MediaObject " + j
+ "(SDD: " + id
+ ") to several objects: " + e
.getMessage());
1636 cdmState
.setUnsuccessfull();
1639 if ((++j
% modCount
) == 0){ logger
.info("MediaObjects handled: " + j
);
1646 // imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves
1647 // but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker
1648 protected void importDescriptiveConcepts(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
1649 /* <DescriptiveConcepts>
1650 <DescriptiveConcept id="dc0">
1652 <Label>Fixed set of modifiers supported in Lucid3</Label>
1655 <Modifier id="mod1">
1657 <Label>rarely</Label>
1659 <ModifierClass>Frequency</ModifierClass>
1660 <ProportionRange lowerestimate="0.0" upperestimate="0.25"/>
1663 </DescriptiveConcept>
1664 </DescriptiveConcepts>
1666 logger
.info("start DescriptiveConcepts ...");
1667 Element elDescriptiveConcepts
= elDataset
.getChild("DescriptiveConcepts",sddNamespace
);
1668 if (elDescriptiveConcepts
!= null) {
1669 List
<Element
> listDescriptiveConcepts
= elDescriptiveConcepts
.getChildren("DescriptiveConcept", sddNamespace
);
1672 for (Element elDescriptiveConcept
: listDescriptiveConcepts
){
1674 String id
= elDescriptiveConcept
.getAttributeValue("id");
1675 Feature feature
= Feature
.NewInstance();
1676 feature
.setKindOf(Feature
.DESCRIPTION());
1677 if (!id
.equals("")) {
1679 // <Label>Body</Label>
1680 importRepresentation(elDescriptiveConcept
, sddNamespace
, feature
, id
, state
);
1681 features
.put(id
, feature
);
1682 getTermService().save(feature
);//XIM
1683 descriptiveConcepts
.add(feature
);
1684 // imports the modifiers
1685 Element elModifiers
= elDescriptiveConcept
.getChild("Modifiers", sddNamespace
);
1686 if (elModifiers
!=null){
1687 List
<Element
> listModifiers
= elModifiers
.getChildren("Modifier", sddNamespace
);
1688 TermVocabulary
<DefinedTerm
> termVocabularyState
= TermVocabulary
.NewInstance(TermType
.Modifier
, null, null, null, null);
1689 for (Element elModifier
: listModifiers
) {
1690 DefinedTerm modif
= DefinedTerm
.NewModifierInstance(null, null, null);
1691 String idmod
= elModifier
.getAttributeValue("id");
1692 importRepresentation(elModifier
, sddNamespace
, modif
, idmod
, state
);
1693 termVocabularyState
.addTerm(modif
);
1694 //termVocabularyStates.add(termVocabularyState);
1695 getVocabularyService().save(termVocabularyState
);//XIM
1696 modifiers
.put(idmod
, modif
);
1698 feature
.addRecommendedModifierEnumeration(termVocabularyState
);
1703 catch (Exception e
) {
1704 logger
.warn("Import of DescriptiveConcept " + j
+ " failed: " + e
.getMessage());
1706 if ((++j
% modCount
) == 0){ logger
.info("DescriptiveConcepts handled: " + j
);}
1712 // imports the <CharacterTrees> block
1713 protected void importCharacterTrees(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1715 logger
.info("start CharacterTrees ...");
1716 Element elCharacterTrees
= elDataset
.getChild("CharacterTrees",sddNamespace
);
1718 if (elCharacterTrees
!= null) {
1719 List
<Element
> listCharacterTrees
= elCharacterTrees
.getChildren("CharacterTree", sddNamespace
);
1721 for (Element elCharacterTree
: listCharacterTrees
){
1723 Element elRepresentation
= elCharacterTree
.getChild("Representation",sddNamespace
);
1724 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1725 //Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ?
1727 FeatureTree featureTree
= FeatureTree
.NewInstance();
1728 importRepresentation(elCharacterTree
, sddNamespace
, featureTree
, "", cdmState
);
1729 FeatureNode root
= featureTree
.getRoot();
1730 List
<Element
> listeOfNodes
= elCharacterTree
.getChildren("Nodes", sddNamespace
);
1732 //Nodes of CharacterTrees in SDD always refer to DescriptiveConcepts
1733 for (Element elNodes
: listeOfNodes
) {
1734 handleCharacterNodes(sddNamespace
, root
, elNodes
);
1736 featureTrees
.add(featureTree
);
1737 if (workingSet
.getDescriptiveSystem() != null){
1738 //TODO how to handle multiple
1739 logger
.warn("Multiple feature trees not yet supported");
1741 workingSet
.setDescriptiveSystem(featureTree
);
1745 catch (Exception e
) {
1746 logger
.warn("Import of Character tree " + j
+ " failed.");
1747 cdmState
.setUnsuccessfull();
1749 if ((++j
% modCount
) == 0){ logger
.info("CharacterTrees handled: " + j
);}
1757 * @param sddNamespace
1761 private void handleCharacterNodes(Namespace sddNamespace
, FeatureNode root
, Element elNodes
) {
1762 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1763 if (listNodes
!= null) {
1764 for (Element elNode
: listNodes
){
1765 String idN
= elNode
.getAttributeValue("id");
1766 FeatureNode fn
= null;
1769 // DescriptiveConcepts are used as nodes in CharacterTrees
1770 Element elDescriptiveConcept
= elNode
.getChild("DescriptiveConcept", sddNamespace
);
1771 if (elDescriptiveConcept
!= null){
1772 String refDC
= elDescriptiveConcept
.getAttributeValue("ref");
1773 dc
= features
.get(refDC
);
1774 fn
= FeatureNode
.NewInstance(dc
);
1777 fn
= FeatureNode
.NewInstance();
1779 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1780 // in SDD links between Nodes are referenced by the <Parent> tag
1781 if (elParent
!=null){
1782 String refP
= elParent
.getAttributeValue("ref");
1784 FeatureNode parent
= featureNodes
.get(refP
);
1786 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1789 parent
.addChild(fn
);
1794 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1797 featureNodes
.put(idN
, fn
);
1801 // Leaves of CharacterTrees in SDD are always CharNodes (referring to Characters)
1802 List
<Element
> listCharNodes
= elNodes
.getChildren("CharNode", sddNamespace
);
1803 if (listCharNodes
!= null) {
1804 for (Element elCharNode
: listCharNodes
){
1805 Element elParent
= elCharNode
.getChild("Parent", sddNamespace
);
1806 Element elCharacter
= elCharNode
.getChild("Character", sddNamespace
);
1807 Element elDependencyRules
= elCharNode
.getChild("DependencyRules", sddNamespace
);
1808 FeatureNode fn
= FeatureNode
.NewInstance();
1810 if (elDependencyRules
!=null){
1811 Element elInapplicableIf
= elCharNode
.getChild("InapplicableIf", sddNamespace
);
1812 if (elInapplicableIf
!=null){
1813 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1814 for (Element stateElement
: listStates
) {
1815 String refState
= stateElement
.getAttributeValue("ref");
1816 if ((refState
!=null)&&(!refState
.equals(""))) {
1817 State state
= states
.get(refState
);
1818 fn
.addInapplicableState(state
);
1822 Element elOnlyapplicableIf
= elCharNode
.getChild("OnlyApplicableIf", sddNamespace
);
1823 if (elOnlyapplicableIf
!=null){
1824 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1825 for (Element stateElement
: listStates
) {
1826 String refState
= stateElement
.getAttributeValue("ref");
1827 if ((refState
!=null)&&(!refState
.equals(""))) {
1828 State state
= states
.get(refState
);
1829 fn
.addApplicableState(state
);
1835 if (elParent
!=null){
1836 String refP
= elParent
.getAttributeValue("ref");
1837 if ((refP
!=null)&&(!refP
.equals(""))) {
1838 FeatureNode parent
= featureNodes
.get(refP
);
1840 parent
= root
; // if no parent found or the reference is broken, add the node to the root of the tree
1842 parent
.addChild(fn
);
1845 String refC
= elCharacter
.getAttributeValue("ref");
1846 if ((refC
!=null)&&(!refC
.equals(""))){
1847 Feature character
= features
.get(refC
);
1848 fn
.setFeature(character
);
1849 featureNodes
.put(refC
, fn
);
1855 // imports the <TaxonHierarchies> block
1856 protected void importTaxonHierarchies(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1858 logger
.info("start TaxonHierarchies ...");
1859 Element elTaxonHierarchies
= elDataset
.getChild("TaxonHierarchies",sddNamespace
);
1861 if (elTaxonHierarchies
!= null) {
1862 List
<Element
> listTaxonHierarchies
= elTaxonHierarchies
.getChildren("TaxonHierarchy", sddNamespace
);
1864 for (Element elTaxonHierarchy
: listTaxonHierarchies
){
1866 Element elRepresentation
= elTaxonHierarchy
.getChild("Representation",sddNamespace
);
1867 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1868 Classification classification
= Classification
.NewInstance(label
);
1869 importRepresentation(elTaxonHierarchy
, sddNamespace
, classification
, "", cdmState
);
1871 Element elNodes
= elTaxonHierarchy
.getChild("Nodes", sddNamespace
); // There can be only one <Nodes> block for TaxonHierarchies
1872 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1874 for (Element elNode
: listNodes
){
1875 String idN
= elNode
.getAttributeValue("id");
1876 TaxonNameBase
<?
,?
> tnb
= null;
1877 if (!idN
.equals("")) {
1878 Element elTaxonName
= elNode
.getChild("TaxonName", sddNamespace
);
1879 String refTN
= elTaxonName
.getAttributeValue("ref");
1880 tnb
= taxonNameBases
.get(refTN
);
1881 Taxon taxon
= (Taxon
) tnb
.getTaxa().iterator().next() ;
1882 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1883 if (elParent
!=null){
1884 String refP
= elParent
.getAttributeValue("ref");
1885 if (!refP
.equals("")) {
1886 TaxonNode parent
= taxonNodes
.get(refP
);
1887 TaxonNode child
= parent
.addChildTaxon(taxon
, sec
, null);
1888 child
.setSynonymToBeUsed( Synonym
.NewInstance(tnb
, sec
)); //TODO is this required??
1889 taxonNodes
.put(idN
,child
);
1893 TaxonNode tn
= classification
.addChildTaxon(taxon
, sec
, null); // if no parent found or the reference is broken, add the node to the root of the tree
1894 tn
.setSynonymToBeUsed( Synonym
.NewInstance(tnb
, sec
)); //TODO is this required??
1895 taxonNodes
.put(idN
,tn
);
1900 classifications
.add(classification
);
1903 catch (Exception e
) {
1905 logger
.warn("Import of Taxon Hierarchy " + j
+ " failed.");
1906 cdmState
.setUnsuccessfull();
1909 if ((++j
% modCount
) == 0){ logger
.info("TaxonHierarchies handled: " + j
);}
1917 // imports the <GeographicAreas> block
1918 protected void importGeographicAreas(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
1919 Element elGeographicAreas
= elDataset
.getChild("GeographicAreas",sddNamespace
);
1920 if (elGeographicAreas
!= null) {
1921 List
<Element
> listGeographicAreas
= elGeographicAreas
.getChildren("GeographicArea", sddNamespace
);
1924 for (Element elGeographicArea
: listGeographicAreas
){
1926 String id
= elGeographicArea
.getAttributeValue("id");
1927 NamedArea na
= new NamedArea();
1928 importRepresentation(elGeographicArea
, sddNamespace
, na
, id
, cdmState
);
1929 namedAreas
.put(id
,na
);
1931 if ((++j
% modCount
) == 0){ logger
.info("GeographicAreas handled: " + j
);}