org.lumongo.example.medline.MedlineJAXBReader Maven / Gradle / Ivy
package org.lumongo.example.medline;
import java.text.DateFormatSymbols;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.joda.time.DateTime;
import org.lumongo.example.medline.schema.Article;
import org.lumongo.example.medline.schema.Author;
import org.lumongo.example.medline.schema.AuthorList;
import org.lumongo.example.medline.schema.CollectiveName;
import org.lumongo.example.medline.schema.Day;
import org.lumongo.example.medline.schema.ForeName;
import org.lumongo.example.medline.schema.Initials;
import org.lumongo.example.medline.schema.Journal;
import org.lumongo.example.medline.schema.JournalIssue;
import org.lumongo.example.medline.schema.LastName;
import org.lumongo.example.medline.schema.MedlineCitation;
import org.lumongo.example.medline.schema.MedlineJournalInfo;
import org.lumongo.example.medline.schema.Month;
import org.lumongo.example.medline.schema.PubDate;
import org.lumongo.example.medline.schema.Suffix;
import org.lumongo.example.medline.schema.Year;
import org.lumongo.xml.StaxJAXBReader;
public abstract class MedlineJAXBReader extends StaxJAXBReader {
private static List shortMonths = Arrays.asList(new DateFormatSymbols().getShortMonths());
protected MedlineJAXBReader(Class documentJAXBClass, String documentElementName) throws JAXBException {
super(documentJAXBClass, documentElementName);
}
@Override
public void handle(MedlineCitation item) throws Exception {
final MedlineDocument document = handleRecord(item);
handleMedlineDocument(document);
}
public abstract void handleMedlineDocument(MedlineDocument document) throws Exception;
public static MedlineDocument handleRecord(final MedlineCitation medlineCitation) throws Exception {
MedlineDocument document = new MedlineDocument();
Article article = medlineCitation.getArticle();
AuthorList authorList = article.getAuthorList();
if (authorList != null) {
for (Author author : authorList.getAuthor()) {
String valid = author.getValidYN();
if (valid != null && valid.equals("Y")) {
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy