Korrekturen am BibTeX Importer
git-svn-id: https://svn.libreccm.org/ccm/trunk@2043 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
2082346610
commit
e255dc6198
|
|
@ -1 +1,2 @@
|
|||
com.arsdigita.cms.scipublications.importer.ris.RisImporter
|
||||
com.arsdigita.cms.scipublications.importer.bibtex.BibTeXPublicationsImporter
|
||||
|
|
@ -57,7 +57,7 @@ public class BibTeXConverters {
|
|||
final PublicationImportReport report = new PublicationImportReport();
|
||||
|
||||
BibTeXConverter<Publication, PublicationBundle> converter = converters.get(bibTeXEntry.
|
||||
getType().getValue());
|
||||
getType().getValue().toLowerCase());
|
||||
|
||||
if (converter == null) {
|
||||
report.addMessage(String.format("No converter for BibTeX type '%s' available. Publication '%s' has not"
|
||||
|
|
@ -98,7 +98,6 @@ public class BibTeXConverters {
|
|||
publication.setLanguage(Kernel.getConfig().getLanguagesIndependentCode());
|
||||
}
|
||||
final PublicationBundle bundle = converter.createBundle(publication, pretend);
|
||||
report.setType(publication.BASE_DATA_OBJECT_TYPE);
|
||||
|
||||
converter.processFields(bibTeXEntry, publication, importerUtil, report, pretend);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@ import com.arsdigita.cms.scipublications.importer.SciPublicationsImportException
|
|||
import com.arsdigita.cms.scipublications.importer.SciPublicationsImporter;
|
||||
import com.arsdigita.cms.scipublications.importer.report.ImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import javax.activation.MimeType;
|
||||
import javax.activation.MimeTypeParseException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -14,6 +17,7 @@ import org.jbibtex.BibTeXDatabase;
|
|||
import org.jbibtex.BibTeXEntry;
|
||||
import org.jbibtex.BibTeXParser;
|
||||
import org.jbibtex.Key;
|
||||
import org.jbibtex.ParseException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -44,12 +48,30 @@ public class BibTeXPublicationsImporter implements SciPublicationsImporter {
|
|||
final ImporterUtil importerUtil = new ImporterUtil(publishNewItems);
|
||||
final BibTeXConverters converters = BibTeXConverters.getInstance();
|
||||
|
||||
report.setImporter(BibTeXPublicationsImporter.class.getName());
|
||||
report.setPretend(pretend);
|
||||
|
||||
final StringReader reader = new StringReader(publications);
|
||||
final BibTeXParser parser = new BibTeXParser(reader);
|
||||
final BibTeXDatabase database = parser.getDatabase();
|
||||
final BibTeXParser parser = new BibTeXParser();
|
||||
final BibTeXDatabase database;
|
||||
try {
|
||||
database = parser.parse(reader);
|
||||
} catch (IOException ex) {
|
||||
final PrintWriter writer = new PrintWriter(System.err);
|
||||
writer.print("Failed to parse BibTeX file.");
|
||||
ex.printStackTrace(writer);
|
||||
|
||||
return report;
|
||||
} catch (ParseException ex) {
|
||||
final PrintWriter writer = new PrintWriter(System.err);
|
||||
writer.print("Failed to parse BibTeX file.");
|
||||
ex.printStackTrace(writer);
|
||||
|
||||
return report;
|
||||
}
|
||||
final Map<Key, BibTeXEntry> entries = database.getEntries();
|
||||
|
||||
for(BibTeXEntry entry : entries.values()) {
|
||||
for (BibTeXEntry entry : entries.values()) {
|
||||
report.addPublication(converters.convert(entry, importerUtil, pretend, publishNewItems));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class ArticleConverter implements BibTeXConverter<ArticleInJournal, Artic
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(ArticleInJournal.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ public class BookConverter implements BibTeXConverter<Monograph, PublicationWith
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(Monograph.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class BookletConverter implements BibTeXConverter<Monograph, PublicationW
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(Monograph.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class InBookConverter implements BibTeXConverter<ArticleInCollectedVolume
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(ArticleInCollectedVolume.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class InCollectionConverter implements BibTeXConverter<ArticleInCollected
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(ArticleInCollectedVolume.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class InProceedingsConverter implements BibTeXConverter<InProceedings, In
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(InProceedings.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class ManualConverter implements BibTeXConverter<Monograph, PublicationWi
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(Monograph.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class MasterThesisConverter implements BibTeXConverter<GreyLiterature, Un
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(GreyLiterature.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class MiscConverter implements BibTeXConverter<GreyLiterature, UnPublishe
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(GreyLiterature.class.getName());
|
||||
|
||||
bibTeXUtil.processIntField(pubKey,
|
||||
BibTeXEntry.KEY_YEAR,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class PhdThesisConverter implements BibTeXConverter<Monograph, Publicatio
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(Monograph.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class ProceedingsConverter implements BibTeXConverter<Proceedings, Procee
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(Proceedings.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ public class TechReportConverter implements BibTeXConverter<GreyLiterature, UnPu
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(GreyLiterature.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public class UnPublishedConverter implements BibTeXConverter<GreyLiterature, UnP
|
|||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||
final Key pubKey = bibTeXEntry.getKey();
|
||||
|
||||
importReport.setType(GreyLiterature.class.getName());
|
||||
|
||||
bibTeXUtil.processAuthors(pubKey,
|
||||
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||
publication,
|
||||
|
|
|
|||
|
|
@ -41,24 +41,16 @@ public class AuthorListParser {
|
|||
parseLastName(nameTokens[0], author);
|
||||
} else if (nameTokens.length == 1) {
|
||||
final String[] nameParts = nameTokens[0].split(" ");
|
||||
|
||||
if (nameParts.length == 1) {
|
||||
author.setLast(nameParts[0]);
|
||||
|
||||
return;
|
||||
} else if (nameParts.length == 2) {
|
||||
author.setFirst(nameParts[0]);
|
||||
author.setLast(nameParts[1]);
|
||||
|
||||
return;
|
||||
} else if (nameParts.length >= 3) {
|
||||
author.setFirst(nameParts[0]);
|
||||
author.setPreLast(nameParts[1]);
|
||||
author.setLast(nameParts[2]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
authorList.add(author);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.arsdigita.cms.contenttypes.InternetArticle;
|
|||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
||||
import com.arsdigita.cms.contenttypes.UnPublished;
|
||||
import com.arsdigita.cms.scipublications.importer.report.AuthorImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.util.AuthorData;
|
||||
|
|
@ -108,7 +109,10 @@ public class BibTeXUtil {
|
|||
final List<Author> authorList = authorListParser.parse(toPlainString(authors));
|
||||
|
||||
for (Author author : authorList) {
|
||||
importerUtil.processAuthor(publication, createAuthorData(author, editors), pretend);
|
||||
final AuthorImportReport authorReport = importerUtil.processAuthor(publication,
|
||||
createAuthorData(author, editors),
|
||||
pretend);
|
||||
importReport.addAuthor(authorReport);
|
||||
}
|
||||
|
||||
} catch (IOException ex) {
|
||||
|
|
@ -144,9 +148,15 @@ public class BibTeXUtil {
|
|||
|
||||
try {
|
||||
if (address == null) {
|
||||
importerUtil.processPublisher(publication, "", toPlainString(publisher), pretend);
|
||||
importReport.setPublisher(importerUtil.processPublisher(publication,
|
||||
"",
|
||||
toPlainString(publisher),
|
||||
pretend));
|
||||
} else {
|
||||
importerUtil.processPublisher(publication, toPlainString(address), toPlainString(publisher), pretend);
|
||||
importReport.setPublisher(importerUtil.processPublisher(publication,
|
||||
toPlainString(address),
|
||||
toPlainString(publisher),
|
||||
pretend));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse publisher for publication '%s'.", pubKey.getValue()),
|
||||
|
|
@ -169,7 +179,7 @@ public class BibTeXUtil {
|
|||
}
|
||||
|
||||
try {
|
||||
importerUtil.processSeries(publication, toPlainString(series), pretend);
|
||||
importReport.setSeries(importerUtil.processSeries(publication, toPlainString(series), pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse series for publication '%s'.", pubKey.getValue()),
|
||||
ex,
|
||||
|
|
@ -190,7 +200,7 @@ public class BibTeXUtil {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
importerUtil.processJournal(article, toPlainString(journal), pretend);
|
||||
importReport.setJournal(importerUtil.processJournal(article, toPlainString(journal), pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse journal for article '%s'.", pubKey.getValue()),
|
||||
ex,
|
||||
|
|
@ -226,14 +236,14 @@ public class BibTeXUtil {
|
|||
authorData.add(createAuthorData(author, false));
|
||||
}
|
||||
|
||||
importerUtil.processCollectedVolume(article,
|
||||
toPlainString(collectedVolume),
|
||||
toPlainString(yearValue),
|
||||
authorData,
|
||||
toPlainString(publisherValue),
|
||||
toPlainString(addressValue),
|
||||
toPlainString(editonValue),
|
||||
pretend);
|
||||
importReport.setCollectedVolume(importerUtil.processCollectedVolume(article,
|
||||
toPlainString(collectedVolume),
|
||||
toPlainString(yearValue),
|
||||
authorData,
|
||||
toPlainString(publisherValue),
|
||||
toPlainString(addressValue),
|
||||
toPlainString(editonValue),
|
||||
pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse collected volume for article '%s'.",
|
||||
bibTeXEntry.getKey().getValue()),
|
||||
|
|
@ -270,14 +280,14 @@ public class BibTeXUtil {
|
|||
authorData.add(createAuthorData(author, false));
|
||||
}
|
||||
|
||||
importerUtil.processProceedings(inProceedings,
|
||||
toPlainString(proceedings),
|
||||
toPlainString(yearValue),
|
||||
"",
|
||||
authorData,
|
||||
toPlainString(publisherValue),
|
||||
toPlainString(addressValue),
|
||||
pretend);
|
||||
importReport.setProceedings(importerUtil.processProceedings(inProceedings,
|
||||
toPlainString(proceedings),
|
||||
toPlainString(yearValue),
|
||||
"",
|
||||
authorData,
|
||||
toPlainString(publisherValue),
|
||||
toPlainString(addressValue),
|
||||
pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse proceedings for in proceedings '%s'.",
|
||||
bibTeXEntry.getKey().getValue()),
|
||||
|
|
@ -301,7 +311,9 @@ public class BibTeXUtil {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
importerUtil.processOrganization(publication, toPlainString(organization), pretend);
|
||||
importReport.addOrgaUnit(importerUtil.processOrganization(publication,
|
||||
toPlainString(organization),
|
||||
pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||
ex,
|
||||
|
|
@ -323,7 +335,7 @@ public class BibTeXUtil {
|
|||
return;
|
||||
}
|
||||
try {
|
||||
importerUtil.processOrganization(article, toPlainString(organization), pretend);
|
||||
importReport.addOrgaUnit(importerUtil.processOrganization(article, toPlainString(organization), pretend));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||
ex,
|
||||
|
|
@ -401,8 +413,11 @@ public class BibTeXUtil {
|
|||
try {
|
||||
final String str = toPlainString(value);
|
||||
final int intValue = Integer.parseInt(str);
|
||||
publication.set(target, intValue);
|
||||
|
||||
if (!pretend) {
|
||||
publication.set(target, intValue);
|
||||
}
|
||||
importReport.addField(new FieldImportReport(target, str));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse field '%s' for publication '%s'.",
|
||||
pubKey.getValue(),
|
||||
|
|
@ -437,7 +452,10 @@ public class BibTeXUtil {
|
|||
}
|
||||
|
||||
try {
|
||||
publication.set(target, toPlainString(value));
|
||||
if (!pretend) {
|
||||
publication.set(target, toPlainString(value));
|
||||
}
|
||||
importReport.addField(new FieldImportReport(target, toPlainString(value)));
|
||||
} catch (IOException ex) {
|
||||
addExceptionMsg(String.format("Failed to parse value of field '%s' for publication '%s'.",
|
||||
pubKey.getValue(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue