4 package eu
.etaxonomy
.cdm
.io
.tcsxml
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.jdom
.Element
;
11 import org
.jdom
.Namespace
;
13 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
14 import eu
.etaxonomy
.cdm
.common
.DoubleResult
;
15 import eu
.etaxonomy
.cdm
.common
.XmlHelp
;
16 import eu
.etaxonomy
.cdm
.io
.common
.ICdmIO
;
17 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
18 import eu
.etaxonomy
.cdm
.io
.common
.ImportHelper
;
19 import eu
.etaxonomy
.cdm
.io
.common
.MapWrapper
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.Generic
;
22 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
28 public class TcsXmlPublicationsIO
extends TcsXmlIoBase
implements ICdmIO
{
29 private static final Logger logger
= Logger
.getLogger(TcsXmlPublicationsIO
.class);
31 private static int modCount
= 1000;
33 public TcsXmlPublicationsIO(){
38 public boolean doCheck(IImportConfigurator config
){
39 boolean result
= true;
40 result
&= checkArticlesWithoutJournal(config
);
41 //result &= checkPartOfJournal(config);
46 private static boolean checkArticlesWithoutJournal(IImportConfigurator bmiConfig
){
48 boolean result
= true;
50 // result = firstRow = false;
54 } catch (Exception e
) {
63 public boolean doInvoke(IImportConfigurator config
,
64 Map
<String
, MapWrapper
<?
extends CdmBase
>> stores
){
66 logger
.info("start make Publications ...");
67 boolean success
= true;
71 MapWrapper
<ReferenceBase
> referenceMap
= (MapWrapper
<ReferenceBase
>)stores
.get(ICdmIO
.REFERENCE_STORE
);
72 IReferenceService referenceService
= config
.getCdmAppController().getReferenceService();
74 TcsXmlImportConfigurator tcsConfig
= (TcsXmlImportConfigurator
)config
;
75 Element elDataSet
= getDataSetElement(tcsConfig
);
76 Namespace tcsNamespace
= tcsConfig
.getTcsXmlNamespace();
78 DoubleResult
<Element
, Boolean
> doubleResult
;
79 childName
= "Publications";
81 doubleResult
= XmlHelp
.getSingleChildElement(elDataSet
, childName
, tcsNamespace
, obligatory
);
82 success
&= doubleResult
.getSecondResult();
83 Element elPublications
= doubleResult
.getFirstResult();
85 String tcsElementName
= "Publication";
86 String idNamespace
= "Publication";
87 List
<Element
> elPublicationList
= elPublications
.getChildren(tcsElementName
, tcsNamespace
);
91 for (Element elPublication
: elPublicationList
){
92 if ((++i
% modCount
) == 0){ logger
.info("publications handled: " + (i
-1));}
94 //create TaxonName element
95 String strId
= elPublication
.getAttributeValue("id");
99 doubleResult
= XmlHelp
.getSingleChildElement(elPublication
, childName
, tcsNamespace
, obligatory
);
100 success
&= doubleResult
.getSecondResult();
101 Element elSimple
= doubleResult
.getFirstResult();
103 String simple
= elSimple
.getTextNormalize();
104 ReferenceBase reference
= Generic
.NewInstance();
105 reference
.setTitleCache(simple
);
107 childName
= "PublicationDetailed";
109 doubleResult
= XmlHelp
.getSingleChildElement(elPublication
, childName
, tcsNamespace
, obligatory
);
110 success
&= doubleResult
.getSecondResult();
111 Element elPublicationDetailed
= doubleResult
.getFirstResult();
113 success
&= tcsConfig
.getPlaceholderClass().makePublicationDetailed(tcsConfig
, elPublicationDetailed
, reference
);
114 ImportHelper
.setOriginalSource(reference
, config
.getSourceReference(), strId
, idNamespace
);
116 referenceMap
.put(strId
, reference
);
120 // //save and store in map
121 // logger.info("Save nomenclatural references (" + nomRefCount + ")");
122 // referenceService.saveReferenceAll(nomRefMap.objects());
123 logger
.info("Save bibliographical references (" + i
+")");
124 referenceService
.saveReferenceAll(referenceMap
.objects());
126 logger
.info("end make publications ...");
131 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator)
133 protected boolean isIgnore(IImportConfigurator config
){
134 return (config
.getDoReferences() == IImportConfigurator
.DO_REFERENCES
.NONE
);