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
.media
.ImageInfo
;
35 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
36 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
37 import eu
.etaxonomy
.cdm
.io
.common
.CdmImportBase
;
38 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ICdmImport
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
41 import eu
.etaxonomy
.cdm
.io
.sdd
.SDDTransformer
;
42 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
43 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
44 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
45 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
46 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
47 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
48 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
49 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
50 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
51 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
52 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
53 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
54 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
55 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
56 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
57 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
58 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
59 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
60 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
61 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
62 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
63 import eu
.etaxonomy
.cdm
.model
.description
.Modifier
;
64 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
65 import eu
.etaxonomy
.cdm
.model
.description
.State
;
66 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
67 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
68 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
69 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
70 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
71 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
72 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
73 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
74 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
75 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
76 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
77 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentationPart
;
78 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
79 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
80 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
81 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
82 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
83 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
84 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
85 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
86 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
87 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
90 * This class is not used yet. It is meant for refactoring the SDD import.
97 public class SDDDataSetImport
extends CdmImportBase
<SDDImportConfigurator
, SDDImportState
> implements ICdmImport
<SDDImportConfigurator
, SDDImportState
> {
98 private static final Logger logger
= Logger
.getLogger(SDDDataSetImport
.class);
100 private static int modCount
= 1000;
102 private Map
<String
,Person
> authors
= new HashMap
<String
,Person
>();
103 private Map
<String
,String
> citations
= new HashMap
<String
,String
>();
104 private Map
<String
,String
> defaultUnitPrefixes
= new HashMap
<String
,String
>();
105 private Map
<String
,Person
> editors
= new HashMap
<String
,Person
>();
106 private Map
<String
,FeatureNode
> featureNodes
= new HashMap
<String
,FeatureNode
>();
107 private Map
<String
,Feature
> features
= new HashMap
<String
,Feature
>();
108 private Map
<String
,String
> locations
= new HashMap
<String
,String
>();
109 private Map
<String
,List
<CdmBase
>> mediaObject_ListCdmBase
= new HashMap
<String
,List
<CdmBase
>>();
110 private Map
<String
,String
> mediaObject_Role
= new HashMap
<String
,String
>();
111 private Map
<String
,Reference
> publications
= new HashMap
<String
,Reference
>();
112 private Map
<String
,State
> states
= new HashMap
<String
,State
>();
113 private Map
<String
,TaxonDescription
> taxonDescriptions
= new HashMap
<String
,TaxonDescription
>();
114 private Map
<String
,NonViralName
> taxonNameBases
= new HashMap
<String
,NonViralName
>();
115 private Map
<String
,MeasurementUnit
> units
= new HashMap
<String
,MeasurementUnit
>();
116 private Map
<String
,TaxonNode
> taxonNodes
= new HashMap
<String
,TaxonNode
>();
117 private Map
<String
,NamedArea
> namedAreas
= new HashMap
<String
,NamedArea
>();
118 private Map
<String
,Specimen
> specimens
= new HashMap
<String
,Specimen
>();
119 private Map
<String
,Modifier
> modifiers
= new HashMap
<String
,Modifier
>();
121 private Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
122 private Set
<TermVocabulary
> vocabularies
= new HashSet
<TermVocabulary
>();
124 private Set
<Feature
> descriptiveConcepts
= new HashSet
<Feature
>();
125 private Set
<AnnotationType
> annotationTypes
= new HashSet
<AnnotationType
>();
126 // private Set<Feature> featureSet = new HashSet<Feature>();
127 private Set
<Reference
> sources
= new HashSet
<Reference
>();
128 private Reference sec
= ReferenceFactory
.newDatabase();
129 private Reference sourceReference
= null;
131 private Language datasetLanguage
= null;
132 private WorkingSet workingSet
= null;
134 private Namespace xmlNamespace
= Namespace
.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
136 private String generatorName
= "";
137 private String generatorVersion
= "";
140 private Set
<StatisticalMeasure
> statisticalMeasures
= new HashSet
<StatisticalMeasure
>();
141 private Set
<VersionableEntity
> featureData
= new HashSet
<VersionableEntity
>();
142 private Set
<FeatureTree
> featureTrees
= new HashSet
<FeatureTree
>();
143 private Set
<Classification
> classifications
= new HashSet
<Classification
>();
145 private Rights copyright
= null;
147 private int taxonNamesCount
= 0;
149 protected Class
<ICdmIO
>[] ioClassList
;
151 public SDDDataSetImport(){
155 protected void makeIoClassList(){
156 ioClassList
= new Class
[]{
162 public boolean doCheck(SDDImportState state
){
163 boolean result
= true;
166 // for (Class<ICdmIO> ioClass: ioClassList){
168 // String ioBeanName = CdmApplicationAwareDefaultImport.getComponentBeanName(ioClass);
169 // ICdmIO cdmIo = (ICdmIO)getTermService().getBean(ioBeanName, ICdmIO.class);
170 // if (cdmIo != null){
171 //// result &= cdmIo.invoke(config, stores);
172 // state.setCurrentIO(cdmIo);
173 // result &= cdmIo.invoke(state);
175 // logger.error("cdmIO was null");
178 // } catch (Exception e) {
180 // e.printStackTrace();
184 logger
.warn("No check implemented for SDD");
189 // public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){
191 public void doInvoke(SDDImportState state
){
193 TransactionStatus ts
= startTransaction();
194 SDDImportConfigurator sddConfig
= state
.getConfig();
195 IProgressMonitor progressMonitor
= sddConfig
.getProgressMonitor();
197 logger
.info("start Datasets ...");
199 // <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">
200 Element root
= sddConfig
.getSourceRoot();
201 Namespace sddNamespace
= sddConfig
.getSddNamespace();
203 logger
.info("start TechnicalMetadata ...");
204 // <TechnicalMetadata created="2006-04-20T10:00:00">
205 importTechnicalMetadata(root
, sddNamespace
, sddConfig
);
206 List
<Element
> elDatasets
= root
.getChildren("Dataset",sddNamespace
);
210 logger
.info("start Dataset ...");
211 progressMonitor
.beginTask("Importing SDD data", elDatasets
.size());
212 for (Element elDataset
: elDatasets
){
213 importDataset(elDataset
, sddNamespace
, state
);
214 // if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);}
215 // logger.info(i + " dataset(s) handled");
216 progressMonitor
.worked(1);
218 commitTransaction(ts
);
219 progressMonitor
.done();
220 logger
.info("End of transaction");
225 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
227 protected boolean isIgnore(SDDImportState state
){
232 // associates the reference of a media object in SDD with a CdmBase Object
233 protected void associateImageWithCdmBase(String refMO
, CdmBase cb
){
234 if ((refMO
!= null) && (cb
!=null)) {
235 if (! refMO
.equals("")) {
236 if (! mediaObject_ListCdmBase
.containsKey(refMO
)) {
237 List
<CdmBase
> lcb
= new ArrayList
<CdmBase
>();
239 mediaObject_ListCdmBase
.put(refMO
,lcb
);
241 List
<CdmBase
> lcb
= mediaObject_ListCdmBase
.get(refMO
);
243 mediaObject_ListCdmBase
.put(refMO
,lcb
);
249 // imports information about the Dataset
250 protected void importDatasetRepresentation(Element parent
, Namespace sddNamespace
){
251 logger
.info("start Representation ...");
253 <Label>The Genus Viola</Label>
254 <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>
260 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
261 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
);
262 String detail
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Detail",sddNamespace
);
265 Representation representation
= Representation
.NewInstance(detail
, label
, null, datasetLanguage
);
266 workingSet
.addRepresentation(representation
);
270 // sec.setTitleCache(label, true);
272 // if (detail != null) {
273 // Annotation annotation = Annotation.NewInstance(detail, datasetLanguage);
274 // annotation.setAnnotationType(AnnotationType.EDITORIAL());
275 // sec.addAnnotation(annotation);
279 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject",sddNamespace
);
281 for (Element elMediaObject
: listMediaObjects
) {
284 if (elMediaObject
!= null) {
285 ref
= elMediaObject
.getAttributeValue("ref");
286 role
= elMediaObject
.getAttributeValue("role");
289 if (!ref
.equals("")) {
290 this.associateImageWithCdmBase(ref
,sourceReference
);
291 this.associateImageWithCdmBase(ref
,sec
);
292 mediaObject_Role
.put(ref
,role
);
298 // imports the representation (label, detail, lang) of a particular SDD element
299 protected void importRepresentation(Element parent
, Namespace sddNamespace
, VersionableEntity ve
, String id
, SDDImportState state
){
300 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
302 Map
<Language
,List
<String
>> langLabDet
= new HashMap
<Language
,List
<String
>>();
304 handleRepresentationLabels(sddNamespace
, elRepresentation
, langLabDet
);
305 handleRepresentationDetails(sddNamespace
, elRepresentation
, langLabDet
);
307 if (ve
instanceof TermBase
) {
308 makeRepresentationForTerms((TermBase
)ve
, langLabDet
);
309 }else if (ve
instanceof Media
) {
310 makeRepresentationForMedia((Media
)ve
, langLabDet
);
311 }else if (ve
instanceof IdentifiableEntity
<?
>) {
312 IdentifiableEntity
<?
> ie
= (IdentifiableEntity
<?
>)ve
;
313 makeRepresentationForIdentifiableEntity(sddNamespace
, ie
, elRepresentation
, langLabDet
);
314 if (ve
instanceof IdentifiableMediaEntity
<?
>){
315 makeRepresentationForIdentifiableMediaEntity(parent
, sddNamespace
, (IdentifiableMediaEntity
<?
>)ve
);
319 makeRepresentationMediaObjects(sddNamespace
, ve
, elRepresentation
);//FIXME
325 * Handles the "Detail" children of representations. Adds the result to the langLabDet.
326 * @param sddNamespace
327 * @param elRepresentation
330 private void handleRepresentationDetails(Namespace sddNamespace
,
331 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
332 List
<Element
> listDetails
= elRepresentation
.getChildren("Detail",sddNamespace
);
333 for (Element elDetail
: listDetails
){
334 Language language
= getLanguage(elDetail
);
335 String role
= elDetail
.getAttributeValue("role");
336 String detail
= elDetail
.getText();
337 List
<String
> labDet
= langLabDet
.get(language
);
340 langLabDet
.put(language
, labDet
);
345 * Handles the "Label" children of representations. Adds the result to the langLabDet.
346 * @param sddNamespace
347 * @param elRepresentation
350 private void handleRepresentationLabels(Namespace sddNamespace
,
351 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
352 // <Label xml:lang="la">Viola hederacea Labill.</Label>
353 List
<Element
> listLabels
= elRepresentation
.getChildren("Label",sddNamespace
);
354 for (Element elLabel
: listLabels
){
355 Language language
= getLanguage(elLabel
);
356 String label
= elLabel
.getText();
357 List
<String
> labDet
= new ArrayList
<String
>(3);
359 langLabDet
.put(language
, labDet
);
368 private void makeRepresentationForMedia(Media m
, Map
<Language
, List
<String
>> langLabDet
) {
369 for (Language lang
: langLabDet
.keySet()){
370 List
<String
> labDet
= langLabDet
.get(lang
);
371 if (labDet
.get(0) != null){
372 m
.putTitle(LanguageString
.NewInstance(labDet
.get(0), lang
));
374 if (labDet
.size()>1) {
375 m
.addDescription(labDet
.get(1), lang
);
381 * Handles representations for terms. Adds one representation per language in langLabDet.
386 private void makeRepresentationForTerms(TermBase tb
, Map
<Language
, List
<String
>> langLabDet
) {
387 for (Language lang
: langLabDet
.keySet()){
388 List
<String
> labDet
= langLabDet
.get(lang
);
389 if (labDet
.size()>0){
390 if (labDet
.size()>1) {
391 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(1), labDet
.get(0), labDet
.get(0), lang
));
393 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(0), labDet
.get(0), labDet
.get(0), lang
));
401 * Handles the "MediaObject" children of representations.
402 * @param sddNamespace
404 * @param elRepresentation
406 private void makeRepresentationMediaObjects(Namespace sddNamespace
, VersionableEntity ve
, Element elRepresentation
) {
407 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject", sddNamespace
);
408 for (Element elMediaObject
: listMediaObjects
) {
412 if (elMediaObject
!= null) {
413 ref
= elMediaObject
.getAttributeValue("ref");
414 role
= elMediaObject
.getAttributeValue("role");
416 if (StringUtils
.isNotBlank(ref
)) {
417 if (ve
instanceof TaxonDescription
) {
418 TaxonDescription td
= (TaxonDescription
) ve
;
419 if (td
.getSources().size() > 0) {
420 this.associateImageWithCdmBase(ref
, td
.getSources().iterator().next().getCitation());
422 Reference
<?
> descriptionSource
= ReferenceFactory
.newGeneric();
423 sources
.add(descriptionSource
);
424 td
.addSource(null, null, descriptionSource
, null);
425 this.associateImageWithCdmBase(ref
,descriptionSource
);
428 this.associateImageWithCdmBase(ref
,ve
);
435 * Handles the "Links" element
437 * @param sddNamespace
440 private void makeRepresentationForIdentifiableMediaEntity(Element parent
,
441 Namespace sddNamespace
, IdentifiableMediaEntity ime
) {
442 Element elLinks
= parent
.getChild("Links",sddNamespace
);
444 if (elLinks
!= null) {
446 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
447 List
<Element
> listLinks
= elLinks
.getChildren("Link", sddNamespace
);
448 Media link
= Media
.NewInstance();
449 MediaRepresentation mr
= MediaRepresentation
.NewInstance();
452 for (Element elLink
: listLinks
){
456 String rel
= elLink
.getAttributeValue("rel");
457 String href
= elLink
.getAttributeValue("href");
458 URI uri
= new URI(href
);
459 mr
.addRepresentationPart(MediaRepresentationPart
.NewInstance(uri
, null));
460 link
.addRepresentation(mr
);
463 } catch (Exception e
) {
465 logger
.warn("Import of Link " + k
+ " failed.");
468 if ((++k
% modCount
) == 0){ logger
.info("Links handled: " + k
);}
475 * @param sddNamespace
477 * @param elRepresentation
481 private void makeRepresentationForIdentifiableEntity(Namespace sddNamespace
, IdentifiableEntity
<?
> ie
,
482 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
483 List
<String
> labDet
= null;
485 if (ie
instanceof TaxonNameBase
) {
486 if (langLabDet
.keySet().contains(getTermService().getLanguageByIso("la"))) {
487 labDet
= langLabDet
.get(getTermService().getLanguageByIso("la"));
488 } else if (langLabDet
.keySet().contains(datasetLanguage
)) {
489 labDet
= langLabDet
.get(datasetLanguage
);
490 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
492 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
493 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
496 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
499 //FIXME labDet is != null only for TaxonNameBase
500 ie
.setTitleCache(labDet
.get(0), true);
502 if (labDet
.size()>1) {
503 Annotation annotation
= null;
504 if (labDet
.get(1) != null) {
505 if (labDet
.get(2) != null) {
506 annotation
= Annotation
.NewInstance(labDet
.get(2) + " - " + labDet
.get(1), datasetLanguage
);
508 annotation
= Annotation
.NewInstance(labDet
.get(1), datasetLanguage
);
511 ie
.addAnnotation(annotation
);
520 private Language
getLanguage(Element elLanguage
) {
521 String lang
= elLanguage
.getAttributeValue("lang",xmlNamespace
);
522 Language language
= null;
523 if (StringUtils
.isNotBlank(lang
)) {
524 language
= getTermService().getLanguageByIso(lang
.substring(0, 2));
526 language
= datasetLanguage
;
532 // imports the representation (label, detail, lang) of a particular SDD element
533 protected void importTechnicalMetadata(Element root
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
534 Element elTechnicalMetadata
= root
.getChild("TechnicalMetadata", sddNamespace
);
535 String nameCreated
= elTechnicalMetadata
.getAttributeValue("created");
536 sourceReference
= sddConfig
.getSourceReference();
538 if (nameCreated
!= null) {
539 if (!nameCreated
.equals("")) {
540 int year
= Integer
.parseInt(nameCreated
.substring(0,4));
541 int monthOfYear
= Integer
.parseInt(nameCreated
.substring(5,7));
542 int dayOfMonth
= Integer
.parseInt(nameCreated
.substring(8,10));
543 int hourOfDay
= Integer
.parseInt(nameCreated
.substring(11,13));
544 int minuteOfHour
= Integer
.parseInt(nameCreated
.substring(14,16));
545 int secondOfMinute
= Integer
.parseInt(nameCreated
.substring(17,19));
546 DateTime created
= new DateTime(year
,monthOfYear
,dayOfMonth
,hourOfDay
,minuteOfHour
,secondOfMinute
,0);
547 sourceReference
.setCreated(created
);
548 sec
.setCreated(created
);
552 // <Generator name="n/a, handcrafted instance document" version="n/a"/>
553 Element elGenerator
= elTechnicalMetadata
.getChild("Generator", sddNamespace
);
554 generatorName
= elGenerator
.getAttributeValue("name");
555 generatorVersion
= elGenerator
.getAttributeValue("version");
557 sec
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
558 sourceReference
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
562 // imports the complete dataset information
563 protected void importDataset(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){ // <Dataset xml:lang="en-us">
564 // SDDImportConfigurator sddConfig = state.getConfig();
566 workingSet
= WorkingSet
.NewInstance();
567 importDatasetLanguage(elDataset
,state
);
568 importDatasetRepresentation(elDataset
, sddNamespace
);
569 importRevisionData(elDataset
, sddNamespace
);
570 importIPRStatements(elDataset
, sddNamespace
, state
);
571 importTaxonNames(elDataset
, sddNamespace
, state
);
573 importDescriptiveConcepts(elDataset
, sddNamespace
, state
);
574 importCharacters(elDataset
, sddNamespace
, state
);
575 importCharacterTrees(elDataset
, sddNamespace
, state
);
577 MarkerType editorMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerEditor
, "editor", "Editor", "edt");
578 MarkerType geographicAreaMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerSDDGeographicArea
, "SDDGeographicArea", "SDDGeographicArea", "ga");
579 MarkerType descriptiveConceptMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerDescriptiveConcept
, "DescriptiveConcept", "Descriptive Concept", "DC");
580 markerTypes
.add(editorMarkerType
);
581 markerTypes
.add(geographicAreaMarkerType
);
582 markerTypes
.add(descriptiveConceptMarkerType
);
584 //saving of all imported data into the CDM db
590 saveAreas(geographicAreaMarkerType
);
592 saveStatisticalMeasure();
593 saveAnnotationType();
595 importCodedDescriptions(elDataset
, sddNamespace
, state
);
596 importAgents(elDataset
, sddNamespace
, state
);
597 importPublications(elDataset
, sddNamespace
, state
);
598 importMediaObjects(elDataset
, sddNamespace
, state
);
599 importTaxonHierarchies(elDataset
, sddNamespace
, state
);
600 importGeographicAreas(elDataset
, sddNamespace
, state
);
601 importSpecimens(elDataset
,sddNamespace
, state
);
604 if ((authors
!= null)||(editors
!= null)) {
605 Team team
= Team
.NewInstance();
606 if (authors
!= null) {
607 for (Person author
: authors
.values()){
608 team
.addTeamMember(author
);
611 if (editors
!= null) {
612 Marker marker
= Marker
.NewInstance();
613 marker
.setMarkerType(editorMarkerType
);
614 for (Person editor
: editors
.values()){
615 Person edit
= editor
;
616 edit
.addMarker(marker
);
617 team
.addTeamMember(edit
);
620 sec
.setAuthorTeam(team
);
621 sourceReference
.setAuthorTeam(team
);
624 if (copyright
!= null) {
625 sourceReference
.addRights(copyright
);
626 sec
.addRights(copyright
);
629 // Returns a CdmApplicationController created by the values of this configuration.
630 IDescriptionService descriptionService
= getDescriptionService();
632 for (TaxonDescription taxonDescription
: taxonDescriptions
.values()){
633 // Persists a Description
634 descriptionService
.save(taxonDescription
);
637 for (String ref
: taxonDescriptions
.keySet()){
638 TaxonDescription td
= taxonDescriptions
.get(ref
);
639 if (citations
.containsKey(ref
)) {
640 Reference publication
= publications
.get(citations
.get(ref
));
641 if (locations
.containsKey(ref
)) {
642 Annotation location
= Annotation
.NewInstance(locations
.get(ref
), datasetLanguage
);
643 AnnotationType annotationType
= AnnotationType
.NewInstance("", "location", "");
644 annotationTypes
.add(annotationType
);
645 location
.setAnnotationType(annotationType
);
646 (publication
).addAnnotation(location
);
648 td
.addSource(null, null, publication
, null);
651 logger
.info("end makeTaxonDescriptions ...");
653 if (descriptiveConcepts
!= null) {
654 for (Feature feature
: descriptiveConcepts
) {
655 Marker marker
= Marker
.NewInstance();
656 marker
.setMarkerType(descriptiveConceptMarkerType
);
657 feature
.addMarker(marker
);
662 for (Reference publication
: publications
.values()){
663 getReferenceService().save(publication
);
666 for (Reference source
: sources
){
667 getReferenceService().save(source
);
670 for (FeatureTree featureTree
: featureTrees
) {
671 getFeatureTreeService().save(featureTree
);
673 getWorkingSetService().save(workingSet
);
674 for (Classification classification
: classifications
) {
675 getClassificationService().save(classification
);
677 for (Specimen specimen
: specimens
.values()) {
678 getOccurrenceService().save(specimen
);
680 logger
.info("end of persistence ...");
688 private void saveVocabularies() {
689 for (TermVocabulary vocabulary
: vocabularies
){
690 getVocabularyService().save(vocabulary
);
695 private void saveAnnotationType() {
696 for (AnnotationType annotationType
: annotationTypes
){
697 getTermService().save(annotationType
);
701 private void saveStatisticalMeasure() {
702 for (StatisticalMeasure sm
: statisticalMeasures
){
703 getTermService().save(sm
);
707 private void saveUnits() {
709 for (MeasurementUnit unit
: units
.values()){
711 getTermService().save(unit
);
717 private void saveAreas(MarkerType geographicAreaMarkerType
) {
718 for (NamedArea area
: namedAreas
.values() ){
719 Marker marker
= Marker
.NewInstance();
720 marker
.setMarkerType(geographicAreaMarkerType
);
721 area
.addMarker(marker
);
722 getTermService().save(area
);
726 private void saveStates() {
727 for (State state
: states
.values() ){
728 getTermService().save(state
);
732 private void saveMarkerType() {
733 for (MarkerType markerType
: markerTypes
){
734 getTermService().save(markerType
);
738 private void saveModifiers() {
739 for (Modifier modifier
: modifiers
.values() ){
740 getTermService().save(modifier
);
744 private void saveFeatures() {
745 for (Feature feature
: features
.values() ){
746 getTermService().save(feature
);
750 // imports the default language of the dataset
751 protected void importDatasetLanguage(Element elDataset
, SDDImportState state
){
752 String nameLang
= elDataset
.getAttributeValue("lang",xmlNamespace
);
754 if (StringUtils
.isNotBlank(nameLang
)) {
755 String iso
= nameLang
.substring(0, 2);
756 datasetLanguage
= getTermService().getLanguageByIso(iso
);
758 datasetLanguage
= Language
.DEFAULT();
760 if (datasetLanguage
== null) {
761 datasetLanguage
= Language
.DEFAULT();
765 // imports the specimens
766 protected void importSpecimens(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
767 logger
.info("start Specimens ...");
771 <Label>TJM45337</Label>
776 Element elSpecimens
= elDataset
.getChild("Specimens",sddNamespace
);
777 if (elSpecimens
!= null){
778 List
<Element
> listSpecimens
= elSpecimens
.getChildren("Specimen", sddNamespace
);
780 for (Element elSpecimen
: listSpecimens
) {
781 String id
= elSpecimen
.getAttributeValue("id");
782 Specimen specimen
= null;
783 if (!id
.equals("")) {
784 specimen
= Specimen
.NewInstance();
785 specimens
.put(id
,specimen
);
786 importRepresentation(elSpecimen
, sddNamespace
, specimen
, id
, cdmState
);
793 // imports the revision data associated with the Dataset (authors, modifications)
794 protected void importRevisionData(Element elDataset
, Namespace sddNamespace
){
796 logger
.info("start RevisionData ...");
797 Element elRevisionData
= elDataset
.getChild("RevisionData",sddNamespace
);
798 if (elRevisionData
!= null){
800 Element elCreators
= elRevisionData
.getChild("Creators",sddNamespace
);
802 // <Agent role="aut" ref="a1"/>
803 List
<Element
> listAgents
= elCreators
.getChildren("Agent", sddNamespace
);
807 for (Element elAgent
: listAgents
){
809 String role
= elAgent
.getAttributeValue("role");
810 String ref
= elAgent
.getAttributeValue("ref");
811 if (role
.equals("aut")) {
812 if(!ref
.equals("")) {
813 authors
.put(ref
, null);
816 if (role
.equals("edt")) {
817 if(!ref
.equals("")) {
818 editors
.put(ref
, null);
821 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
825 // <DateModified>2006-04-08T00:00:00</DateModified>
826 String stringDateModified
= (String
)ImportHelper
.getXmlInputValue(elRevisionData
, "DateModified",sddNamespace
);
828 if (stringDateModified
!= null) {
829 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
832 d
= sdf
.parse(stringDateModified
);
833 } catch(Exception e
) {
834 System
.err
.println("Exception :");
838 DateTime updated
= null;
840 updated
= new DateTime(d
);
841 sourceReference
.setUpdated(updated
);
842 sec
.setUpdated(updated
);
848 // imports ipr statements associated with a dataset
849 protected void importIPRStatements(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
851 logger
.info("start IPRStatements ...");
852 Element elIPRStatements
= elDataset
.getChild("IPRStatements",sddNamespace
);
853 // <IPRStatement role="Copyright">
854 if (elIPRStatements
!= null) {
855 List
<Element
> listIPRStatements
= elIPRStatements
.getChildren("IPRStatement", sddNamespace
);
857 //for each IPRStatement
859 for (Element elIPRStatement
: listIPRStatements
){
861 String role
= elIPRStatement
.getAttributeValue("role");
862 // <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
863 Element elLabel
= elIPRStatement
.getChild("Label",sddNamespace
);
865 if (elLabel
!= null) {
866 lang
= elLabel
.getAttributeValue("lang",xmlNamespace
);
868 String label
= (String
)ImportHelper
.getXmlInputValue(elIPRStatement
, "Label",sddNamespace
);
870 if (role
.equals("Copyright")) {
871 Language iprLanguage
= null;
873 if (!lang
.equals("")) {
874 iprLanguage
= getTermService().getLanguageByIso(lang
.substring(0, 2));
876 iprLanguage
= datasetLanguage
;
879 if (iprLanguage
== null) {
880 iprLanguage
= datasetLanguage
;
882 copyright
= Rights
.NewInstance(label
, iprLanguage
);
885 if (copyright
!= null) {
886 sourceReference
.addRights(copyright
);
887 sec
.addRights(copyright
);
890 if ((++j
% modCount
) == 0){ logger
.info("IPRStatements handled: " + j
);}
896 // imports the taxon names
897 protected void importTaxonNames(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
899 logger
.info("start TaxonNames ...");
900 Element elTaxonNames
= elDataset
.getChild("TaxonNames",sddNamespace
);
901 // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
902 if (elTaxonNames
!= null) {
903 List
<Element
> listTaxonNames
= elTaxonNames
.getChildren("TaxonName", sddNamespace
);
906 for (Element elTaxonName
: listTaxonNames
){
908 String id
= elTaxonName
.getAttributeValue("id");
909 String uri
= elTaxonName
.getAttributeValue("uri");
911 NonViralName tnb
= null;
912 if (!id
.equals("")) {
913 tnb
= NonViralName
.NewInstance(null);
914 IdentifiableSource source
= null;
916 if (!uri
.equals("")) {
917 source
= IdentifiableSource
.NewInstance(id
, "TaxonName", ReferenceFactory
.newGeneric(), uri
);
920 source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
922 tnb
.addSource(source
);
923 taxonNameBases
.put(id
,tnb
);
927 // <Label xml:lang="la">Viola hederacea Labill.</Label>
928 importRepresentation(elTaxonName
, sddNamespace
, tnb
, id
, cdmState
);
930 if ((++j
% modCount
) == 0){ logger
.info("TaxonNames handled: " + j
);}
936 // imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features
937 protected void importCharacters(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
939 logger
.info("start Characters ...");
940 Element elCharacters
= elDataset
.getChild("Characters", sddNamespace
);
942 // <CategoricalCharacter id="c1">
943 if (elCharacters
!= null) {
944 handleCategoricalData(sddNamespace
, state
, elCharacters
);
945 handleQuantitativeData(sddNamespace
, state
, elCharacters
);
946 handleTextCharacters(sddNamespace
, state
, elCharacters
);
949 /*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){
950 featureSet.add(f.next()); //XIM Why this line ?
958 * @param sddNamespace
960 * @param elCharacters
963 private void handleCategoricalData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
964 List
<Element
> elCategoricalCharacters
= elCharacters
.getChildren("CategoricalCharacter", sddNamespace
);
966 for (Element elCategoricalCharacter
: elCategoricalCharacters
){
969 String idCC
= elCategoricalCharacter
.getAttributeValue("id");
970 Feature categoricalCharacter
= Feature
.NewInstance();
971 categoricalCharacter
.setKindOf(Feature
.DESCRIPTION());
972 importRepresentation(elCategoricalCharacter
, sddNamespace
, categoricalCharacter
, idCC
, cdmState
);
973 categoricalCharacter
.setSupportsCategoricalData(true);
976 Element elStates
= elCategoricalCharacter
.getChild("States",sddNamespace
);
978 // <StateDefinition id="s1">
979 List
<Element
> elStateDefinitions
= elStates
.getChildren("StateDefinition",sddNamespace
);
980 TermVocabulary
<State
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
982 vocabularies
.add(termVocabularyState
);
985 //for each StateDefinition
986 for (Element elStateDefinition
: elStateDefinitions
){
988 if ((++k
% modCount
) == 0){ logger
.info("StateDefinitions handled: " + (k
-1));}
990 String idS
= elStateDefinition
.getAttributeValue("id");
991 State state
= states
.get(idS
);
993 state
= State
.NewInstance();
995 logger
.debug("State duplicate found");
997 importRepresentation(elStateDefinition
, sddNamespace
, state
, idS
, cdmState
);
999 termVocabularyState
.addTerm(state
);
1000 states
.put(idS
,state
);
1002 categoricalCharacter
.addSupportedCategoricalEnumeration(termVocabularyState
);
1003 features
.put(idCC
, categoricalCharacter
);
1005 } catch (Exception e
) {
1006 logger
.warn("Import of CategoricalCharacter " + j
+ " failed.");
1007 cdmState
.setUnsuccessfull();
1010 if ((++j
% modCount
) == 0){ logger
.info("CategoricalCharacters handled: " + j
);}
1017 * @param sddNamespace
1019 * @param elCharacters
1021 private void handleQuantitativeData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1023 // <QuantitativeCharacter id="c2">
1024 List
<Element
> elQuantitativeCharacters
= elCharacters
.getChildren("QuantitativeCharacter", sddNamespace
);
1026 //for each QuantitativeCharacter
1027 for (Element elQuantitativeCharacter
: elQuantitativeCharacters
){
1031 String idQC
= elQuantitativeCharacter
.getAttributeValue("id");
1034 // <Label>Leaf length</Label>
1035 // </Representation>
1036 Feature quantitativeCharacter
= Feature
.NewInstance();
1037 quantitativeCharacter
.setKindOf(Feature
.DESCRIPTION());
1038 importRepresentation(elQuantitativeCharacter
, sddNamespace
, quantitativeCharacter
, idQC
, cdmState
);
1040 quantitativeCharacter
.setSupportsQuantitativeData(true);
1042 // <MeasurementUnit>
1043 // <Label role="Abbrev">m</Label>
1044 // </MeasurementUnit>
1045 Element elMeasurementUnit
= elQuantitativeCharacter
.getChild("MeasurementUnit",sddNamespace
);
1048 if (elMeasurementUnit
!= null) {
1049 Element elLabel
= elMeasurementUnit
.getChild("Label",sddNamespace
);
1050 role
= elLabel
.getAttributeValue("role");
1051 label
= (String
)ImportHelper
.getXmlInputValue(elMeasurementUnit
, "Label",sddNamespace
);
1054 MeasurementUnit unit
= null;
1055 if (!label
.equals("")){
1057 if (role
.equals("Abbrev")){
1058 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1061 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1066 units
.put(idQC
, unit
);
1070 // <MeasurementUnitPrefix>milli</MeasurementUnitPrefix>
1072 Element elDefault
= elQuantitativeCharacter
.getChild("Default",sddNamespace
);
1073 if (elDefault
!= null) {
1074 String measurementUnitPrefix
= (String
)ImportHelper
.getXmlInputValue(elDefault
, "MeasurementUnitPrefix",sddNamespace
);
1075 if (! measurementUnitPrefix
.equals("")){
1076 defaultUnitPrefixes
.put(idQC
, measurementUnitPrefix
);
1080 features
.put(idQC
, quantitativeCharacter
);
1082 } catch (Exception e
) {
1084 logger
.warn("Import of QuantitativeCharacter " + j
+ " failed.");
1085 cdmState
.setUnsuccessfull();
1088 if ((++j
% modCount
) == 0){ logger
.info("QuantitativeCharacters handled: " + j
);}
1094 private void handleTextCharacters(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1096 // <TextCharacter id="c3">
1097 List
<Element
> elTextCharacters
= elCharacters
.getChildren("TextCharacter", sddNamespace
);
1099 //for each TextCharacter
1100 for (Element elTextCharacter
: elTextCharacters
){
1104 String idTC
= elTextCharacter
.getAttributeValue("id");
1107 // <Label xml:lang="en">Leaf features not covered by other characters</Label>
1108 // </Representation>
1109 Feature textCharacter
= Feature
.NewInstance();
1110 textCharacter
.setKindOf(Feature
.DESCRIPTION());
1111 importRepresentation(elTextCharacter
, sddNamespace
, textCharacter
, idTC
, cdmState
);
1113 textCharacter
.setSupportsTextData(true);
1115 features
.put(idTC
, textCharacter
);
1117 } catch (Exception e
) {
1119 logger
.warn("Import of TextCharacter " + j
+ " failed.");
1120 cdmState
.setUnsuccessfull();
1123 if ((++j
% modCount
) == 0){ logger
.info("TextCharacters handled: " + j
);}
1129 // imports the descriptions of taxa
1130 protected void importCodedDescriptions(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1132 // <CodedDescriptions>
1133 logger
.info("start CodedDescriptions ...");
1134 Element elCodedDescriptions
= elDataset
.getChild("CodedDescriptions",sddNamespace
);
1136 // <CodedDescription id="D101">
1137 if (elCodedDescriptions
!= null) {
1138 List
<Element
> listCodedDescriptions
= elCodedDescriptions
.getChildren("CodedDescription", sddNamespace
);
1140 //for each CodedDescription
1141 for (Element elCodedDescription
: listCodedDescriptions
){
1142 handleCodedDescription(sddNamespace
, cdmState
, elCodedDescription
, j
);
1143 if ((++j
% modCount
) == 0){ logger
.info("CodedDescriptions handled: " + j
);}
1150 * @param sddNamespace
1153 * @param elCodedDescription
1156 private void handleCodedDescription(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
, int j
) {
1159 String idCD
= elCodedDescription
.getAttributeValue("id");
1162 // <Label><i>Viola hederacea</i> Labill. as revised by R. Morris April 8, 2006</Label>
1163 // </Representation>
1164 TaxonDescription taxonDescription
= TaxonDescription
.NewInstance();
1165 if (!generatorName
.isEmpty()){
1166 Annotation annotation
= Annotation
.NewInstance(generatorName
, AnnotationType
.TECHNICAL(),Language
.DEFAULT());
1167 taxonDescription
.addAnnotation(annotation
);
1169 importRepresentation(elCodedDescription
, sddNamespace
, taxonDescription
, idCD
, cdmState
);
1172 // <TaxonName ref="t1"/>
1173 // <Citation ref="p1" location="p. 30"/>
1175 Element elScope
= elCodedDescription
.getChild("Scope", sddNamespace
);
1177 if (elScope
!= null) {
1178 taxon
= handleCDScope(sddNamespace
, cdmState
, idCD
, elScope
);
1179 } else {//in case no taxon is linked to the description, a new one is created
1180 taxon
= handleCDNoScope(sddNamespace
, cdmState
, elCodedDescription
);
1184 Element elSummaryData
= elCodedDescription
.getChild("SummaryData",sddNamespace
);
1185 if (elSummaryData
!= null) {
1186 handleSummaryCategoricalData(sddNamespace
, taxonDescription
, elSummaryData
);
1187 handleSummaryQuantitativeData(sddNamespace
, taxonDescription
, elSummaryData
);
1188 handleSummaryTextData(sddNamespace
, taxonDescription
, elSummaryData
);
1191 if (taxon
!= null) {
1192 taxon
.addDescription(taxonDescription
);
1195 workingSet
.addDescription(taxonDescription
);
1197 //OLD taxonDescription.setDescriptiveSystem(featureSet);
1199 taxonDescriptions
.put(idCD
, taxonDescription
);//FIXME
1201 } catch (Exception e
) {
1203 logger
.warn("Import of CodedDescription " + j
+ " failed.", e
);
1204 cdmState
.setUnsuccessfull();
1210 * @param sddNamespace
1212 * @param elCodedDescription
1216 private Taxon
handleCDNoScope(Namespace sddNamespace
,
1217 SDDImportState cdmState
, Element elCodedDescription
) {
1219 NonViralName nonViralName
= NonViralName
.NewInstance(null);
1220 String id
= new String("" + taxonNamesCount
);
1221 IdentifiableSource source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
1222 importRepresentation(elCodedDescription
, sddNamespace
, nonViralName
, id
, cdmState
);
1224 if(cdmState
.getConfig().isDoMatchTaxa()){
1225 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1229 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1230 // taxonNameBases.put(id ,tnb);
1231 // taxonNamesCount++;
1232 logger
.info("using existing Taxon " + taxon
.getTitleCache());
1234 nonViralName
.addSource(source
);
1235 taxonNameBases
.put(id
,nonViralName
);
1237 logger
.info("creating new Taxon from TaxonName " + nonViralName
.getTitleCache());
1238 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1244 * @param sddNamespace
1251 private Taxon
handleCDScope(Namespace sddNamespace
, SDDImportState cdmState
,
1252 String idCD
, Element elScope
) {
1254 Element elTaxonName
= elScope
.getChild("TaxonName", sddNamespace
);
1255 String ref
= elTaxonName
.getAttributeValue("ref");
1256 NonViralName nonViralName
= taxonNameBases
.get(ref
);
1258 if(cdmState
.getConfig().isDoMatchTaxa()){
1259 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1263 logger
.info("using existing Taxon" + taxon
.getTitleCache());
1264 if(!nonViralName
.getUuid().equals(taxon
.getName().getUuid())){
1265 logger
.warn("TaxonNameBase entity of existing taxon does not match Name in list -> replacing Name in list");
1266 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1269 logger
.info("creating new Taxon from TaxonName '" + nonViralName
.getTitleCache()+"'");
1270 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1274 Element elCitation
= elScope
.getChild("Citation",sddNamespace
);
1275 if (elCitation
!= null) {
1276 String refCitation
= elCitation
.getAttributeValue("ref");
1277 if (! refCitation
.equals("")){
1278 citations
.put(idCD
, refCitation
);
1280 String location
= elCitation
.getAttributeValue("location");
1281 if (! location
.equals("")){
1282 locations
.put(idCD
, location
);
1289 * @param sddNamespace
1290 * @param taxonDescription
1291 * @param elSummaryData
1293 private void handleSummaryTextData(Namespace sddNamespace
,
1294 TaxonDescription taxonDescription
, Element elSummaryData
) {
1297 // <TextChar ref="c3">
1298 List
<Element
> elTextChars
= elSummaryData
.getChildren("TextChar", sddNamespace
);
1301 for (Element elTextChar
: elTextChars
){
1302 if ((++k
% modCount
) == 0){ logger
.info("TextChar handled: " + (k
-1));}
1303 ref
= elTextChar
.getAttributeValue("ref");
1304 Feature feature
= features
.get(ref
);
1305 TextData textData
= TextData
.NewInstance();
1306 textData
.setFeature(feature
);
1308 // <Content>Free form text</Content>
1309 String content
= (String
)ImportHelper
.getXmlInputValue(elTextChar
, "Content",sddNamespace
);
1310 textData
.putText(datasetLanguage
, content
);
1311 taxonDescription
.addElement(textData
);
1316 * @param sddNamespace
1317 * @param taxonDescription
1318 * @param elSummaryData
1320 private void handleSummaryQuantitativeData(Namespace sddNamespace
,
1321 TaxonDescription taxonDescription
, Element elSummaryData
) {
1324 // <Quantitative ref="c2">
1325 List
<Element
> elQuantitatives
= elSummaryData
.getChildren("Quantitative", sddNamespace
);
1327 //for each Quantitative
1328 for (Element elQuantitative
: elQuantitatives
){
1329 if ((++k
% modCount
) == 0){ logger
.warn("Quantitative handled: " + (k
-1));}
1330 ref
= elQuantitative
.getAttributeValue("ref");
1331 Feature feature
= features
.get(ref
);
1332 QuantitativeData quantitativeData
= QuantitativeData
.NewInstance();
1333 quantitativeData
.setFeature(feature
);
1335 MeasurementUnit unit
= units
.get(ref
);
1336 String prefix
= defaultUnitPrefixes
.get(ref
);
1338 String u
= unit
.getLabel();
1339 if (prefix
!= null) {
1343 quantitativeData
.setUnit(unit
);
1346 // <Measure type="Min" value="2.3"/>
1347 List
<Element
> elMeasures
= elQuantitative
.getChildren("Measure", sddNamespace
);
1351 for (Element elMeasure
: elMeasures
){
1352 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1353 String type
= elMeasure
.getAttributeValue("type");
1354 String value
= elMeasure
.getAttributeValue("value");
1355 if (value
.contains(",")) {
1356 value
= value
.replace(',', '.');
1358 Float v
= Float
.parseFloat(value
);
1359 //Float v = new Float(0);
1360 StatisticalMeasure t
= null;
1361 if (type
.equals("Min")) {
1362 t
= StatisticalMeasure
.MIN();
1363 } else if (type
.equals("Mean")) {
1364 t
= StatisticalMeasure
.AVERAGE();
1365 } else if (type
.equals("Max")) {
1366 t
= StatisticalMeasure
.MAX();
1367 } else if (type
.equals("SD")) {
1368 t
= StatisticalMeasure
.STANDARD_DEVIATION();
1369 } else if (type
.equals("N")) {
1370 t
= StatisticalMeasure
.SAMPLE_SIZE();
1371 } else if (type
.equals("UMethLower")) {
1372 t
= StatisticalMeasure
.TYPICAL_LOWER_BOUNDARY();
1373 } else if (type
.equals("UMethUpper")) {
1374 t
= StatisticalMeasure
.TYPICAL_UPPER_BOUNDARY();
1375 } else if (type
.equals("Var")) {
1376 t
= StatisticalMeasure
.VARIANCE();
1378 t
= StatisticalMeasure
.NewInstance(type
,type
,type
);
1379 statisticalMeasures
.add(t
);
1382 StatisticalMeasurementValue statisticalValue
= StatisticalMeasurementValue
.NewInstance();
1383 statisticalValue
.setValue(v
);
1384 statisticalValue
.setType(t
);
1385 quantitativeData
.addStatisticalValue(statisticalValue
);
1386 featureData
.add(statisticalValue
);
1388 taxonDescription
.addElement(quantitativeData
);
1393 * @param sddNamespace
1394 * @param taxonDescription
1395 * @param elSummaryData
1397 private void handleSummaryCategoricalData(Namespace sddNamespace
,
1398 TaxonDescription taxonDescription
, Element elSummaryData
) {
1400 // <Categorical ref="c4">
1401 List
<Element
> elCategoricals
= elSummaryData
.getChildren("Categorical", sddNamespace
);
1403 //for each Categorical
1404 for (Element elCategorical
: elCategoricals
){
1405 if ((++k
% modCount
) == 0){ logger
.warn("Categorical handled: " + (k
-1));}
1406 ref
= elCategorical
.getAttributeValue("ref");
1407 Feature feature
= features
.get(ref
);
1408 CategoricalData categoricalData
= CategoricalData
.NewInstance();
1409 categoricalData
.setFeature(feature
);
1411 // <State ref="s3"/>
1412 List
<Element
> elStates
= elCategorical
.getChildren("State", sddNamespace
);
1416 for (Element elState
: elStates
){
1417 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1418 ref
= elState
.getAttributeValue("ref");
1419 State state
= states
.get(ref
);
1420 if (state
!= null) {
1421 StateData stateData
= StateData
.NewInstance();
1422 stateData
.setState(state
);
1423 List
<Element
> elModifiers
= elState
.getChildren("Modifier", sddNamespace
);
1424 for (Element elModifier
: elModifiers
){
1425 ref
= elModifier
.getAttributeValue("ref");
1426 Modifier modifier
= modifiers
.get(ref
);
1427 if (modifier
!= null) {
1428 stateData
.addModifier(modifier
);
1431 categoricalData
.addState(stateData
);
1433 taxonDescription
.addElement(categoricalData
);
1438 // imports the persons associated with the dataset creation, modification, related publications
1439 protected void importAgents(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1441 logger
.info("start Agents ...");
1442 Element elAgents
= elDataset
.getChild("Agents",sddNamespace
);
1443 if (elAgents
!= null) {
1445 List
<Element
> listAgents
= elAgents
.getChildren("Agent", sddNamespace
);
1448 for (Element elAgent
: listAgents
){
1452 String idA
= elAgent
.getAttributeValue("id");
1455 // <Label>Kevin Thiele</Label>
1456 // <Detail role="Description">Ali Baba is also known as r.a.m.</Detail>
1457 // </Representation>
1458 Person person
= Person
.NewInstance();
1459 importRepresentation(elAgent
, sddNamespace
, person
, idA
, cdmState
);
1460 person
.addSource(IdentifiableSource
.NewInstance(idA
, "Agent"));
1463 Element elLinks = elAgent.getChild("Links",sddNamespace);
1465 if (elLinks != null) {
1467 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
1468 List<Element> listLinks = elLinks.getChildren("Link", sddNamespace);
1471 for (Element elLink : listLinks){
1475 String rel = elLink.getAttributeValue("rel");
1476 String href = elLink.getAttributeValue("href");
1478 Media link = Media.NewInstance();
1479 MediaRepresentation mr = MediaRepresentation.NewInstance();
1480 mr.addRepresentationPart(MediaRepresentationPart.NewInstance(href, null));
1481 link.addRepresentation(mr);
1482 person.addMedia(link);
1484 } catch (Exception e) {
1486 logger.warn("Import of Link " + k + " failed.");
1490 if ((++k % modCount) == 0){ logger.info("Links handled: " + k);}
1495 if (authors
.containsKey(idA
)) {
1496 authors
.put(idA
,person
);
1499 if (editors
.containsKey(idA
)) {
1500 editors
.put(idA
, person
);
1503 } catch (Exception e
) {
1505 logger
.warn("Import of Agent " + j
+ " failed.");
1506 cdmState
.setUnsuccessfull();
1509 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
1515 // imports publications related with the data set
1516 protected void importPublications(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1518 <Publication id="p112">
1520 <Label>Gee, X. & Haa, Y. (2003). How to be happy in five minutes. Instant Gratifications, Palm Beach.</Label>
1523 <Link rel="BasedOn" href="doi:10.1992/32311"/>
1524 <Link rel="Alternate" href="http://some.service.net/providing/bibliographic.data"/>
1528 logger
.info("start Publications ...");
1529 Element elPublications
= elDataset
.getChild("Publications",sddNamespace
);
1531 if (elPublications
!= null) {
1532 List
<Element
> listPublications
= elPublications
.getChildren("Publication", sddNamespace
);
1534 for (Element elPublication
: listPublications
){
1538 String idP
= elPublication
.getAttributeValue("id");
1539 Reference publication
= ReferenceFactory
.newArticle();
1540 importRepresentation(elPublication
, sddNamespace
, publication
, idP
, cdmState
);
1542 publications
.put(idP
,publication
);
1544 } catch (Exception e
) {
1545 logger
.warn("Import of Publication " + j
+ " failed.");
1546 cdmState
.setUnsuccessfull();
1549 if ((++j
% modCount
) == 0){ logger
.info("Publications handled: " + j
);}
1555 // imports media objects such as images //FIXME check mediaobj
1556 protected void importMediaObjects(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1558 logger
.info("start MediaObjects ...");
1559 Element elMediaObjects
= elDataset
.getChild("MediaObjects",sddNamespace
);
1561 if (elMediaObjects
!= null) {
1562 // <MediaObject id="m1">
1563 List
<Element
> listMediaObjects
= elMediaObjects
.getChildren("MediaObject", sddNamespace
);
1565 for (Element elMO
: listMediaObjects
){
1570 String idMO
= elMO
.getAttributeValue("id");
1574 // <Label>Image description, e.g. to be used for alt-attribute in html.</Label>
1575 // </Representation>
1576 Media media
= Media
.NewInstance();
1577 importRepresentation(elMO
, sddNamespace
, media
, idMO
, cdmState
);
1579 // <Type>Image</Type>
1580 // <Source href="http://test.edu/test.jpg"/>
1581 String type
= (String
)ImportHelper
.getXmlInputValue(elMO
,"Type",sddNamespace
);
1583 if ((type
!= null) && (type
.equals("Image"))) {
1584 Element elSource
= elMO
.getChild("Source",sddNamespace
);
1585 String href
= elSource
.getAttributeValue("href");
1587 ImageInfo imageMetaData
= null;
1588 ImageFile image
= null;
1589 if (href
.substring(0,7).equals("http://")) {
1591 URL url
= new URL(href
);
1593 imageMetaData
= ImageInfo
.NewInstance(url
.toURI(), 0);
1594 image
= ImageFile
.NewInstance(url
.toURI(), null, imageMetaData
);
1595 } catch (MalformedURLException e
) {
1596 logger
.error("Malformed URL", e
);
1599 String sns
= cdmState
.getConfig().getSourceNameString();
1600 File f
= new File(sns
);
1601 File parent
= f
.getParentFile();
1602 String fi
= parent
.toString() + File
.separator
+ href
;
1603 File file
= new File(fi
);
1604 imageMetaData
= ImageInfo
.NewInstance(new URI(fi
), 0); //file
1605 image
= ImageFile
.NewInstance(file
.toURI(), null, imageMetaData
);
1607 MediaRepresentation representation
= MediaRepresentation
.NewInstance(imageMetaData
.getMimeType(), null);
1608 representation
.addRepresentationPart(image
);
1610 media
.addRepresentation(representation
);
1612 ArrayList
<CdmBase
> lcb
= (ArrayList
<CdmBase
>) mediaObject_ListCdmBase
.get(idMO
);
1614 for (int k
= 0; k
< lcb
.size(); k
++) {
1615 if (lcb
.get(k
) instanceof DefinedTermBase
) {
1616 DefinedTermBase dtb
= (DefinedTermBase
) lcb
.get(k
);
1617 // if (lcb.get(0) instanceof DefinedTermBase) {
1618 // DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1621 dtb
.addMedia(media
);
1622 //System.out.println(dtb.getLabel());
1624 // Media me = (Media) media.clone();
1625 // dtb.addMedia(me);
1628 } else if (lcb
.get(k
) instanceof Reference
) {
1629 Reference rb
= (Reference
) lcb
.get(k
);
1630 //} else if (lcb.get(0) instanceof Reference) {
1631 //Reference rb = (Reference) lcb.get(0);
1632 // rb.setTitleCache(label);
1636 //System.out.println(rb.getTitle());
1638 // Media me = (Media) media.clone();
1642 }/* else if (lcb.get(k) instanceof TaxonNameBase){
1643 TaxonNameBase tb = (TaxonNameBase) lcb.get(k);
1650 } catch (Exception e
) {
1652 logger
.warn("Could not attach MediaObject " + j
+ "(SDD: " + id
+ ") to several objects.");
1653 cdmState
.setUnsuccessfull();
1656 if ((++j
% modCount
) == 0){ logger
.info("MediaObjects handled: " + j
);
1663 // imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves
1664 // but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker
1665 protected void importDescriptiveConcepts(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1666 /* <DescriptiveConcepts>
1667 <DescriptiveConcept id="dc0">
1669 <Label>Fixed set of modifiers supported in Lucid3</Label>
1672 <Modifier id="mod1">
1674 <Label>rarely</Label>
1676 <ModifierClass>Frequency</ModifierClass>
1677 <ProportionRange lowerestimate="0.0" upperestimate="0.25"/>
1680 </DescriptiveConcept>
1681 </DescriptiveConcepts>
1683 logger
.info("start DescriptiveConcepts ...");
1684 Element elDescriptiveConcepts
= elDataset
.getChild("DescriptiveConcepts",sddNamespace
);
1685 if (elDescriptiveConcepts
!= null) {
1686 List
<Element
> listDescriptiveConcepts
= elDescriptiveConcepts
.getChildren("DescriptiveConcept", sddNamespace
);
1689 for (Element elDescriptiveConcept
: listDescriptiveConcepts
){
1691 String id
= elDescriptiveConcept
.getAttributeValue("id");
1692 Feature feature
= Feature
.NewInstance();
1693 feature
.setKindOf(Feature
.DESCRIPTION());
1694 if (!id
.equals("")) {
1696 // <Label>Body</Label>
1697 importRepresentation(elDescriptiveConcept
, sddNamespace
, feature
, id
, cdmState
);
1698 features
.put(id
, feature
);
1699 getTermService().save(feature
);//XIM
1700 descriptiveConcepts
.add(feature
);
1701 // imports the modifiers
1702 Element elModifiers
= elDescriptiveConcept
.getChild("Modifiers", sddNamespace
);
1703 if (elModifiers
!=null){
1704 List
<Element
> listModifiers
= elModifiers
.getChildren("Modifier", sddNamespace
);
1705 TermVocabulary
<Modifier
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
1706 for (Element elModifier
: listModifiers
) {
1707 Modifier modif
= Modifier
.NewInstance();
1708 String idmod
= elModifier
.getAttributeValue("id");
1709 importRepresentation(elModifier
, sddNamespace
, modif
, idmod
, cdmState
);
1710 termVocabularyState
.addTerm(modif
);
1711 //termVocabularyStates.add(termVocabularyState);
1712 getVocabularyService().save(termVocabularyState
);//XIM
1713 modifiers
.put(idmod
, modif
);
1715 feature
.addRecommendedModifierEnumeration(termVocabularyState
);
1720 catch (Exception e
) {
1721 logger
.warn("Import of DescriptiveConcept " + j
+ " failed: " + e
.getMessage());
1723 if ((++j
% modCount
) == 0){ logger
.info("DescriptiveConcepts handled: " + j
);}
1729 // imports the <CharacterTrees> block
1730 protected void importCharacterTrees(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1732 logger
.info("start CharacterTrees ...");
1733 Element elCharacterTrees
= elDataset
.getChild("CharacterTrees",sddNamespace
);
1735 if (elCharacterTrees
!= null) {
1736 List
<Element
> listCharacterTrees
= elCharacterTrees
.getChildren("CharacterTree", sddNamespace
);
1738 for (Element elCharacterTree
: listCharacterTrees
){
1740 Element elRepresentation
= elCharacterTree
.getChild("Representation",sddNamespace
);
1741 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1742 //Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ?
1744 FeatureTree featureTree
= FeatureTree
.NewInstance();
1745 importRepresentation(elCharacterTree
, sddNamespace
, featureTree
, "", cdmState
);
1746 FeatureNode root
= featureTree
.getRoot();
1747 List
<Element
> listeOfNodes
= elCharacterTree
.getChildren("Nodes", sddNamespace
);
1749 //Nodes of CharacterTrees in SDD always refer to DescriptiveConcepts
1750 for (Element elNodes
: listeOfNodes
) {
1751 handleCharacterNodes(sddNamespace
, root
, elNodes
);
1753 featureTrees
.add(featureTree
);
1754 if (workingSet
.getDescriptiveSystem() != null){
1755 //TODO how to handle multiple
1756 logger
.warn("Multiple feature trees not yet supported");
1758 workingSet
.setDescriptiveSystem(featureTree
);
1762 catch (Exception e
) {
1763 logger
.warn("Import of Character tree " + j
+ " failed.");
1764 cdmState
.setUnsuccessfull();
1766 if ((++j
% modCount
) == 0){ logger
.info("CharacterTrees handled: " + j
);}
1774 * @param sddNamespace
1778 private void handleCharacterNodes(Namespace sddNamespace
, FeatureNode root
, Element elNodes
) {
1779 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1780 if (listNodes
!= null) {
1781 for (Element elNode
: listNodes
){
1782 String idN
= elNode
.getAttributeValue("id");
1783 FeatureNode fn
= null;
1786 // DescriptiveConcepts are used as nodes in CharacterTrees
1787 Element elDescriptiveConcept
= elNode
.getChild("DescriptiveConcept", sddNamespace
);
1788 if (elDescriptiveConcept
!= null){
1789 String refDC
= elDescriptiveConcept
.getAttributeValue("ref");
1790 dc
= features
.get(refDC
);
1791 fn
= FeatureNode
.NewInstance(dc
);
1794 fn
= FeatureNode
.NewInstance();
1796 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1797 // in SDD links between Nodes are referenced by the <Parent> tag
1798 if (elParent
!=null){
1799 String refP
= elParent
.getAttributeValue("ref");
1801 FeatureNode parent
= featureNodes
.get(refP
);
1803 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1806 parent
.addChild(fn
);
1811 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1814 featureNodes
.put(idN
, fn
);
1818 // Leaves of CharacterTrees in SDD are always CharNodes (referring to Characters)
1819 List
<Element
> listCharNodes
= elNodes
.getChildren("CharNode", sddNamespace
);
1820 if (listCharNodes
!= null) {
1821 for (Element elCharNode
: listCharNodes
){
1822 Element elParent
= elCharNode
.getChild("Parent", sddNamespace
);
1823 Element elCharacter
= elCharNode
.getChild("Character", sddNamespace
);
1824 Element elDependencyRules
= elCharNode
.getChild("DependencyRules", sddNamespace
);
1825 FeatureNode fn
= FeatureNode
.NewInstance();
1827 if (elDependencyRules
!=null){
1828 Element elInapplicableIf
= elCharNode
.getChild("InapplicableIf", sddNamespace
);
1829 if (elInapplicableIf
!=null){
1830 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1831 for (Element stateElement
: listStates
) {
1832 String refState
= stateElement
.getAttributeValue("ref");
1833 if ((refState
!=null)&&(!refState
.equals(""))) {
1834 State state
= states
.get(refState
);
1835 fn
.addInapplicableState(state
);
1839 Element elOnlyapplicableIf
= elCharNode
.getChild("OnlyApplicableIf", sddNamespace
);
1840 if (elOnlyapplicableIf
!=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
.addApplicableState(state
);
1852 if (elParent
!=null){
1853 String refP
= elParent
.getAttributeValue("ref");
1854 if ((refP
!=null)&&(!refP
.equals(""))) {
1855 FeatureNode parent
= featureNodes
.get(refP
);
1857 parent
= root
; // if no parent found or the reference is broken, add the node to the root of the tree
1859 parent
.addChild(fn
);
1862 String refC
= elCharacter
.getAttributeValue("ref");
1863 if ((refC
!=null)&&(!refC
.equals(""))){
1864 Feature character
= features
.get(refC
);
1865 fn
.setFeature(character
);
1866 featureNodes
.put(refC
, fn
);
1872 // imports the <TaxonHierarchies> block
1873 protected void importTaxonHierarchies(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1875 logger
.info("start TaxonHierarchies ...");
1876 Element elTaxonHierarchies
= elDataset
.getChild("TaxonHierarchies",sddNamespace
);
1878 if (elTaxonHierarchies
!= null) {
1879 List
<Element
> listTaxonHierarchies
= elTaxonHierarchies
.getChildren("TaxonHierarchy", sddNamespace
);
1881 for (Element elTaxonHierarchy
: listTaxonHierarchies
){
1883 Element elRepresentation
= elTaxonHierarchy
.getChild("Representation",sddNamespace
);
1884 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1885 Classification classification
= Classification
.NewInstance(label
);
1886 importRepresentation(elTaxonHierarchy
, sddNamespace
, classification
, "", cdmState
);
1888 Set
<TaxonNode
> root
= classification
.getChildNodes();
1889 Element elNodes
= elTaxonHierarchy
.getChild("Nodes", sddNamespace
); // There can be only one <Nodes> block for TaxonHierarchies
1890 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1892 for (Element elNode
: listNodes
){
1893 String idN
= elNode
.getAttributeValue("id");
1894 TaxonNameBase tnb
= null;
1895 if (!idN
.equals("")) {
1896 Element elTaxonName
= elNode
.getChild("TaxonName", sddNamespace
);
1897 String refTN
= elTaxonName
.getAttributeValue("ref");
1898 tnb
= taxonNameBases
.get(refTN
);
1899 Taxon taxon
= (Taxon
) tnb
.getTaxa().iterator().next() ;
1900 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1901 if (elParent
!=null){
1902 String refP
= elParent
.getAttributeValue("ref");
1903 if (!refP
.equals("")) {
1904 TaxonNode parent
= taxonNodes
.get(refP
);
1905 TaxonNode child
= parent
.addChildTaxon(taxon
, sec
, "", Synonym
.NewInstance(tnb
, sec
));
1906 taxonNodes
.put(idN
,child
);
1910 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
1911 taxonNodes
.put(idN
,tn
);
1916 classifications
.add(classification
);
1919 catch (Exception e
) {
1921 logger
.warn("Import of Taxon Hierarchy " + j
+ " failed.");
1922 cdmState
.setUnsuccessfull();
1925 if ((++j
% modCount
) == 0){ logger
.info("TaxonHierarchies handled: " + j
);}
1933 // imports the <GeographicAreas> block
1934 protected void importGeographicAreas(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
1935 Element elGeographicAreas
= elDataset
.getChild("GeographicAreas",sddNamespace
);
1936 if (elGeographicAreas
!= null) {
1937 List
<Element
> listGeographicAreas
= elGeographicAreas
.getChildren("GeographicArea", sddNamespace
);
1940 for (Element elGeographicArea
: listGeographicAreas
){
1942 String id
= elGeographicArea
.getAttributeValue("id");
1943 NamedArea na
= new NamedArea();
1944 importRepresentation(elGeographicArea
, sddNamespace
, na
, id
, cdmState
);
1945 namedAreas
.put(id
,na
);
1947 if ((++j
% modCount
) == 0){ logger
.info("GeographicAreas handled: " + j
);}