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
.tcsrdf
;
12 import java
.io
.IOException
;
13 import java
.io
.InputStream
;
14 import java
.util
.List
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.jdom
.Attribute
;
19 import org
.jdom
.Element
;
20 import org
.jdom
.Namespace
;
21 import org
.springframework
.stereotype
.Component
;
23 import com
.hp
.hpl
.jena
.rdf
.model
.Model
;
24 import com
.hp
.hpl
.jena
.rdf
.model
.ModelFactory
;
25 import com
.hp
.hpl
.jena
.rdf
.model
.RDFNode
;
26 import com
.hp
.hpl
.jena
.rdf
.model
.ResIterator
;
27 import com
.hp
.hpl
.jena
.rdf
.model
.Resource
;
28 import com
.hp
.hpl
.jena
.rdf
.model
.Selector
;
29 import com
.hp
.hpl
.jena
.rdf
.model
.SimpleSelector
;
30 import com
.hp
.hpl
.jena
.rdf
.model
.Statement
;
31 import com
.hp
.hpl
.jena
.rdf
.model
.StmtIterator
;
32 import com
.hp
.hpl
.jena
.vocabulary
.*;
33 import com
.hp
.hpl
.jena
.rdf
.model
.Property
;
35 import org
.apache
.commons
.io
.IOUtils
;
36 import org
.apache
.jena
.iri
.IRIFactory
;
38 import eu
.etaxonomy
.cdm
.common
.XmlHelp
;
39 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
40 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
41 import eu
.etaxonomy
.cdm
.io
.common
.MapWrapper
;
42 import eu
.etaxonomy
.cdm
.model
.agent
.INomenclaturalAuthor
;
43 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
44 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
45 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
46 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
47 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
48 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
49 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatus
;
50 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
51 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
52 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
53 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
54 import eu
.etaxonomy
.cdm
.model
.name
.ViralName
;
55 import eu
.etaxonomy
.cdm
.model
.reference
.IGeneric
;
56 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
57 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
58 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
66 public class TcsRdfTaxonNameImport
extends TcsRdfImportBase
implements ICdmIO
<TcsRdfImportState
> {
67 private static final Logger logger
= Logger
.getLogger(TcsRdfTaxonNameImport
.class);
69 private static int modCount
= 5000;
71 public TcsRdfTaxonNameImport(){
76 public boolean doCheck(TcsRdfImportState config
){
77 boolean result
= true;
78 logger
.warn("BasionymRelations not yet implemented");
79 logger
.warn("Checking for TaxonNames not yet implemented");
80 //result &= checkArticlesWithoutJournal(tcsConfig);
81 //result &= checkPartOfJournal(tcsConfig);
86 protected static CdmSingleAttributeRDFMapperBase
[] standardMappers
= new CdmSingleAttributeRDFMapperBase
[]{
87 new CdmTextElementMapper("genusPart", "genusOrUninomial")
88 , new CdmTextElementMapper("uninomial", "genusOrUninomial") //TODO make it a more specific Mapper for both attributes
89 , new CdmTextElementMapper("specificEpithet", "specificEpithet")
90 , new CdmTextElementMapper("infraspecificEpithet", "infraSpecificEpithet")
91 , new CdmTextElementMapper("infragenericEpithet", "infraGenericEpithet")
92 , new CdmTextElementMapper("microReference", nsTcom
, "nomenclaturalMicroReference")
96 protected static CdmSingleAttributeRDFMapperBase
[] operationalMappers
= new CdmSingleAttributeRDFMapperBase
[]{
97 new CdmUnclearMapper("basionymAuthorship")
98 , new CdmUnclearMapper("combinationAuthorship")
99 , new CdmUnclearMapper("hasAnnotation")
100 , new CdmUnclearMapper("rank")
101 , new CdmUnclearMapper("nomenclaturalCode")
102 , new CdmUnclearMapper("publishedIn", nsTcom
)
103 , new CdmUnclearMapper("year")
106 protected static CdmSingleAttributeRDFMapperBase
[] unclearMappers
= new CdmSingleAttributeRDFMapperBase
[]{
107 new CdmUnclearMapper("authorship")
108 , new CdmUnclearMapper("rankString")
109 , new CdmUnclearMapper("nameComplete")
110 , new CdmUnclearMapper("hasBasionym")
111 , new CdmUnclearMapper("dateOfEntry", nsTpalm
)
115 protected void doInvoke(TcsRdfImportState state
){
117 MapWrapper
<TaxonNameBase
> taxonNameMap
= (MapWrapper
<TaxonNameBase
>)state
.getStore(ICdmIO
.TAXONNAME_STORE
);
118 MapWrapper
<Reference
> referenceMap
= (MapWrapper
<Reference
>)state
.getStore(ICdmIO
.REFERENCE_STORE
);
119 MapWrapper
<TeamOrPersonBase
> authorMap
= (MapWrapper
<TeamOrPersonBase
>)state
.getStore(ICdmIO
.TEAM_STORE
);
121 String tcsElementName
;
122 Namespace tcsNamespace
;
125 logger
.info("start makeTaxonNames ...");
126 TcsRdfImportConfigurator config
= state
.getConfig();
127 Model root
= config
.getSourceRoot();
129 String rdfNamespace
= config
.getRdfNamespaceURIString();
130 String taxonNameNamespace
= config
.getTnNamespaceURIString();
132 String idNamespace
= "TaxonName";
134 Resource elTaxonName
= root
.getResource(taxonNameNamespace
);
139 Property property
= root
.getProperty(taxonNameNamespace
+"authorship");
141 ResIterator iterator
= root
.listSubjectsWithProperty(property
, (RDFNode
) null);
143 while (iterator
.hasNext()){
145 Resource resource
= iterator
.next();
147 name
= handleNameResource(resource
, config
);
148 id
= resource
.getNameSpace();
149 taxonNameMap
.put(id
, name
);
152 logger
.info(i
+ " names handled");
153 getNameService().save(taxonNameMap
.objects());
154 // makeNameSpecificData(nameMap);
155 logger
.info("end makeTaxonNames ...");
160 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
163 protected boolean isIgnore(TcsRdfImportState state
){
164 return ! state
.getConfig().isDoTaxonNames();
167 protected TaxonNameBase
handleNameModel(Model model
, TcsRdfImportConfigurator config
, MapWrapper
<TaxonNameBase
> taxonNameMap
, String uri
){
168 Resource nameAbout
= model
.getResource(uri
);
169 TaxonNameBase result
= handleNameResource(nameAbout
, config
);
170 taxonNameMap
.put(uri
, result
);
175 private TaxonNameBase
handleNameResource(Resource nameAbout
, TcsRdfImportConfigurator config
){
176 String idNamespace
= "TaxonName";
178 StmtIterator stmts
= nameAbout
.listProperties();
180 Property prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"nomenclaturalCode");
181 Statement stateNomenclaturalCode
= nameAbout
.getProperty(prop
);
182 String strNomenclaturalCode
= stateNomenclaturalCode
.getObject().toString();
184 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"rankString");
185 String strRank
= nameAbout
.getProperty(prop
).getString();
191 Rank rank
= TcsRdfTransformer
.rankString2Rank(strRank
);
192 NomenclaturalCode nomCode
;
193 if (strNomenclaturalCode
!= null){
194 nomCode
= TcsRdfTransformer
.nomCodeString2NomCode(strNomenclaturalCode
);
196 nomCode
= NomenclaturalCode
.ICNAFP
;
199 TaxonNameBase
<?
,?
> nameBase
= nomCode
.getNewTaxonNameInstance(rank
);
201 Set
<String
> omitAttributes
= null;
202 //makeStandardMapper(nameAbout, nameBase, omitAttributes, standardMappers);
204 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"nameComplete");
205 String strNameComplete
= nameAbout
.getProperty(prop
).getString();
206 nameBase
.setTitleCache(strNameComplete
, true);
208 prop
= nameAbout
.getModel().getProperty(config
.getCommonNamespaceURIString()+"publishedIn");
209 String strPublishedIn
= nameAbout
.getProperty(prop
).getString();
210 if (strPublishedIn
!= null && strPublishedIn
!= ""){
211 IGeneric nomRef
= ReferenceFactory
.newGeneric(); //TODO
212 nomRef
.setTitleCache(strPublishedIn
, true);
213 nameBase
.setNomenclaturalReference(nomRef
);
215 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"year");
216 String strYear
= nameAbout
.getProperty(prop
).getString();
218 if (strYear
!= null){
220 year
= Integer
.valueOf(strYear
);
221 TimePeriod timeP
= TimePeriod
.NewInstance(year
);
222 nomRef
.setDatePublished(timeP
);
223 } catch (RuntimeException e
) {
224 logger
.warn("year could not be parsed");
227 }catch(NullPointerException e
){
229 if (config
.isPublishReferences()){
230 ((Reference
<?
>)nomRef
).addMarker(Marker
.NewInstance(MarkerType
.PUBLISH(), false));
234 if (nameBase
instanceof NonViralName
){
235 NonViralName
<?
> nonViralName
= (NonViralName
<?
>)nameBase
;
236 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"genusPart");
239 strGenusPart
= nameAbout
.getProperty(prop
).getString();
240 }catch(NullPointerException e
){
241 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"uninomial");
242 strGenusPart
= nameAbout
.getProperty(prop
).getString();
245 nonViralName
.setGenusOrUninomial(strGenusPart
);
247 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"infragenericEpithet");
249 String strInfragenericEpithet
= nameAbout
.getProperty(prop
).getString();
250 nonViralName
.setInfraGenericEpithet(strInfragenericEpithet
);
251 }catch(NullPointerException e
){
255 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"specificEpithet");
256 String strSpecificEpithet
= nameAbout
.getProperty(prop
).getString();
257 nonViralName
.setSpecificEpithet(strSpecificEpithet
);
258 }catch(NullPointerException e
){
262 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"infraspecificEpithet");
263 String strInfraspecificEpithet
= nameAbout
.getProperty(prop
).getString();
264 nonViralName
.setInfraSpecificEpithet(strInfraspecificEpithet
);
265 }catch(NullPointerException e
){
270 prop
= nameAbout
.getModel().getProperty(config
.getTnNamespaceURIString()+"authorship");
271 Statement stateAuthorship
= nameAbout
.getProperty(prop
);
272 prop
= nameAbout
.getModel().getProperty(config
.getTeamNamespaceURIString()+"name");
273 Team authorTeam
= new Team();
274 authorTeam
.setTitleCache(stateAuthorship
.getObject().toString(), true);
275 prop
= nameAbout
.getModel().getProperty(config
.getTeamNamespaceURIString()+"hasMember");
276 //String strTeamMember = nameAbout.getProperty(prop).getString();
277 nonViralName
.setCombinationAuthorTeam(authorTeam
);
282 <tn:NomenclaturalNote>
283 <tn:noteType rdf:resource="http://rs.tdwg.org/ontology/voc/TaxonName#replacementNameFor"/>
284 <tn:objectTaxonName rdf:resource="urn:lsid:ipni.org:names:151538-1"/>
285 </tn:NomenclaturalNote>
289 String strInfraspecificEpithet = nameAbout.getProperty(prop).getString();
290 tcsElementName = "basionymAuthorship";
291 String basionymAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
292 if (basionymAuthorValue != null){
293 TeamOrPersonBase<?> basionymAuthor = Team.NewInstance();
294 basionymAuthor.setNomenclaturalTitle(basionymAuthorValue);
295 nonViralName.setBasionymAuthorTeam(basionymAuthor);
299 tcsElementName = "combinationAuthorship";
300 String combinationAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
301 if (combinationAuthorValue != null){
302 TeamOrPersonBase<?> combinationAuthor = Team.NewInstance();
303 combinationAuthor.setNomenclaturalTitle(combinationAuthorValue);
304 nonViralName.setCombinationAuthorTeam(combinationAuthor);
307 //set the authorshipCache
308 tcsElementName = "authorship";
309 String authorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
310 String cache = nonViralName.getAuthorshipCache();
311 if ( authorValue != null){
312 //compare existing authorship cache with new one and check if it is necessary to
313 //make cache protected //TODO refinement
315 nonViralName.setAuthorshipCache(authorValue);
317 cache = basionymAuthorValue == null ? cache : cache.replace(basionymAuthorValue, "");
318 cache = combinationAuthorValue == null ? cache : cache.replace(combinationAuthorValue, "");
319 cache = cache.replace("\\(|\\)", "");
320 cache = cache.trim();
321 if (! cache.equals("")){
322 nonViralName.setAuthorshipCache(authorValue);
327 //ImportHelper.setOriginalSource(nameBase, config.getSourceReference(), nameAbout, idNamespace);
329 //checkAdditionalContents(elTaxonName, standardMappers, operationalMappers, unclearMappers);
339 String strNameComplete = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "nameComplete", rdfNamespace);
340 nameBase.setTitleCache(strNameComplete, true);
344 String tcsElementName = "publishedIn";
345 Namespace tcsNamespace = config.getCommonNamespaceURIString();
346 String value = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, tcsNamespace);
347 if (value != null && value != ""){
348 IGeneric nomRef = ReferenceFactory.newGeneric(); //TODO
349 nomRef.setTitleCache(value, true);
350 nameBase.setNomenclaturalReference(nomRef);
353 tcsElementName = "year";
354 tcsNamespace = taxonNameNamespace;
356 value = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, tcsNamespace);
359 year = Integer.valueOf(value);
360 TimePeriod timeP = TimePeriod.NewInstance(year);
361 nomRef.setDatePublished(timeP);
362 } catch (RuntimeException e) {
363 logger.warn("year could not be parsed");
366 if (config.isPublishReferences()){
367 ((Reference<?>)nomRef).addMarker(Marker.NewInstance(MarkerType.PUBLISH(), false));
372 tcsNamespace = taxonNameNamespace;
373 Element elAnnotation = elTaxonName.getChild("hasAnnotation", tcsNamespace);
374 if (elAnnotation != null){
375 Element elNomenclaturalNote = elAnnotation.getChild("NomenclaturalNote", tcsNamespace);
376 if (elNomenclaturalNote != null){
377 String statusValue = (String)ImportHelper.getXmlInputValue(elNomenclaturalNote, "note", tcsNamespace);
378 String type = XmlHelp.getChildAttributeValue(elNomenclaturalNote, "type", tcsNamespace, "resource", rdfNamespace);
379 String tdwgType = "http://rs.tdwg.org/ontology/voc/TaxonName#PublicationStatus";
380 if (tdwgType.equalsIgnoreCase(type)){
382 NomenclaturalStatusType statusType = TcsRdfTransformer.nomStatusString2NomStatus(statusValue);
383 //NomenclaturalStatusType statusType = NomenclaturalStatusType.getNomenclaturalStatusTypeByAbbreviation(statusValue);
384 if (statusType != null){
385 nameBase.addStatus(NomenclaturalStatus.NewInstance(statusType));
387 } catch (UnknownCdmTypeException e) {
388 if (! statusValue.equals("valid")){
389 logger.warn("Unknown NomenclaturalStatusType: " + statusValue);
396 if (nameBase instanceof NonViralName){
397 NonViralName<?> nonViralName = (NonViralName<?>)nameBase;
398 String strGenusPart = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "genusPart", rdfNamespace);
400 //for names of rank genus the uninomial property should be used
401 if (strGenusPart == null){
402 strGenusPart = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "uninomial", rdfNamespace);
404 nonViralName.setGenusOrUninomial(strGenusPart);
406 String strInfragenericEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "infragenericEpithet", rdfNamespace);
407 nonViralName.setGenusOrUninomial(strInfragenericEpithet);
411 String strSpecificEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "specificEpithet", rdfNamespace);
412 nonViralName.setSpecificEpithet(strSpecificEpithet);
414 String strInfraspecificEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "infraspecificEpithet", rdfNamespace);
415 nonViralName.setInfraSpecificEpithet(strInfraspecificEpithet);
418 tcsElementName = "basionymAuthorship";
419 String basionymAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
420 if (basionymAuthorValue != null){
421 TeamOrPersonBase<?> basionymAuthor = Team.NewInstance();
422 basionymAuthor.setNomenclaturalTitle(basionymAuthorValue);
423 nonViralName.setBasionymAuthorTeam(basionymAuthor);
427 tcsElementName = "combinationAuthorship";
428 String combinationAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
429 if (combinationAuthorValue != null){
430 TeamOrPersonBase<?> combinationAuthor = Team.NewInstance();
431 combinationAuthor.setNomenclaturalTitle(combinationAuthorValue);
432 nonViralName.setCombinationAuthorTeam(combinationAuthor);
435 //set the authorshipCache
436 tcsElementName = "authorship";
437 String authorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
438 String cache = nonViralName.getAuthorshipCache();
439 if ( authorValue != null){
440 //compare existing authorship cache with new one and check if it is necessary to
441 //make cache protected //TODO refinement
443 nonViralName.setAuthorshipCache(authorValue);
445 cache = basionymAuthorValue == null ? cache : cache.replace(basionymAuthorValue, "");
446 cache = combinationAuthorValue == null ? cache : cache.replace(combinationAuthorValue, "");
447 cache = cache.replace("\\(|\\)", "");
448 cache = cache.trim();
449 if (! cache.equals("")){
450 nonViralName.setAuthorshipCache(authorValue);
455 ImportHelper.setOriginalSource(nameBase, config.getSourceReference(), nameAbout, idNamespace);
457 checkAdditionalContents(elTaxonName, standardMappers, operationalMappers, unclearMappers);
461 //ImportHelper.setOriginalSource(nameBase, tcsConfig.getSourceReference(), nameId);
462 //taxonNameMap.put(nameAbout, nameBase);
464 }catch(UnknownCdmTypeException e){
470 protected TaxonNameBase
handleNameElement(Element elTaxonName
, Namespace rdfNamespace
, Namespace taxonNameNamespace
, TcsRdfImportConfigurator config
, MapWrapper
<TaxonNameBase
> taxonNameMap
){
471 String idNamespace
= "TaxonName";
472 Attribute about
= elTaxonName
.getAttribute("about", rdfNamespace
);
474 //create TaxonName element
477 String nameAbout
= elTaxonName
.getAttributeValue("about", rdfNamespace
);
478 if (nameAbout
== null){
479 nameAbout
= XmlHelp
.getChildAttributeValue(elTaxonName
, "TaxonName", taxonNameNamespace
, "about", rdfNamespace
);
483 String strRank
= XmlHelp
.getChildAttributeValue(elTaxonName
, "rankString", taxonNameNamespace
, "rankString", rdfNamespace
);
484 if (strRank
== null){
485 strRank
= XmlHelp
.getChildContent(elTaxonName
, "TaxonName", taxonNameNamespace
, "rankString", rdfNamespace
);
489 if (strRank
== null){
490 strRank
= XmlHelp
.getChildAttributeValue(elTaxonName
, "rank", taxonNameNamespace
, "resource", rdfNamespace
);
494 String strNomenclaturalCode
= XmlHelp
.getChildContentAttributeValue(elTaxonName
, "TaxonName", taxonNameNamespace
, "nomenclaturalCode", rdfNamespace
);
495 if (strNomenclaturalCode
== null){
496 strNomenclaturalCode
= XmlHelp
.getChildAttributeValue(elTaxonName
, "nomenclaturalCode", taxonNameNamespace
, "resource", rdfNamespace
);
501 Rank rank
= TcsRdfTransformer
.rankString2Rank(strRank
);
502 NomenclaturalCode nomCode
;
503 if (strNomenclaturalCode
!= null){
504 nomCode
= TcsRdfTransformer
.nomCodeString2NomCode(strNomenclaturalCode
);
506 nomCode
= NomenclaturalCode
.ICNAFP
;
509 TaxonNameBase
<?
,?
> nameBase
= nomCode
.getNewTaxonNameInstance(rank
);
511 Set
<String
> omitAttributes
= null;
512 //makeStandardMapper(elTaxonName, nameBase, omitAttributes, standardMappers);
515 String strNameComplete
= XmlHelp
.getChildContent(elTaxonName
, "TaxonName", taxonNameNamespace
, "nameComplete", rdfNamespace
);
516 nameBase
.setTitleCache(strNameComplete
, true);
520 String tcsElementName
= "publishedIn";
521 String tcsNamespace
= config
.getCommonNamespaceURIString();
522 /*String value = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, tcsNamespace);
523 if (value != null && value != ""){
524 IGeneric nomRef = ReferenceFactory.newGeneric(); //TODO
525 nomRef.setTitleCache(value, true);
526 nameBase.setNomenclaturalReference(nomRef);
529 tcsElementName = "year";
530 tcsNamespace = taxonNameNamespace;
532 value = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, tcsNamespace);
535 year = Integer.valueOf(value);
536 TimePeriod timeP = TimePeriod.NewInstance(year);
537 nomRef.setDatePublished(timeP);
538 } catch (RuntimeException e) {
539 logger.warn("year could not be parsed");
542 if (config.isPublishReferences()){
543 ((Reference<?>)nomRef).addMarker(Marker.NewInstance(MarkerType.PUBLISH(), false));
548 tcsNamespace = taxonNameNamespace;
549 Element elAnnotation = elTaxonName.getChild("hasAnnotation", tcsNamespace);
550 if (elAnnotation != null){
551 Element elNomenclaturalNote = elAnnotation.getChild("NomenclaturalNote", tcsNamespace);
552 if (elNomenclaturalNote != null){
553 String statusValue = (String)ImportHelper.getXmlInputValue(elNomenclaturalNote, "note", tcsNamespace);
554 String type = XmlHelp.getChildAttributeValue(elNomenclaturalNote, "type", tcsNamespace, "resource", rdfNamespace);
555 String tdwgType = "http://rs.tdwg.org/ontology/voc/TaxonName#PublicationStatus";
556 if (tdwgType.equalsIgnoreCase(type)){
558 NomenclaturalStatusType statusType = TcsRdfTransformer.nomStatusString2NomStatus(statusValue);
559 //NomenclaturalStatusType statusType = NomenclaturalStatusType.getNomenclaturalStatusTypeByAbbreviation(statusValue);
560 if (statusType != null){
561 nameBase.addStatus(NomenclaturalStatus.NewInstance(statusType));
563 } catch (UnknownCdmTypeException e) {
564 if (! statusValue.equals("valid")){
565 logger.warn("Unknown NomenclaturalStatusType: " + statusValue);
572 if (nameBase instanceof NonViralName){
573 NonViralName<?> nonViralName = (NonViralName<?>)nameBase;
574 String strGenusPart = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "genusPart", rdfNamespace);
576 //for names of rank genus the uninomial property should be used
577 if (strGenusPart == null){
578 strGenusPart = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "uninomial", rdfNamespace);
580 nonViralName.setGenusOrUninomial(strGenusPart);
582 String strInfragenericEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "infragenericEpithet", rdfNamespace);
583 nonViralName.setGenusOrUninomial(strInfragenericEpithet);
587 String strSpecificEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "specificEpithet", rdfNamespace);
588 nonViralName.setSpecificEpithet(strSpecificEpithet);
590 String strInfraspecificEpithet = XmlHelp.getChildContent(elTaxonName, "TaxonName", taxonNameNamespace, "infraspecificEpithet", rdfNamespace);
591 nonViralName.setInfraSpecificEpithet(strInfraspecificEpithet);
594 tcsElementName = "basionymAuthorship";
595 String basionymAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
596 if (basionymAuthorValue != null){
597 TeamOrPersonBase<?> basionymAuthor = Team.NewInstance();
598 basionymAuthor.setNomenclaturalTitle(basionymAuthorValue);
599 nonViralName.setBasionymAuthorTeam(basionymAuthor);
603 tcsElementName = "combinationAuthorship";
604 String combinationAuthorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
605 if (combinationAuthorValue != null){
606 TeamOrPersonBase<?> combinationAuthor = Team.NewInstance();
607 combinationAuthor.setNomenclaturalTitle(combinationAuthorValue);
608 nonViralName.setCombinationAuthorTeam(combinationAuthor);
611 //set the authorshipCache
612 tcsElementName = "authorship";
613 String authorValue = (String)ImportHelper.getXmlInputValue(elTaxonName, tcsElementName, taxonNameNamespace);
614 String cache = nonViralName.getAuthorshipCache();
615 if ( authorValue != null){
616 //compare existing authorship cache with new one and check if it is necessary to
617 //make cache protected //TODO refinement
619 nonViralName.setAuthorshipCache(authorValue);
621 cache = basionymAuthorValue == null ? cache : cache.replace(basionymAuthorValue, "");
622 cache = combinationAuthorValue == null ? cache : cache.replace(combinationAuthorValue, "");
623 cache = cache.replace("\\(|\\)", "");
624 cache = cache.trim();
625 if (! cache.equals("")){
626 nonViralName.setAuthorshipCache(authorValue);
631 ImportHelper.setOriginalSource(nameBase, config.getSourceReference(), nameAbout, idNamespace);
633 checkAdditionalContents(elTaxonName, standardMappers, operationalMappers, unclearMappers);
637 //ImportHelper.setOriginalSource(nameBase, tcsConfig.getSourceReference(), nameId);
638 //taxonNameMap.put(nameAbout, nameBase);
640 */}catch(UnknownCdmTypeException e
){
646 public TaxonNameBase
handleRdfElementFromStream(InputStream is
, TcsRdfImportConfigurator config
, MapWrapper
<TaxonNameBase
> taxonNameMap
, String uri
){
647 Model model
= ModelFactory
.createDefaultModel();
649 model
.read(is
, null);
651 config
.makeNamespaces(model
);
653 String rdfNamespace
= config
.getRdfNamespaceURIString();
654 String taxonNameNamespace
= config
.getTnNamespaceURIString();
655 return handleNameModel(model
, config
, taxonNameMap
, uri
);
658 }catch(com
.hp
.hpl
.jena
.shared
.JenaException e
){
659 logger
.debug("The file was no valid rdf file");