Erste Beta des BibTeX Importers
git-svn-id: https://svn.libreccm.org/ccm/trunk@2042 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f293755302
commit
2082346610
|
|
@ -0,0 +1,13 @@
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.ArticleConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.BookConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.BookletConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.InBookConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.InCollectionConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.InProceedingsConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.ManualConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.MasterThesisConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.MiscConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.PhdThesisConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.ProceedingsConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.TechReportConverter
|
||||||
|
com.arsdigita.cms.scipublications.importer.bibtex.converters.UnPublishedConverter
|
||||||
|
|
@ -0,0 +1,101 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournalBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ArticleConverter implements BibTeXConverter<ArticleInJournal, ArticleInJournalBundle> {
|
||||||
|
|
||||||
|
public ArticleInJournal createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInJournal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticleInJournalBundle createBundle(final ArticleInJournal publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInJournalBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInJournal publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInJournal publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
pretend,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processJournal(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_JOURNAL),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_VOLUME,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_VOLUME),
|
||||||
|
ArticleInJournal.VOLUME,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_NUMBER,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NUMBER),
|
||||||
|
ArticleInJournal.ISSUE,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPages(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_PAGES),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_PAGES, bibTeXEntry.getField(BibTeXEntry.KEY_PAGES),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_ARTICLE.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.Monograph;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisherBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the BibTeX type {@code book} to the SciPublications type {@link Monograph}.
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class BookConverter implements BibTeXConverter<Monograph, PublicationWithPublisherBundle> {
|
||||||
|
|
||||||
|
public Monograph createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new Monograph();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new PublicationWithPublisherBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR),
|
||||||
|
publication,
|
||||||
|
true,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPublisher(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_PUBLISHER),
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_VOLUME,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_VOLUME),
|
||||||
|
PublicationWithPublisher.VOLUME,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NUMBER,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NUMBER),
|
||||||
|
PublicationWithPublisher.VOLUME,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processSeries(bibTeXEntry.getKey(),
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_SERIES),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_EDITION,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_EDITION),
|
||||||
|
PublicationWithPublisher.EDITION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_BOOK.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.Monograph;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisherBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class BookletConverter implements BibTeXConverter<Monograph, PublicationWithPublisherBundle> {
|
||||||
|
|
||||||
|
public Monograph createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new Monograph();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new PublicationWithPublisherBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_BOOKLET.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolumeBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InBookConverter implements BibTeXConverter<ArticleInCollectedVolume, ArticleInCollectedVolumeBundle> {
|
||||||
|
|
||||||
|
public ArticleInCollectedVolume createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInCollectedVolume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInCollectedVolumeBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInCollectedVolume publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInCollectedVolume publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processCollectedVolume(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_CHAPTER,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_CHAPTER),
|
||||||
|
ArticleInCollectedVolume.CHAPTER,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_INBOOK.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolumeBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InCollectionConverter implements BibTeXConverter<ArticleInCollectedVolume, ArticleInCollectedVolumeBundle> {
|
||||||
|
|
||||||
|
public ArticleInCollectedVolume createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInCollectedVolume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ArticleInCollectedVolumeBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInCollectedVolume publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInCollectedVolume publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
pretend,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processCollectedVolume(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_CHAPTER,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_CHAPTER),
|
||||||
|
ArticleInCollectedVolume.CHAPTER,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPages(pubKey, bibTeXEntry.getField(BibTeXEntry.KEY_PAGES), publication, importReport, pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_INCOLLECTION.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.InProceedings;
|
||||||
|
import com.arsdigita.cms.contenttypes.InProceedingsBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InProceedingsConverter implements BibTeXConverter<InProceedings, InProceedingsBundle> {
|
||||||
|
|
||||||
|
public InProceedings createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new InProceedings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public InProceedingsBundle createBundle(final InProceedings publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new InProceedingsBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final InProceedings publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final InProceedings publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
pretend,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processProceedings(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR),
|
||||||
|
publication,
|
||||||
|
pretend,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPages(pubKey, bibTeXEntry.getField(BibTeXEntry.KEY_PAGES), publication, importReport, pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_INPROCEEDINGS.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.Monograph;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisherBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ManualConverter implements BibTeXConverter<Monograph, PublicationWithPublisherBundle> {
|
||||||
|
|
||||||
|
public Monograph createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new Monograph();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new PublicationWithPublisherBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
pretend,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_EDITION,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_EDITION),
|
||||||
|
PublicationWithPublisher.EDITION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_MANUAL.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GreyLiterature;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublished;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublishedBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MasterThesisConverter implements BibTeXConverter<GreyLiterature, UnPublishedBundle> {
|
||||||
|
|
||||||
|
public GreyLiterature createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new GreyLiterature();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new UnPublishedBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processOrganization(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_SCHOOL),
|
||||||
|
publication,
|
||||||
|
importerUtil,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_ADDRESS,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS),
|
||||||
|
UnPublished.PLACE,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_MASTERSTHESIS.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GreyLiterature;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublishedBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MiscConverter implements BibTeXConverter<GreyLiterature, UnPublishedBundle> {
|
||||||
|
|
||||||
|
public GreyLiterature createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new GreyLiterature();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new UnPublishedBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_MASTERSTHESIS.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.Monograph;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.PublicationWithPublisherBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class PhdThesisConverter implements BibTeXConverter<Monograph, PublicationWithPublisherBundle> {
|
||||||
|
|
||||||
|
public Monograph createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new Monograph();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new PublicationWithPublisherBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Monograph publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPublisher(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_SCHOOL),
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_PHDTHESIS.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.Proceedings;
|
||||||
|
import com.arsdigita.cms.contenttypes.ProceedingsBundle;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ProceedingsConverter implements BibTeXConverter<Proceedings, ProceedingsBundle> {
|
||||||
|
|
||||||
|
public Proceedings createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new Proceedings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProceedingsBundle createBundle(final Proceedings publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new ProceedingsBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Proceedings publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Proceedings publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR),
|
||||||
|
publication,
|
||||||
|
true,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processPublisher(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_PUBLISHER),
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processSeries(bibTeXEntry.getKey(),
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_SERIES),
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_PROCEEDINGS.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GreyLiterature;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublished;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublishedBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class TechReportConverter implements BibTeXConverter<GreyLiterature, UnPublishedBundle> {
|
||||||
|
|
||||||
|
public GreyLiterature createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new GreyLiterature();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new UnPublishedBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processOrganization(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_INSTITUTION),
|
||||||
|
publication,
|
||||||
|
importerUtil,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(pubKey,
|
||||||
|
BibTeXEntry.KEY_ADDRESS,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS),
|
||||||
|
UnPublished.PLACE,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_TECHREPORT.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.converters;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.GreyLiterature;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.UnPublishedBundle;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.BibTeXConverter;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class UnPublishedConverter implements BibTeXConverter<GreyLiterature, UnPublishedBundle> {
|
||||||
|
|
||||||
|
public GreyLiterature createPublication(final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new GreyLiterature();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||||
|
if (pretend) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new UnPublishedBundle(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||||
|
bibTeXUtil.processTitle(bibTeXEntry, publication, importReport, pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processFields(final BibTeXEntry bibTeXEntry,
|
||||||
|
final GreyLiterature publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final BibTeXUtil bibTeXUtil = new BibTeXUtil(importerUtil);
|
||||||
|
final Key pubKey = bibTeXEntry.getKey();
|
||||||
|
|
||||||
|
bibTeXUtil.processAuthors(pubKey,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_AUTHOR),
|
||||||
|
publication,
|
||||||
|
false,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processIntField(pubKey,
|
||||||
|
BibTeXEntry.KEY_YEAR,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_YEAR),
|
||||||
|
Publication.YEAR_OF_PUBLICATION,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
bibTeXUtil.processField(bibTeXEntry.getKey(),
|
||||||
|
BibTeXEntry.KEY_NOTE,
|
||||||
|
bibTeXEntry.getField(BibTeXEntry.KEY_NOTE),
|
||||||
|
Publication.MISC,
|
||||||
|
publication,
|
||||||
|
importReport,
|
||||||
|
pretend);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBibTeXType() {
|
||||||
|
return BibTeXEntry.TYPE_UNPUBLISHED.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a Author token from a BibTeX entry.
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class Author {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First name
|
||||||
|
*/
|
||||||
|
private String first = "";
|
||||||
|
/**
|
||||||
|
* Last name
|
||||||
|
*/
|
||||||
|
private String last = "";
|
||||||
|
/**
|
||||||
|
* von, van etc.
|
||||||
|
*/
|
||||||
|
private String preLast = "";
|
||||||
|
/**
|
||||||
|
* Jr., PhD etc.
|
||||||
|
*/
|
||||||
|
private String suffix = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can only created by the {@link AuthorListParser} class in this package.
|
||||||
|
*/
|
||||||
|
Author() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirst() {
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setFirst(final String first) {
|
||||||
|
this.first = first;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLast() {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setLast(final String last) {
|
||||||
|
this.last = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreLast() {
|
||||||
|
return preLast;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setPreLast(final String preLast) {
|
||||||
|
this.preLast = preLast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuffix() {
|
||||||
|
return suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSuffix(final String suffix) {
|
||||||
|
this.suffix = suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class AuthorListParser {
|
||||||
|
|
||||||
|
public AuthorListParser() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Author> parse(final String authors) {
|
||||||
|
final String[] authorTokens = authors.split("and");
|
||||||
|
|
||||||
|
final List<Author> authorList = new ArrayList<Author>(authorTokens.length);
|
||||||
|
|
||||||
|
for (final String authorToken : authorTokens) {
|
||||||
|
parseAuthorToken(authorToken, authorList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return authorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseAuthorToken(final String authorToken, final List<Author> authorList) {
|
||||||
|
final String token = authorToken.trim();
|
||||||
|
|
||||||
|
final Author author = new Author();
|
||||||
|
|
||||||
|
final String[] nameTokens = token.split(",");
|
||||||
|
if (nameTokens.length == 2) {
|
||||||
|
author.setFirst(nameTokens[1]);
|
||||||
|
parseLastName(nameTokens[0], author);
|
||||||
|
} else if (nameTokens.length > 2) {
|
||||||
|
author.setFirst(nameTokens[2]);
|
||||||
|
author.setSuffix(nameTokens[1]);
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseLastName(final String lastName, final Author author) {
|
||||||
|
final String[] lastNameParts = lastName.split(" ");
|
||||||
|
if (lastNameParts.length == 1) {
|
||||||
|
author.setLast(lastNameParts[0]);
|
||||||
|
|
||||||
|
} else if (lastNameParts.length == 2) {
|
||||||
|
author.setPreLast(lastNameParts[0]);
|
||||||
|
author.setLast(lastNameParts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,505 @@
|
||||||
|
package com.arsdigita.cms.scipublications.importer.bibtex.util;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;
|
||||||
|
import com.arsdigita.cms.contenttypes.ArticleInJournal;
|
||||||
|
import com.arsdigita.cms.contenttypes.InProceedings;
|
||||||
|
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.FieldImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.AuthorData;
|
||||||
|
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import org.jbibtex.BibTeXEntry;
|
||||||
|
import org.jbibtex.Key;
|
||||||
|
import org.jbibtex.LaTeXObject;
|
||||||
|
import org.jbibtex.LaTeXParser;
|
||||||
|
import org.jbibtex.LaTeXPrinter;
|
||||||
|
import org.jbibtex.ParseException;
|
||||||
|
import org.jbibtex.Value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class BibTeXUtil {
|
||||||
|
|
||||||
|
private final ImporterUtil importerUtil;
|
||||||
|
|
||||||
|
public BibTeXUtil(final ImporterUtil importerUtil) {
|
||||||
|
super();
|
||||||
|
this.importerUtil = importerUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processTitle(final BibTeXEntry bibTeXEntry,
|
||||||
|
final Publication publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
try {
|
||||||
|
final String title = toPlainString(bibTeXEntry.getField(BibTeXEntry.KEY_TITLE));
|
||||||
|
|
||||||
|
if (!pretend) {
|
||||||
|
publication.setTitle(title);
|
||||||
|
String name = normalizeString(title);
|
||||||
|
if (name.length() > 200) {
|
||||||
|
name = name.substring(0, 200);
|
||||||
|
}
|
||||||
|
publication.setName(name);
|
||||||
|
}
|
||||||
|
importReport.setTitle(title);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse title for BibTeX entry '%s'. Using key as title. ",
|
||||||
|
bibTeXEntry.getKey().getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
|
||||||
|
if (!pretend) {
|
||||||
|
publication.setTitle(bibTeXEntry.getKey().getValue());
|
||||||
|
String name = normalizeString(bibTeXEntry.getKey().getValue());
|
||||||
|
if (name.length() > 200) {
|
||||||
|
name = name.substring(0, 200);
|
||||||
|
}
|
||||||
|
publication.setName(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
importReport.setTitle(bibTeXEntry.getKey().getValue());
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse title for BibTeX entry '%s'. Using key as title. ",
|
||||||
|
bibTeXEntry.getKey().getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
|
||||||
|
if (!pretend) {
|
||||||
|
publication.setTitle(bibTeXEntry.getKey().getValue());
|
||||||
|
String name = normalizeString(bibTeXEntry.getKey().getValue());
|
||||||
|
if (name.length() > 200) {
|
||||||
|
name = name.substring(0, 200);
|
||||||
|
}
|
||||||
|
publication.setName(name);
|
||||||
|
}
|
||||||
|
importReport.setTitle(bibTeXEntry.getKey().getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processAuthors(final Key pubKey,
|
||||||
|
final Value authors,
|
||||||
|
final Publication publication,
|
||||||
|
final boolean editors,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
|
||||||
|
if (authors == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final AuthorListParser authorListParser = new AuthorListParser();
|
||||||
|
try {
|
||||||
|
final List<Author> authorList = authorListParser.parse(toPlainString(authors));
|
||||||
|
|
||||||
|
for (Author author : authorList) {
|
||||||
|
importerUtil.processAuthor(publication, createAuthorData(author, editors), pretend);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to process author of publication '%s'.",
|
||||||
|
pubKey.getValue()), ex, importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to process author of publication '%s'.",
|
||||||
|
pubKey.getValue()), ex, importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AuthorData createAuthorData(final Author author, final boolean editor) {
|
||||||
|
final AuthorData authorData = new AuthorData();
|
||||||
|
authorData.setEditor(editor);
|
||||||
|
authorData.setSurname(String.format("%s %s %s",
|
||||||
|
author.getPreLast(),
|
||||||
|
author.getLast(),
|
||||||
|
author.getSuffix()).trim());
|
||||||
|
authorData.setGivenName(author.getFirst());
|
||||||
|
|
||||||
|
return authorData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processPublisher(final Key pubKey,
|
||||||
|
final Value publisher,
|
||||||
|
final Value address,
|
||||||
|
final PublicationWithPublisher publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (publisher == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (address == null) {
|
||||||
|
importerUtil.processPublisher(publication, "", toPlainString(publisher), pretend);
|
||||||
|
} else {
|
||||||
|
importerUtil.processPublisher(publication, toPlainString(address), toPlainString(publisher), pretend);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse publisher for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse publisher for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSeries(final Key pubKey,
|
||||||
|
final Value series,
|
||||||
|
final Publication publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (series == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
importerUtil.processSeries(publication, toPlainString(series), pretend);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse series for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse series for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processJournal(final Key pubKey,
|
||||||
|
final Value journal,
|
||||||
|
final ArticleInJournal article,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (journal == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
importerUtil.processJournal(article, toPlainString(journal), pretend);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse journal for article '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse journal for article '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processCollectedVolume(final BibTeXEntry bibTeXEntry,
|
||||||
|
final ArticleInCollectedVolume article,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final Value collectedVolume = bibTeXEntry.getField(BibTeXEntry.KEY_BOOKTITLE);
|
||||||
|
|
||||||
|
if (collectedVolume == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Value yearValue = bibTeXEntry.getField(BibTeXEntry.KEY_YEAR);
|
||||||
|
final Value editorValue = bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR);
|
||||||
|
final Value publisherValue = bibTeXEntry.getField(BibTeXEntry.KEY_PUBLISHER);
|
||||||
|
final Value addressValue = bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS);
|
||||||
|
final Value editonValue = bibTeXEntry.getField(BibTeXEntry.KEY_EDITION);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final AuthorListParser authorListParser = new AuthorListParser();
|
||||||
|
final List<Author> authors = authorListParser.parse(toPlainString(editorValue));
|
||||||
|
final List<AuthorData> authorData = new ArrayList<AuthorData>();
|
||||||
|
for (Author author : authors) {
|
||||||
|
authorData.add(createAuthorData(author, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
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()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse collected volume for article '%s'.",
|
||||||
|
bibTeXEntry.getKey().getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processProceedings(final BibTeXEntry bibTeXEntry,
|
||||||
|
final InProceedings inProceedings,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
final Value proceedings = bibTeXEntry.getField(BibTeXEntry.KEY_BOOKTITLE);
|
||||||
|
|
||||||
|
if (proceedings == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Value yearValue = bibTeXEntry.getField(BibTeXEntry.KEY_YEAR);
|
||||||
|
final Value editorValue = bibTeXEntry.getField(BibTeXEntry.KEY_EDITOR);
|
||||||
|
final Value publisherValue = bibTeXEntry.getField(BibTeXEntry.KEY_PUBLISHER);
|
||||||
|
final Value addressValue = bibTeXEntry.getField(BibTeXEntry.KEY_ADDRESS);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final AuthorListParser authorListParser = new AuthorListParser();
|
||||||
|
final List<Author> authors = authorListParser.parse(toPlainString(editorValue));
|
||||||
|
final List<AuthorData> authorData = new ArrayList<AuthorData>();
|
||||||
|
for (Author author : authors) {
|
||||||
|
authorData.add(createAuthorData(author, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
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()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse proceedings for in proceedings '%s'.",
|
||||||
|
bibTeXEntry.getKey().getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processOrganization(final Key pubKey,
|
||||||
|
final Value organization,
|
||||||
|
final UnPublished publication,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (organization == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
importerUtil.processOrganization(publication, toPlainString(organization), pretend);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processOrganization(final Key pubKey,
|
||||||
|
final Value organization,
|
||||||
|
final InternetArticle article,
|
||||||
|
final ImporterUtil importerUtil,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (organization == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
importerUtil.processOrganization(article, toPlainString(organization), pretend);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse organization for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processPages(final Key pubKey,
|
||||||
|
final Value pages,
|
||||||
|
final Publication publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
try {
|
||||||
|
final String pagesStr = toPlainString(pages);
|
||||||
|
|
||||||
|
final String[] tokens = pagesStr.split("-");
|
||||||
|
if (tokens.length == 2) {
|
||||||
|
try {
|
||||||
|
final int pagesFrom = Integer.parseInt(tokens[0]);
|
||||||
|
final int pagesTo = Integer.parseInt(tokens[1]);
|
||||||
|
if (!pretend) {
|
||||||
|
publication.set("pagesFrom", pagesFrom);
|
||||||
|
publication.set("pagesTo", pagesTo);
|
||||||
|
}
|
||||||
|
importReport.addField(new FieldImportReport("pagesFrom", Integer.toString(pagesFrom)));
|
||||||
|
importReport.addField(new FieldImportReport("pagesTo", Integer.toString(pagesTo)));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
importReport.addMessage(String.format("Failed to parse pages for publication '%s'. "
|
||||||
|
+ "One of the values given is not an integer.",
|
||||||
|
pubKey.getValue()));
|
||||||
|
}
|
||||||
|
} else if (tokens.length == 1) {
|
||||||
|
try {
|
||||||
|
final int pagesFrom = Integer.parseInt(tokens[0]);
|
||||||
|
if (!pretend) {
|
||||||
|
publication.set("pagesFrom", pagesFrom);
|
||||||
|
}
|
||||||
|
importReport.addField(new FieldImportReport("pagesFrom", Integer.toString(pagesFrom)));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
importReport.addMessage(String.format("Failed to parse pages for publication '%s'. "
|
||||||
|
+ "Value is not an integer.",
|
||||||
|
pubKey.getValue()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
importReport.addMessage(String.format("Failed to parse pages for publication '%s'.",
|
||||||
|
pubKey.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse pages for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse pages for publication '%s'.", pubKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processIntField(final Key pubKey,
|
||||||
|
final Key fieldKey,
|
||||||
|
final Value value,
|
||||||
|
final String target,
|
||||||
|
final Publication publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final String str = toPlainString(value);
|
||||||
|
final int intValue = Integer.parseInt(str);
|
||||||
|
publication.set(target, intValue);
|
||||||
|
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse field '%s' for publication '%s'.",
|
||||||
|
pubKey.getValue(),
|
||||||
|
fieldKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse field '%s' for publication '%s'.",
|
||||||
|
pubKey.getValue(),
|
||||||
|
fieldKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse field '%s' for publication '%s'.",
|
||||||
|
pubKey.getValue(),
|
||||||
|
fieldKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processField(final Key pubKey,
|
||||||
|
final Key fieldKey,
|
||||||
|
final Value value,
|
||||||
|
final String target,
|
||||||
|
final Publication publication,
|
||||||
|
final PublicationImportReport importReport,
|
||||||
|
final boolean pretend) {
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
publication.set(target, toPlainString(value));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
addExceptionMsg(String.format("Failed to parse value of field '%s' for publication '%s'.",
|
||||||
|
pubKey.getValue(),
|
||||||
|
fieldKey.getValue()),
|
||||||
|
ex,
|
||||||
|
importReport);
|
||||||
|
} catch (ParseException ex) {
|
||||||
|
Logger.getLogger(BibTeXUtil.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toPlainString(final Value value) throws IOException, ParseException {
|
||||||
|
return toPlainString(value.toUserString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toPlainString(final String str) throws IOException, ParseException {
|
||||||
|
final List<LaTeXObject> objects = parseLaTeX(str);
|
||||||
|
|
||||||
|
return printLaTeX(objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LaTeXObject> parseLaTeX(final String string) throws IOException, ParseException {
|
||||||
|
final Reader reader = new StringReader(string);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final LaTeXParser parser = new LaTeXParser();
|
||||||
|
|
||||||
|
return parser.parse(reader);
|
||||||
|
} finally {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String printLaTeX(final List<LaTeXObject> objects) {
|
||||||
|
final LaTeXPrinter printer = new LaTeXPrinter();
|
||||||
|
|
||||||
|
return printer.print(objects);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeString(final String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
return str.replace("ä", "ae").replace("ö", "oe").replace("ü", "ue").
|
||||||
|
replace(
|
||||||
|
"Ä", "Ae").replace("Ü", "Ue").replace("Ö", "Oe").replace("ß",
|
||||||
|
"ss").
|
||||||
|
replace(" ", "-").
|
||||||
|
replaceAll("[^a-zA-Z0-9\\-]", "").toLowerCase().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExceptionMsg(final String msg, final Exception exception, final PublicationImportReport importReport) {
|
||||||
|
final StringWriter strWriter = new StringWriter();
|
||||||
|
final PrintWriter writer = new PrintWriter(strWriter);
|
||||||
|
|
||||||
|
exception.printStackTrace(writer);
|
||||||
|
writer.flush();
|
||||||
|
strWriter.flush();
|
||||||
|
|
||||||
|
importReport.addMessage(String.format("%s Exeception was: %s.",
|
||||||
|
msg,
|
||||||
|
strWriter.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue