2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.io
.sdd
.in
;
13 import java
.io
.IOException
;
14 import java
.net
.MalformedURLException
;
17 import java
.text
.SimpleDateFormat
;
18 import java
.util
.ArrayList
;
19 import java
.util
.Date
;
20 import java
.util
.HashMap
;
21 import java
.util
.HashSet
;
22 import java
.util
.List
;
25 import java
.util
.UUID
;
27 import org
.apache
.commons
.lang
.StringUtils
;
28 import org
.apache
.log4j
.Logger
;
29 import org
.jdom
.Element
;
30 import org
.jdom
.Namespace
;
31 import org
.joda
.time
.DateTime
;
32 import org
.springframework
.stereotype
.Component
;
33 import org
.springframework
.transaction
.TransactionStatus
;
35 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
36 import eu
.etaxonomy
.cdm
.common
.media
.ImageInfo
;
37 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
38 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ICdmImport
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
41 import eu
.etaxonomy
.cdm
.io
.common
.XmlImportBase
;
42 import eu
.etaxonomy
.cdm
.io
.sdd
.SDDTransformer
;
43 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
44 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
45 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
46 import eu
.etaxonomy
.cdm
.model
.common
.AnnotationType
;
47 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
48 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
49 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
50 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
51 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
52 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
53 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
54 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
55 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
56 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
57 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
58 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
59 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
60 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
61 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
62 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
63 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
64 import eu
.etaxonomy
.cdm
.model
.description
.Modifier
;
65 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
66 import eu
.etaxonomy
.cdm
.model
.description
.State
;
67 import eu
.etaxonomy
.cdm
.model
.description
.StateData
;
68 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
69 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasurementValue
;
70 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
71 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
72 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
73 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
74 import eu
.etaxonomy
.cdm
.model
.media
.IdentifiableMediaEntity
;
75 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
76 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
77 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
78 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentationPart
;
79 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
80 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
81 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
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
;
96 @Component("sddImport")
97 public class SDDImport
extends XmlImportBase
<SDDImportConfigurator
, SDDImportState
> implements ICdmImport
<SDDImportConfigurator
, SDDImportState
> {
98 private static final Logger logger
= Logger
.getLogger(SDDImport
.class);
100 private static int modCount
= 1000;
102 private UUID uuidAnnotationTypeLocation
= UUID
.fromString("a3737e07-72e3-46d2-986d-fa4cf5de0b63");
105 private Map
<String
,Person
> authors
= new HashMap
<String
,Person
>();
106 private Map
<String
,String
> citations
= new HashMap
<String
,String
>();
107 private Map
<String
,String
> defaultUnitPrefixes
= new HashMap
<String
,String
>();
108 private Map
<String
,Person
> editors
= new HashMap
<String
,Person
>();
109 private Map
<String
,FeatureNode
> featureNodes
= new HashMap
<String
,FeatureNode
>();
110 private Map
<String
,Feature
> features
= new HashMap
<String
,Feature
>();
111 private Map
<String
,String
> locations
= new HashMap
<String
,String
>();
112 private Map
<String
,List
<CdmBase
>> mediaObject_ListCdmBase
= new HashMap
<String
,List
<CdmBase
>>();
113 private Map
<String
,String
> mediaObject_Role
= new HashMap
<String
,String
>();
114 private Map
<String
,Reference
<?
>> publications
= new HashMap
<String
,Reference
<?
>>();
115 private Map
<String
,State
> states
= new HashMap
<String
,State
>();
116 private Map
<String
,TaxonDescription
> taxonDescriptions
= new HashMap
<String
,TaxonDescription
>();
117 private Map
<String
,NonViralName
<?
>> taxonNameBases
= new HashMap
<String
,NonViralName
<?
>>();
118 private Map
<String
,MeasurementUnit
> units
= new HashMap
<String
,MeasurementUnit
>();
119 private Map
<String
,TaxonNode
> taxonNodes
= new HashMap
<String
,TaxonNode
>();
120 private Map
<String
,NamedArea
> namedAreas
= new HashMap
<String
,NamedArea
>();
121 private Map
<String
,Specimen
> specimens
= new HashMap
<String
,Specimen
>();
122 private Map
<String
,Modifier
> modifiers
= new HashMap
<String
,Modifier
>();
124 private Set
<MarkerType
> markerTypes
= new HashSet
<MarkerType
>();
125 private Set
<TermVocabulary
<?
>> vocabularies
= new HashSet
<TermVocabulary
<?
>>();
127 private Set
<Feature
> descriptiveConcepts
= new HashSet
<Feature
>();
128 private Set
<AnnotationType
> annotationTypes
= new HashSet
<AnnotationType
>();
129 // private Set<Feature> featureSet = new HashSet<Feature>();
130 private Set
<Reference
<?
>> sources
= new HashSet
<Reference
<?
>>();
131 private Reference
<?
> sec
= ReferenceFactory
.newDatabase();
132 private Reference
<?
> sourceReference
= null;
134 private Language datasetLanguage
= null;
135 private WorkingSet workingSet
= null;
137 private Namespace xmlNamespace
= Namespace
.getNamespace("xml","http://www.w3.org/XML/1998/namespace");
139 private String generatorName
= "";
140 private String generatorVersion
= "";
143 private Set
<StatisticalMeasure
> statisticalMeasures
= new HashSet
<StatisticalMeasure
>();
144 private Set
<VersionableEntity
> featureData
= new HashSet
<VersionableEntity
>();
145 private Set
<FeatureTree
> featureTrees
= new HashSet
<FeatureTree
>();
146 private Set
<Classification
> classifications
= new HashSet
<Classification
>();
148 private Rights copyright
= null;
150 private int taxonNamesCount
= 0;
157 public boolean doCheck(SDDImportState state
){
158 boolean result
= true;
159 logger
.warn("No check implemented for SDD");
164 // public boolean doInvoke(IImportConfigurator config, Map<String, MapWrapper<? extends CdmBase>> stores){
166 public void doInvoke(SDDImportState state
){
168 TransactionStatus ts
= startTransaction();
169 SDDImportConfigurator sddConfig
= state
.getConfig();
170 IProgressMonitor progressMonitor
= sddConfig
.getProgressMonitor();
172 logger
.info("start Datasets ...");
174 // <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">
175 Element root
= sddConfig
.getSourceRoot();
176 Namespace sddNamespace
= sddConfig
.getSddNamespace();
178 logger
.info("start TechnicalMetadata ...");
179 // <TechnicalMetadata created="2006-04-20T10:00:00">
180 importTechnicalMetadata(root
, sddNamespace
, sddConfig
);
181 List
<Element
> elDatasets
= root
.getChildren("Dataset",sddNamespace
);
185 logger
.info("start Dataset ...");
186 progressMonitor
.beginTask("Importing SDD data", elDatasets
.size());
187 for (Element elDataset
: elDatasets
){
188 importDataset(elDataset
, sddNamespace
, state
);
189 // if ((++i % modCount) == 0){ logger.info("dataset(s) handled: " + i);}
190 // logger.info(i + " dataset(s) handled");
191 progressMonitor
.worked(1);
193 commitTransaction(ts
);
194 progressMonitor
.done();
195 logger
.info("End of transaction");
200 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
202 protected boolean isIgnore(SDDImportState state
){
207 // associates the reference of a media object in SDD with a CdmBase Object
208 protected void associateImageWithCdmBase(String refMO
, CdmBase cb
){
209 if ((refMO
!= null) && (cb
!=null)) {
210 if (! refMO
.equals("")) {
211 if (! mediaObject_ListCdmBase
.containsKey(refMO
)) {
212 List
<CdmBase
> lcb
= new ArrayList
<CdmBase
>();
214 mediaObject_ListCdmBase
.put(refMO
,lcb
);
216 List
<CdmBase
> lcb
= mediaObject_ListCdmBase
.get(refMO
);
218 mediaObject_ListCdmBase
.put(refMO
,lcb
);
224 // imports information about the Dataset
225 protected void importDatasetRepresentation(Element parent
, Namespace sddNamespace
){
226 logger
.info("start Representation ...");
228 <Label>The Genus Viola</Label>
229 <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>
235 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
236 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
);
237 String detail
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Detail",sddNamespace
);
240 Representation representation
= Representation
.NewInstance(detail
, label
, null, datasetLanguage
);
241 workingSet
.addRepresentation(representation
);
245 // sec.setTitleCache(label, true);
247 // if (detail != null) {
248 // Annotation annotation = Annotation.NewInstance(detail, datasetLanguage);
249 // annotation.setAnnotationType(AnnotationType.EDITORIAL());
250 // sec.addAnnotation(annotation);
254 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject",sddNamespace
);
256 for (Element elMediaObject
: listMediaObjects
) {
259 if (elMediaObject
!= null) {
260 ref
= elMediaObject
.getAttributeValue("ref");
261 role
= elMediaObject
.getAttributeValue("role");
264 if (!ref
.equals("")) {
265 this.associateImageWithCdmBase(ref
,sourceReference
);
266 this.associateImageWithCdmBase(ref
,sec
);
267 mediaObject_Role
.put(ref
,role
);
273 // imports the representation (label, detail, lang) of a particular SDD element
274 protected void importRepresentation(Element parent
, Namespace sddNamespace
, VersionableEntity ve
, String id
, SDDImportState state
){
275 Element elRepresentation
= parent
.getChild("Representation",sddNamespace
);
277 Map
<Language
,List
<String
>> langLabDet
= new HashMap
<Language
,List
<String
>>();
279 handleRepresentationLabels(sddNamespace
, elRepresentation
, langLabDet
);
280 handleRepresentationDetails(sddNamespace
, elRepresentation
, langLabDet
);
282 if (ve
instanceof TermBase
) {
283 makeRepresentationForTerms((TermBase
)ve
, langLabDet
);
284 }else if (ve
instanceof Media
) {
285 makeRepresentationForMedia((Media
)ve
, langLabDet
);
286 }else if (ve
instanceof IdentifiableEntity
<?
>) {
287 IdentifiableEntity
<?
> ie
= (IdentifiableEntity
<?
>)ve
;
288 makeRepresentationForIdentifiableEntity(sddNamespace
, ie
, elRepresentation
, langLabDet
);
289 if (ve
instanceof IdentifiableMediaEntity
<?
>){
290 makeRepresentationForIdentifiableMediaEntity(parent
, sddNamespace
, (IdentifiableMediaEntity
<?
>)ve
);
294 makeRepresentationMediaObjects(sddNamespace
, ve
, elRepresentation
);//FIXME
300 * Handles the "Detail" children of representations. Adds the result to the langLabDet.
301 * @param sddNamespace
302 * @param elRepresentation
305 private void handleRepresentationDetails(Namespace sddNamespace
,
306 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
307 List
<Element
> listDetails
= elRepresentation
.getChildren("Detail",sddNamespace
);
308 for (Element elDetail
: listDetails
){
309 Language language
= getLanguage(elDetail
);
310 String role
= elDetail
.getAttributeValue("role");
311 String detail
= elDetail
.getText();
312 List
<String
> labDet
= langLabDet
.get(language
);
315 langLabDet
.put(language
, labDet
);
320 * Handles the "Label" children of representations. Adds the result to the langLabDet.
321 * @param sddNamespace
322 * @param elRepresentation
325 private void handleRepresentationLabels(Namespace sddNamespace
,
326 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
327 // <Label xml:lang="la">Viola hederacea Labill.</Label>
328 List
<Element
> listLabels
= elRepresentation
.getChildren("Label",sddNamespace
);
329 for (Element elLabel
: listLabels
){
330 Language language
= getLanguage(elLabel
);
331 String label
= elLabel
.getText();
332 List
<String
> labDet
= new ArrayList
<String
>(3);
334 langLabDet
.put(language
, labDet
);
343 private void makeRepresentationForMedia(Media m
, Map
<Language
, List
<String
>> langLabDet
) {
344 for (Language lang
: langLabDet
.keySet()){
345 List
<String
> labDet
= langLabDet
.get(lang
);
346 if (labDet
.get(0) != null){
347 m
.putTitle(LanguageString
.NewInstance(labDet
.get(0), lang
));
349 if (labDet
.size()>1) {
350 m
.addDescription(labDet
.get(1), lang
);
356 * Handles representations for terms. Adds one representation per language in langLabDet.
361 private void makeRepresentationForTerms(TermBase tb
, Map
<Language
, List
<String
>> langLabDet
) {
362 for (Language lang
: langLabDet
.keySet()){
363 List
<String
> labDet
= langLabDet
.get(lang
);
364 if (labDet
.size()>0){
365 if (labDet
.size()>1) {
366 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(1), labDet
.get(0), labDet
.get(0), lang
));
368 tb
.addRepresentation(Representation
.NewInstance(labDet
.get(0), labDet
.get(0), labDet
.get(0), lang
));
376 * Handles the "MediaObject" children of representations.
377 * @param sddNamespace
379 * @param elRepresentation
381 private void makeRepresentationMediaObjects(Namespace sddNamespace
, VersionableEntity ve
, Element elRepresentation
) {
382 List
<Element
> listMediaObjects
= elRepresentation
.getChildren("MediaObject", sddNamespace
);
383 for (Element elMediaObject
: listMediaObjects
) {
387 if (elMediaObject
!= null) {
388 ref
= elMediaObject
.getAttributeValue("ref");
389 role
= elMediaObject
.getAttributeValue("role");
391 if (StringUtils
.isNotBlank(ref
)) {
392 if (ve
instanceof TaxonDescription
) {
393 TaxonDescription td
= (TaxonDescription
) ve
;
394 if (td
.getSources().size() > 0) {
395 this.associateImageWithCdmBase(ref
, td
.getSources().iterator().next().getCitation());
397 Reference
<?
> descriptionSource
= ReferenceFactory
.newGeneric();
398 sources
.add(descriptionSource
);
399 td
.addSource(null, null, descriptionSource
, null);
400 this.associateImageWithCdmBase(ref
,descriptionSource
);
403 this.associateImageWithCdmBase(ref
,ve
);
410 * Handles the "Links" element
412 * @param sddNamespace
415 private void makeRepresentationForIdentifiableMediaEntity(Element parent
,
416 Namespace sddNamespace
, IdentifiableMediaEntity ime
) {
417 Element elLinks
= parent
.getChild("Links",sddNamespace
);
419 if (elLinks
!= null) {
421 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
422 List
<Element
> listLinks
= elLinks
.getChildren("Link", sddNamespace
);
423 Media link
= Media
.NewInstance();
424 MediaRepresentation mr
= MediaRepresentation
.NewInstance();
427 for (Element elLink
: listLinks
){
431 String rel
= elLink
.getAttributeValue("rel");
432 String href
= elLink
.getAttributeValue("href");
433 URI uri
= new URI(href
);
434 mr
.addRepresentationPart(MediaRepresentationPart
.NewInstance(uri
, null));
435 link
.addRepresentation(mr
);
438 } catch (Exception e
) {
440 logger
.warn("Import of Link " + k
+ " failed.");
443 if ((++k
% modCount
) == 0){ logger
.info("Links handled: " + k
);}
450 * @param sddNamespace
452 * @param elRepresentation
456 private void makeRepresentationForIdentifiableEntity(Namespace sddNamespace
, IdentifiableEntity
<?
> ie
,
457 Element elRepresentation
, Map
<Language
, List
<String
>> langLabDet
) {
458 List
<String
> labDet
= null;
460 if (ie
instanceof TaxonNameBase
) {
461 if (langLabDet
.keySet().contains(getTermService().getLanguageByIso("la"))) {
462 labDet
= langLabDet
.get(getTermService().getLanguageByIso("la"));
463 } else if (langLabDet
.keySet().contains(datasetLanguage
)) {
464 labDet
= langLabDet
.get(datasetLanguage
);
465 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
467 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
468 logger
.info("TaxonName " + (String
)ImportHelper
.getXmlInputValue(elRepresentation
, "Label",sddNamespace
) + " is not specified as a latin name.");
471 labDet
= langLabDet
.get(langLabDet
.keySet().iterator().next());
474 //FIXME labDet is != null only for TaxonNameBase
475 ie
.setTitleCache(labDet
.get(0), true);
477 if (labDet
.size()>1) {
478 Annotation annotation
= null;
479 if (labDet
.get(1) != null) {
480 if (labDet
.get(2) != null) {
481 annotation
= Annotation
.NewInstance(labDet
.get(2) + " - " + labDet
.get(1), datasetLanguage
);
483 annotation
= Annotation
.NewInstance(labDet
.get(1), datasetLanguage
);
486 ie
.addAnnotation(annotation
);
495 private Language
getLanguage(Element elLanguage
) {
496 String lang
= elLanguage
.getAttributeValue("lang",xmlNamespace
);
497 Language language
= null;
498 if (StringUtils
.isNotBlank(lang
)) {
499 language
= getTermService().getLanguageByIso(lang
.substring(0, 2));
501 language
= datasetLanguage
;
507 // imports the representation (label, detail, lang) of a particular SDD element
508 protected void importTechnicalMetadata(Element root
, Namespace sddNamespace
, SDDImportConfigurator sddConfig
){
509 Element elTechnicalMetadata
= root
.getChild("TechnicalMetadata", sddNamespace
);
510 String nameCreated
= elTechnicalMetadata
.getAttributeValue("created");
511 sourceReference
= sddConfig
.getSourceReference();
513 if (nameCreated
!= null) {
514 if (!nameCreated
.equals("")) {
515 int year
= Integer
.parseInt(nameCreated
.substring(0,4));
516 int monthOfYear
= Integer
.parseInt(nameCreated
.substring(5,7));
517 int dayOfMonth
= Integer
.parseInt(nameCreated
.substring(8,10));
518 int hourOfDay
= Integer
.parseInt(nameCreated
.substring(11,13));
519 int minuteOfHour
= Integer
.parseInt(nameCreated
.substring(14,16));
520 int secondOfMinute
= Integer
.parseInt(nameCreated
.substring(17,19));
521 DateTime created
= new DateTime(year
,monthOfYear
,dayOfMonth
,hourOfDay
,minuteOfHour
,secondOfMinute
,0);
522 sourceReference
.setCreated(created
);
523 sec
.setCreated(created
);
527 // <Generator name="n/a, handcrafted instance document" version="n/a"/>
528 Element elGenerator
= elTechnicalMetadata
.getChild("Generator", sddNamespace
);
529 generatorName
= elGenerator
.getAttributeValue("name");
530 generatorVersion
= elGenerator
.getAttributeValue("version");
532 sec
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
533 sourceReference
.addAnnotation(Annotation
.NewDefaultLanguageInstance(generatorName
+ " - " + generatorVersion
));
537 // imports the complete dataset information
538 protected void importDataset(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){ // <Dataset xml:lang="en-us">
540 workingSet
= WorkingSet
.NewInstance();
541 importDatasetLanguage(elDataset
,state
);
542 importDatasetRepresentation(elDataset
, sddNamespace
);
543 importRevisionData(elDataset
, sddNamespace
);
544 importIPRStatements(elDataset
, sddNamespace
, state
);
545 importTaxonNames(elDataset
, sddNamespace
, state
);
547 importDescriptiveConcepts(elDataset
, sddNamespace
, state
);
548 importCharacters(elDataset
, sddNamespace
, state
);
549 importCharacterTrees(elDataset
, sddNamespace
, state
);
551 MarkerType editorMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerEditor
, "editor", "Editor", "edt");
552 MarkerType geographicAreaMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerSDDGeographicArea
, "SDDGeographicArea", "SDDGeographicArea", "ga");
553 MarkerType descriptiveConceptMarkerType
= getMarkerType(state
, SDDTransformer
.uuidMarkerDescriptiveConcept
, "DescriptiveConcept", "Descriptive Concept", "DC");
554 markerTypes
.add(editorMarkerType
);
555 markerTypes
.add(geographicAreaMarkerType
);
556 markerTypes
.add(descriptiveConceptMarkerType
);
558 //saving of all imported data into the CDM db
564 saveAreas(geographicAreaMarkerType
);
566 saveStatisticalMeasure();
567 saveAnnotationType();
569 importCodedDescriptions(elDataset
, sddNamespace
, state
);
570 importAgents(elDataset
, sddNamespace
, state
);
571 importPublications(elDataset
, sddNamespace
, state
);
572 importMediaObjects(elDataset
, sddNamespace
, state
);
573 importTaxonHierarchies(elDataset
, sddNamespace
, state
);
574 importGeographicAreas(elDataset
, sddNamespace
, state
);
575 importSpecimens(elDataset
,sddNamespace
, state
);
578 if ((authors
!= null)||(editors
!= null)) {
579 Team team
= Team
.NewInstance();
580 if (authors
!= null) {
581 for (Person author
: authors
.values()){
582 team
.addTeamMember(author
);
585 if (editors
!= null) {
586 Marker marker
= Marker
.NewInstance();
587 marker
.setMarkerType(editorMarkerType
);
588 for (Person editor
: editors
.values()){
589 Person edit
= editor
;
590 edit
.addMarker(marker
);
591 team
.addTeamMember(edit
);
594 sec
.setAuthorTeam(team
);
595 sourceReference
.setAuthorTeam(team
);
598 if (copyright
!= null) {
599 sourceReference
.addRights(copyright
);
600 sec
.addRights(copyright
);
603 // Returns a CdmApplicationController created by the values of this configuration.
604 IDescriptionService descriptionService
= getDescriptionService();
606 for (TaxonDescription taxonDescription
: taxonDescriptions
.values()){
607 // Persists a Description
608 descriptionService
.save(taxonDescription
);
611 for (String ref
: taxonDescriptions
.keySet()){
612 TaxonDescription td
= taxonDescriptions
.get(ref
);
613 if (citations
.containsKey(ref
)) {
614 Reference
<?
> publication
= publications
.get(citations
.get(ref
));
615 if (locations
.containsKey(ref
)) {
616 Annotation location
= Annotation
.NewInstance(locations
.get(ref
), datasetLanguage
);
617 //TODO move to a generic place (implemented in hurry therefore dirty)
618 AnnotationType annotationType
= getAnnotationType(state
, uuidAnnotationTypeLocation
, "location", "location", "location", null);
619 // annotationTypes.add(annotationType); TODO necessary??
620 location
.setAnnotationType(annotationType
);
621 (publication
).addAnnotation(location
);
623 td
.addSource(null, null,publication
, null);
626 logger
.info("end makeTaxonDescriptions ...");
628 if (descriptiveConcepts
!= null) {
629 for (Feature feature
: descriptiveConcepts
) {
630 Marker marker
= Marker
.NewInstance();
631 marker
.setMarkerType(descriptiveConceptMarkerType
);
632 feature
.addMarker(marker
);
637 for (Reference
<?
> publication
: publications
.values()){
638 getReferenceService().save(publication
);
641 for (Reference
<?
> source
: sources
){
642 getReferenceService().save(source
);
645 for (FeatureTree featureTree
: featureTrees
) {
646 getFeatureTreeService().save(featureTree
);
648 getWorkingSetService().save(workingSet
);
649 for (Classification classification
: classifications
) {
650 getClassificationService().save(classification
);
652 for (Specimen specimen
: specimens
.values()) {
653 getOccurrenceService().save(specimen
);
655 logger
.info("end of persistence ...");
663 private void saveVocabularies() {
664 for (TermVocabulary
<?
> vocabulary
: vocabularies
){
665 getVocabularyService().save(vocabulary
);
670 private void saveAnnotationType() {
671 for (AnnotationType annotationType
: annotationTypes
){
672 getTermService().saveOrUpdate(annotationType
);
676 private void saveStatisticalMeasure() {
677 for (StatisticalMeasure sm
: statisticalMeasures
){
678 getTermService().save(sm
);
682 private void saveUnits() {
684 for (MeasurementUnit unit
: units
.values()){
686 getTermService().save(unit
);
692 private void saveAreas(MarkerType geographicAreaMarkerType
) {
693 for (NamedArea area
: namedAreas
.values() ){
694 Marker marker
= Marker
.NewInstance();
695 marker
.setMarkerType(geographicAreaMarkerType
);
696 area
.addMarker(marker
);
697 getTermService().save(area
);
701 private void saveStates() {
702 for (State state
: states
.values() ){
703 getTermService().save(state
);
707 private void saveMarkerType() {
708 for (MarkerType markerType
: markerTypes
){
709 getTermService().save(markerType
);
713 private void saveModifiers() {
714 for (Modifier modifier
: modifiers
.values() ){
715 getTermService().save(modifier
);
719 private void saveFeatures() {
720 for (Feature feature
: features
.values() ){
721 getTermService().save(feature
);
725 // imports the default language of the dataset
726 protected void importDatasetLanguage(Element elDataset
, SDDImportState state
){
727 String nameLang
= elDataset
.getAttributeValue("lang",xmlNamespace
);
729 if (StringUtils
.isNotBlank(nameLang
)) {
730 String iso
= nameLang
.substring(0, 2);
731 datasetLanguage
= getTermService().getLanguageByIso(iso
);
733 datasetLanguage
= Language
.DEFAULT();
735 if (datasetLanguage
== null) {
736 datasetLanguage
= Language
.DEFAULT();
740 // imports the specimens
741 protected void importSpecimens(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
742 logger
.info("start Specimens ...");
746 <Label>TJM45337</Label>
751 Element elSpecimens
= elDataset
.getChild("Specimens",sddNamespace
);
752 if (elSpecimens
!= null){
753 List
<Element
> listSpecimens
= elSpecimens
.getChildren("Specimen", sddNamespace
);
754 for (Element elSpecimen
: listSpecimens
) {
755 String id
= elSpecimen
.getAttributeValue("id");
756 Specimen specimen
= null;
757 if (!id
.equals("")) {
758 specimen
= Specimen
.NewInstance();
759 specimens
.put(id
,specimen
);
760 importRepresentation(elSpecimen
, sddNamespace
, specimen
, id
, cdmState
);
767 // imports the revision data associated with the Dataset (authors, modifications)
768 protected void importRevisionData(Element elDataset
, Namespace sddNamespace
){
770 logger
.info("start RevisionData ...");
771 Element elRevisionData
= elDataset
.getChild("RevisionData",sddNamespace
);
772 if (elRevisionData
!= null){
774 Element elCreators
= elRevisionData
.getChild("Creators",sddNamespace
);
776 // <Agent role="aut" ref="a1"/>
777 List
<Element
> listAgents
= elCreators
.getChildren("Agent", sddNamespace
);
781 for (Element elAgent
: listAgents
){
783 String role
= elAgent
.getAttributeValue("role");
784 String ref
= elAgent
.getAttributeValue("ref");
785 if (role
.equals("aut")) {
786 if(!ref
.equals("")) {
787 authors
.put(ref
, null);
790 if (role
.equals("edt")) {
791 if(!ref
.equals("")) {
792 editors
.put(ref
, null);
795 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
799 // <DateModified>2006-04-08T00:00:00</DateModified>
800 String stringDateModified
= (String
)ImportHelper
.getXmlInputValue(elRevisionData
, "DateModified",sddNamespace
);
802 if (stringDateModified
!= null) {
803 SimpleDateFormat sdf
= new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
806 d
= sdf
.parse(stringDateModified
);
807 } catch(Exception e
) {
808 System
.err
.println("Exception :");
812 DateTime updated
= null;
814 updated
= new DateTime(d
);
815 sourceReference
.setUpdated(updated
);
816 sec
.setUpdated(updated
);
822 // imports ipr statements associated with a dataset
823 protected void importIPRStatements(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
825 logger
.info("start IPRStatements ...");
826 Element elIPRStatements
= elDataset
.getChild("IPRStatements",sddNamespace
);
827 // <IPRStatement role="Copyright">
828 if (elIPRStatements
!= null) {
829 List
<Element
> listIPRStatements
= elIPRStatements
.getChildren("IPRStatement", sddNamespace
);
831 //for each IPRStatement
833 for (Element elIPRStatement
: listIPRStatements
){
835 String role
= elIPRStatement
.getAttributeValue("role");
836 // <Label xml:lang="en-au">(c) 2003-2006 Centre for Occasional Botany.</Label>
837 Element elLabel
= elIPRStatement
.getChild("Label",sddNamespace
);
839 if (elLabel
!= null) {
840 lang
= elLabel
.getAttributeValue("lang",xmlNamespace
);
842 String label
= (String
)ImportHelper
.getXmlInputValue(elIPRStatement
, "Label",sddNamespace
);
844 if (role
.equals("Copyright")) {
845 Language iprLanguage
= null;
847 if (!lang
.equals("")) {
848 iprLanguage
= getTermService().getLanguageByIso(lang
.substring(0, 2));
850 iprLanguage
= datasetLanguage
;
853 if (iprLanguage
== null) {
854 iprLanguage
= datasetLanguage
;
856 copyright
= Rights
.NewInstance(label
, iprLanguage
);
859 if (copyright
!= null) {
860 sourceReference
.addRights(copyright
);
861 sec
.addRights(copyright
);
864 if ((++j
% modCount
) == 0){ logger
.info("IPRStatements handled: " + j
);}
870 // imports the taxon names
871 protected void importTaxonNames(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
873 logger
.info("start TaxonNames ...");
874 Element elTaxonNames
= elDataset
.getChild("TaxonNames",sddNamespace
);
875 // <TaxonName id="t1" uri="urn:lsid:authority:namespace:my-own-id">
876 if (elTaxonNames
!= null) {
877 List
<Element
> listTaxonNames
= elTaxonNames
.getChildren("TaxonName", sddNamespace
);
880 for (Element elTaxonName
: listTaxonNames
){
882 String id
= elTaxonName
.getAttributeValue("id");
883 String uri
= elTaxonName
.getAttributeValue("uri");
885 NonViralName
<?
> tnb
= null;
886 if (!id
.equals("")) {
887 tnb
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
888 IdentifiableSource source
= null;
890 if (!uri
.equals("")) {
891 source
= IdentifiableSource
.NewInstance(id
, "TaxonName", ReferenceFactory
.newGeneric(), uri
);
894 source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
896 tnb
.addSource(source
);
897 taxonNameBases
.put(id
,tnb
);
901 // <Label xml:lang="la">Viola hederacea Labill.</Label>
902 importRepresentation(elTaxonName
, sddNamespace
, tnb
, id
, state
);
904 if ((++j
% modCount
) == 0){ logger
.info("TaxonNames handled: " + j
);}
910 // imports the characters (categorical, quantitative and text ; sequence characters not supported) which correspond to CDM Features
911 protected void importCharacters(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
913 logger
.info("start Characters ...");
914 Element elCharacters
= elDataset
.getChild("Characters", sddNamespace
);
916 // <CategoricalCharacter id="c1">
917 if (elCharacters
!= null) {
918 handleCategoricalData(sddNamespace
, cdmState
, elCharacters
);
919 handleQuantitativeData(sddNamespace
, cdmState
, elCharacters
);
920 handleTextCharacters(sddNamespace
, cdmState
, elCharacters
);
923 /*for (Iterator<Feature> f = features.values().iterator() ; f.hasNext() ;){
924 featureSet.add(f.next()); //XIM Why this line ?
932 * @param sddNamespace
934 * @param elCharacters
937 private void handleCategoricalData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
938 List
<Element
> elCategoricalCharacters
= elCharacters
.getChildren("CategoricalCharacter", sddNamespace
);
940 for (Element elCategoricalCharacter
: elCategoricalCharacters
){
943 String idCC
= elCategoricalCharacter
.getAttributeValue("id");
944 Feature categoricalCharacter
= Feature
.NewInstance();
945 categoricalCharacter
.setKindOf(Feature
.DESCRIPTION());
946 importRepresentation(elCategoricalCharacter
, sddNamespace
, categoricalCharacter
, idCC
, cdmState
);
947 categoricalCharacter
.setSupportsCategoricalData(true);
950 Element elStates
= elCategoricalCharacter
.getChild("States",sddNamespace
);
952 // <StateDefinition id="s1">
953 List
<Element
> elStateDefinitions
= elStates
.getChildren("StateDefinition",sddNamespace
);
954 TermVocabulary
<State
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
956 vocabularies
.add(termVocabularyState
);
959 //for each StateDefinition
960 for (Element elStateDefinition
: elStateDefinitions
){
962 if ((++k
% modCount
) == 0){ logger
.info("StateDefinitions handled: " + (k
-1));}
964 String idS
= elStateDefinition
.getAttributeValue("id");
965 State state
= states
.get(idS
);
967 state
= State
.NewInstance();
969 logger
.debug("State duplicate found");
971 importRepresentation(elStateDefinition
, sddNamespace
, state
, idS
, cdmState
);
973 termVocabularyState
.addTerm(state
);
974 states
.put(idS
,state
);
976 categoricalCharacter
.addSupportedCategoricalEnumeration(termVocabularyState
);
977 features
.put(idCC
, categoricalCharacter
);
979 } catch (Exception e
) {
980 logger
.warn("Import of CategoricalCharacter " + j
+ " failed.");
981 cdmState
.setUnsuccessfull();
984 if ((++j
% modCount
) == 0){ logger
.info("CategoricalCharacters handled: " + j
);}
991 * @param sddNamespace
993 * @param elCharacters
995 private void handleQuantitativeData(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
997 // <QuantitativeCharacter id="c2">
998 List
<Element
> elQuantitativeCharacters
= elCharacters
.getChildren("QuantitativeCharacter", sddNamespace
);
1000 //for each QuantitativeCharacter
1001 for (Element elQuantitativeCharacter
: elQuantitativeCharacters
){
1005 String idQC
= elQuantitativeCharacter
.getAttributeValue("id");
1008 // <Label>Leaf length</Label>
1009 // </Representation>
1010 Feature quantitativeCharacter
= Feature
.NewInstance();
1011 quantitativeCharacter
.setKindOf(Feature
.DESCRIPTION());
1012 importRepresentation(elQuantitativeCharacter
, sddNamespace
, quantitativeCharacter
, idQC
, cdmState
);
1014 quantitativeCharacter
.setSupportsQuantitativeData(true);
1016 // <MeasurementUnit>
1017 // <Label role="Abbrev">m</Label>
1018 // </MeasurementUnit>
1019 Element elMeasurementUnit
= elQuantitativeCharacter
.getChild("MeasurementUnit",sddNamespace
);
1022 if (elMeasurementUnit
!= null) {
1023 Element elLabel
= elMeasurementUnit
.getChild("Label",sddNamespace
);
1024 role
= elLabel
.getAttributeValue("role");
1025 label
= (String
)ImportHelper
.getXmlInputValue(elMeasurementUnit
, "Label",sddNamespace
);
1028 MeasurementUnit unit
= null;
1029 if (!label
.equals("")){
1031 if (role
.equals("Abbrev")){
1032 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1035 unit
= MeasurementUnit
.NewInstance(label
,label
,label
);
1040 units
.put(idQC
, unit
);
1044 // <MeasurementUnitPrefix>milli</MeasurementUnitPrefix>
1046 Element elDefault
= elQuantitativeCharacter
.getChild("Default",sddNamespace
);
1047 if (elDefault
!= null) {
1048 String measurementUnitPrefix
= (String
)ImportHelper
.getXmlInputValue(elDefault
, "MeasurementUnitPrefix",sddNamespace
);
1049 if (! measurementUnitPrefix
.equals("")){
1050 defaultUnitPrefixes
.put(idQC
, measurementUnitPrefix
);
1054 features
.put(idQC
, quantitativeCharacter
);
1056 } catch (Exception e
) {
1058 logger
.warn("Import of QuantitativeCharacter " + j
+ " failed.");
1059 cdmState
.setUnsuccessfull();
1062 if ((++j
% modCount
) == 0){ logger
.info("QuantitativeCharacters handled: " + j
);}
1068 private void handleTextCharacters(Namespace sddNamespace
, SDDImportState cdmState
, Element elCharacters
) {
1070 // <TextCharacter id="c3">
1071 List
<Element
> elTextCharacters
= elCharacters
.getChildren("TextCharacter", sddNamespace
);
1073 //for each TextCharacter
1074 for (Element elTextCharacter
: elTextCharacters
){
1078 String idTC
= elTextCharacter
.getAttributeValue("id");
1081 // <Label xml:lang="en">Leaf features not covered by other characters</Label>
1082 // </Representation>
1083 Feature textCharacter
= Feature
.NewInstance();
1084 textCharacter
.setKindOf(Feature
.DESCRIPTION());
1085 importRepresentation(elTextCharacter
, sddNamespace
, textCharacter
, idTC
, cdmState
);
1087 textCharacter
.setSupportsTextData(true);
1089 features
.put(idTC
, textCharacter
);
1091 } catch (Exception e
) {
1093 logger
.warn("Import of TextCharacter " + j
+ " failed.");
1094 cdmState
.setUnsuccessfull();
1097 if ((++j
% modCount
) == 0){ logger
.info("TextCharacters handled: " + j
);}
1103 // imports the descriptions of taxa
1104 protected void importCodedDescriptions(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1106 // <CodedDescriptions>
1107 logger
.info("start CodedDescriptions ...");
1108 Element elCodedDescriptions
= elDataset
.getChild("CodedDescriptions",sddNamespace
);
1110 // <CodedDescription id="D101">
1111 if (elCodedDescriptions
!= null) {
1112 List
<Element
> listCodedDescriptions
= elCodedDescriptions
.getChildren("CodedDescription", sddNamespace
);
1114 //for each CodedDescription
1115 for (Element elCodedDescription
: listCodedDescriptions
){
1116 handleCodedDescription(sddNamespace
, cdmState
, elCodedDescription
, j
);
1117 if ((++j
% modCount
) == 0){ logger
.info("CodedDescriptions handled: " + j
);}
1124 * @param sddNamespace
1127 * @param elCodedDescription
1130 private void handleCodedDescription(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
, int j
) {
1133 String idCD
= elCodedDescription
.getAttributeValue("id");
1136 // <Label><i>Viola hederacea</i> Labill. as revised by R. Morris April 8, 2006</Label>
1137 // </Representation>
1138 TaxonDescription taxonDescription
= TaxonDescription
.NewInstance();
1139 if (!generatorName
.isEmpty()){
1140 Annotation annotation
= Annotation
.NewInstance(generatorName
, AnnotationType
.TECHNICAL(),Language
.DEFAULT());
1141 taxonDescription
.addAnnotation(annotation
);
1143 importRepresentation(elCodedDescription
, sddNamespace
, taxonDescription
, idCD
, cdmState
);
1146 // <TaxonName ref="t1"/>
1147 // <Citation ref="p1" location="p. 30"/>
1149 Element elScope
= elCodedDescription
.getChild("Scope", sddNamespace
);
1151 if (elScope
!= null) {
1152 taxon
= handleCDScope(sddNamespace
, cdmState
, idCD
, elScope
);
1153 } else {//in case no taxon is linked to the description, a new one is created
1154 taxon
= handleCDNoScope(sddNamespace
, cdmState
, elCodedDescription
);
1158 Element elSummaryData
= elCodedDescription
.getChild("SummaryData",sddNamespace
);
1159 if (elSummaryData
!= null) {
1160 handleSummaryCategoricalData(sddNamespace
, taxonDescription
, elSummaryData
);
1161 handleSummaryQuantitativeData(sddNamespace
, taxonDescription
, elSummaryData
);
1162 handleSummaryTextData(sddNamespace
, taxonDescription
, elSummaryData
);
1165 if (taxon
!= null) {
1166 taxon
.addDescription(taxonDescription
);
1169 workingSet
.addDescription(taxonDescription
);
1171 //OLD taxonDescription.setDescriptiveSystem(featureSet);
1173 taxonDescriptions
.put(idCD
, taxonDescription
);//FIXME
1175 } catch (Exception e
) {
1177 logger
.warn("Import of CodedDescription " + j
+ " failed.", e
);
1178 cdmState
.setUnsuccessfull();
1184 * @param sddNamespace
1186 * @param elCodedDescription
1190 private Taxon
handleCDNoScope(Namespace sddNamespace
, SDDImportState cdmState
, Element elCodedDescription
) {
1192 NonViralName
<?
> nonViralName
= NonViralName
.NewInstance(Rank
.UNKNOWN_RANK());
1193 String id
= new String("" + taxonNamesCount
);
1194 IdentifiableSource source
= IdentifiableSource
.NewInstance(id
, "TaxonName");
1195 importRepresentation(elCodedDescription
, sddNamespace
, nonViralName
, id
, cdmState
);
1197 if(cdmState
.getConfig().isDoMatchTaxa()){
1198 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1202 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1203 // taxonNameBases.put(id ,tnb);
1204 // taxonNamesCount++;
1205 logger
.info("using existing Taxon " + taxon
.getTitleCache());
1207 nonViralName
.addSource(source
);
1208 taxonNameBases
.put(id
,nonViralName
);
1210 logger
.info("creating new Taxon from TaxonName " + nonViralName
.getTitleCache());
1211 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1217 * @param sddNamespace
1224 private Taxon
handleCDScope(Namespace sddNamespace
, SDDImportState cdmState
,
1225 String idCD
, Element elScope
) {
1227 Element elTaxonName
= elScope
.getChild("TaxonName", sddNamespace
);
1228 String ref
= elTaxonName
.getAttributeValue("ref");
1229 NonViralName
<?
> nonViralName
= taxonNameBases
.get(ref
);
1231 if(cdmState
.getConfig().isDoMatchTaxa()){
1232 taxon
= getTaxonService().findBestMatchingTaxon(nonViralName
.getTitleCache());
1236 logger
.info("using existing Taxon" + taxon
.getTitleCache());
1237 if(!nonViralName
.getUuid().equals(taxon
.getName().getUuid())){
1238 logger
.warn("TaxonNameBase entity of existing taxon does not match Name in list -> replacing Name in list");
1239 nonViralName
= HibernateProxyHelper
.deproxy(taxon
.getName(), NonViralName
.class);
1242 logger
.info("creating new Taxon from TaxonName '" + nonViralName
.getTitleCache()+"'");
1243 taxon
= Taxon
.NewInstance(nonViralName
, sec
);
1247 Element elCitation
= elScope
.getChild("Citation",sddNamespace
);
1248 if (elCitation
!= null) {
1249 String refCitation
= elCitation
.getAttributeValue("ref");
1250 if (! refCitation
.equals("")){
1251 citations
.put(idCD
, refCitation
);
1253 String location
= elCitation
.getAttributeValue("location");
1254 if (! location
.equals("")){
1255 locations
.put(idCD
, location
);
1262 * @param sddNamespace
1263 * @param taxonDescription
1264 * @param elSummaryData
1266 private void handleSummaryTextData(Namespace sddNamespace
,
1267 TaxonDescription taxonDescription
, Element elSummaryData
) {
1270 // <TextChar ref="c3">
1271 List
<Element
> elTextChars
= elSummaryData
.getChildren("TextChar", sddNamespace
);
1274 for (Element elTextChar
: elTextChars
){
1275 if ((++k
% modCount
) == 0){ logger
.info("TextChar handled: " + (k
-1));}
1276 ref
= elTextChar
.getAttributeValue("ref");
1277 Feature feature
= features
.get(ref
);
1278 TextData textData
= TextData
.NewInstance();
1279 textData
.setFeature(feature
);
1281 // <Content>Free form text</Content>
1282 String content
= (String
)ImportHelper
.getXmlInputValue(elTextChar
, "Content",sddNamespace
);
1283 textData
.putText(datasetLanguage
, content
);
1284 taxonDescription
.addElement(textData
);
1289 * @param sddNamespace
1290 * @param taxonDescription
1291 * @param elSummaryData
1293 private void handleSummaryQuantitativeData(Namespace sddNamespace
,
1294 TaxonDescription taxonDescription
, Element elSummaryData
) {
1297 // <Quantitative ref="c2">
1298 List
<Element
> elQuantitatives
= elSummaryData
.getChildren("Quantitative", sddNamespace
);
1300 //for each Quantitative
1301 for (Element elQuantitative
: elQuantitatives
){
1302 if ((++k
% modCount
) == 0){ logger
.warn("Quantitative handled: " + (k
-1));}
1303 ref
= elQuantitative
.getAttributeValue("ref");
1304 Feature feature
= features
.get(ref
);
1305 QuantitativeData quantitativeData
= QuantitativeData
.NewInstance();
1306 quantitativeData
.setFeature(feature
);
1308 MeasurementUnit unit
= units
.get(ref
);
1309 String prefix
= defaultUnitPrefixes
.get(ref
);
1311 String u
= unit
.getLabel();
1312 if (prefix
!= null) {
1316 quantitativeData
.setUnit(unit
);
1319 // <Measure type="Min" value="2.3"/>
1320 List
<Element
> elMeasures
= elQuantitative
.getChildren("Measure", sddNamespace
);
1324 for (Element elMeasure
: elMeasures
){
1325 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1326 String type
= elMeasure
.getAttributeValue("type");
1327 String value
= elMeasure
.getAttributeValue("value");
1328 if (value
.contains(",")) {
1329 value
= value
.replace(',', '.');
1331 Float v
= Float
.parseFloat(value
);
1332 //Float v = new Float(0);
1333 StatisticalMeasure t
= null;
1334 if (type
.equals("Min")) {
1335 t
= StatisticalMeasure
.MIN();
1336 } else if (type
.equals("Mean")) {
1337 t
= StatisticalMeasure
.AVERAGE();
1338 } else if (type
.equals("Max")) {
1339 t
= StatisticalMeasure
.MAX();
1340 } else if (type
.equals("SD")) {
1341 t
= StatisticalMeasure
.STANDARD_DEVIATION();
1342 } else if (type
.equals("N")) {
1343 t
= StatisticalMeasure
.SAMPLE_SIZE();
1344 } else if (type
.equals("UMethLower")) {
1345 t
= StatisticalMeasure
.TYPICAL_LOWER_BOUNDARY();
1346 } else if (type
.equals("UMethUpper")) {
1347 t
= StatisticalMeasure
.TYPICAL_UPPER_BOUNDARY();
1348 } else if (type
.equals("Var")) {
1349 t
= StatisticalMeasure
.VARIANCE();
1351 t
= StatisticalMeasure
.NewInstance(type
,type
,type
);
1352 statisticalMeasures
.add(t
);
1355 StatisticalMeasurementValue statisticalValue
= StatisticalMeasurementValue
.NewInstance();
1356 statisticalValue
.setValue(v
);
1357 statisticalValue
.setType(t
);
1358 quantitativeData
.addStatisticalValue(statisticalValue
);
1359 featureData
.add(statisticalValue
);
1361 taxonDescription
.addElement(quantitativeData
);
1366 * @param sddNamespace
1367 * @param taxonDescription
1368 * @param elSummaryData
1370 private void handleSummaryCategoricalData(Namespace sddNamespace
,
1371 TaxonDescription taxonDescription
, Element elSummaryData
) {
1373 // <Categorical ref="c4">
1374 List
<Element
> elCategoricals
= elSummaryData
.getChildren("Categorical", sddNamespace
);
1376 //for each Categorical
1377 for (Element elCategorical
: elCategoricals
){
1378 if ((++k
% modCount
) == 0){ logger
.warn("Categorical handled: " + (k
-1));}
1379 ref
= elCategorical
.getAttributeValue("ref");
1380 Feature feature
= features
.get(ref
);
1381 CategoricalData categoricalData
= CategoricalData
.NewInstance();
1382 categoricalData
.setFeature(feature
);
1384 // <State ref="s3"/>
1385 List
<Element
> elStates
= elCategorical
.getChildren("State", sddNamespace
);
1389 for (Element elState
: elStates
){
1390 if ((++l
% modCount
) == 0){ logger
.info("States handled: " + (l
-1));}
1391 ref
= elState
.getAttributeValue("ref");
1392 State state
= states
.get(ref
);
1393 if (state
!= null) {
1394 StateData stateData
= StateData
.NewInstance();
1395 stateData
.setState(state
);
1396 List
<Element
> elModifiers
= elState
.getChildren("Modifier", sddNamespace
);
1397 for (Element elModifier
: elModifiers
){
1398 ref
= elModifier
.getAttributeValue("ref");
1399 Modifier modifier
= modifiers
.get(ref
);
1400 if (modifier
!= null) {
1401 stateData
.addModifier(modifier
);
1404 categoricalData
.addState(stateData
);
1406 taxonDescription
.addElement(categoricalData
);
1411 // imports the persons associated with the dataset creation, modification, related publications
1412 protected void importAgents(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1414 logger
.info("start Agents ...");
1415 Element elAgents
= elDataset
.getChild("Agents",sddNamespace
);
1416 if (elAgents
!= null) {
1418 List
<Element
> listAgents
= elAgents
.getChildren("Agent", sddNamespace
);
1421 for (Element elAgent
: listAgents
){
1425 String idA
= elAgent
.getAttributeValue("id");
1428 // <Label>Kevin Thiele</Label>
1429 // <Detail role="Description">Ali Baba is also known as r.a.m.</Detail>
1430 // </Representation>
1431 Person person
= Person
.NewInstance();
1432 importRepresentation(elAgent
, sddNamespace
, person
, idA
, cdmState
);
1433 person
.addSource(IdentifiableSource
.NewInstance(idA
, "Agent"));
1436 Element elLinks = elAgent.getChild("Links",sddNamespace);
1438 if (elLinks != null) {
1440 // <Link rel="Alternate" href="http://www.diversitycampus.net/people/hagedorn"/>
1441 List<Element> listLinks = elLinks.getChildren("Link", sddNamespace);
1444 for (Element elLink : listLinks){
1448 String rel = elLink.getAttributeValue("rel");
1449 String href = elLink.getAttributeValue("href");
1451 Media link = Media.NewInstance();
1452 MediaRepresentation mr = MediaRepresentation.NewInstance();
1453 mr.addRepresentationPart(MediaRepresentationPart.NewInstance(href, null));
1454 link.addRepresentation(mr);
1455 person.addMedia(link);
1457 } catch (Exception e) {
1459 logger.warn("Import of Link " + k + " failed.");
1463 if ((++k % modCount) == 0){ logger.info("Links handled: " + k);}
1468 if (authors
.containsKey(idA
)) {
1469 authors
.put(idA
,person
);
1472 if (editors
.containsKey(idA
)) {
1473 editors
.put(idA
, person
);
1476 } catch (Exception e
) {
1478 logger
.warn("Import of Agent " + j
+ " failed.");
1479 cdmState
.setUnsuccessfull();
1482 if ((++j
% modCount
) == 0){ logger
.info("Agents handled: " + j
);}
1488 // imports publications related with the data set
1489 protected void importPublications(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1491 <Publication id="p112">
1493 <Label>Gee, X. & Haa, Y. (2003). How to be happy in five minutes. Instant Gratifications, Palm Beach.</Label>
1496 <Link rel="BasedOn" href="doi:10.1992/32311"/>
1497 <Link rel="Alternate" href="http://some.service.net/providing/bibliographic.data"/>
1501 logger
.info("start Publications ...");
1502 Element elPublications
= elDataset
.getChild("Publications",sddNamespace
);
1504 if (elPublications
!= null) {
1505 List
<Element
> listPublications
= elPublications
.getChildren("Publication", sddNamespace
);
1507 for (Element elPublication
: listPublications
){
1511 String idP
= elPublication
.getAttributeValue("id");
1512 Reference
<?
> publication
= ReferenceFactory
.newArticle();
1513 importRepresentation(elPublication
, sddNamespace
, publication
, idP
, cdmState
);
1515 publications
.put(idP
,publication
);
1517 } catch (Exception e
) {
1518 logger
.warn("Import of Publication " + j
+ " failed.");
1519 cdmState
.setUnsuccessfull();
1522 if ((++j
% modCount
) == 0){ logger
.info("Publications handled: " + j
);}
1528 // imports media objects such as images //FIXME check mediaobj
1529 protected void importMediaObjects(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1531 logger
.info("start MediaObjects ...");
1532 Element elMediaObjects
= elDataset
.getChild("MediaObjects",sddNamespace
);
1534 if (elMediaObjects
!= null) {
1535 // <MediaObject id="m1">
1536 List
<Element
> listMediaObjects
= elMediaObjects
.getChildren("MediaObject", sddNamespace
);
1538 for (Element elMO
: listMediaObjects
){
1543 String idMO
= elMO
.getAttributeValue("id");
1547 // <Label>Image description, e.g. to be used for alt-attribute in html.</Label>
1548 // </Representation>
1549 Media media
= Media
.NewInstance();
1550 importRepresentation(elMO
, sddNamespace
, media
, idMO
, cdmState
);
1552 // <Type>Image</Type>
1553 // <Source href="http://test.edu/test.jpg"/>
1554 String type
= (String
)ImportHelper
.getXmlInputValue(elMO
,"Type",sddNamespace
);
1556 if ((type
!= null) && (type
.equals("Image"))) {
1557 Element elSource
= elMO
.getChild("Source",sddNamespace
);
1558 String href
= elSource
.getAttributeValue("href");
1560 ImageInfo imageMetaData
= null;
1561 ImageFile image
= null;
1563 if (href
.substring(0,7).equals("http://")) {
1565 URL url
= new URL(href
);
1567 imageMetaData
= ImageInfo
.NewInstance(url
.toURI(), 0);
1568 image
= ImageFile
.NewInstance(url
.toURI(), null, imageMetaData
);
1569 } catch (MalformedURLException e
) {
1570 logger
.error("Malformed URL", e
);
1571 } catch (IOException ioe
) {
1572 logger
.warn("(IO ex: " + id
+ "): " + ioe
.getMessage());
1576 String sns
= cdmState
.getConfig().getSourceNameString();
1577 File f
= new File(sns
);
1578 File parent
= f
.getParentFile();
1579 String fi
= parent
.toString() + File
.separator
+ href
;
1580 File file
= new File(fi
);
1581 imageMetaData
= ImageInfo
.NewInstance(new URI(fi
), 0); //file
1582 image
= ImageFile
.NewInstance(file
.toURI(), null, imageMetaData
);
1584 MediaRepresentation representation
= MediaRepresentation
.NewInstance(imageMetaData
.getMimeType(), null);
1585 representation
.addRepresentationPart(image
);
1587 media
.addRepresentation(representation
);
1589 ArrayList
<CdmBase
> lcb
= (ArrayList
<CdmBase
>) mediaObject_ListCdmBase
.get(idMO
);
1591 for (int k
= 0; k
< lcb
.size(); k
++) {
1592 if (lcb
.get(k
) instanceof DefinedTermBase
) {
1593 DefinedTermBase
<?
> dtb
= (DefinedTermBase
<?
>) lcb
.get(k
);
1594 // if (lcb.get(0) instanceof DefinedTermBase) {
1595 // DefinedTermBase dtb = (DefinedTermBase) lcb.get(0);
1598 dtb
.addMedia(media
);
1599 //System.out.println(dtb.getLabel());
1601 // Media me = (Media) media.clone();
1602 // dtb.addMedia(me);
1605 } else if (lcb
.get(k
) instanceof Reference
) {
1606 Reference
<?
> rb
= (Reference
<?
>) lcb
.get(k
);
1607 //} else if (lcb.get(0) instanceof Reference) {
1608 //Reference rb = (Reference) lcb.get(0);
1609 // rb.setTitleCache(label);
1613 //System.out.println(rb.getTitle());
1615 // Media me = (Media) media.clone();
1619 // else if (lcb.get(k) instanceof TaxonNameBase){
1620 // TaxonNameBase tb = (TaxonNameBase) lcb.get(k);
1621 // tb.addMedia(media);
1623 logger
.warn("Can't handle associated media for " + lcb
.get(k
).getId() + "(" + lcb
.get(k
).getClass().getSimpleName()+")" );
1629 } catch (Exception e
) {
1631 logger
.warn("Could not attach MediaObject " + j
+ "(SDD: " + id
+ ") to several objects: " + e
.getMessage());
1632 cdmState
.setUnsuccessfull();
1635 if ((++j
% modCount
) == 0){ logger
.info("MediaObjects handled: " + j
);
1642 // imports the <DescriptiveConcepts> block ; DescriptiveConcepts are used as nodes in CharacterTrees and Characters as leaves
1643 // but since Modifiers can be linked to DescriptiveConcepts they are stored as features with a particular Marker
1644 protected void importDescriptiveConcepts(Element elDataset
, Namespace sddNamespace
, SDDImportState state
){
1645 /* <DescriptiveConcepts>
1646 <DescriptiveConcept id="dc0">
1648 <Label>Fixed set of modifiers supported in Lucid3</Label>
1651 <Modifier id="mod1">
1653 <Label>rarely</Label>
1655 <ModifierClass>Frequency</ModifierClass>
1656 <ProportionRange lowerestimate="0.0" upperestimate="0.25"/>
1659 </DescriptiveConcept>
1660 </DescriptiveConcepts>
1662 logger
.info("start DescriptiveConcepts ...");
1663 Element elDescriptiveConcepts
= elDataset
.getChild("DescriptiveConcepts",sddNamespace
);
1664 if (elDescriptiveConcepts
!= null) {
1665 List
<Element
> listDescriptiveConcepts
= elDescriptiveConcepts
.getChildren("DescriptiveConcept", sddNamespace
);
1668 for (Element elDescriptiveConcept
: listDescriptiveConcepts
){
1670 String id
= elDescriptiveConcept
.getAttributeValue("id");
1671 Feature feature
= Feature
.NewInstance();
1672 feature
.setKindOf(Feature
.DESCRIPTION());
1673 if (!id
.equals("")) {
1675 // <Label>Body</Label>
1676 importRepresentation(elDescriptiveConcept
, sddNamespace
, feature
, id
, state
);
1677 features
.put(id
, feature
);
1678 getTermService().save(feature
);//XIM
1679 descriptiveConcepts
.add(feature
);
1680 // imports the modifiers
1681 Element elModifiers
= elDescriptiveConcept
.getChild("Modifiers", sddNamespace
);
1682 if (elModifiers
!=null){
1683 List
<Element
> listModifiers
= elModifiers
.getChildren("Modifier", sddNamespace
);
1684 TermVocabulary
<Modifier
> termVocabularyState
= TermVocabulary
.NewInstance(null, null, null, null);
1685 for (Element elModifier
: listModifiers
) {
1686 Modifier modif
= Modifier
.NewInstance();
1687 String idmod
= elModifier
.getAttributeValue("id");
1688 importRepresentation(elModifier
, sddNamespace
, modif
, idmod
, state
);
1689 termVocabularyState
.addTerm(modif
);
1690 //termVocabularyStates.add(termVocabularyState);
1691 getVocabularyService().save(termVocabularyState
);//XIM
1692 modifiers
.put(idmod
, modif
);
1694 feature
.addRecommendedModifierEnumeration(termVocabularyState
);
1699 catch (Exception e
) {
1700 logger
.warn("Import of DescriptiveConcept " + j
+ " failed: " + e
.getMessage());
1702 if ((++j
% modCount
) == 0){ logger
.info("DescriptiveConcepts handled: " + j
);}
1708 // imports the <CharacterTrees> block
1709 protected void importCharacterTrees(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1711 logger
.info("start CharacterTrees ...");
1712 Element elCharacterTrees
= elDataset
.getChild("CharacterTrees",sddNamespace
);
1714 if (elCharacterTrees
!= null) {
1715 List
<Element
> listCharacterTrees
= elCharacterTrees
.getChildren("CharacterTree", sddNamespace
);
1717 for (Element elCharacterTree
: listCharacterTrees
){
1719 Element elRepresentation
= elCharacterTree
.getChild("Representation",sddNamespace
);
1720 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1721 //Element elDesignedFor = elCharacterTree.getChild("DesignedFor",sddNamespace);//TODO ?
1723 FeatureTree featureTree
= FeatureTree
.NewInstance();
1724 importRepresentation(elCharacterTree
, sddNamespace
, featureTree
, "", cdmState
);
1725 FeatureNode root
= featureTree
.getRoot();
1726 List
<Element
> listeOfNodes
= elCharacterTree
.getChildren("Nodes", sddNamespace
);
1728 //Nodes of CharacterTrees in SDD always refer to DescriptiveConcepts
1729 for (Element elNodes
: listeOfNodes
) {
1730 handleCharacterNodes(sddNamespace
, root
, elNodes
);
1732 featureTrees
.add(featureTree
);
1733 if (workingSet
.getDescriptiveSystem() != null){
1734 //TODO how to handle multiple
1735 logger
.warn("Multiple feature trees not yet supported");
1737 workingSet
.setDescriptiveSystem(featureTree
);
1741 catch (Exception e
) {
1742 logger
.warn("Import of Character tree " + j
+ " failed.");
1743 cdmState
.setUnsuccessfull();
1745 if ((++j
% modCount
) == 0){ logger
.info("CharacterTrees handled: " + j
);}
1753 * @param sddNamespace
1757 private void handleCharacterNodes(Namespace sddNamespace
, FeatureNode root
, Element elNodes
) {
1758 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1759 if (listNodes
!= null) {
1760 for (Element elNode
: listNodes
){
1761 String idN
= elNode
.getAttributeValue("id");
1762 FeatureNode fn
= null;
1765 // DescriptiveConcepts are used as nodes in CharacterTrees
1766 Element elDescriptiveConcept
= elNode
.getChild("DescriptiveConcept", sddNamespace
);
1767 if (elDescriptiveConcept
!= null){
1768 String refDC
= elDescriptiveConcept
.getAttributeValue("ref");
1769 dc
= features
.get(refDC
);
1770 fn
= FeatureNode
.NewInstance(dc
);
1773 fn
= FeatureNode
.NewInstance();
1775 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1776 // in SDD links between Nodes are referenced by the <Parent> tag
1777 if (elParent
!=null){
1778 String refP
= elParent
.getAttributeValue("ref");
1780 FeatureNode parent
= featureNodes
.get(refP
);
1782 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1785 parent
.addChild(fn
);
1790 root
.addChild(fn
); // if no parent found or the reference is broken, add the node to the root of the tree
1793 featureNodes
.put(idN
, fn
);
1797 // Leaves of CharacterTrees in SDD are always CharNodes (referring to Characters)
1798 List
<Element
> listCharNodes
= elNodes
.getChildren("CharNode", sddNamespace
);
1799 if (listCharNodes
!= null) {
1800 for (Element elCharNode
: listCharNodes
){
1801 Element elParent
= elCharNode
.getChild("Parent", sddNamespace
);
1802 Element elCharacter
= elCharNode
.getChild("Character", sddNamespace
);
1803 Element elDependencyRules
= elCharNode
.getChild("DependencyRules", sddNamespace
);
1804 FeatureNode fn
= FeatureNode
.NewInstance();
1806 if (elDependencyRules
!=null){
1807 Element elInapplicableIf
= elCharNode
.getChild("InapplicableIf", sddNamespace
);
1808 if (elInapplicableIf
!=null){
1809 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1810 for (Element stateElement
: listStates
) {
1811 String refState
= stateElement
.getAttributeValue("ref");
1812 if ((refState
!=null)&&(!refState
.equals(""))) {
1813 State state
= states
.get(refState
);
1814 fn
.addInapplicableState(state
);
1818 Element elOnlyapplicableIf
= elCharNode
.getChild("OnlyApplicableIf", sddNamespace
);
1819 if (elOnlyapplicableIf
!=null){
1820 List
<Element
> listStates
= elInapplicableIf
.getChildren("State", sddNamespace
);
1821 for (Element stateElement
: listStates
) {
1822 String refState
= stateElement
.getAttributeValue("ref");
1823 if ((refState
!=null)&&(!refState
.equals(""))) {
1824 State state
= states
.get(refState
);
1825 fn
.addApplicableState(state
);
1831 if (elParent
!=null){
1832 String refP
= elParent
.getAttributeValue("ref");
1833 if ((refP
!=null)&&(!refP
.equals(""))) {
1834 FeatureNode parent
= featureNodes
.get(refP
);
1836 parent
= root
; // if no parent found or the reference is broken, add the node to the root of the tree
1838 parent
.addChild(fn
);
1841 String refC
= elCharacter
.getAttributeValue("ref");
1842 if ((refC
!=null)&&(!refC
.equals(""))){
1843 Feature character
= features
.get(refC
);
1844 fn
.setFeature(character
);
1845 featureNodes
.put(refC
, fn
);
1851 // imports the <TaxonHierarchies> block
1852 protected void importTaxonHierarchies(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
){
1854 logger
.info("start TaxonHierarchies ...");
1855 Element elTaxonHierarchies
= elDataset
.getChild("TaxonHierarchies",sddNamespace
);
1857 if (elTaxonHierarchies
!= null) {
1858 List
<Element
> listTaxonHierarchies
= elTaxonHierarchies
.getChildren("TaxonHierarchy", sddNamespace
);
1860 for (Element elTaxonHierarchy
: listTaxonHierarchies
){
1862 Element elRepresentation
= elTaxonHierarchy
.getChild("Representation",sddNamespace
);
1863 String label
= (String
)ImportHelper
.getXmlInputValue(elRepresentation
,"Label",sddNamespace
);
1864 Classification classification
= Classification
.NewInstance(label
);
1865 importRepresentation(elTaxonHierarchy
, sddNamespace
, classification
, "", cdmState
);
1867 Element elNodes
= elTaxonHierarchy
.getChild("Nodes", sddNamespace
); // There can be only one <Nodes> block for TaxonHierarchies
1868 List
<Element
> listNodes
= elNodes
.getChildren("Node", sddNamespace
);
1870 for (Element elNode
: listNodes
){
1871 String idN
= elNode
.getAttributeValue("id");
1872 TaxonNameBase
<?
,?
> tnb
= null;
1873 if (!idN
.equals("")) {
1874 Element elTaxonName
= elNode
.getChild("TaxonName", sddNamespace
);
1875 String refTN
= elTaxonName
.getAttributeValue("ref");
1876 tnb
= taxonNameBases
.get(refTN
);
1877 Taxon taxon
= (Taxon
) tnb
.getTaxa().iterator().next() ;
1878 Element elParent
= elNode
.getChild("Parent", sddNamespace
);
1879 if (elParent
!=null){
1880 String refP
= elParent
.getAttributeValue("ref");
1881 if (!refP
.equals("")) {
1882 TaxonNode parent
= taxonNodes
.get(refP
);
1883 TaxonNode child
= parent
.addChildTaxon(taxon
, sec
, "", Synonym
.NewInstance(tnb
, sec
));
1884 taxonNodes
.put(idN
,child
);
1888 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
1889 taxonNodes
.put(idN
,tn
);
1894 classifications
.add(classification
);
1897 catch (Exception e
) {
1899 logger
.warn("Import of Taxon Hierarchy " + j
+ " failed.");
1900 cdmState
.setUnsuccessfull();
1903 if ((++j
% modCount
) == 0){ logger
.info("TaxonHierarchies handled: " + j
);}
1911 // imports the <GeographicAreas> block
1912 protected void importGeographicAreas(Element elDataset
, Namespace sddNamespace
, SDDImportState cdmState
) {
1913 Element elGeographicAreas
= elDataset
.getChild("GeographicAreas",sddNamespace
);
1914 if (elGeographicAreas
!= null) {
1915 List
<Element
> listGeographicAreas
= elGeographicAreas
.getChildren("GeographicArea", sddNamespace
);
1918 for (Element elGeographicArea
: listGeographicAreas
){
1920 String id
= elGeographicArea
.getAttributeValue("id");
1921 NamedArea na
= new NamedArea();
1922 importRepresentation(elGeographicArea
, sddNamespace
, na
, id
, cdmState
);
1923 namedAreas
.put(id
,na
);
1925 if ((++j
% modCount
) == 0){ logger
.info("GeographicAreas handled: " + j
);}