Revision 55455
Added by Alessia Bardi almost 5 years ago
OdfToHbaseXsltFunctions.java | ||
---|---|---|
17 | 17 |
import eu.dnetlib.data.proto.ResultProtos.Result; |
18 | 18 |
import eu.dnetlib.data.proto.ResultProtos.Result.Context; |
19 | 19 |
import eu.dnetlib.data.proto.ResultProtos.Result.Instance; |
20 |
import eu.dnetlib.data.proto.ResultProtos.Result.Metadata.Builder; |
|
20 | 21 |
import eu.dnetlib.data.proto.TypeProtos.Type; |
21 | 22 |
import org.apache.commons.lang3.StringUtils; |
22 | 23 |
import org.w3c.dom.Element; |
... | ... | |
143 | 144 |
|
144 | 145 |
final NodeList creatorNames = creator.getElementsByTagName("creatorName"); |
145 | 146 |
if (creatorNames.getLength() > 0) { |
146 |
final Element creatorName = (Element) creatorNames.item(0); |
|
147 |
|
|
148 |
final Author.Builder author = Author.newBuilder(); |
|
149 |
author.setRank(i+1); |
|
150 |
final String fullname = StringUtils.trim(creatorName.getTextContent()); |
|
151 |
|
|
152 |
author.setFullname(fullname); |
|
153 |
|
|
154 |
final eu.dnetlib.pace.model.Person p = new eu.dnetlib.pace.model.Person(fullname, false); |
|
155 |
if (p.isAccurate()) { |
|
156 |
author.setName(p.getNormalisedFirstName()); |
|
157 |
author.setSurname(p.getNormalisedSurname()); |
|
147 |
createAuthor(metadataProto, i, creator, creatorNames); |
|
148 |
} else{ |
|
149 |
//handle authors with namespaceprefix |
|
150 |
final NodeList creatorNamesNs = creator.getElementsByTagNameNS("http://datacite.org/schema/kernel-4", "creatorName"); |
|
151 |
if (creatorNamesNs.getLength() > 0) { |
|
152 |
createAuthor(metadataProto, i, creator, creatorNamesNs); |
|
158 | 153 |
} |
159 |
final NodeList nameIdentifiers = creator.getElementsByTagName("nameIdentifier"); |
|
160 |
if (nameIdentifiers.getLength() > 0) { |
|
161 |
final Element nameIdentifier = (Element) nameIdentifiers.item(0); |
|
162 |
final String nameIdentifierScheme = nameIdentifier.getAttribute("nameIdentifierScheme"); |
|
163 |
final String id = StringUtils.trim(nameIdentifier.getTextContent()); |
|
164 |
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(nameIdentifierScheme)) { |
|
165 |
author.addPid(getKV(nameIdentifierScheme, id)); |
|
166 |
} |
|
167 |
} |
|
168 | 154 |
|
169 |
addField(metadataProto, Result.Metadata.getDescriptor().findFieldByName("author"), author); |
|
170 | 155 |
} |
171 | 156 |
} |
172 | 157 |
} |
... | ... | |
390 | 375 |
|
391 | 376 |
} |
392 | 377 |
|
378 |
private static void createAuthor(final Builder metadataProto, final int i, final Element creator, final NodeList creatorNames) { |
|
379 |
final Element creatorName = (Element) creatorNames.item(0); |
|
380 |
|
|
381 |
final Author.Builder author = Author.newBuilder(); |
|
382 |
author.setRank(i+1); |
|
383 |
final String fullname = StringUtils.trim(creatorName.getTextContent()); |
|
384 |
|
|
385 |
author.setFullname(fullname); |
|
386 |
|
|
387 |
final eu.dnetlib.pace.model.Person p = new eu.dnetlib.pace.model.Person(fullname, false); |
|
388 |
if (p.isAccurate()) { |
|
389 |
author.setName(p.getNormalisedFirstName()); |
|
390 |
author.setSurname(p.getNormalisedSurname()); |
|
391 |
} |
|
392 |
final NodeList nameIdentifiers = creator.getElementsByTagName("nameIdentifier"); |
|
393 |
if (nameIdentifiers.getLength() > 0) { |
|
394 |
final Element nameIdentifier = (Element) nameIdentifiers.item(0); |
|
395 |
final String nameIdentifierScheme = nameIdentifier.getAttribute("nameIdentifierScheme"); |
|
396 |
final String id = StringUtils.trim(nameIdentifier.getTextContent()); |
|
397 |
if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(nameIdentifierScheme)) { |
|
398 |
author.addPid(getKV(nameIdentifierScheme, id)); |
|
399 |
} |
|
400 |
} |
|
401 |
|
|
402 |
addField(metadataProto, Result.Metadata.getDescriptor().findFieldByName("author"), author); |
|
403 |
} |
|
404 |
|
|
393 | 405 |
private static String getResultType(final NodeList cobjcategoryNode) { |
394 | 406 |
|
395 | 407 |
final ValueMap values = ValueMap.parseNodeList(cobjcategoryNode); |
Also available in: Unified diff
Handle creators under the datacite namespace or in no namespace