Skip to content

Commit

Permalink
Fix issue with empty title narratives
Browse files Browse the repository at this point in the history
  • Loading branch information
gmutuhu committed Aug 2, 2016
1 parent b2a9f67 commit c1a961e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,18 @@ private List<InternalDocument> extractDocuments(Document doc) throws Exception {
if (fieldElement.getChildNodes().getLength() == 1) {
String mlStringValue = fieldElement.getChildNodes().item(0).getNodeValue();
Node langAttr = fieldElement.getAttributes().getNamedItem("xml:lang");

if(langAttr != null){
String lang = langAttr.getNodeValue();
Optional<Language> selectedLanguage = this.getFilterLanguages().stream().filter(language -> lang.equalsIgnoreCase(language.getCode()) && language.getSelected() == true ).findFirst();
if(selectedLanguage.isPresent()){
mlv.put(lang, mlStringValue);
}
}else{
mlv.put(defaultLanguageCode, mlStringValue);
}
if(mlStringValue != null && !("".equals(mlStringValue))){
if(langAttr != null){
String lang = langAttr.getNodeValue();
Optional<Language> selectedLanguage = this.getFilterLanguages().stream().filter(language -> lang.equalsIgnoreCase(language.getCode()) && language.getSelected() == true ).findFirst();
if(selectedLanguage.isPresent()){
mlv.put(lang, mlStringValue);
}
}else{
mlv.put(defaultLanguageCode, mlStringValue);
}
}


}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,23 @@ private List<InternalDocument> extractDocuments(Document doc) throws Exception {
for (int j = 0; j < narrativeNodeList.getLength(); j++) {
Element narrativeElement = (Element) narrativeNodeList.item(j);
if (narrativeElement.getChildNodes().getLength() == 1) {
mlStringValue = narrativeElement.getChildNodes().item(0).getNodeValue();
if (!"".equals(narrativeElement.getAttribute("xml:lang"))) {
String languageCode = narrativeElement.getAttribute("xml:lang");
Optional<Language> selectedLanguage = this.getFilterLanguages().stream().filter(language -> languageCode.equalsIgnoreCase(language.getCode()) && language.getSelected() == true ).findFirst();
if(selectedLanguage.isPresent()){
mlv.put(languageCode, mlStringValue);
mlStringValue = narrativeElement.getChildNodes().item(0).getNodeValue();
if(mlStringValue != null && !("".equals(mlStringValue))){
if (!"".equals(narrativeElement.getAttribute("xml:lang"))) {
String languageCode = narrativeElement.getAttribute("xml:lang");
Optional<Language> selectedLanguage = this.getFilterLanguages().stream().filter(language -> languageCode.equalsIgnoreCase(language.getCode()) && language.getSelected() == true ).findFirst();
if(selectedLanguage.isPresent()){
mlv.put(languageCode, mlStringValue);
}
}else{
mlv.put(defaultLanguageCode, mlStringValue);
}
}else{
}
} else {
if(mlStringValue != null && !("".equals(mlStringValue))){
mlv.put(defaultLanguageCode, mlStringValue);
}

} else {
mlv.put(defaultLanguageCode, mlStringValue);
}


Expand Down

0 comments on commit c1a961e

Please sign in to comment.