Revision 531fc7bc
Added by Andreas Müller almost 8 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/tcsxml/in/TcsXmlPublicationsImport.java | ||
---|---|---|
5 | 5 |
* |
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 |
*/
|
|
9 |
|
|
8 |
*/ |
|
9 |
|
|
10 | 10 |
package eu.etaxonomy.cdm.io.tcsxml.in; |
11 | 11 |
|
12 | 12 |
import java.util.ArrayList; |
... | ... | |
20 | 20 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
21 | 21 |
import eu.etaxonomy.cdm.common.DoubleResult; |
22 | 22 |
import eu.etaxonomy.cdm.common.XmlHelp; |
23 |
|
|
24 | 23 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
25 | 24 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator; |
26 | 25 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
... | ... | |
37 | 36 |
private static final Logger logger = Logger.getLogger(TcsXmlPublicationsImport.class); |
38 | 37 |
|
39 | 38 |
private static int modCount = 1000; |
40 |
|
|
41 |
|
|
39 |
|
|
40 |
|
|
42 | 41 |
public TcsXmlPublicationsImport(){ |
43 | 42 |
super(); |
44 |
|
|
43 |
|
|
45 | 44 |
} |
46 |
|
|
45 |
|
|
47 | 46 |
@Override |
48 | 47 |
public boolean doCheck(TcsXmlImportState state){ |
49 | 48 |
boolean result = true; |
50 | 49 |
result &= checkArticlesWithoutJournal(state.getConfig()); |
51 | 50 |
//result &= checkPartOfJournal(config); |
52 |
|
|
51 |
|
|
53 | 52 |
return result; |
54 | 53 |
} |
55 |
|
|
54 |
|
|
56 | 55 |
private static boolean checkArticlesWithoutJournal(IImportConfigurator bmiConfig){ |
57 | 56 |
try { |
58 | 57 |
boolean result = true; |
59 | 58 |
//TODO |
60 | 59 |
// result = firstRow = false; |
61 | 60 |
// } |
62 |
//
|
|
61 |
// |
|
63 | 62 |
return result; |
64 | 63 |
} catch (Exception e) { |
65 | 64 |
e.printStackTrace(); |
66 | 65 |
return false; |
67 | 66 |
} |
68 | 67 |
} |
69 |
|
|
70 | 68 |
|
71 |
|
|
69 |
|
|
70 |
|
|
72 | 71 |
@Override |
73 | 72 |
public void doInvoke(TcsXmlImportState state){ |
74 |
|
|
73 |
|
|
75 | 74 |
logger.info("start make Publications ..."); |
76 | 75 |
boolean success = true; |
77 | 76 |
String childName; |
78 | 77 |
boolean obligatory; |
79 |
|
|
78 |
|
|
80 | 79 |
MapWrapper<Reference> referenceMap = (MapWrapper<Reference>)state.getStore(ICdmIO.REFERENCE_STORE); |
81 | 80 |
IReferenceService referenceService = getReferenceService(); |
82 |
|
|
81 |
|
|
83 | 82 |
TcsXmlImportConfigurator config = state.getConfig(); |
84 | 83 |
Element elDataSet = getDataSetElement(config); |
85 | 84 |
Namespace tcsNamespace = config.getTcsXmlNamespace(); |
86 |
|
|
85 |
|
|
87 | 86 |
DoubleResult<Element, Boolean> doubleResult; |
88 | 87 |
childName = "Publications"; |
89 | 88 |
obligatory = false; |
90 | 89 |
doubleResult = XmlHelp.getSingleChildElement(elDataSet, childName, tcsNamespace, obligatory); |
91 | 90 |
success &= doubleResult.getSecondResult(); |
92 | 91 |
Element elPublications = doubleResult.getFirstResult(); |
93 |
|
|
92 |
|
|
94 | 93 |
String tcsElementName = "Publication"; |
95 | 94 |
String idNamespace = "Publication"; |
96 | 95 |
List<Element> elPublicationList = elPublications == null ? new ArrayList<Element>() : elPublications.getChildren(tcsElementName, tcsNamespace); |
97 |
|
|
96 |
|
|
98 | 97 |
int i = 0; |
99 | 98 |
//for each taxonName |
100 | 99 |
for (Element elPublication : elPublicationList){ |
101 | 100 |
if ((++i % modCount) == 0){ logger.info("publications handled: " + (i-1));} |
102 |
|
|
101 |
|
|
103 | 102 |
//create TaxonName element |
104 | 103 |
String strId = elPublication.getAttributeValue("id"); |
105 |
|
|
104 |
|
|
106 | 105 |
childName = "Simple"; |
107 | 106 |
obligatory = true; |
108 | 107 |
doubleResult = XmlHelp.getSingleChildElement(elPublication, childName, tcsNamespace, obligatory); |
... | ... | |
110 | 109 |
Element elSimple = doubleResult.getFirstResult(); |
111 | 110 |
|
112 | 111 |
String simple = elSimple.getTextNormalize(); |
113 |
|
|
114 |
Reference<?> reference = ReferenceFactory.newGeneric();
|
|
112 |
|
|
113 |
Reference reference = ReferenceFactory.newGeneric(); |
|
115 | 114 |
reference.setTitleCache(simple, true); |
116 | 115 |
|
117 | 116 |
childName = "PublicationDetailed"; |
... | ... | |
122 | 121 |
|
123 | 122 |
success &= config.getPlaceholderClass().makePublicationDetailed(config, elPublicationDetailed, reference); |
124 | 123 |
ImportHelper.setOriginalSource(reference, config.getSourceReference(), strId, idNamespace); |
125 |
|
|
124 |
|
|
126 | 125 |
referenceMap.put(strId, reference); |
127 |
|
|
128 |
|
|
126 |
|
|
127 |
|
|
129 | 128 |
} |
130 | 129 |
// //save and store in map |
131 | 130 |
// logger.info("Save nomenclatural references (" + nomRefCount + ")"); |
... | ... | |
139 | 138 |
} |
140 | 139 |
return; |
141 | 140 |
} |
142 |
|
|
141 |
|
|
143 | 142 |
/* (non-Javadoc) |
144 | 143 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
145 | 144 |
*/ |
146 |
protected boolean isIgnore(TcsXmlImportState state){ |
|
145 |
@Override |
|
146 |
protected boolean isIgnore(TcsXmlImportState state){ |
|
147 | 147 |
return (state.getConfig().getDoReferences() == IImportConfigurator.DO_REFERENCES.NONE); |
148 | 148 |
} |
149 |
|
|
149 |
|
|
150 | 150 |
} |
Also available in: Unified diff
Remove generics from Reference in cdmlib (except for cdmlib-model) #5830