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
.net
.MalformedURLException
;
16 import java
.text
.SimpleDateFormat
;
17 import java
.util
.ArrayList
;
18 import java
.util
.Date
;
19 import java
.util
.HashMap
;
20 import java
.util
.HashSet
;
21 import java
.util
.List
;
25 import org
.apache
.commons
.lang
.StringUtils
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.jdom
.Element
;
28 import org
.jdom
.Namespace
;
29 import org
.joda
.time
.DateTime
;
30 import org
.springframework
.stereotype
.Component
;
31 import org
.springframework
.transaction
.TransactionStatus
;
33 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
34 import eu
.etaxonomy
.cdm
.common
.IProgressMonitor
;
35 import eu
.etaxonomy
.cdm
.common
.mediaMetaData
.ImageMetaData
;
36 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
37 import eu
.etaxonomy
.cdm
.io
.common
.CdmApplicationAwareDefaultImport
;
38 import eu
.etaxonomy
.cdm
.io
.common
.CdmImportBase
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ICdmImport
;
41 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
42 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
43 import eu
.etaxonomy
.cdm
.io
.sdd
.SDDTransformer
;
44 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
45 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
46 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
47 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
48 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
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
.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
.TaxonNameBase
;
83 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
84 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
85 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
86 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
87 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
88 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
89 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
92 * This class is not used yet. It is meant for refactoring the SDD import.
99 public class SDDDataSetImport
extends CdmImportBase
<SDDImportConfigurator
, SDDImportState
> implements ICdmImport
<SDDImportConfigurator
, SDDImportState
> {
100 private static final Logger logger
= Logger
.getLogger(SDDDataSetImport
.class);
102 private static int modCount
= 1000;
104 private Map
<String
,Person
> authors
= new HashMap
<String
,Person
>();
105 private Map
<String
,String
> citations
= new HashMap
<String
,String
>();
106 private Map
<String
,String
> defaultUnitPrefixes
= new HashMap
<String
,String
>();
107 private Map
<String
,Person
> editors
= new HashMap
<String
,Person
>();
108 private Map
<String
,FeatureNode
> featureNodes
= new HashMap
<String
,FeatureNode
>();
109 private Map
<String
,Feature
> features
= new HashMap
<String
,Feature
>();
110 private Map
<String
,String
> locations
= new HashMap
<String
,String
>();
111 private Map
<String
,List
<CdmBase
>> mediaObject_ListCdmBase
= new HashMap
<String
,List
<CdmBase
>>();
112 private Map
<String
,String
> mediaObject_Role
= new HashMap
<String
,String
>();
113 private Map
<String
,Reference
> publications
= new HashMap
<String
,Reference
>();
114 private Map
<String
,State
> states
= new HashMap
<String
,State
>();
115 private Map
<String
,TaxonDescription
> taxonDescriptions
= new HashMap
<String
,TaxonDescription
>();
116 private Map
<String
,NonViralName
> taxonNameBases
= new HashMap
<String
,NonViralName
>();
117 private Map
<String
,MeasurementUnit
> units
= new HashMap
<String
,MeasurementUnit
>();
118 private Map
<String
,TaxonNode
> taxonNodes
= new HashMap
<String
,TaxonNode
>();
119 private Map
<String
,NamedArea
> namedAreas
= new HashMap
<String
,NamedArea
>();
120 private Map
<String
,Specimen
> specimens
= new HashMap
<String
,Specimen
>();
121 private Map
<String
,Modifier
> modifiers
= new HashMap
<String
,Modifier
>();
123 private Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
124 private Set
<TermVocabulary
> vocabularies
= new HashSet
<TermVocabulary
>();
126 private Set
<Feature
> descriptiveConcepts
= new HashSet
<Feature
>();
127 private Set
<AnnotationType
> annotationTypes
= new HashSet
<AnnotationType
>();
128 // private Set<Feature> featureSet = new HashSet<Feature>();
129 private Set
<Reference
> sources
= new HashSet
<Reference
>();
130 private Reference sec
= ReferenceFactory
.newDatabase();
131 private Reference sourceReference
= null;
133 private Language datasetLanguage
= null;
134 private WorkingSet workingSet
= null;
136 private Namespace xmlNamespace
= Namespace
.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
138 private String generatorName
= "";
139 private String generatorVersion
= "";
142 private Set
<StatisticalMeasure
> statisticalMeasures
= new HashSet
<StatisticalMeasure
>();
143 private Set
<VersionableEntity
> featureData
= new HashSet
<VersionableEntity
>();
144 private Set
<FeatureTree
> featureTrees
= new HashSet
<FeatureTree
>();
145 private Set
<Classification
> classifications
= new HashSet
<Classification
>();
147 private Rights copyright
= null;
149 private int taxonNamesCount
= 0;
151 protected Class
<ICdmIO
>[] ioClassList
;
153 public SDDDataSetImport(){
157 protected void makeIoClassList(){
158 ioClassList
= new Class
[]{
164 public boolean doCheck(SDDImportState state
){
165 boolean result
= true;
168 // for (Class<ICdmIO> ioClass: ioClassList){
170 // String ioBeanName = CdmApplicationAwareDefaultImport.getComponentBeanName(ioClass);
171 // ICdmIO cdmIo = (ICdmIO)getTermService().getBean(ioBeanName, ICdmIO.class);
172 // if (cdmIo != null){
173 //// result &= cdmIo.invoke(config, stores);
174 // state.setCurrentIO(cdmIo);
175 // result &= cdmIo.invoke(state);
177 // logger.error("cdmIO was null");
180 // } catch (Exception e) {
182 // e.printStackTrace();
186 logger
.warn("No check implemented for SDD");
191 // public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){
193 public boolean doInvoke(SDDImportState state
){
194 boolean success
= true;
196 TransactionStatus ts
= startTransaction();
197 SDDImportConfigurator sddConfig
= state
.getConfig();
198 IProgressMonitor progressMonitor
= sddConfig
.getProgressMonitor();
200 logger
.info("start Datasets ...");
202 // <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">
203 Element root
= sddConfig
.getSourceRoot();
204 Namespace sddNamespace
= sddConfig
.getSddNamespace();
206 logger
.info("start TechnicalMetadata ...");
207 // <TechnicalMetadata created="2006-04-20T10:00:00">
208 importTechnicalMetadata(root
, sddNamespace
, sddConfig
);
209 List
<Element
> elDatasets
= root
.getChildren("Dataset",sddNamespace
);
213 logger
.info("start Dataset ...");
214 progressMonitor
.beginTask("Importing SDD data", elDatasets
.size());
215 for (Element elDataset
: elDatasets
){
216 success
&= importDataset(elDataset
, sddNamespace
, state
);
217 // if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);}
218 // logger.info(i + " dataset(s) handled");
219 progressMonitor
.worked(1);
221 commitTransaction(ts
);
222 progressMonitor
.done();
223 logger
.info("End of transaction");
228 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
230 protected boolean isIgnore(SDDImportState state
){
235 // associates the reference of a media object in SDD with a CdmBase Object
236 protected void associateImageWithCdmBase(String refMO
, CdmBase cb
){
237 if ((refMO
!= null) && (cb
!=null)) {
238 if (! refMO
.equals("")) {
239 if (! mediaObject_ListCdmBase
.containsKey(refMO
)) {
240 List
<CdmBase
> lcb
= new ArrayList
<CdmBase
>();
242 mediaObject_ListCdmBase
.put(refMO
,lcb
);
244 List
<CdmBase
> lcb
= mediaObject_ListCdmBase
.get(refMO
);
246 mediaObject_ListCdmBase
.put(refMO
,lcb
);
252 // imports information about the Dataset
253 protected void importDatasetRepresentation(Element parent
, Namespace sddNamespace
){
254 logger
.info("start Representation ...");
256 <Label>The Genus Viola</Label>
257 <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>
263 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
264 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
);
265 String detail
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Detail",sddNamespace
);
268 Representation representation
= Representation
.NewInstance(detail
, label
, null, datasetLanguage
);
269 workingSet
.addRepresentation(representation
);
273 // sec.setTitleCache(label, true);
275 // if (detail != null) {
276 // Annotation annotation = Annotation.NewInstance(detail, datasetLanguage);
277 // annotation.setAnnotationType(AnnotationType.EDITORIAL());
278 // sec.addAnnotation(annotation);
282 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject",sddNamespace
);
284 for (Element elMediaObject
: listMediaObjects
) {
287 if (elMediaObject
!= null) {
288 ref
= elMediaObject
.getAttributeValue("ref");
289 role
= elMediaObject
.getAttributeValue("role");
292 if (!ref
.equals("")) {
293 this.associateImageWithCdmBase(ref
,sourceReference
);
294 this.associateImageWithCdmBase(ref
,sec
);
295 mediaObject_Role
.put(ref
,role
);
301 // imports the representation (label, detail, lang) of a particular SDD element
302 protected void importRepresentation(Element parent
, Namespace sddNamespace
, VersionableEntity ve
, String id
, IImportConfigurator config
){
303 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
305 Map
<Language
,List
<String
>> langLabDet
= new HashMap
<Language
,List
<String
>>();
307 handleRepresentationLabels(sddNamespace
, elRepresentation
, langLabDet
);
308 handleRepresentationDetails(sddNamespace
, elRepresentation
, langLabDet
);
310 if (ve
instanceof TermBase
) {
311 makeRepresentationForTerms((TermBase
)ve
, langLabDet
);
312 }else if (ve
instanceof Media
) {
313 makeRepresentationForMedia((Media
)ve
, langLabDet
);
314 }else if (ve
instanceof IdentifiableEntity
<?
>) {
315 IdentifiableEntity
<?
> ie
= (IdentifiableEntity
<?
>)ve
;
316 makeRepresentationForIdentifiableEntity(sddNamespace
, ie
, elRepresentation
, langLabDet
);
317 if (ve
instanceof IdentifiableMediaEntity
<?
>){
318 makeRepresentationForIdentifiableMediaEntity(parent
, sddNamespace
, (IdentifiableMediaEntity
<?
>)ve
);
322 makeRepresentationMediaObjects(sddNamespace
, ve
, elRepresentation
);//FIXME
328 * Handles the "Detail" children of representations. Adds the result to the langLabDet.
329 * @param sddNamespace
330 * @param elRepresentation
333 private void handleRepresentationDetails(Namespace sddNamespace
,
334 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
335 List
<Element
> listDetails
= elRepresentation
.getChildren("Detail",sddNamespace
);
336 for (Element elDetail
: listDetails
){
337 Language language
= getLanguage(elDetail
);
338 String role
= elDetail
.getAttributeValue("role");
339 String detail
= elDetail
.getText();
340 List
<String
> labDet
= langLabDet
.get(language
);
343 langLabDet
.put(language
, labDet
);
348 * Handles the "Label" children of representations. Adds the result to the langLabDet.
349 * @param sddNamespace
350 * @param elRepresentation
353 private void handleRepresentationLabels(Namespace sddNamespace
,
354 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
355 // <Label xml:lang="la">Viola hederacea Labill.</Label>
356 List
<Element
> listLabels
= elRepresentation
.getChildren("Label",sddNamespace
);
357 for (Element elLabel
: listLabels
){
358 Language language
= getLanguage(elLabel
);
359 String label
= elLabel
.getText();
360 List
<String
> labDet
= new ArrayList
<String
>(3);
362 langLabDet
.put(language
, labDet
);
371 private void makeRepresentationForMedia(Media m
, Map
<Language
, List
<String
>> langLabDet
) {
372 for (Language lang
: langLabDet
.keySet()){
373 List
<String
> labDet
= langLabDet
.get(lang
);
374 if (labDet
.get(0) != null){
375 m
.putTitle(LanguageString
.NewInstance(labDet
.get(0), lang
));
377 if (labDet
.size()>1) {
378 m
.addDescription(labDet
.get(1), lang
);
384 * Handles representations for terms. Adds one representation per language in langLabDet.
389 private void makeRepresentationForTerms(TermBase tb
, Map
<Language
, List
<String
>> langLabDet
) {
390 for (Language lang
: langLabDet
.keySet()){
391 List
<String
> labDet
= langLabDet
.get(lang
);
392 if (labDet
.size()>0){
393 if (labDet
.size()>1) {
394 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(1), labDet
.get(0), labDet
.get(0), lang
));
396 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(0), labDet
.get(0), labDet
.get(0), lang
));
404 * Handles the "MediaObject" children of representations.
405 * @param sddNamespace
407 * @param elRepresentation
409 private void makeRepresentationMediaObjects(Namespace sddNamespace
, VersionableEntity ve
, Element elRepresentation
) {
410 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject", sddNamespace
);
411 for (Element elMediaObject
: listMediaObjects
) {
415 if (elMediaObject
!= null) {
416 ref
= elMediaObject
.getAttributeValue("ref");
417 role
= elMediaObject
.getAttributeValue("role");
419 if (StringUtils
.isNotBlank(ref
)) {
420 if (ve
instanceof TaxonDescription
) {
421 TaxonDescription td
= (TaxonDescription
) ve
;
422 if (td
.getDescriptionSources().size() > 0) {
423 this.associateImageWithCdmBase(ref
,(Reference
) td
.getDescriptionSources().toArray()[0]);
425 Reference descriptionSource
= ReferenceFactory
.newGeneric();
426 sources
.add(descriptionSource
);
427 td
.addDescriptionSource(descriptionSource
);
428 this.associateImageWithCdmBase(ref
,descriptionSource
);
431 this.associateImageWithCdmBase(ref
,ve
);
438 * Handles the "Links" element
440 * @param sddNamespace
443 private void makeRepresentationForIdentifiableMediaEntity(Element parent
,
444 Namespace sddNamespace
, IdentifiableMediaEntity ime
) {
445 Element elLinks
= parent
.getChild("Links",sddNamespace
);
447 if (elLinks
!= null) {
449 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
450 List
<Element
> listLinks
= elLinks
.getChildren("Link", sddNamespace
);
451 Media link
= Media
.NewInstance();
452 MediaRepresentation mr
= MediaRepresentation
.NewInstance();
455 for (Element elLink
: listLinks
){
459 String rel
= elLink
.getAttributeValue("rel");
460 String href
= elLink
.getAttributeValue("href");
461 URI uri
= new URI(href
);
462 mr
.addRepresentationPart(MediaRepresentationPart
.NewInstance(uri
, null));
463 link
.addRepresentation(mr
);
466 } catch (Exception e
) {
468 logger
.warn("Import of Link " + k
+ " failed.");
471 if ((++k
% modCount
) == 0){ logger
.info("Links handled: " + k
);}
478 * @param sddNamespace
480 * @param elRepresentation
484 private void makeRepresentationForIdentifiableEntity(Namespace sddNamespace
, IdentifiableEntity
<?
> ie
,
485 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
486 List
<String
> labDet
= null;
488 if (ie
instanceof TaxonNameBase
) {
489 if (langLabDet
.keySet().contains(getTermService().getLanguageByIso("la"))) {
490 labDet
= langLabDet
.get(getTermService().getLanguageByIso("la"));
491 } else if (langLabDet
.keySet().contains(datasetLanguage
)) {
492 labDet
= langLabDet
.get(datasetLanguage
);
493 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
495 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
496 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
499 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
502 //FIXME labDet is != null only for TaxonNameBase
503 ie
.setTitleCache(labDet
.get(0), true);
505 if (labDet
.size()>1) {
506 Annotation annotation
= null;
507 if (labDet
.get(1) != null) {
508 if (labDet
.get(2) != null) {
509 annotation
= Annotation
.NewInstance(labDet
.get(2) + " - " + labDet
.get(1), datasetLanguage
);
511 annotation
= Annotation
.NewInstance(labDet
.get(1), datasetLanguage
);
514 ie
.addAnnotation(annotation
);
523 private Language
getLanguage(Element elLanguage
) {
524 String lang
= elLanguage
.getAttributeValue("lang",xmlNamespace
);
525 Language language
= null;
526 if (StringUtils
.isNotBlank(lang
)) {
527 language
= getTermService().getLanguageByIso(lang
.substring(0, 2));
529 language
= datasetLanguage
;
535 // imports the representation (label, detail, lang) of a particular SDD element
536 protected void importTechnicalMetadata(Element root
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
537 Element elTechnicalMetadata
= root
.getChild("TechnicalMetadata", sddNamespace
);
538 String nameCreated
= elTechnicalMetadata
.getAttributeValue("created");
539 sourceReference
= sddConfig
.getSourceReference();
541 if (nameCreated
!= null) {
542 if (!nameCreated
.equals("")) {
543 int year
= Integer
.parseInt(nameCreated
.substring(0,4));
544 int monthOfYear
= Integer
.parseInt(nameCreated
.substring(5,7));
545 int dayOfMonth
= Integer
.parseInt(nameCreated
.substring(8,10));
546 int hourOfDay
= Integer
.parseInt(nameCreated
.substring(11,13));
547 int minuteOfHour
= Integer
.parseInt(nameCreated
.substring(14,16));
548 int secondOfMinute
= Integer
.parseInt(nameCreated
.substring(17,19));
549 DateTime created
= new DateTime(year
,monthOfYear
,dayOfMonth
,hourOfDay
,minuteOfHour
,secondOfMinute
,0);
550 sourceReference
.setCreated(created
);
551 sec
.setCreated(created
);
555 // <Generator name="n/a, handcrafted instance document" version="n/a"/>
556 Element elGenerator
= elTechnicalMetadata
.getChild("Generator", sddNamespace
);
557 generatorName
= elGenerator
.getAttributeValue("name");
558 generatorVersion
= elGenerator
.getAttributeValue("version");
560 sec
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
561 sourceReference
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
565 // imports the complete dataset information
566 protected boolean importDataset(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){ // <Dataset xml:lang="en-us">
567 boolean success
= true;
568 SDDImportConfigurator sddConfig
= state
.getConfig();
570 workingSet
= WorkingSet
.NewInstance();
571 importDatasetLanguage(elDataset
,sddConfig
);
572 importDatasetRepresentation(elDataset
, sddNamespace
);
573 importRevisionData(elDataset
, sddNamespace
);
574 importIPRStatements(elDataset
, sddNamespace
, sddConfig
);
575 importTaxonNames(elDataset
, sddNamespace
, sddConfig
);
577 importDescriptiveConcepts(elDataset
, sddNamespace
, sddConfig
);
578 success
&= importCharacters(elDataset
, sddNamespace
, sddConfig
);
579 importCharacterTrees(elDataset
, sddNamespace
, sddConfig
, success
);
581 MarkerType editorMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerEditor
, "editor", "Editor", "edt");
582 MarkerType geographicAreaMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerSDDGeographicArea
, "SDDGeographicArea", "SDDGeographicArea", "ga");
583 MarkerType descriptiveConceptMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerDescriptiveConcept
, "DescriptiveConcept", "Descriptive Concept", "DC");
584 markerTypes
.add(editorMarkerType
);
585 markerTypes
.add(geographicAreaMarkerType
);
586 markerTypes
.add(descriptiveConceptMarkerType
);
588 //saving of all imported data into the CDM db
594 saveAreas(geographicAreaMarkerType
);
596 saveStatisticalMeasure();
597 saveAnnotationType();
599 success
&= importCodedDescriptions(elDataset
, sddNamespace
, sddConfig
);
600 importAgents(elDataset
, sddNamespace
, sddConfig
, success
);
601 importPublications(elDataset
, sddNamespace
, sddConfig
, success
);
602 importMediaObjects(elDataset
, sddNamespace
, sddConfig
, success
);
603 importTaxonHierarchies(elDataset
, sddNamespace
, sddConfig
, success
);
604 importGeographicAreas(elDataset
, sddNamespace
, sddConfig
);
605 importSpecimens(elDataset
,sddNamespace
, sddConfig
);
608 if ((authors
!= null)||(editors
!= null)) {
609 Team team
= Team
.NewInstance();
610 if (authors
!= null) {
611 for (Person author
: authors
.values()){
612 team
.addTeamMember(author
);
615 if (editors
!= null) {
616 Marker marker
= Marker
.NewInstance();
617 marker
.setMarkerType(editorMarkerType
);
618 for (Person editor
: editors
.values()){
619 Person edit
= editor
;
620 edit
.addMarker(marker
);
621 team
.addTeamMember(edit
);
624 sec
.setAuthorTeam(team
);
625 sourceReference
.setAuthorTeam(team
);
628 if (copyright
!= null) {
629 sourceReference
.addRights(copyright
);
630 sec
.addRights(copyright
);
633 // Returns a CdmApplicationController created by the values of this configuration.
634 IDescriptionService descriptionService
= getDescriptionService();
636 for (TaxonDescription taxonDescription
: taxonDescriptions
.values()){
637 // Persists a Description
638 descriptionService
.save(taxonDescription
);
641 for (String ref
: taxonDescriptions
.keySet()){
642 TaxonDescription td
= taxonDescriptions
.get(ref
);
643 if (citations
.containsKey(ref
)) {
644 Reference publication
= publications
.get(citations
.get(ref
));
645 if (locations
.containsKey(ref
)) {
646 Annotation location
= Annotation
.NewInstance(locations
.get(ref
), datasetLanguage
);
647 AnnotationType annotationType
= AnnotationType
.NewInstance("", "location", "");
648 annotationTypes
.add(annotationType
);
649 location
.setAnnotationType(annotationType
);
650 (publication
).addAnnotation(location
);
652 td
.addDescriptionSource(publication
);
655 logger
.info("end makeTaxonDescriptions ...");
657 if (descriptiveConcepts
!= null) {
658 for (Feature feature
: descriptiveConcepts
) {
659 Marker marker
= Marker
.NewInstance();
660 marker
.setMarkerType(descriptiveConceptMarkerType
);
661 feature
.addMarker(marker
);
666 for (Reference publication
: publications
.values()){
667 getReferenceService().save(publication
);
670 for (Reference source
: sources
){
671 getReferenceService().save(source
);
674 for (FeatureTree featureTree
: featureTrees
) {
675 getFeatureTreeService().save(featureTree
);
677 getWorkingSetService().save(workingSet
);
678 for (Classification classification
: classifications
) {
679 getClassificationService().save(classification
);
681 for (Specimen specimen
: specimens
.values()) {
682 getOccurrenceService().save(specimen
);
684 logger
.info("end of persistence ...");
692 private void saveVocabularies() {
693 for (TermVocabulary vocabulary
: vocabularies
){
694 getVocabularyService().save(vocabulary
);
699 private void saveAnnotationType() {
700 for (AnnotationType annotationType
: annotationTypes
){
701 getTermService().save(annotationType
);
705 private void saveStatisticalMeasure() {
706 for (StatisticalMeasure sm
: statisticalMeasures
){
707 getTermService().save(sm
);
711 private void saveUnits() {
713 for (MeasurementUnit unit
: units
.values()){
715 getTermService().save(unit
);
721 private void saveAreas(MarkerType geographicAreaMarkerType
) {
722 for (NamedArea area
: namedAreas
.values() ){
723 Marker marker
= Marker
.NewInstance();
724 marker
.setMarkerType(geographicAreaMarkerType
);
725 area
.addMarker(marker
);
726 getTermService().save(area
);
730 private void saveStates() {
731 for (State state
: states
.values() ){
732 getTermService().save(state
);
736 private void saveMarkerType() {
737 for (MarkerType markerType
: markerTypes
){
738 getTermService().save(markerType
);
742 private void saveModifiers() {
743 for (Modifier modifier
: modifiers
.values() ){
744 getTermService().save(modifier
);
748 private void saveFeatures() {
749 for (Feature feature
: features
.values() ){
750 getTermService().save(feature
);
754 // imports the default language of the dataset
755 protected void importDatasetLanguage(Element elDataset
, SDDImportConfigurator sddConfig
){
756 String nameLang
= elDataset
.getAttributeValue("lang",xmlNamespace
);
758 if (StringUtils
.isNotBlank(nameLang
)) {
759 String iso
= nameLang
.substring(0, 2);
760 datasetLanguage
= getTermService().getLanguageByIso(iso
);
762 datasetLanguage
= Language
.DEFAULT();
764 if (datasetLanguage
== null) {
765 datasetLanguage
= Language
.DEFAULT();
769 // imports the specimens
770 protected void importSpecimens(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
) {
771 logger
.info("start Specimens ...");
775 <Label>TJM45337</Label>
780 Element elSpecimens
= elDataset
.getChild("Specimens",sddNamespace
);
781 if (elSpecimens
!= null){
782 List
<Element
> listSpecimens
= elSpecimens
.getChildren("Specimen", sddNamespace
);
784 for (Element elSpecimen
: listSpecimens
) {
785 String id
= elSpecimen
.getAttributeValue("id");
786 Specimen specimen
= null;
787 if (!id
.equals("")) {
788 specimen
= Specimen
.NewInstance();
789 specimens
.put(id
,specimen
);
790 importRepresentation(elSpecimen
, sddNamespace
, specimen
, id
, sddConfig
);
797 // imports the revision data associated with the Dataset (authors, modifications)
798 protected void importRevisionData(Element elDataset
, Namespace sddNamespace
){
800 logger
.info("start RevisionData ...");
801 Element elRevisionData
= elDataset
.getChild("RevisionData",sddNamespace
);
802 if (elRevisionData
!= null){
804 Element elCreators
= elRevisionData
.getChild("Creators",sddNamespace
);
806 // <Agent role="aut" ref="a1"/>
807 List
<Element
> listAgents
= elCreators
.getChildren("Agent", sddNamespace
);
811 for (Element elAgent
: listAgents
){
813 String role
= elAgent
.getAttributeValue("role");
814 String ref
= elAgent
.getAttributeValue("ref");
815 if (role
.equals("aut")) {
816 if(!ref
.equals("")) {
817 authors
.put(ref
, null);
820 if (role
.equals("edt")) {
821 if(!ref
.equals("")) {
822 editors
.put(ref
, null);
825 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
829 // <DateModified>2006-04-08T00:00:00</DateModified>
830 String stringDateModified
= (String
)ImportHelper
.getXmlInputValue(elRevisionData
, "DateModified",sddNamespace
);
832 if (stringDateModified
!= null) {
833 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
836 d
= sdf
.parse(stringDateModified
);
837 } catch(Exception e
) {
838 System
.err
.println("Exception :");
842 DateTime updated
= null;
844 updated
= new DateTime(d
);
845 sourceReference
.setUpdated(updated
);
846 sec
.setUpdated(updated
);
852 // imports ipr statements associated with a dataset
853 protected void importIPRStatements(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
855 logger
.info("start IPRStatements ...");
856 Element elIPRStatements
= elDataset
.getChild("IPRStatements",sddNamespace
);
857 // <IPRStatement role="Copyright">
858 if (elIPRStatements
!= null) {
859 List
<Element
> listIPRStatements
= elIPRStatements
.getChildren("IPRStatement", sddNamespace
);
861 //for each IPRStatement
863 for (Element elIPRStatement
: listIPRStatements
){
865 String role
= elIPRStatement
.getAttributeValue("role");
866 // <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
867 Element elLabel
= elIPRStatement
.getChild("Label",sddNamespace
);
869 if (elLabel
!= null) {
870 lang
= elLabel
.getAttributeValue("lang",xmlNamespace
);
872 String label
= (String
)ImportHelper
.getXmlInputValue(elIPRStatement
, "Label",sddNamespace
);
874 if (role
.equals("Copyright")) {
875 Language iprLanguage
= null;
877 if (!lang
.equals("")) {
878 iprLanguage
= getTermService().getLanguageByIso(lang
.substring(0, 2));
880 iprLanguage
= datasetLanguage
;
883 if (iprLanguage
== null) {
884 iprLanguage
= datasetLanguage
;
886 copyright
= Rights
.NewInstance(label
, iprLanguage
);
889 if (copyright
!= null) {
890 sourceReference
.addRights(copyright
);
891 sec
.addRights(copyright
);
894 if ((++j
% modCount
) == 0){ logger
.info("IPRStatements handled: " + j
);}
900 // imports the taxon names
901 protected void importTaxonNames(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
903 logger
.info("start TaxonNames ...");
904 Element elTaxonNames
= elDataset
.getChild("TaxonNames",sddNamespace
);
905 // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
906 if (elTaxonNames
!= null) {
907 List
<Element
> listTaxonNames
= elTaxonNames
.getChildren("TaxonName", sddNamespace
);
910 for (Element elTaxonName
: listTaxonNames
){
912 String id
= elTaxonName
.getAttributeValue("id");
913 String uri
= elTaxonName
.getAttributeValue("uri");
915 NonViralName tnb
= null;
916 if (!id
.equals("")) {
917 tnb
= NonViralName
.NewInstance(null);
918 IdentifiableSource source
= null;
920 if (!uri
.equals("")) {
921 source
= IdentifiableSource
.NewInstance(id
, "TaxonName", ReferenceFactory
.newGeneric(), uri
);
924 source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
926 tnb
.addSource(source
);
927 taxonNameBases
.put(id
,tnb
);
931 // <Label xml:lang="la">Viola hederacea Labill.</Label>
932 importRepresentation(elTaxonName
, sddNamespace
, tnb
, id
, sddConfig
);
934 if ((++j
% modCount
) == 0){ logger
.info("TaxonNames handled: " + j
);}
940 // imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features
941 protected boolean importCharacters(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
942 boolean success
= true;
944 logger
.info("start Characters ...");
945 Element elCharacters
= elDataset
.getChild("Characters", sddNamespace
);
947 // <CategoricalCharacter id="c1">
948 if (elCharacters
!= null) {
949 success
&= handleCategoricalData(sddNamespace
, sddConfig
, elCharacters
);
950 success
&= handleQuantitativeData(sddNamespace
, sddConfig
, elCharacters
);
951 success
&= handleTextCharacters(sddNamespace
, sddConfig
, elCharacters
);
954 /*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){
955 featureSet.add(f.next()); //XIM Why this line ?
963 * @param sddNamespace
966 * @param elCharacters
969 private boolean handleCategoricalData(Namespace sddNamespace
, SDDImportConfigurator sddConfig
, Element elCharacters
) {
970 boolean success
= true;
971 List
<Element
> elCategoricalCharacters
= elCharacters
.getChildren("CategoricalCharacter", sddNamespace
);
973 for (Element elCategoricalCharacter
: elCategoricalCharacters
){
976 String idCC
= elCategoricalCharacter
.getAttributeValue("id");
977 Feature categoricalCharacter
= Feature
.NewInstance();
978 categoricalCharacter
.setKindOf(Feature
.DESCRIPTION());
979 importRepresentation(elCategoricalCharacter
, sddNamespace
, categoricalCharacter
, idCC
, sddConfig
);
980 categoricalCharacter
.setSupportsCategoricalData(true);
983 Element elStates
= elCategoricalCharacter
.getChild("States",sddNamespace
);
985 // <StateDefinition id="s1">
986 List
<Element
> elStateDefinitions
= elStates
.getChildren("StateDefinition",sddNamespace
);
987 TermVocabulary
<State
> termVocabularyState
= new TermVocabulary
<State
>();
989 vocabularies
.add(termVocabularyState
);
992 //for each StateDefinition
993 for (Element elStateDefinition
: elStateDefinitions
){
995 if ((++k
% modCount
) == 0){ logger
.info("StateDefinitions handled: " + (k
-1));}
997 String idS
= elStateDefinition
.getAttributeValue("id");
998 State state
= states
.get(idS
);
1000 state
= State
.NewInstance();
1002 logger
.debug("State duplicate found");
1004 importRepresentation(elStateDefinition
, sddNamespace
, state
, idS
, sddConfig
);
1006 termVocabularyState
.addTerm(state
);
1007 states
.put(idS
,state
);
1009 categoricalCharacter
.addSupportedCategoricalEnumeration(termVocabularyState
);
1010 features
.put(idCC
, categoricalCharacter
);
1012 } catch (Exception e
) {
1013 logger
.warn("Import of CategoricalCharacter " + j
+ " failed.");
1017 if ((++j
% modCount
) == 0){ logger
.info("CategoricalCharacters handled: " + j
);}
1024 * @param sddNamespace
1026 * @param elCharacters
1028 private boolean handleQuantitativeData(Namespace sddNamespace
, SDDImportConfigurator sddConfig
, Element elCharacters
) {
1029 boolean success
= true;
1031 // <QuantitativeCharacter id="c2">
1032 List
<Element
> elQuantitativeCharacters
= elCharacters
.getChildren("QuantitativeCharacter", sddNamespace
);
1034 //for each QuantitativeCharacter
1035 for (Element elQuantitativeCharacter
: elQuantitativeCharacters
){
1039 String idQC
= elQuantitativeCharacter
.getAttributeValue("id");
1042 // <Label>Leaf length</Label>
1043 // </Representation>
1044 Feature quantitativeCharacter
= Feature
.NewInstance();
1045 quantitativeCharacter
.setKindOf(Feature
.DESCRIPTION());
1046 importRepresentation(elQuantitativeCharacter
, sddNamespace
, quantitativeCharacter
, idQC
, sddConfig
);
1048 quantitativeCharacter
.setSupportsQuantitativeData(true);
1050 // <MeasurementUnit>
1051 // <Label role="Abbrev">m</Label>
1052 // </MeasurementUnit>
1053 Element elMeasurementUnit
= elQuantitativeCharacter
.getChild("MeasurementUnit",sddNamespace
);
1056 if (elMeasurementUnit
!= null) {
1057 Element elLabel
= elMeasurementUnit
.getChild("Label",sddNamespace
);
1058 role
= elLabel
.getAttributeValue("role");
1059 label
= (String
)ImportHelper
.getXmlInputValue(elMeasurementUnit
, "Label",sddNamespace
);
1062 MeasurementUnit unit
= null;
1063 if (!label
.equals("")){
1065 if (role
.equals("Abbrev")){
1066 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1069 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1074 units
.put(idQC
, unit
);
1078 // <MeasurementUnitPrefix>milli</MeasurementUnitPrefix>
1080 Element elDefault
= elQuantitativeCharacter
.getChild("Default",sddNamespace
);
1081 if (elDefault
!= null) {
1082 String measurementUnitPrefix
= (String
)ImportHelper
.getXmlInputValue(elDefault
, "MeasurementUnitPrefix",sddNamespace
);
1083 if (! measurementUnitPrefix
.equals("")){
1084 defaultUnitPrefixes
.put(idQC
, measurementUnitPrefix
);
1088 features
.put(idQC
, quantitativeCharacter
);
1090 } catch (Exception e
) {
1092 logger
.warn("Import of QuantitativeCharacter " + j
+ " failed.");
1096 if ((++j
% modCount
) == 0){ logger
.info("QuantitativeCharacters handled: " + j
);}
1102 private boolean handleTextCharacters(Namespace sddNamespace
, SDDImportConfigurator sddConfig
, Element elCharacters
) {
1103 boolean success
= true;
1105 // <TextCharacter id="c3">
1106 List
<Element
> elTextCharacters
= elCharacters
.getChildren("TextCharacter", sddNamespace
);
1108 //for each TextCharacter
1109 for (Element elTextCharacter
: elTextCharacters
){
1113 String idTC
= elTextCharacter
.getAttributeValue("id");
1116 // <Label xml:lang="en">Leaf features not covered by other characters</Label>
1117 // </Representation>
1118 Feature textCharacter
= Feature
.NewInstance();
1119 textCharacter
.setKindOf(Feature
.DESCRIPTION());
1120 importRepresentation(elTextCharacter
, sddNamespace
, textCharacter
, idTC
, sddConfig
);
1122 textCharacter
.setSupportsTextData(true);
1124 features
.put(idTC
, textCharacter
);
1126 } catch (Exception e
) {
1128 logger
.warn("Import of TextCharacter " + j
+ " failed.");
1132 if ((++j
% modCount
) == 0){ logger
.info("TextCharacters handled: " + j
);}
1138 // imports the descriptions of taxa
1139 protected boolean importCodedDescriptions(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
1140 boolean success
= true;
1142 // <CodedDescriptions>
1143 logger
.info("start CodedDescriptions ...");
1144 Element elCodedDescriptions
= elDataset
.getChild("CodedDescriptions",sddNamespace
);
1146 // <CodedDescription id="D101">
1147 if (elCodedDescriptions
!= null) {
1148 List
<Element
> listCodedDescriptions
= elCodedDescriptions
.getChildren("CodedDescription", sddNamespace
);
1150 //for each CodedDescription
1151 for (Element elCodedDescription
: listCodedDescriptions
){
1152 success
&= handleCodedDescription(sddNamespace
, sddConfig
, elCodedDescription
, j
);
1153 if ((++j
% modCount
) == 0){ logger
.info("CodedDescriptions handled: " + j
);}
1160 * @param sddNamespace
1163 * @param elCodedDescription
1166 private boolean handleCodedDescription(Namespace sddNamespace
, SDDImportConfigurator sddConfig
, Element elCodedDescription
, int j
) {
1167 boolean success
= true ;
1170 String idCD
= elCodedDescription
.getAttributeValue("id");
1173 // <Label><i>Viola hederacea</i> Labill. as revised by R. Morris April 8, 2006</Label>
1174 // </Representation>
1175 TaxonDescription taxonDescription
= TaxonDescription
.NewInstance();
1176 if (!generatorName
.isEmpty()){
1177 Annotation annotation
= Annotation
.NewInstance(generatorName
, AnnotationType
.TECHNICAL(),Language
.DEFAULT());
1178 taxonDescription
.addAnnotation(annotation
);
1180 importRepresentation(elCodedDescription
, sddNamespace
, taxonDescription
, idCD
, sddConfig
);
1183 // <TaxonName ref="t1"/>
1184 // <Citation ref="p1" location="p. 30"/>
1186 Element elScope
= elCodedDescription
.getChild("Scope", sddNamespace
);
1188 if (elScope
!= null) {
1189 taxon
= handleCDScope(sddNamespace
, sddConfig
, idCD
, elScope
);
1190 } else {//in case no taxon is linked to the description, a new one is created
1191 taxon
= handleCDNoScope(sddNamespace
, sddConfig
, elCodedDescription
);
1195 Element elSummaryData
= elCodedDescription
.getChild("SummaryData",sddNamespace
);
1196 if (elSummaryData
!= null) {
1197 handleSummaryCategoricalData(sddNamespace
, taxonDescription
, elSummaryData
);
1198 handleSummaryQuantitativeData(sddNamespace
, taxonDescription
, elSummaryData
);
1199 handleSummaryTextData(sddNamespace
, taxonDescription
, elSummaryData
);
1202 if (taxon
!= null) {
1203 taxon
.addDescription(taxonDescription
);
1206 workingSet
.addDescription(taxonDescription
);
1208 //OLD taxonDescription.setDescriptiveSystem(featureSet);
1210 taxonDescriptions
.put(idCD
, taxonDescription
);//FIXME
1212 } catch (Exception e
) {
1214 logger
.warn("Import of CodedDescription " + j
+ " failed.", e
);
1221 * @param sddNamespace
1223 * @param elCodedDescription
1227 private Taxon
handleCDNoScope(Namespace sddNamespace
,
1228 SDDImportConfigurator sddConfig
, Element elCodedDescription
) {
1230 NonViralName nonViralName
= NonViralName
.NewInstance(null);
1231 String id
= new String("" + taxonNamesCount
);
1232 IdentifiableSource source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
1233 importRepresentation(elCodedDescription
, sddNamespace
, nonViralName
, id
, sddConfig
);
1235 if(sddConfig
.isDoMatchTaxa()){
1236 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1240 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1241 // taxonNameBases.put(id ,tnb);
1242 // taxonNamesCount++;
1243 logger
.info("using existing Taxon " + taxon
.getTitleCache());
1245 nonViralName
.addSource(source
);
1246 taxonNameBases
.put(id
,nonViralName
);
1248 logger
.info("creating new Taxon from TaxonName " + nonViralName
.getTitleCache());
1249 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1255 * @param sddNamespace
1262 private Taxon
handleCDScope(Namespace sddNamespace
, SDDImportConfigurator sddConfig
,
1263 String idCD
, Element elScope
) {
1265 Element elTaxonName
= elScope
.getChild("TaxonName", sddNamespace
);
1266 String ref
= elTaxonName
.getAttributeValue("ref");
1267 NonViralName nonViralName
= taxonNameBases
.get(ref
);
1269 if(sddConfig
.isDoMatchTaxa()){
1270 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1274 logger
.info("using existing Taxon" + taxon
.getTitleCache());
1275 if(!nonViralName
.getUuid().equals(taxon
.getName().getUuid())){
1276 logger
.warn("TaxonNameBase entity of existing taxon does not match Name in list -> replacing Name in list");
1277 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1280 logger
.info("creating new Taxon from TaxonName '" + nonViralName
.getTitleCache()+"'");
1281 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1285 Element elCitation
= elScope
.getChild("Citation",sddNamespace
);
1286 if (elCitation
!= null) {
1287 String refCitation
= elCitation
.getAttributeValue("ref");
1288 if (! refCitation
.equals("")){
1289 citations
.put(idCD
, refCitation
);
1291 String location
= elCitation
.getAttributeValue("location");
1292 if (! location
.equals("")){
1293 locations
.put(idCD
, location
);
1300 * @param sddNamespace
1301 * @param taxonDescription
1302 * @param elSummaryData
1304 private void handleSummaryTextData(Namespace sddNamespace
,
1305 TaxonDescription taxonDescription
, Element elSummaryData
) {
1308 // <TextChar ref="c3">
1309 List
<Element
> elTextChars
= elSummaryData
.getChildren("TextChar", sddNamespace
);
1312 for (Element elTextChar
: elTextChars
){
1313 if ((++k
% modCount
) == 0){ logger
.info("TextChar handled: " + (k
-1));}
1314 ref
= elTextChar
.getAttributeValue("ref");
1315 Feature feature
= features
.get(ref
);
1316 TextData textData
= TextData
.NewInstance();
1317 textData
.setFeature(feature
);
1319 // <Content>Free form text</Content>
1320 String content
= (String
)ImportHelper
.getXmlInputValue(elTextChar
, "Content",sddNamespace
);
1321 textData
.putText(datasetLanguage
, content
);
1322 taxonDescription
.addElement(textData
);
1327 * @param sddNamespace
1328 * @param taxonDescription
1329 * @param elSummaryData
1331 private void handleSummaryQuantitativeData(Namespace sddNamespace
,
1332 TaxonDescription taxonDescription
, Element elSummaryData
) {
1335 // <Quantitative ref="c2">
1336 List
<Element
> elQuantitatives
= elSummaryData
.getChildren("Quantitative", sddNamespace
);
1338 //for each Quantitative
1339 for (Element elQuantitative
: elQuantitatives
){
1340 if ((++k
% modCount
) == 0){ logger
.warn("Quantitative handled: " + (k
-1));}
1341 ref
= elQuantitative
.getAttributeValue("ref");
1342 Feature feature
= features
.get(ref
);
1343 QuantitativeData quantitativeData
= QuantitativeData
.NewInstance();
1344 quantitativeData
.setFeature(feature
);
1346 MeasurementUnit unit
= units
.get(ref
);
1347 String prefix
= defaultUnitPrefixes
.get(ref
);
1349 String u
= unit
.getLabel();
1350 if (prefix
!= null) {
1354 quantitativeData
.setUnit(unit
);
1357 // <Measure type="Min" value="2.3"/>
1358 List
<Element
> elMeasures
= elQuantitative
.getChildren("Measure", sddNamespace
);
1362 for (Element elMeasure
: elMeasures
){
1363 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1364 String type
= elMeasure
.getAttributeValue("type");
1365 String value
= elMeasure
.getAttributeValue("value");
1366 if (value
.contains(",")) {
1367 value
= value
.replace(',', '.');
1369 Float v
= Float
.parseFloat(value
);
1370 //Float v = new Float(0);
1371 StatisticalMeasure t
= null;
1372 if (type
.equals("Min")) {
1373 t
= StatisticalMeasure
.MIN();
1374 } else if (type
.equals("Mean")) {
1375 t
= StatisticalMeasure
.AVERAGE();
1376 } else if (type
.equals("Max")) {
1377 t
= StatisticalMeasure
.MAX();
1378 } else if (type
.equals("SD")) {
1379 t
= StatisticalMeasure
.STANDARD_DEVIATION();
1380 } else if (type
.equals("N")) {
1381 t
= StatisticalMeasure
.SAMPLE_SIZE();
1382 } else if (type
.equals("UMethLower")) {
1383 t
= StatisticalMeasure
.TYPICAL_LOWER_BOUNDARY();
1384 } else if (type
.equals("UMethUpper")) {
1385 t
= StatisticalMeasure
.TYPICAL_UPPER_BOUNDARY();
1386 } else if (type
.equals("Var")) {
1387 t
= StatisticalMeasure
.VARIANCE();
1389 t
= StatisticalMeasure
.NewInstance(type
,type
,type
);
1390 statisticalMeasures
.add(t
);
1393 StatisticalMeasurementValue statisticalValue
= StatisticalMeasurementValue
.NewInstance();
1394 statisticalValue
.setValue(v
);
1395 statisticalValue
.setType(t
);
1396 quantitativeData
.addStatisticalValue(statisticalValue
);
1397 featureData
.add(statisticalValue
);
1399 taxonDescription
.addElement(quantitativeData
);
1404 * @param sddNamespace
1405 * @param taxonDescription
1406 * @param elSummaryData
1408 private void handleSummaryCategoricalData(Namespace sddNamespace
,
1409 TaxonDescription taxonDescription
, Element elSummaryData
) {
1411 // <Categorical ref="c4">
1412 List
<Element
> elCategoricals
= elSummaryData
.getChildren("Categorical", sddNamespace
);
1414 //for each Categorical
1415 for (Element elCategorical
: elCategoricals
){
1416 if ((++k
% modCount
) == 0){ logger
.warn("Categorical handled: " + (k
-1));}
1417 ref
= elCategorical
.getAttributeValue("ref");
1418 Feature feature
= features
.get(ref
);
1419 CategoricalData categoricalData
= CategoricalData
.NewInstance();
1420 categoricalData
.setFeature(feature
);
1422 // <State ref="s3"/>
1423 List
<Element
> elStates
= elCategorical
.getChildren("State", sddNamespace
);
1427 for (Element elState
: elStates
){
1428 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1429 ref
= elState
.getAttributeValue("ref");
1430 State state
= states
.get(ref
);
1431 if (state
!= null) {
1432 StateData stateData
= StateData
.NewInstance();
1433 stateData
.setState(state
);
1434 List
<Element
> elModifiers
= elState
.getChildren("Modifier", sddNamespace
);
1435 for (Element elModifier
: elModifiers
){
1436 ref
= elModifier
.getAttributeValue("ref");
1437 Modifier modifier
= modifiers
.get(ref
);
1438 if (modifier
!= null) {
1439 stateData
.addModifier(modifier
);
1442 categoricalData
.addState(stateData
);
1444 taxonDescription
.addElement(categoricalData
);
1449 // imports the persons associated with the dataset creation, modification, related publications
1450 protected void importAgents(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
, boolean success
){
1452 logger
.info("start Agents ...");
1453 Element elAgents
= elDataset
.getChild("Agents",sddNamespace
);
1454 if (elAgents
!= null) {
1456 List
<Element
> listAgents
= elAgents
.getChildren("Agent", sddNamespace
);
1459 for (Element elAgent
: listAgents
){
1463 String idA
= elAgent
.getAttributeValue("id");
1466 // <Label>Kevin Thiele</Label>
1467 // <Detail role="Description">Ali Baba is also known as r.a.m.</Detail>
1468 // </Representation>
1469 Person person
= Person
.NewInstance();
1470 importRepresentation(elAgent
, sddNamespace
, person
, idA
, sddConfig
);
1471 person
.addSource(IdentifiableSource
.NewInstance(idA
, "Agent"));
1474 Element elLinks = elAgent.getChild("Links",sddNamespace);
1476 if (elLinks != null) {
1478 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
1479 List<Element> listLinks = elLinks.getChildren("Link", sddNamespace);
1482 for (Element elLink : listLinks){
1486 String rel = elLink.getAttributeValue("rel");
1487 String href = elLink.getAttributeValue("href");
1489 Media link = Media.NewInstance();
1490 MediaRepresentation mr = MediaRepresentation.NewInstance();
1491 mr.addRepresentationPart(MediaRepresentationPart.NewInstance(href, null));
1492 link.addRepresentation(mr);
1493 person.addMedia(link);
1495 } catch (Exception e) {
1497 logger.warn("Import of Link " + k + " failed.");
1501 if ((++k % modCount) == 0){ logger.info("Links handled: " + k);}
1506 if (authors
.containsKey(idA
)) {
1507 authors
.put(idA
,person
);
1510 if (editors
.containsKey(idA
)) {
1511 editors
.put(idA
, person
);
1514 } catch (Exception e
) {
1516 logger
.warn("Import of Agent " + j
+ " failed.");
1520 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
1526 // imports publications related with the data set
1527 protected void importPublications(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
, boolean success
){
1529 <Publication id="p112">
1531 <Label>Gee, X. & Haa, Y. (2003). How to be happy in five minutes. Instant Gratifications, Palm Beach.</Label>
1534 <Link rel="BasedOn" href="doi:10.1992/32311"/>
1535 <Link rel="Alternate" href="http://some.service.net/providing/bibliographic.data"/>
1539 logger
.info("start Publications ...");
1540 Element elPublications
= elDataset
.getChild("Publications",sddNamespace
);
1542 if (elPublications
!= null) {
1543 List
<Element
> listPublications
= elPublications
.getChildren("Publication", sddNamespace
);
1545 for (Element elPublication
: listPublications
){
1549 String idP
= elPublication
.getAttributeValue("id");
1550 Reference publication
= ReferenceFactory
.newArticle();
1551 importRepresentation(elPublication
, sddNamespace
, publication
, idP
, sddConfig
);
1553 publications
.put(idP
,publication
);
1555 } catch (Exception e
) {
1556 logger
.warn("Import of Publication " + j
+ " failed.");
1560 if ((++j
% modCount
) == 0){ logger
.info("Publications handled: " + j
);}
1566 // imports media objects such as images //FIXME check mediaobj
1567 protected void importMediaObjects(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
, boolean success
){
1569 logger
.info("start MediaObjects ...");
1570 Element elMediaObjects
= elDataset
.getChild("MediaObjects",sddNamespace
);
1572 if (elMediaObjects
!= null) {
1573 // <MediaObject id="m1">
1574 List
<Element
> listMediaObjects
= elMediaObjects
.getChildren("MediaObject", sddNamespace
);
1576 for (Element elMO
: listMediaObjects
){
1581 String idMO
= elMO
.getAttributeValue("id");
1585 // <Label>Image description, e.g. to be used for alt-attribute in html.</Label>
1586 // </Representation>
1587 Media media
= Media
.NewInstance();
1588 importRepresentation(elMO
, sddNamespace
, media
, idMO
, sddConfig
);
1590 // <Type>Image</Type>
1591 // <Source href="http://test.edu/test.jpg"/>
1592 String type
= (String
)ImportHelper
.getXmlInputValue(elMO
,"Type",sddNamespace
);
1594 if ((type
!= null) && (type
.equals("Image"))) {
1595 Element elSource
= elMO
.getChild("Source",sddNamespace
);
1596 String href
= elSource
.getAttributeValue("href");
1598 ImageMetaData imageMetaData
= ImageMetaData
.newInstance();
1599 ImageFile image
= null;
1600 if (href
.substring(0,7).equals("http://")) {
1602 URL url
= new URL(href
);
1604 imageMetaData
.readMetaData(url
.toURI(), 0);
1605 image
= ImageFile
.NewInstance(url
.toURI(), null, imageMetaData
);
1606 } catch (MalformedURLException e
) {
1607 logger
.error("Malformed URL", e
);
1610 String sns
= sddConfig
.getSourceNameString();
1611 File f
= new File(sns
);
1612 File parent
= f
.getParentFile();
1613 String fi
= parent
.toString() + File
.separator
+ href
;
1614 File file
= new File(fi
);
1615 imageMetaData
.readMetaData(new URI(fi
), 0); //file
1616 image
= ImageFile
.NewInstance(file
.toURI(), null, imageMetaData
);
1618 MediaRepresentation representation
= MediaRepresentation
.NewInstance(imageMetaData
.getMimeType(), null);
1619 representation
.addRepresentationPart(image
);
1621 media
.addRepresentation(representation
);
1623 ArrayList
<CdmBase
> lcb
= (ArrayList
<CdmBase
>) mediaObject_ListCdmBase
.get(idMO
);
1625 for (int k
= 0; k
< lcb
.size(); k
++) {
1626 if (lcb
.get(k
) instanceof DefinedTermBase
) {
1627 DefinedTermBase dtb
= (DefinedTermBase
) lcb
.get(k
);
1628 // if (lcb.get(0) instanceof DefinedTermBase) {
1629 // DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1632 dtb
.addMedia(media
);
1633 //System.out.println(dtb.getLabel());
1635 // Media me = (Media) media.clone();
1636 // dtb.addMedia(me);
1639 } else if (lcb
.get(k
) instanceof Reference
) {
1640 Reference rb
= (Reference
) lcb
.get(k
);
1641 //} else if (lcb.get(0) instanceof Reference) {
1642 //Reference rb = (Reference) lcb.get(0);
1643 // rb.setTitleCache(label);
1647 //System.out.println(rb.getTitle());
1649 // Media me = (Media) media.clone();
1653 }/* else if (lcb.get(k) instanceof TaxonNameBase){
1654 TaxonNameBase tb = (TaxonNameBase) lcb.get(k);
1661 } catch (Exception e
) {
1663 logger
.warn("Could not attach MediaObject " + j
+ "(SDD: " + id
+ ") to several objects.");
1667 if ((++j
% modCount
) == 0){ logger
.info("MediaObjects handled: " + j
);
1674 // imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves
1675 // but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker
1676 protected void importDescriptiveConcepts(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
1677 /* <DescriptiveConcepts>
1678 <DescriptiveConcept id="dc0">
1680 <Label>Fixed set of modifiers supported in Lucid3</Label>
1683 <Modifier id="mod1">
1685 <Label>rarely</Label>
1687 <ModifierClass>Frequency</ModifierClass>
1688 <ProportionRange lowerestimate="0.0" upperestimate="0.25"/>
1691 </DescriptiveConcept>
1692 </DescriptiveConcepts>
1694 logger
.info("start DescriptiveConcepts ...");
1695 Element elDescriptiveConcepts
= elDataset
.getChild("DescriptiveConcepts",sddNamespace
);
1696 if (elDescriptiveConcepts
!= null) {
1697 List
<Element
> listDescriptiveConcepts
= elDescriptiveConcepts
.getChildren("DescriptiveConcept", sddNamespace
);
1700 for (Element elDescriptiveConcept
: listDescriptiveConcepts
){
1702 String id
= elDescriptiveConcept
.getAttributeValue("id");
1703 Feature feature
= Feature
.NewInstance();
1704 feature
.setKindOf(Feature
.DESCRIPTION());
1705 if (!id
.equals("")) {
1707 // <Label>Body</Label>
1708 importRepresentation(elDescriptiveConcept
, sddNamespace
, feature
, id
, sddConfig
);
1709 features
.put(id
, feature
);
1710 getTermService().save(feature
);//XIM
1711 descriptiveConcepts
.add(feature
);
1712 // imports the modifiers
1713 Element elModifiers
= elDescriptiveConcept
.getChild("Modifiers", sddNamespace
);
1714 if (elModifiers
!=null){
1715 List
<Element
> listModifiers
= elModifiers
.getChildren("Modifier", sddNamespace
);
1716 TermVocabulary
<Modifier
> termVocabularyState
= new TermVocabulary
<Modifier
>();
1717 for (Element elModifier
: listModifiers
) {
1718 Modifier modif
= Modifier
.NewInstance();
1719 String idmod
= elModifier
.getAttributeValue("id");
1720 importRepresentation(elModifier
, sddNamespace
, modif
, idmod
, sddConfig
);
1721 termVocabularyState
.addTerm(modif
);
1722 //termVocabularyStates.add(termVocabularyState);
1723 getVocabularyService().save(termVocabularyState
);//XIM
1724 modifiers
.put(idmod
, modif
);
1726 feature
.addRecommendedModifierEnumeration(termVocabularyState
);
1731 catch (Exception e
) {
1732 logger
.warn("Import of DescriptiveConcept " + j
+ " failed: " + e
.getMessage());
1734 if ((++j
% modCount
) == 0){ logger
.info("DescriptiveConcepts handled: " + j
);}
1740 // imports the <CharacterTrees> block
1741 protected void importCharacterTrees(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
, boolean success
){
1743 logger
.info("start CharacterTrees ...");
1744 Element elCharacterTrees
= elDataset
.getChild("CharacterTrees",sddNamespace
);
1746 if (elCharacterTrees
!= null) {
1747 List
<Element
> listCharacterTrees
= elCharacterTrees
.getChildren("CharacterTree", sddNamespace
);
1749 for (Element elCharacterTree
: listCharacterTrees
){
1751 Element elRepresentation
= elCharacterTree
.getChild("Representation",sddNamespace
);
1752 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1753 //Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ?
1755 FeatureTree featureTree
= FeatureTree
.NewInstance();
1756 importRepresentation(elCharacterTree
, sddNamespace
, featureTree
, "", sddConfig
);
1757 FeatureNode root
= featureTree
.getRoot();
1758 List
<Element
> listeOfNodes
= elCharacterTree
.getChildren("Nodes", sddNamespace
);
1760 //Nodes of CharacterTrees in SDD always refer to DescriptiveConcepts
1761 for (Element elNodes
: listeOfNodes
) {
1762 handleCharacterNodes(sddNamespace
, root
, elNodes
);
1764 featureTrees
.add(featureTree
);
1765 if (workingSet
.getDescriptiveSystem() != null){
1766 //TODO how to handle multiple
1767 logger
.warn("Multiple feature trees not yet supported");
1769 workingSet
.setDescriptiveSystem(featureTree
);
1773 catch (Exception e
) {
1774 logger
.warn("Import of Character tree " + j
+ " failed.");
1777 if ((++j
% modCount
) == 0){ logger
.info("CharacterTrees handled: " + j
);}
1785 * @param sddNamespace
1789 private void handleCharacterNodes(Namespace sddNamespace
, FeatureNode root
, Element elNodes
) {
1790 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1791 if (listNodes
!= null) {
1792 for (Element elNode
: listNodes
){
1793 String idN
= elNode
.getAttributeValue("id");
1794 FeatureNode fn
= null;
1797 // DescriptiveConcepts are used as nodes in CharacterTrees
1798 Element elDescriptiveConcept
= elNode
.getChild("DescriptiveConcept", sddNamespace
);
1799 if (elDescriptiveConcept
!= null){
1800 String refDC
= elDescriptiveConcept
.getAttributeValue("ref");
1801 dc
= features
.get(refDC
);
1802 fn
= FeatureNode
.NewInstance(dc
);
1805 fn
= FeatureNode
.NewInstance();
1807 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1808 // in SDD links between Nodes are referenced by the <Parent> tag
1809 if (elParent
!=null){
1810 String refP
= elParent
.getAttributeValue("ref");
1812 FeatureNode parent
= featureNodes
.get(refP
);
1814 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1817 parent
.addChild(fn
);
1822 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1825 featureNodes
.put(idN
, fn
);
1829 // Leaves of CharacterTrees in SDD are always CharNodes (referring to Characters)
1830 List
<Element
> listCharNodes
= elNodes
.getChildren("CharNode", sddNamespace
);
1831 if (listCharNodes
!= null) {
1832 for (Element elCharNode
: listCharNodes
){
1833 Element elParent
= elCharNode
.getChild("Parent", sddNamespace
);
1834 Element elCharacter
= elCharNode
.getChild("Character", sddNamespace
);
1835 Element elDependencyRules
= elCharNode
.getChild("DependencyRules", sddNamespace
);
1836 FeatureNode fn
= FeatureNode
.NewInstance();
1838 if (elDependencyRules
!=null){
1839 Element elInapplicableIf
= elCharNode
.getChild("InapplicableIf", sddNamespace
);
1840 if (elInapplicableIf
!=null){
1841 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1842 for (Element stateElement
: listStates
) {
1843 String refState
= stateElement
.getAttributeValue("ref");
1844 if ((refState
!=null)&&(!refState
.equals(""))) {
1845 State state
= states
.get(refState
);
1846 fn
.addInapplicableState(state
);
1850 Element elOnlyapplicableIf
= elCharNode
.getChild("OnlyApplicableIf", sddNamespace
);
1851 if (elOnlyapplicableIf
!=null){
1852 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1853 for (Element stateElement
: listStates
) {
1854 String refState
= stateElement
.getAttributeValue("ref");
1855 if ((refState
!=null)&&(!refState
.equals(""))) {
1856 State state
= states
.get(refState
);
1857 fn
.addApplicableState(state
);
1863 if (elParent
!=null){
1864 String refP
= elParent
.getAttributeValue("ref");
1865 if ((refP
!=null)&&(!refP
.equals(""))) {
1866 FeatureNode parent
= featureNodes
.get(refP
);
1868 parent
= root
; // if no parent found or the reference is broken, add the node to the root of the tree
1870 parent
.addChild(fn
);
1873 String refC
= elCharacter
.getAttributeValue("ref");
1874 if ((refC
!=null)&&(!refC
.equals(""))){
1875 Feature character
= features
.get(refC
);
1876 fn
.setFeature(character
);
1877 featureNodes
.put(refC
, fn
);
1883 // imports the <TaxonHierarchies> block
1884 protected void importTaxonHierarchies(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
, boolean success
){
1886 logger
.info("start TaxonHierarchies ...");
1887 Element elTaxonHierarchies
= elDataset
.getChild("TaxonHierarchies",sddNamespace
);
1889 if (elTaxonHierarchies
!= null) {
1890 List
<Element
> listTaxonHierarchies
= elTaxonHierarchies
.getChildren("TaxonHierarchy", sddNamespace
);
1892 for (Element elTaxonHierarchy
: listTaxonHierarchies
){
1894 Element elRepresentation
= elTaxonHierarchy
.getChild("Representation",sddNamespace
);
1895 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1896 Classification classification
= Classification
.NewInstance(label
);
1897 importRepresentation(elTaxonHierarchy
, sddNamespace
, classification
, "", sddConfig
);
1899 Set
<TaxonNode
> root
= classification
.getChildNodes();
1900 Element elNodes
= elTaxonHierarchy
.getChild("Nodes", sddNamespace
); // There can be only one <Nodes> block for TaxonHierarchies
1901 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1903 for (Element elNode
: listNodes
){
1904 String idN
= elNode
.getAttributeValue("id");
1905 TaxonNameBase tnb
= null;
1906 if (!idN
.equals("")) {
1907 Element elTaxonName
= elNode
.getChild("TaxonName", sddNamespace
);
1908 String refTN
= elTaxonName
.getAttributeValue("ref");
1909 tnb
= taxonNameBases
.get(refTN
);
1910 Taxon taxon
= (Taxon
) tnb
.getTaxa().iterator().next() ;
1911 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1912 if (elParent
!=null){
1913 String refP
= elParent
.getAttributeValue("ref");
1914 if (!refP
.equals("")) {
1915 TaxonNode parent
= taxonNodes
.get(refP
);
1916 TaxonNode child
= parent
.addChildTaxon(taxon
, sec
, "", Synonym
.NewInstance(tnb
, sec
));
1917 taxonNodes
.put(idN
,child
);
1921 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
1922 taxonNodes
.put(idN
,tn
);
1927 classifications
.add(classification
);
1930 catch (Exception e
) {
1932 logger
.warn("Import of Taxon Hierarchy " + j
+ " failed.");
1936 if ((++j
% modCount
) == 0){ logger
.info("TaxonHierarchies handled: " + j
);}
1944 // imports the <GeographicAreas> block
1945 protected void importGeographicAreas(Element elDataset
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
) {
1946 Element elGeographicAreas
= elDataset
.getChild("GeographicAreas",sddNamespace
);
1947 if (elGeographicAreas
!= null) {
1948 List
<Element
> listGeographicAreas
= elGeographicAreas
.getChildren("GeographicArea", sddNamespace
);
1951 for (Element elGeographicArea
: listGeographicAreas
){
1953 String id
= elGeographicArea
.getAttributeValue("id");
1954 NamedArea na
= new NamedArea();
1955 importRepresentation(elGeographicArea
, sddNamespace
, na
, id
, sddConfig
);
1956 namedAreas
.put(id
,na
);
1958 if ((++j
% modCount
) == 0){ logger
.info("GeographicAreas handled: " + j
);}