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
.DefinedTermBase
;
49 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
50 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
51 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
52 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
53 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
54 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
55 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceType
;
56 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
57 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
58 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
59 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
60 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
61 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
62 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
63 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
64 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
65 import eu
.etaxonomy
.cdm
.model
.description
.Modifier
;
66 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
67 import eu
.etaxonomy
.cdm
.model
.description
.State
;
68 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
69 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
70 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
71 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
72 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
73 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
74 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
75 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
76 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
77 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
78 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
79 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentationPart
;
80 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
81 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
82 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
83 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
84 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
85 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
86 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
87 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
88 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
89 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
90 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
97 @Component("sddImport")
98 public class SDDImport
extends XmlImportBase
<SDDImportConfigurator
, SDDImportState
> implements ICdmImport
<SDDImportConfigurator
, SDDImportState
> {
99 private static final Logger logger
= Logger
.getLogger(SDDImport
.class);
101 private static int modCount
= 1000;
103 private UUID uuidAnnotationTypeLocation
= UUID
.fromString("a3737e07-72e3-46d2-986d-fa4cf5de0b63");
106 private Map
<String
,Person
> authors
= new HashMap
<String
,Person
>();
107 private Map
<String
,String
> citations
= new HashMap
<String
,String
>();
108 private Map
<String
,String
> defaultUnitPrefixes
= new HashMap
<String
,String
>();
109 private Map
<String
,Person
> editors
= new HashMap
<String
,Person
>();
110 private Map
<String
,FeatureNode
> featureNodes
= new HashMap
<String
,FeatureNode
>();
111 private Map
<String
,Feature
> features
= new HashMap
<String
,Feature
>();
112 private Map
<String
,String
> locations
= new HashMap
<String
,String
>();
113 private Map
<String
,List
<CdmBase
>> mediaObject_ListCdmBase
= new HashMap
<String
,List
<CdmBase
>>();
114 private Map
<String
,String
> mediaObject_Role
= new HashMap
<String
,String
>();
115 private Map
<String
,Reference
<?
>> publications
= new HashMap
<String
,Reference
<?
>>();
116 private Map
<String
,State
> states
= new HashMap
<String
,State
>();
117 private Map
<String
,TaxonDescription
> taxonDescriptions
= new HashMap
<String
,TaxonDescription
>();
118 private Map
<String
,NonViralName
<?
>> taxonNameBases
= new HashMap
<String
,NonViralName
<?
>>();
119 private Map
<String
,MeasurementUnit
> units
= new HashMap
<String
,MeasurementUnit
>();
120 private Map
<String
,TaxonNode
> taxonNodes
= new HashMap
<String
,TaxonNode
>();
121 private Map
<String
,NamedArea
> namedAreas
= new HashMap
<String
,NamedArea
>();
122 private Map
<String
,Specimen
> specimens
= new HashMap
<String
,Specimen
>();
123 private Map
<String
,Modifier
> modifiers
= new HashMap
<String
,Modifier
>();
125 private Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
126 private Set
<TermVocabulary
<?
>> vocabularies
= new HashSet
<TermVocabulary
<?
>>();
128 private Set
<Feature
> descriptiveConcepts
= new HashSet
<Feature
>();
129 private Set
<AnnotationType
> annotationTypes
= new HashSet
<AnnotationType
>();
130 // private Set<Feature> featureSet = new HashSet<Feature>();
131 private Set
<Reference
<?
>> sources
= new HashSet
<Reference
<?
>>();
132 private Reference
<?
> sec
= ReferenceFactory
.newDatabase();
133 private Reference
<?
> sourceReference
= null;
135 private Language datasetLanguage
= null;
136 private WorkingSet workingSet
= null;
138 private Namespace xmlNamespace
= Namespace
.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
140 private String generatorName
= "";
141 private String generatorVersion
= "";
144 private Set
<StatisticalMeasure
> statisticalMeasures
= new HashSet
<StatisticalMeasure
>();
145 private Set
<VersionableEntity
> featureData
= new HashSet
<VersionableEntity
>();
146 private Set
<FeatureTree
> featureTrees
= new HashSet
<FeatureTree
>();
147 private Set
<Classification
> classifications
= new HashSet
<Classification
>();
149 private Rights copyright
= null;
151 private int taxonNamesCount
= 0;
158 public boolean doCheck(SDDImportState state
){
159 boolean result
= true;
160 logger
.warn("No check implemented for SDD");
165 // public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){
167 public void doInvoke(SDDImportState state
){
169 TransactionStatus ts
= startTransaction();
170 SDDImportConfigurator sddConfig
= state
.getConfig();
171 IProgressMonitor progressMonitor
= sddConfig
.getProgressMonitor();
173 logger
.info("start Datasets ...");
175 // <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">
176 Element root
= sddConfig
.getSourceRoot();
177 Namespace sddNamespace
= sddConfig
.getSddNamespace();
179 logger
.info("start TechnicalMetadata ...");
180 // <TechnicalMetadata created="2006-04-20T10:00:00">
181 importTechnicalMetadata(root
, sddNamespace
, sddConfig
);
182 List
<Element
> elDatasets
= root
.getChildren("Dataset",sddNamespace
);
186 logger
.info("start Dataset ...");
187 progressMonitor
.beginTask("Importing SDD data", elDatasets
.size());
188 for (Element elDataset
: elDatasets
){
189 importDataset(elDataset
, sddNamespace
, state
);
190 // if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);}
191 // logger.info(i + " dataset(s) handled");
192 progressMonitor
.worked(1);
194 commitTransaction(ts
);
195 progressMonitor
.done();
196 logger
.info("End of transaction");
201 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
203 protected boolean isIgnore(SDDImportState state
){
208 // associates the reference of a media object in SDD with a CdmBase Object
209 protected void associateImageWithCdmBase(String refMO
, CdmBase cb
){
210 if ((refMO
!= null) && (cb
!=null)) {
211 if (! refMO
.equals("")) {
212 if (! mediaObject_ListCdmBase
.containsKey(refMO
)) {
213 List
<CdmBase
> lcb
= new ArrayList
<CdmBase
>();
215 mediaObject_ListCdmBase
.put(refMO
,lcb
);
217 List
<CdmBase
> lcb
= mediaObject_ListCdmBase
.get(refMO
);
219 mediaObject_ListCdmBase
.put(refMO
,lcb
);
225 // imports information about the Dataset
226 protected void importDatasetRepresentation(Element parent
, Namespace sddNamespace
){
227 logger
.info("start Representation ...");
229 <Label>The Genus Viola</Label>
230 <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>
236 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
237 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
);
238 String detail
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Detail",sddNamespace
);
241 Representation representation
= Representation
.NewInstance(detail
, label
, null, datasetLanguage
);
242 workingSet
.addRepresentation(representation
);
246 // sec.setTitleCache(label, true);
248 // if (detail != null) {
249 // Annotation annotation = Annotation.NewInstance(detail, datasetLanguage);
250 // annotation.setAnnotationType(AnnotationType.EDITORIAL());
251 // sec.addAnnotation(annotation);
255 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject",sddNamespace
);
257 for (Element elMediaObject
: listMediaObjects
) {
260 if (elMediaObject
!= null) {
261 ref
= elMediaObject
.getAttributeValue("ref");
262 role
= elMediaObject
.getAttributeValue("role");
265 if (!ref
.equals("")) {
266 this.associateImageWithCdmBase(ref
,sourceReference
);
267 this.associateImageWithCdmBase(ref
,sec
);
268 mediaObject_Role
.put(ref
,role
);
274 // imports the representation (label, detail, lang) of a particular SDD element
275 protected void importRepresentation(Element parent
, Namespace sddNamespace
, VersionableEntity ve
, String id
, SDDImportState state
){
276 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
278 Map
<Language
,List
<String
>> langLabDet
= new HashMap
<Language
,List
<String
>>();
280 handleRepresentationLabels(sddNamespace
, elRepresentation
, langLabDet
);
281 handleRepresentationDetails(sddNamespace
, elRepresentation
, langLabDet
);
283 if (ve
instanceof TermBase
) {
284 makeRepresentationForTerms((TermBase
)ve
, langLabDet
);
285 }else if (ve
instanceof Media
) {
286 makeRepresentationForMedia((Media
)ve
, langLabDet
);
287 }else if (ve
instanceof IdentifiableEntity
<?
>) {
288 IdentifiableEntity
<?
> ie
= (IdentifiableEntity
<?
>)ve
;
289 makeRepresentationForIdentifiableEntity(sddNamespace
, ie
, elRepresentation
, langLabDet
);
290 if (ve
instanceof IdentifiableMediaEntity
<?
>){
291 makeRepresentationForIdentifiableMediaEntity(parent
, sddNamespace
, (IdentifiableMediaEntity
<?
>)ve
);
295 makeRepresentationMediaObjects(sddNamespace
, ve
, elRepresentation
);//FIXME
301 * Handles the "Detail" children of representations. Adds the result to the langLabDet.
302 * @param sddNamespace
303 * @param elRepresentation
306 private void handleRepresentationDetails(Namespace sddNamespace
,
307 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
308 List
<Element
> listDetails
= elRepresentation
.getChildren("Detail",sddNamespace
);
309 for (Element elDetail
: listDetails
){
310 Language language
= getLanguage(elDetail
);
311 String role
= elDetail
.getAttributeValue("role");
312 String detail
= elDetail
.getText();
313 List
<String
> labDet
= langLabDet
.get(language
);
316 langLabDet
.put(language
, labDet
);
321 * Handles the "Label" children of representations. Adds the result to the langLabDet.
322 * @param sddNamespace
323 * @param elRepresentation
326 private void handleRepresentationLabels(Namespace sddNamespace
,
327 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
328 // <Label xml:lang="la">Viola hederacea Labill.</Label>
329 List
<Element
> listLabels
= elRepresentation
.getChildren("Label",sddNamespace
);
330 for (Element elLabel
: listLabels
){
331 Language language
= getLanguage(elLabel
);
332 String label
= elLabel
.getText();
333 List
<String
> labDet
= new ArrayList
<String
>(3);
335 langLabDet
.put(language
, labDet
);
344 private void makeRepresentationForMedia(Media m
, Map
<Language
, List
<String
>> langLabDet
) {
345 for (Language lang
: langLabDet
.keySet()){
346 List
<String
> labDet
= langLabDet
.get(lang
);
347 if (labDet
.get(0) != null){
348 m
.putTitle(LanguageString
.NewInstance(labDet
.get(0), lang
));
350 if (labDet
.size()>1) {
351 m
.addDescription(labDet
.get(1), lang
);
357 * Handles representations for terms. Adds one representation per language in langLabDet.
362 private void makeRepresentationForTerms(TermBase tb
, Map
<Language
, List
<String
>> langLabDet
) {
363 for (Language lang
: langLabDet
.keySet()){
364 List
<String
> labDet
= langLabDet
.get(lang
);
365 if (labDet
.size()>0){
366 if (labDet
.size()>1) {
367 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(1), labDet
.get(0), labDet
.get(0), lang
));
369 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(0), labDet
.get(0), labDet
.get(0), lang
));
377 * Handles the "MediaObject" children of representations.
378 * @param sddNamespace
380 * @param elRepresentation
382 private void makeRepresentationMediaObjects(Namespace sddNamespace
, VersionableEntity ve
, Element elRepresentation
) {
383 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject", sddNamespace
);
384 for (Element elMediaObject
: listMediaObjects
) {
388 if (elMediaObject
!= null) {
389 ref
= elMediaObject
.getAttributeValue("ref");
390 role
= elMediaObject
.getAttributeValue("role");
392 if (StringUtils
.isNotBlank(ref
)) {
393 if (ve
instanceof TaxonDescription
) {
394 TaxonDescription td
= (TaxonDescription
) ve
;
395 if (td
.getSources().size() > 0) {
396 this.associateImageWithCdmBase(ref
, td
.getSources().iterator().next().getCitation());
398 Reference
<?
> descriptionSource
= ReferenceFactory
.newGeneric();
399 sources
.add(descriptionSource
);
401 td
.addSource(OriginalSourceType
.Unknown
, null, null, descriptionSource
, null);
402 this.associateImageWithCdmBase(ref
,descriptionSource
);
405 this.associateImageWithCdmBase(ref
,ve
);
412 * Handles the "Links" element
414 * @param sddNamespace
417 private void makeRepresentationForIdentifiableMediaEntity(Element parent
,
418 Namespace sddNamespace
, IdentifiableMediaEntity ime
) {
419 Element elLinks
= parent
.getChild("Links",sddNamespace
);
421 if (elLinks
!= null) {
423 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
424 List
<Element
> listLinks
= elLinks
.getChildren("Link", sddNamespace
);
425 Media link
= Media
.NewInstance();
426 MediaRepresentation mr
= MediaRepresentation
.NewInstance();
429 for (Element elLink
: listLinks
){
433 String rel
= elLink
.getAttributeValue("rel");
434 String href
= elLink
.getAttributeValue("href");
435 URI uri
= new URI(href
);
436 mr
.addRepresentationPart(MediaRepresentationPart
.NewInstance(uri
, null));
437 link
.addRepresentation(mr
);
440 } catch (Exception e
) {
442 logger
.warn("Import of Link " + k
+ " failed.");
445 if ((++k
% modCount
) == 0){ logger
.info("Links handled: " + k
);}
452 * @param sddNamespace
454 * @param elRepresentation
458 private void makeRepresentationForIdentifiableEntity(Namespace sddNamespace
, IdentifiableEntity
<?
> ie
,
459 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
460 List
<String
> labDet
= null;
462 if (ie
instanceof TaxonNameBase
) {
463 if (langLabDet
.keySet().contains(getTermService().getLanguageByIso("la"))) {
464 labDet
= langLabDet
.get(getTermService().getLanguageByIso("la"));
465 } else if (langLabDet
.keySet().contains(datasetLanguage
)) {
466 labDet
= langLabDet
.get(datasetLanguage
);
467 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
469 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
470 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
473 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
476 //FIXME labDet is != null only for TaxonNameBase
477 ie
.setTitleCache(labDet
.get(0), true);
479 if (labDet
.size()>1) {
480 Annotation annotation
= null;
481 if (labDet
.get(1) != null) {
482 if (labDet
.get(2) != null) {
483 annotation
= Annotation
.NewInstance(labDet
.get(2) + " - " + labDet
.get(1), datasetLanguage
);
485 annotation
= Annotation
.NewInstance(labDet
.get(1), datasetLanguage
);
488 ie
.addAnnotation(annotation
);
497 private Language
getLanguage(Element elLanguage
) {
498 String lang
= elLanguage
.getAttributeValue("lang",xmlNamespace
);
499 Language language
= null;
500 if (StringUtils
.isNotBlank(lang
)) {
501 language
= getTermService().getLanguageByIso(lang
.substring(0, 2));
503 language
= datasetLanguage
;
509 // imports the representation (label, detail, lang) of a particular SDD element
510 protected void importTechnicalMetadata(Element root
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
511 Element elTechnicalMetadata
= root
.getChild("TechnicalMetadata", sddNamespace
);
512 String nameCreated
= elTechnicalMetadata
.getAttributeValue("created");
513 sourceReference
= sddConfig
.getSourceReference();
515 if (nameCreated
!= null) {
516 if (!nameCreated
.equals("")) {
517 int year
= Integer
.parseInt(nameCreated
.substring(0,4));
518 int monthOfYear
= Integer
.parseInt(nameCreated
.substring(5,7));
519 int dayOfMonth
= Integer
.parseInt(nameCreated
.substring(8,10));
520 int hourOfDay
= Integer
.parseInt(nameCreated
.substring(11,13));
521 int minuteOfHour
= Integer
.parseInt(nameCreated
.substring(14,16));
522 int secondOfMinute
= Integer
.parseInt(nameCreated
.substring(17,19));
523 DateTime created
= new DateTime(year
,monthOfYear
,dayOfMonth
,hourOfDay
,minuteOfHour
,secondOfMinute
,0);
524 sourceReference
.setCreated(created
);
525 sec
.setCreated(created
);
529 // <Generator name="n/a, handcrafted instance document" version="n/a"/>
530 Element elGenerator
= elTechnicalMetadata
.getChild("Generator", sddNamespace
);
531 generatorName
= elGenerator
.getAttributeValue("name");
532 generatorVersion
= elGenerator
.getAttributeValue("version");
534 sec
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
535 sourceReference
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
539 // imports the complete dataset information
540 protected void importDataset(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){ // <Dataset xml:lang="en-us">
542 workingSet
= WorkingSet
.NewInstance();
543 importDatasetLanguage(elDataset
,state
);
544 importDatasetRepresentation(elDataset
, sddNamespace
);
545 importRevisionData(elDataset
, sddNamespace
);
546 importIPRStatements(elDataset
, sddNamespace
, state
);
547 importTaxonNames(elDataset
, sddNamespace
, state
);
549 importDescriptiveConcepts(elDataset
, sddNamespace
, state
);
550 importCharacters(elDataset
, sddNamespace
, state
);
551 importCharacterTrees(elDataset
, sddNamespace
, state
);
553 MarkerType editorMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerEditor
, "editor", "Editor", "edt");
554 MarkerType geographicAreaMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerSDDGeographicArea
, "SDDGeographicArea", "SDDGeographicArea", "ga");
555 MarkerType descriptiveConceptMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerDescriptiveConcept
, "DescriptiveConcept", "Descriptive Concept", "DC");
556 markerTypes
.add(editorMarkerType
);
557 markerTypes
.add(geographicAreaMarkerType
);
558 markerTypes
.add(descriptiveConceptMarkerType
);
560 //saving of all imported data into the CDM db
566 saveAreas(geographicAreaMarkerType
);
568 saveStatisticalMeasure();
569 saveAnnotationType();
571 importCodedDescriptions(elDataset
, sddNamespace
, state
);
572 importAgents(elDataset
, sddNamespace
, state
);
573 importPublications(elDataset
, sddNamespace
, state
);
574 importMediaObjects(elDataset
, sddNamespace
, state
);
575 importTaxonHierarchies(elDataset
, sddNamespace
, state
);
576 importGeographicAreas(elDataset
, sddNamespace
, state
);
577 importSpecimens(elDataset
,sddNamespace
, state
);
580 if ((authors
!= null)||(editors
!= null)) {
581 Team team
= Team
.NewInstance();
582 if (authors
!= null) {
583 for (Person author
: authors
.values()){
584 team
.addTeamMember(author
);
587 if (editors
!= null) {
588 Marker marker
= Marker
.NewInstance();
589 marker
.setMarkerType(editorMarkerType
);
590 for (Person editor
: editors
.values()){
591 Person edit
= editor
;
592 edit
.addMarker(marker
);
593 team
.addTeamMember(edit
);
596 sec
.setAuthorTeam(team
);
597 sourceReference
.setAuthorTeam(team
);
600 if (copyright
!= null) {
601 sourceReference
.addRights(copyright
);
602 sec
.addRights(copyright
);
605 // Returns a CdmApplicationController created by the values of this configuration.
606 IDescriptionService descriptionService
= getDescriptionService();
608 for (TaxonDescription taxonDescription
: taxonDescriptions
.values()){
609 // Persists a Description
610 descriptionService
.save(taxonDescription
);
613 for (String ref
: taxonDescriptions
.keySet()){
614 TaxonDescription td
= taxonDescriptions
.get(ref
);
615 if (citations
.containsKey(ref
)) {
616 Reference
<?
> publication
= publications
.get(citations
.get(ref
));
617 if (locations
.containsKey(ref
)) {
618 Annotation location
= Annotation
.NewInstance(locations
.get(ref
), datasetLanguage
);
619 //TODO move to a generic place (implemented in hurry therefore dirty)
620 AnnotationType annotationType
= getAnnotationType(state
, uuidAnnotationTypeLocation
, "location", "location", "location", null);
621 // annotationTypes.add(annotationType); TODO necessary??
622 location
.setAnnotationType(annotationType
);
623 (publication
).addAnnotation(location
);
625 td
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, null, null,publication
, null);
628 logger
.info("end makeTaxonDescriptions ...");
630 if (descriptiveConcepts
!= null) {
631 for (Feature feature
: descriptiveConcepts
) {
632 Marker marker
= Marker
.NewInstance();
633 marker
.setMarkerType(descriptiveConceptMarkerType
);
634 feature
.addMarker(marker
);
639 for (Reference
<?
> publication
: publications
.values()){
640 getReferenceService().save(publication
);
643 for (Reference
<?
> source
: sources
){
644 getReferenceService().save(source
);
647 for (FeatureTree featureTree
: featureTrees
) {
648 getFeatureTreeService().save(featureTree
);
650 getWorkingSetService().save(workingSet
);
651 for (Classification classification
: classifications
) {
652 getClassificationService().save(classification
);
654 for (Specimen specimen
: specimens
.values()) {
655 getOccurrenceService().save(specimen
);
657 logger
.info("end of persistence ...");
665 private void saveVocabularies() {
666 for (TermVocabulary
<?
> vocabulary
: vocabularies
){
667 getVocabularyService().save(vocabulary
);
672 private void saveAnnotationType() {
673 for (AnnotationType annotationType
: annotationTypes
){
674 getTermService().saveOrUpdate(annotationType
);
678 private void saveStatisticalMeasure() {
679 for (StatisticalMeasure sm
: statisticalMeasures
){
680 getTermService().save(sm
);
684 private void saveUnits() {
686 for (MeasurementUnit unit
: units
.values()){
688 getTermService().save(unit
);
694 private void saveAreas(MarkerType geographicAreaMarkerType
) {
695 for (NamedArea area
: namedAreas
.values() ){
696 Marker marker
= Marker
.NewInstance();
697 marker
.setMarkerType(geographicAreaMarkerType
);
698 area
.addMarker(marker
);
699 getTermService().save(area
);
703 private void saveStates() {
704 for (State state
: states
.values() ){
705 getTermService().save(state
);
709 private void saveMarkerType() {
710 for (MarkerType markerType
: markerTypes
){
711 getTermService().save(markerType
);
715 private void saveModifiers() {
716 for (Modifier modifier
: modifiers
.values() ){
717 getTermService().save(modifier
);
721 private void saveFeatures() {
722 for (Feature feature
: features
.values() ){
723 getTermService().save(feature
);
727 // imports the default language of the dataset
728 protected void importDatasetLanguage(Element elDataset
, SDDImportState state
){
729 String nameLang
= elDataset
.getAttributeValue("lang",xmlNamespace
);
731 if (StringUtils
.isNotBlank(nameLang
)) {
732 String iso
= nameLang
.substring(0, 2);
733 datasetLanguage
= getTermService().getLanguageByIso(iso
);
735 datasetLanguage
= Language
.DEFAULT();
737 if (datasetLanguage
== null) {
738 datasetLanguage
= Language
.DEFAULT();
742 // imports the specimens
743 protected void importSpecimens(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
744 logger
.info("start Specimens ...");
748 <Label>TJM45337</Label>
753 Element elSpecimens
= elDataset
.getChild("Specimens",sddNamespace
);
754 if (elSpecimens
!= null){
755 List
<Element
> listSpecimens
= elSpecimens
.getChildren("Specimen", sddNamespace
);
756 for (Element elSpecimen
: listSpecimens
) {
757 String id
= elSpecimen
.getAttributeValue("id");
758 Specimen specimen
= null;
759 if (!id
.equals("")) {
760 specimen
= Specimen
.NewInstance();
761 specimens
.put(id
,specimen
);
762 importRepresentation(elSpecimen
, sddNamespace
, specimen
, id
, cdmState
);
769 // imports the revision data associated with the Dataset (authors, modifications)
770 protected void importRevisionData(Element elDataset
, Namespace sddNamespace
){
772 logger
.info("start RevisionData ...");
773 Element elRevisionData
= elDataset
.getChild("RevisionData",sddNamespace
);
774 if (elRevisionData
!= null){
776 Element elCreators
= elRevisionData
.getChild("Creators",sddNamespace
);
778 // <Agent role="aut" ref="a1"/>
779 List
<Element
> listAgents
= elCreators
.getChildren("Agent", sddNamespace
);
783 for (Element elAgent
: listAgents
){
785 String role
= elAgent
.getAttributeValue("role");
786 String ref
= elAgent
.getAttributeValue("ref");
787 if (role
.equals("aut")) {
788 if(!ref
.equals("")) {
789 authors
.put(ref
, null);
792 if (role
.equals("edt")) {
793 if(!ref
.equals("")) {
794 editors
.put(ref
, null);
797 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
801 // <DateModified>2006-04-08T00:00:00</DateModified>
802 String stringDateModified
= (String
)ImportHelper
.getXmlInputValue(elRevisionData
, "DateModified",sddNamespace
);
804 if (stringDateModified
!= null) {
805 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
808 d
= sdf
.parse(stringDateModified
);
809 } catch(Exception e
) {
810 System
.err
.println("Exception :");
814 DateTime updated
= null;
816 updated
= new DateTime(d
);
817 sourceReference
.setUpdated(updated
);
818 sec
.setUpdated(updated
);
824 // imports ipr statements associated with a dataset
825 protected void importIPRStatements(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
827 logger
.info("start IPRStatements ...");
828 Element elIPRStatements
= elDataset
.getChild("IPRStatements",sddNamespace
);
829 // <IPRStatement role="Copyright">
830 if (elIPRStatements
!= null) {
831 List
<Element
> listIPRStatements
= elIPRStatements
.getChildren("IPRStatement", sddNamespace
);
833 //for each IPRStatement
835 for (Element elIPRStatement
: listIPRStatements
){
837 String role
= elIPRStatement
.getAttributeValue("role");
838 // <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
839 Element elLabel
= elIPRStatement
.getChild("Label",sddNamespace
);
841 if (elLabel
!= null) {
842 lang
= elLabel
.getAttributeValue("lang",xmlNamespace
);
844 String label
= (String
)ImportHelper
.getXmlInputValue(elIPRStatement
, "Label",sddNamespace
);
846 if (role
.equals("Copyright")) {
847 Language iprLanguage
= null;
849 if (!lang
.equals("")) {
850 iprLanguage
= getTermService().getLanguageByIso(lang
.substring(0, 2));
852 iprLanguage
= datasetLanguage
;
855 if (iprLanguage
== null) {
856 iprLanguage
= datasetLanguage
;
858 copyright
= Rights
.NewInstance(label
, iprLanguage
);
861 if (copyright
!= null) {
862 sourceReference
.addRights(copyright
);
863 sec
.addRights(copyright
);
866 if ((++j
% modCount
) == 0){ logger
.info("IPRStatements handled: " + j
);}
872 // imports the taxon names
873 protected void importTaxonNames(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
875 logger
.info("start TaxonNames ...");
876 Element elTaxonNames
= elDataset
.getChild("TaxonNames",sddNamespace
);
877 // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
878 if (elTaxonNames
!= null) {
879 List
<Element
> listTaxonNames
= elTaxonNames
.getChildren("TaxonName", sddNamespace
);
882 for (Element elTaxonName
: listTaxonNames
){
884 String id
= elTaxonName
.getAttributeValue("id");
885 String uri
= elTaxonName
.getAttributeValue("uri");
887 NonViralName
<?
> tnb
= null;
888 if (!id
.equals("")) {
889 tnb
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
890 IdentifiableSource source
= null;
892 if (! isNotBlank(uri
)) {
894 source
= IdentifiableSource
.NewInstance(OriginalSourceType
.Unknown
, id
, "TaxonName", ReferenceFactory
.newGeneric(), uri
);
897 source
= IdentifiableSource
.NewDataImportInstance(id
, "TaxonName");
899 tnb
.addSource(source
);
900 taxonNameBases
.put(id
,tnb
);
904 // <Label xml:lang="la">Viola hederacea Labill.</Label>
905 importRepresentation(elTaxonName
, sddNamespace
, tnb
, id
, state
);
907 if ((++j
% modCount
) == 0){ logger
.info("TaxonNames handled: " + j
);}
913 // imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features
914 protected void importCharacters(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
916 logger
.info("start Characters ...");
917 Element elCharacters
= elDataset
.getChild("Characters", sddNamespace
);
919 // <CategoricalCharacter id="c1">
920 if (elCharacters
!= null) {
921 handleCategoricalData(sddNamespace
, cdmState
, elCharacters
);
922 handleQuantitativeData(sddNamespace
, cdmState
, elCharacters
);
923 handleTextCharacters(sddNamespace
, cdmState
, elCharacters
);
926 /*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){
927 featureSet.add(f.next()); //XIM Why this line ?
935 * @param sddNamespace
937 * @param elCharacters
940 private void handleCategoricalData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
941 List
<Element
> elCategoricalCharacters
= elCharacters
.getChildren("CategoricalCharacter", sddNamespace
);
943 for (Element elCategoricalCharacter
: elCategoricalCharacters
){
946 String idCC
= elCategoricalCharacter
.getAttributeValue("id");
947 Feature categoricalCharacter
= Feature
.NewInstance();
948 categoricalCharacter
.setKindOf(Feature
.DESCRIPTION());
949 importRepresentation(elCategoricalCharacter
, sddNamespace
, categoricalCharacter
, idCC
, cdmState
);
950 categoricalCharacter
.setSupportsCategoricalData(true);
953 Element elStates
= elCategoricalCharacter
.getChild("States",sddNamespace
);
955 // <StateDefinition id="s1">
956 List
<Element
> elStateDefinitions
= elStates
.getChildren("StateDefinition",sddNamespace
);
957 TermVocabulary
<State
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
959 vocabularies
.add(termVocabularyState
);
962 //for each StateDefinition
963 for (Element elStateDefinition
: elStateDefinitions
){
965 if ((++k
% modCount
) == 0){ logger
.info("StateDefinitions handled: " + (k
-1));}
967 String idS
= elStateDefinition
.getAttributeValue("id");
968 State state
= states
.get(idS
);
970 state
= State
.NewInstance();
972 logger
.debug("State duplicate found");
974 importRepresentation(elStateDefinition
, sddNamespace
, state
, idS
, cdmState
);
976 termVocabularyState
.addTerm(state
);
977 states
.put(idS
,state
);
979 categoricalCharacter
.addSupportedCategoricalEnumeration(termVocabularyState
);
980 features
.put(idCC
, categoricalCharacter
);
982 } catch (Exception e
) {
983 logger
.warn("Import of CategoricalCharacter " + j
+ " failed.");
984 cdmState
.setUnsuccessfull();
987 if ((++j
% modCount
) == 0){ logger
.info("CategoricalCharacters handled: " + j
);}
994 * @param sddNamespace
996 * @param elCharacters
998 private void handleQuantitativeData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1000 // <QuantitativeCharacter id="c2">
1001 List
<Element
> elQuantitativeCharacters
= elCharacters
.getChildren("QuantitativeCharacter", sddNamespace
);
1003 //for each QuantitativeCharacter
1004 for (Element elQuantitativeCharacter
: elQuantitativeCharacters
){
1008 String idQC
= elQuantitativeCharacter
.getAttributeValue("id");
1011 // <Label>Leaf length</Label>
1012 // </Representation>
1013 Feature quantitativeCharacter
= Feature
.NewInstance();
1014 quantitativeCharacter
.setKindOf(Feature
.DESCRIPTION());
1015 importRepresentation(elQuantitativeCharacter
, sddNamespace
, quantitativeCharacter
, idQC
, cdmState
);
1017 quantitativeCharacter
.setSupportsQuantitativeData(true);
1019 // <MeasurementUnit>
1020 // <Label role="Abbrev">m</Label>
1021 // </MeasurementUnit>
1022 Element elMeasurementUnit
= elQuantitativeCharacter
.getChild("MeasurementUnit",sddNamespace
);
1025 if (elMeasurementUnit
!= null) {
1026 Element elLabel
= elMeasurementUnit
.getChild("Label",sddNamespace
);
1027 role
= elLabel
.getAttributeValue("role");
1028 label
= (String
)ImportHelper
.getXmlInputValue(elMeasurementUnit
, "Label",sddNamespace
);
1031 MeasurementUnit unit
= null;
1032 if (!label
.equals("")){
1034 if (role
.equals("Abbrev")){
1035 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1038 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1043 units
.put(idQC
, unit
);
1047 // <MeasurementUnitPrefix>milli</MeasurementUnitPrefix>
1049 Element elDefault
= elQuantitativeCharacter
.getChild("Default",sddNamespace
);
1050 if (elDefault
!= null) {
1051 String measurementUnitPrefix
= (String
)ImportHelper
.getXmlInputValue(elDefault
, "MeasurementUnitPrefix",sddNamespace
);
1052 if (! measurementUnitPrefix
.equals("")){
1053 defaultUnitPrefixes
.put(idQC
, measurementUnitPrefix
);
1057 features
.put(idQC
, quantitativeCharacter
);
1059 } catch (Exception e
) {
1061 logger
.warn("Import of QuantitativeCharacter " + j
+ " failed.");
1062 cdmState
.setUnsuccessfull();
1065 if ((++j
% modCount
) == 0){ logger
.info("QuantitativeCharacters handled: " + j
);}
1071 private void handleTextCharacters(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1073 // <TextCharacter id="c3">
1074 List
<Element
> elTextCharacters
= elCharacters
.getChildren("TextCharacter", sddNamespace
);
1076 //for each TextCharacter
1077 for (Element elTextCharacter
: elTextCharacters
){
1081 String idTC
= elTextCharacter
.getAttributeValue("id");
1084 // <Label xml:lang="en">Leaf features not covered by other characters</Label>
1085 // </Representation>
1086 Feature textCharacter
= Feature
.NewInstance();
1087 textCharacter
.setKindOf(Feature
.DESCRIPTION());
1088 importRepresentation(elTextCharacter
, sddNamespace
, textCharacter
, idTC
, cdmState
);
1090 textCharacter
.setSupportsTextData(true);
1092 features
.put(idTC
, textCharacter
);
1094 } catch (Exception e
) {
1096 logger
.warn("Import of TextCharacter " + j
+ " failed.");
1097 cdmState
.setUnsuccessfull();
1100 if ((++j
% modCount
) == 0){ logger
.info("TextCharacters handled: " + j
);}
1106 // imports the descriptions of taxa
1107 protected void importCodedDescriptions(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1109 // <CodedDescriptions>
1110 logger
.info("start CodedDescriptions ...");
1111 Element elCodedDescriptions
= elDataset
.getChild("CodedDescriptions",sddNamespace
);
1113 // <CodedDescription id="D101">
1114 if (elCodedDescriptions
!= null) {
1115 List
<Element
> listCodedDescriptions
= elCodedDescriptions
.getChildren("CodedDescription", sddNamespace
);
1117 //for each CodedDescription
1118 for (Element elCodedDescription
: listCodedDescriptions
){
1119 handleCodedDescription(sddNamespace
, cdmState
, elCodedDescription
, j
);
1120 if ((++j
% modCount
) == 0){ logger
.info("CodedDescriptions handled: " + j
);}
1127 * @param sddNamespace
1130 * @param elCodedDescription
1133 private void handleCodedDescription(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
, int j
) {
1136 String idCD
= elCodedDescription
.getAttributeValue("id");
1139 // <Label><i>Viola hederacea</i> Labill. as revised by R. Morris April 8, 2006</Label>
1140 // </Representation>
1141 TaxonDescription taxonDescription
= TaxonDescription
.NewInstance();
1142 if (!generatorName
.isEmpty()){
1143 Annotation annotation
= Annotation
.NewInstance(generatorName
, AnnotationType
.TECHNICAL(),Language
.DEFAULT());
1144 taxonDescription
.addAnnotation(annotation
);
1146 importRepresentation(elCodedDescription
, sddNamespace
, taxonDescription
, idCD
, cdmState
);
1149 // <TaxonName ref="t1"/>
1150 // <Citation ref="p1" location="p. 30"/>
1152 Element elScope
= elCodedDescription
.getChild("Scope", sddNamespace
);
1154 if (elScope
!= null) {
1155 taxon
= handleCDScope(sddNamespace
, cdmState
, idCD
, elScope
);
1156 } else {//in case no taxon is linked to the description, a new one is created
1157 taxon
= handleCDNoScope(sddNamespace
, cdmState
, elCodedDescription
);
1161 Element elSummaryData
= elCodedDescription
.getChild("SummaryData",sddNamespace
);
1162 if (elSummaryData
!= null) {
1163 handleSummaryCategoricalData(sddNamespace
, taxonDescription
, elSummaryData
);
1164 handleSummaryQuantitativeData(sddNamespace
, taxonDescription
, elSummaryData
);
1165 handleSummaryTextData(sddNamespace
, taxonDescription
, elSummaryData
);
1168 if (taxon
!= null) {
1169 taxon
.addDescription(taxonDescription
);
1172 workingSet
.addDescription(taxonDescription
);
1174 //OLD taxonDescription.setDescriptiveSystem(featureSet);
1176 taxonDescriptions
.put(idCD
, taxonDescription
);//FIXME
1178 } catch (Exception e
) {
1180 logger
.warn("Import of CodedDescription " + j
+ " failed.", e
);
1181 cdmState
.setUnsuccessfull();
1187 * @param sddNamespace
1189 * @param elCodedDescription
1193 private Taxon
handleCDNoScope(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
) {
1195 NonViralName
<?
> nonViralName
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
1196 String id
= new String("" + taxonNamesCount
);
1197 IdentifiableSource source
= IdentifiableSource
.NewDataImportInstance(id
, "TaxonName");
1198 importRepresentation(elCodedDescription
, sddNamespace
, nonViralName
, id
, cdmState
);
1200 if(cdmState
.getConfig().isDoMatchTaxa()){
1201 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1205 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1206 // taxonNameBases.put(id ,tnb);
1207 // taxonNamesCount++;
1208 logger
.info("using existing Taxon " + taxon
.getTitleCache());
1210 nonViralName
.addSource(source
);
1211 taxonNameBases
.put(id
,nonViralName
);
1213 logger
.info("creating new Taxon from TaxonName " + nonViralName
.getTitleCache());
1214 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1220 * @param sddNamespace
1227 private Taxon
handleCDScope(Namespace sddNamespace
, SDDImportState cdmState
,
1228 String idCD
, Element elScope
) {
1230 Element elTaxonName
= elScope
.getChild("TaxonName", sddNamespace
);
1231 String ref
= elTaxonName
.getAttributeValue("ref");
1232 NonViralName
<?
> nonViralName
= taxonNameBases
.get(ref
);
1234 if(cdmState
.getConfig().isDoMatchTaxa()){
1235 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1239 logger
.info("using existing Taxon" + taxon
.getTitleCache());
1240 if(!nonViralName
.getUuid().equals(taxon
.getName().getUuid())){
1241 logger
.warn("TaxonNameBase entity of existing taxon does not match Name in list -> replacing Name in list");
1242 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1245 logger
.info("creating new Taxon from TaxonName '" + nonViralName
.getTitleCache()+"'");
1246 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1250 Element elCitation
= elScope
.getChild("Citation",sddNamespace
);
1251 if (elCitation
!= null) {
1252 String refCitation
= elCitation
.getAttributeValue("ref");
1253 if (! refCitation
.equals("")){
1254 citations
.put(idCD
, refCitation
);
1256 String location
= elCitation
.getAttributeValue("location");
1257 if (! location
.equals("")){
1258 locations
.put(idCD
, location
);
1265 * @param sddNamespace
1266 * @param taxonDescription
1267 * @param elSummaryData
1269 private void handleSummaryTextData(Namespace sddNamespace
,
1270 TaxonDescription taxonDescription
, Element elSummaryData
) {
1273 // <TextChar ref="c3">
1274 List
<Element
> elTextChars
= elSummaryData
.getChildren("TextChar", sddNamespace
);
1277 for (Element elTextChar
: elTextChars
){
1278 if ((++k
% modCount
) == 0){ logger
.info("TextChar handled: " + (k
-1));}
1279 ref
= elTextChar
.getAttributeValue("ref");
1280 Feature feature
= features
.get(ref
);
1281 TextData textData
= TextData
.NewInstance();
1282 textData
.setFeature(feature
);
1284 // <Content>Free form text</Content>
1285 String content
= (String
)ImportHelper
.getXmlInputValue(elTextChar
, "Content",sddNamespace
);
1286 textData
.putText(datasetLanguage
, content
);
1287 taxonDescription
.addElement(textData
);
1292 * @param sddNamespace
1293 * @param taxonDescription
1294 * @param elSummaryData
1296 private void handleSummaryQuantitativeData(Namespace sddNamespace
,
1297 TaxonDescription taxonDescription
, Element elSummaryData
) {
1300 // <Quantitative ref="c2">
1301 List
<Element
> elQuantitatives
= elSummaryData
.getChildren("Quantitative", sddNamespace
);
1303 //for each Quantitative
1304 for (Element elQuantitative
: elQuantitatives
){
1305 if ((++k
% modCount
) == 0){ logger
.warn("Quantitative handled: " + (k
-1));}
1306 ref
= elQuantitative
.getAttributeValue("ref");
1307 Feature feature
= features
.get(ref
);
1308 QuantitativeData quantitativeData
= QuantitativeData
.NewInstance();
1309 quantitativeData
.setFeature(feature
);
1311 MeasurementUnit unit
= units
.get(ref
);
1312 String prefix
= defaultUnitPrefixes
.get(ref
);
1314 String u
= unit
.getLabel();
1315 if (prefix
!= null) {
1319 quantitativeData
.setUnit(unit
);
1322 // <Measure type="Min" value="2.3"/>
1323 List
<Element
> elMeasures
= elQuantitative
.getChildren("Measure", sddNamespace
);
1327 for (Element elMeasure
: elMeasures
){
1328 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1329 String type
= elMeasure
.getAttributeValue("type");
1330 String value
= elMeasure
.getAttributeValue("value");
1331 if (value
.contains(",")) {
1332 value
= value
.replace(',', '.');
1334 Float v
= Float
.parseFloat(value
);
1335 //Float v = new Float(0);
1336 StatisticalMeasure t
= null;
1337 if (type
.equals("Min")) {
1338 t
= StatisticalMeasure
.MIN();
1339 } else if (type
.equals("Mean")) {
1340 t
= StatisticalMeasure
.AVERAGE();
1341 } else if (type
.equals("Max")) {
1342 t
= StatisticalMeasure
.MAX();
1343 } else if (type
.equals("SD")) {
1344 t
= StatisticalMeasure
.STANDARD_DEVIATION();
1345 } else if (type
.equals("N")) {
1346 t
= StatisticalMeasure
.SAMPLE_SIZE();
1347 } else if (type
.equals("UMethLower")) {
1348 t
= StatisticalMeasure
.TYPICAL_LOWER_BOUNDARY();
1349 } else if (type
.equals("UMethUpper")) {
1350 t
= StatisticalMeasure
.TYPICAL_UPPER_BOUNDARY();
1351 } else if (type
.equals("Var")) {
1352 t
= StatisticalMeasure
.VARIANCE();
1354 t
= StatisticalMeasure
.NewInstance(type
,type
,type
);
1355 statisticalMeasures
.add(t
);
1358 StatisticalMeasurementValue statisticalValue
= StatisticalMeasurementValue
.NewInstance();
1359 statisticalValue
.setValue(v
);
1360 statisticalValue
.setType(t
);
1361 quantitativeData
.addStatisticalValue(statisticalValue
);
1362 featureData
.add(statisticalValue
);
1364 taxonDescription
.addElement(quantitativeData
);
1369 * @param sddNamespace
1370 * @param taxonDescription
1371 * @param elSummaryData
1373 private void handleSummaryCategoricalData(Namespace sddNamespace
,
1374 TaxonDescription taxonDescription
, Element elSummaryData
) {
1376 // <Categorical ref="c4">
1377 List
<Element
> elCategoricals
= elSummaryData
.getChildren("Categorical", sddNamespace
);
1379 //for each Categorical
1380 for (Element elCategorical
: elCategoricals
){
1381 if ((++k
% modCount
) == 0){ logger
.warn("Categorical handled: " + (k
-1));}
1382 ref
= elCategorical
.getAttributeValue("ref");
1383 Feature feature
= features
.get(ref
);
1384 CategoricalData categoricalData
= CategoricalData
.NewInstance();
1385 categoricalData
.setFeature(feature
);
1387 // <State ref="s3"/>
1388 List
<Element
> elStates
= elCategorical
.getChildren("State", sddNamespace
);
1392 for (Element elState
: elStates
){
1393 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1394 ref
= elState
.getAttributeValue("ref");
1395 State state
= states
.get(ref
);
1396 if (state
!= null) {
1397 StateData stateData
= StateData
.NewInstance();
1398 stateData
.setState(state
);
1399 List
<Element
> elModifiers
= elState
.getChildren("Modifier", sddNamespace
);
1400 for (Element elModifier
: elModifiers
){
1401 ref
= elModifier
.getAttributeValue("ref");
1402 Modifier modifier
= modifiers
.get(ref
);
1403 if (modifier
!= null) {
1404 stateData
.addModifier(modifier
);
1407 categoricalData
.addState(stateData
);
1409 taxonDescription
.addElement(categoricalData
);
1414 // imports the persons associated with the dataset creation, modification, related publications
1415 protected void importAgents(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1417 logger
.info("start Agents ...");
1418 Element elAgents
= elDataset
.getChild("Agents",sddNamespace
);
1419 if (elAgents
!= null) {
1421 List
<Element
> listAgents
= elAgents
.getChildren("Agent", sddNamespace
);
1424 for (Element elAgent
: listAgents
){
1428 String idA
= elAgent
.getAttributeValue("id");
1431 // <Label>Kevin Thiele</Label>
1432 // <Detail role="Description">Ali Baba is also known as r.a.m.</Detail>
1433 // </Representation>
1434 Person person
= Person
.NewInstance();
1435 importRepresentation(elAgent
, sddNamespace
, person
, idA
, cdmState
);
1436 person
.addSource(IdentifiableSource
.NewDataImportInstance(idA
, "Agent"));
1439 Element elLinks = elAgent.getChild("Links",sddNamespace);
1441 if (elLinks != null) {
1443 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
1444 List<Element> listLinks = elLinks.getChildren("Link", sddNamespace);
1447 for (Element elLink : listLinks){
1451 String rel = elLink.getAttributeValue("rel");
1452 String href = elLink.getAttributeValue("href");
1454 Media link = Media.NewInstance();
1455 MediaRepresentation mr = MediaRepresentation.NewInstance();
1456 mr.addRepresentationPart(MediaRepresentationPart.NewInstance(href, null));
1457 link.addRepresentation(mr);
1458 person.addMedia(link);
1460 } catch (Exception e) {
1462 logger.warn("Import of Link " + k + " failed.");
1466 if ((++k % modCount) == 0){ logger.info("Links handled: " + k);}
1471 if (authors
.containsKey(idA
)) {
1472 authors
.put(idA
,person
);
1475 if (editors
.containsKey(idA
)) {
1476 editors
.put(idA
, person
);
1479 } catch (Exception e
) {
1481 logger
.warn("Import of Agent " + j
+ " failed.");
1482 cdmState
.setUnsuccessfull();
1485 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
1491 // imports publications related with the data set
1492 protected void importPublications(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1494 <Publication id="p112">
1496 <Label>Gee, X. & Haa, Y. (2003). How to be happy in five minutes. Instant Gratifications, Palm Beach.</Label>
1499 <Link rel="BasedOn" href="doi:10.1992/32311"/>
1500 <Link rel="Alternate" href="http://some.service.net/providing/bibliographic.data"/>
1504 logger
.info("start Publications ...");
1505 Element elPublications
= elDataset
.getChild("Publications",sddNamespace
);
1507 if (elPublications
!= null) {
1508 List
<Element
> listPublications
= elPublications
.getChildren("Publication", sddNamespace
);
1510 for (Element elPublication
: listPublications
){
1514 String idP
= elPublication
.getAttributeValue("id");
1515 Reference
<?
> publication
= ReferenceFactory
.newArticle();
1516 importRepresentation(elPublication
, sddNamespace
, publication
, idP
, cdmState
);
1518 publications
.put(idP
,publication
);
1520 } catch (Exception e
) {
1521 logger
.warn("Import of Publication " + j
+ " failed.");
1522 cdmState
.setUnsuccessfull();
1525 if ((++j
% modCount
) == 0){ logger
.info("Publications handled: " + j
);}
1531 // imports media objects such as images //FIXME check mediaobj
1532 protected void importMediaObjects(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1534 logger
.info("start MediaObjects ...");
1535 Element elMediaObjects
= elDataset
.getChild("MediaObjects",sddNamespace
);
1537 if (elMediaObjects
!= null) {
1538 // <MediaObject id="m1">
1539 List
<Element
> listMediaObjects
= elMediaObjects
.getChildren("MediaObject", sddNamespace
);
1541 for (Element elMO
: listMediaObjects
){
1546 String idMO
= elMO
.getAttributeValue("id");
1550 // <Label>Image description, e.g. to be used for alt-attribute in html.</Label>
1551 // </Representation>
1552 Media media
= Media
.NewInstance();
1553 importRepresentation(elMO
, sddNamespace
, media
, idMO
, cdmState
);
1555 // <Type>Image</Type>
1556 // <Source href="http://test.edu/test.jpg"/>
1557 String type
= (String
)ImportHelper
.getXmlInputValue(elMO
,"Type",sddNamespace
);
1559 if ((type
!= null) && (type
.equals("Image"))) {
1560 Element elSource
= elMO
.getChild("Source",sddNamespace
);
1561 String href
= elSource
.getAttributeValue("href");
1563 ImageInfo imageMetaData
= null;
1564 ImageFile image
= null;
1566 if (href
.substring(0,7).equals("http://")) {
1568 URL url
= new URL(href
);
1570 imageMetaData
= ImageInfo
.NewInstance(url
.toURI(), 0);
1571 image
= ImageFile
.NewInstance(url
.toURI(), null, imageMetaData
);
1572 } catch (MalformedURLException e
) {
1573 logger
.error("Malformed URL", e
);
1574 } catch (IOException ioe
) {
1575 logger
.warn("(IO ex: " + id
+ "): " + ioe
.getMessage());
1579 String sns
= cdmState
.getConfig().getSourceNameString();
1580 File f
= new File(sns
);
1581 File parent
= f
.getParentFile();
1582 String fi
= parent
.toString() + File
.separator
+ href
;
1583 File file
= new File(fi
);
1584 imageMetaData
= ImageInfo
.NewInstance(new URI(fi
), 0); //file
1585 image
= ImageFile
.NewInstance(file
.toURI(), null, imageMetaData
);
1587 MediaRepresentation representation
= MediaRepresentation
.NewInstance(imageMetaData
.getMimeType(), null);
1588 representation
.addRepresentationPart(image
);
1590 media
.addRepresentation(representation
);
1592 ArrayList
<CdmBase
> lcb
= (ArrayList
<CdmBase
>) mediaObject_ListCdmBase
.get(idMO
);
1594 for (int k
= 0; k
< lcb
.size(); k
++) {
1595 if (lcb
.get(k
) instanceof DefinedTermBase
) {
1596 DefinedTermBase
<?
> dtb
= (DefinedTermBase
<?
>) lcb
.get(k
);
1597 // if (lcb.get(0) instanceof DefinedTermBase) {
1598 // DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1601 dtb
.addMedia(media
);
1602 //System.out.println(dtb.getLabel());
1604 // Media me = (Media) media.clone();
1605 // dtb.addMedia(me);
1608 } else if (lcb
.get(k
) instanceof Reference
) {
1609 Reference
<?
> rb
= (Reference
<?
>) lcb
.get(k
);
1610 //} else if (lcb.get(0) instanceof Reference) {
1611 //Reference rb = (Reference) lcb.get(0);
1612 // rb.setTitleCache(label);
1616 //System.out.println(rb.getTitle());
1618 // Media me = (Media) media.clone();
1622 // else if (lcb.get(k) instanceof TaxonNameBase){
1623 // TaxonNameBase tb = (TaxonNameBase) lcb.get(k);
1624 // tb.addMedia(media);
1626 logger
.warn("Can't handle associated media for " + lcb
.get(k
).getId() + "(" + lcb
.get(k
).getClass().getSimpleName()+")" );
1632 } catch (Exception e
) {
1634 logger
.warn("Could not attach MediaObject " + j
+ "(SDD: " + id
+ ") to several objects: " + e
.getMessage());
1635 cdmState
.setUnsuccessfull();
1638 if ((++j
% modCount
) == 0){ logger
.info("MediaObjects handled: " + j
);
1645 // imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves
1646 // but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker
1647 protected void importDescriptiveConcepts(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
1648 /* <DescriptiveConcepts>
1649 <DescriptiveConcept id="dc0">
1651 <Label>Fixed set of modifiers supported in Lucid3</Label>
1654 <Modifier id="mod1">
1656 <Label>rarely</Label>
1658 <ModifierClass>Frequency</ModifierClass>
1659 <ProportionRange lowerestimate="0.0" upperestimate="0.25"/>
1662 </DescriptiveConcept>
1663 </DescriptiveConcepts>
1665 logger
.info("start DescriptiveConcepts ...");
1666 Element elDescriptiveConcepts
= elDataset
.getChild("DescriptiveConcepts",sddNamespace
);
1667 if (elDescriptiveConcepts
!= null) {
1668 List
<Element
> listDescriptiveConcepts
= elDescriptiveConcepts
.getChildren("DescriptiveConcept", sddNamespace
);
1671 for (Element elDescriptiveConcept
: listDescriptiveConcepts
){
1673 String id
= elDescriptiveConcept
.getAttributeValue("id");
1674 Feature feature
= Feature
.NewInstance();
1675 feature
.setKindOf(Feature
.DESCRIPTION());
1676 if (!id
.equals("")) {
1678 // <Label>Body</Label>
1679 importRepresentation(elDescriptiveConcept
, sddNamespace
, feature
, id
, state
);
1680 features
.put(id
, feature
);
1681 getTermService().save(feature
);//XIM
1682 descriptiveConcepts
.add(feature
);
1683 // imports the modifiers
1684 Element elModifiers
= elDescriptiveConcept
.getChild("Modifiers", sddNamespace
);
1685 if (elModifiers
!=null){
1686 List
<Element
> listModifiers
= elModifiers
.getChildren("Modifier", sddNamespace
);
1687 TermVocabulary
<Modifier
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
1688 for (Element elModifier
: listModifiers
) {
1689 Modifier modif
= Modifier
.NewInstance();
1690 String idmod
= elModifier
.getAttributeValue("id");
1691 importRepresentation(elModifier
, sddNamespace
, modif
, idmod
, state
);
1692 termVocabularyState
.addTerm(modif
);
1693 //termVocabularyStates.add(termVocabularyState);
1694 getVocabularyService().save(termVocabularyState
);//XIM
1695 modifiers
.put(idmod
, modif
);
1697 feature
.addRecommendedModifierEnumeration(termVocabularyState
);
1702 catch (Exception e
) {
1703 logger
.warn("Import of DescriptiveConcept " + j
+ " failed: " + e
.getMessage());
1705 if ((++j
% modCount
) == 0){ logger
.info("DescriptiveConcepts handled: " + j
);}
1711 // imports the <CharacterTrees> block
1712 protected void importCharacterTrees(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1714 logger
.info("start CharacterTrees ...");
1715 Element elCharacterTrees
= elDataset
.getChild("CharacterTrees",sddNamespace
);
1717 if (elCharacterTrees
!= null) {
1718 List
<Element
> listCharacterTrees
= elCharacterTrees
.getChildren("CharacterTree", sddNamespace
);
1720 for (Element elCharacterTree
: listCharacterTrees
){
1722 Element elRepresentation
= elCharacterTree
.getChild("Representation",sddNamespace
);
1723 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1724 //Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ?
1726 FeatureTree featureTree
= FeatureTree
.NewInstance();
1727 importRepresentation(elCharacterTree
, sddNamespace
, featureTree
, "", cdmState
);
1728 FeatureNode root
= featureTree
.getRoot();
1729 List
<Element
> listeOfNodes
= elCharacterTree
.getChildren("Nodes", sddNamespace
);
1731 //Nodes of CharacterTrees in SDD always refer to DescriptiveConcepts
1732 for (Element elNodes
: listeOfNodes
) {
1733 handleCharacterNodes(sddNamespace
, root
, elNodes
);
1735 featureTrees
.add(featureTree
);
1736 if (workingSet
.getDescriptiveSystem() != null){
1737 //TODO how to handle multiple
1738 logger
.warn("Multiple feature trees not yet supported");
1740 workingSet
.setDescriptiveSystem(featureTree
);
1744 catch (Exception e
) {
1745 logger
.warn("Import of Character tree " + j
+ " failed.");
1746 cdmState
.setUnsuccessfull();
1748 if ((++j
% modCount
) == 0){ logger
.info("CharacterTrees handled: " + j
);}
1756 * @param sddNamespace
1760 private void handleCharacterNodes(Namespace sddNamespace
, FeatureNode root
, Element elNodes
) {
1761 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1762 if (listNodes
!= null) {
1763 for (Element elNode
: listNodes
){
1764 String idN
= elNode
.getAttributeValue("id");
1765 FeatureNode fn
= null;
1768 // DescriptiveConcepts are used as nodes in CharacterTrees
1769 Element elDescriptiveConcept
= elNode
.getChild("DescriptiveConcept", sddNamespace
);
1770 if (elDescriptiveConcept
!= null){
1771 String refDC
= elDescriptiveConcept
.getAttributeValue("ref");
1772 dc
= features
.get(refDC
);
1773 fn
= FeatureNode
.NewInstance(dc
);
1776 fn
= FeatureNode
.NewInstance();
1778 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1779 // in SDD links between Nodes are referenced by the <Parent> tag
1780 if (elParent
!=null){
1781 String refP
= elParent
.getAttributeValue("ref");
1783 FeatureNode parent
= featureNodes
.get(refP
);
1785 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1788 parent
.addChild(fn
);
1793 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1796 featureNodes
.put(idN
, fn
);
1800 // Leaves of CharacterTrees in SDD are always CharNodes (referring to Characters)
1801 List
<Element
> listCharNodes
= elNodes
.getChildren("CharNode", sddNamespace
);
1802 if (listCharNodes
!= null) {
1803 for (Element elCharNode
: listCharNodes
){
1804 Element elParent
= elCharNode
.getChild("Parent", sddNamespace
);
1805 Element elCharacter
= elCharNode
.getChild("Character", sddNamespace
);
1806 Element elDependencyRules
= elCharNode
.getChild("DependencyRules", sddNamespace
);
1807 FeatureNode fn
= FeatureNode
.NewInstance();
1809 if (elDependencyRules
!=null){
1810 Element elInapplicableIf
= elCharNode
.getChild("InapplicableIf", sddNamespace
);
1811 if (elInapplicableIf
!=null){
1812 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1813 for (Element stateElement
: listStates
) {
1814 String refState
= stateElement
.getAttributeValue("ref");
1815 if ((refState
!=null)&&(!refState
.equals(""))) {
1816 State state
= states
.get(refState
);
1817 fn
.addInapplicableState(state
);
1821 Element elOnlyapplicableIf
= elCharNode
.getChild("OnlyApplicableIf", sddNamespace
);
1822 if (elOnlyapplicableIf
!=null){
1823 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1824 for (Element stateElement
: listStates
) {
1825 String refState
= stateElement
.getAttributeValue("ref");
1826 if ((refState
!=null)&&(!refState
.equals(""))) {
1827 State state
= states
.get(refState
);
1828 fn
.addApplicableState(state
);
1834 if (elParent
!=null){
1835 String refP
= elParent
.getAttributeValue("ref");
1836 if ((refP
!=null)&&(!refP
.equals(""))) {
1837 FeatureNode parent
= featureNodes
.get(refP
);
1839 parent
= root
; // if no parent found or the reference is broken, add the node to the root of the tree
1841 parent
.addChild(fn
);
1844 String refC
= elCharacter
.getAttributeValue("ref");
1845 if ((refC
!=null)&&(!refC
.equals(""))){
1846 Feature character
= features
.get(refC
);
1847 fn
.setFeature(character
);
1848 featureNodes
.put(refC
, fn
);
1854 // imports the <TaxonHierarchies> block
1855 protected void importTaxonHierarchies(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1857 logger
.info("start TaxonHierarchies ...");
1858 Element elTaxonHierarchies
= elDataset
.getChild("TaxonHierarchies",sddNamespace
);
1860 if (elTaxonHierarchies
!= null) {
1861 List
<Element
> listTaxonHierarchies
= elTaxonHierarchies
.getChildren("TaxonHierarchy", sddNamespace
);
1863 for (Element elTaxonHierarchy
: listTaxonHierarchies
){
1865 Element elRepresentation
= elTaxonHierarchy
.getChild("Representation",sddNamespace
);
1866 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1867 Classification classification
= Classification
.NewInstance(label
);
1868 importRepresentation(elTaxonHierarchy
, sddNamespace
, classification
, "", cdmState
);
1870 Element elNodes
= elTaxonHierarchy
.getChild("Nodes", sddNamespace
); // There can be only one <Nodes> block for TaxonHierarchies
1871 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1873 for (Element elNode
: listNodes
){
1874 String idN
= elNode
.getAttributeValue("id");
1875 TaxonNameBase
<?
,?
> tnb
= null;
1876 if (!idN
.equals("")) {
1877 Element elTaxonName
= elNode
.getChild("TaxonName", sddNamespace
);
1878 String refTN
= elTaxonName
.getAttributeValue("ref");
1879 tnb
= taxonNameBases
.get(refTN
);
1880 Taxon taxon
= (Taxon
) tnb
.getTaxa().iterator().next() ;
1881 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1882 if (elParent
!=null){
1883 String refP
= elParent
.getAttributeValue("ref");
1884 if (!refP
.equals("")) {
1885 TaxonNode parent
= taxonNodes
.get(refP
);
1886 TaxonNode child
= parent
.addChildTaxon(taxon
, sec
, "", Synonym
.NewInstance(tnb
, sec
));
1887 taxonNodes
.put(idN
,child
);
1891 TaxonNode tn
= classification
.addChildTaxon(taxon
, sec
, "", Synonym
.NewInstance(tnb
, sec
)); // if no parent found or the reference is broken, add the node to the root of the tree
1892 taxonNodes
.put(idN
,tn
);
1897 classifications
.add(classification
);
1900 catch (Exception e
) {
1902 logger
.warn("Import of Taxon Hierarchy " + j
+ " failed.");
1903 cdmState
.setUnsuccessfull();
1906 if ((++j
% modCount
) == 0){ logger
.info("TaxonHierarchies handled: " + j
);}
1914 // imports the <GeographicAreas> block
1915 protected void importGeographicAreas(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
1916 Element elGeographicAreas
= elDataset
.getChild("GeographicAreas",sddNamespace
);
1917 if (elGeographicAreas
!= null) {
1918 List
<Element
> listGeographicAreas
= elGeographicAreas
.getChildren("GeographicArea", sddNamespace
);
1921 for (Element elGeographicArea
: listGeographicAreas
){
1923 String id
= elGeographicArea
.getAttributeValue("id");
1924 NamedArea na
= new NamedArea();
1925 importRepresentation(elGeographicArea
, sddNamespace
, na
, id
, cdmState
);
1926 namedAreas
.put(id
,na
);
1928 if ((++j
% modCount
) == 0){ logger
.info("GeographicAreas handled: " + j
);}