Revision 48955
Added by Claudio Atzori over 6 years ago
SplitterDatasetsIterator.java | ||
---|---|---|
57 | 57 |
/** |
58 | 58 |
* Instantiates a new splitter datasets iterator. |
59 | 59 |
* |
60 |
* @param datasetsQueue the datasets queue |
|
61 | 60 |
* @param publicationsQueue the publications queue |
62 | 61 |
* @param inputEPR the input epr |
63 | 62 |
* @param rootName the root name |
... | ... | |
66 | 65 |
this.publications = publicationsQueue; |
67 | 66 |
this.inputEPR = inputEPR; |
68 | 67 |
this.rootName = rootName; |
69 |
|
|
70 | 68 |
} |
71 | 69 |
|
72 | 70 |
/** |
... | ... | |
77 | 75 |
if (this.inputEPR == null) return; |
78 | 76 |
for (String inputXML : inputEPR) { |
79 | 77 |
|
80 |
List<String> publication_extracted = extractByTag(new ByteArrayInputStream(inputXML.getBytes(StandardCharsets.UTF_8)), "publication", inputXML); |
|
78 |
final ByteArrayInputStream bais = new ByteArrayInputStream(inputXML.getBytes(StandardCharsets.UTF_8)); |
|
79 |
final List<String> publication_extracted = extractByTag(bais, "publication"); |
|
81 | 80 |
|
82 | 81 |
if (publication_extracted != null) { |
83 | 82 |
publications.addAll(publication_extracted); |
... | ... | |
85 | 84 |
} |
86 | 85 |
} |
87 | 86 |
publications.add(END_QUEUE); |
88 |
|
|
89 | 87 |
} |
90 | 88 |
|
91 | 89 |
/** |
... | ... | |
95 | 93 |
* @param tag the tag |
96 | 94 |
* @return the list |
97 | 95 |
*/ |
98 |
private List<String> extractByTag(final InputStream inputXML, final String tag, final String input) {
|
|
96 |
private List<String> extractByTag(final InputStream inputXML, final String tag) { |
|
99 | 97 |
try { |
100 | 98 |
|
101 | 99 |
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); |
... | ... | |
121 | 119 |
NodeList nodes = (NodeList) xpath.evaluate("//*[local-name()='" + tag + "']/*[local-name()='record']", doc, XPathConstants.NODESET); |
122 | 120 |
|
123 | 121 |
if ((nodes != null) && (nodes.getLength() > 0)) { |
124 |
List<String> result = new ArrayList<String>();
|
|
122 |
List<String> result = new ArrayList<>(); |
|
125 | 123 |
for (int i = 0; i < nodes.getLength(); i++) { |
126 | 124 |
Document currentDoc = dbf.newDocumentBuilder().newDocument(); |
127 | 125 |
Node imported = currentDoc.importNode(nodes.item(i), true); |
Also available in: Unified diff
trivial fixes