Verschiedene Korrekturen an den Importern für RIS und BibTeX.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2044 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e255dc6198
commit
e874b06a24
|
|
@ -17,6 +17,8 @@ public interface BibTeXConverter<T extends Publication, B extends PublicationBun
|
|||
|
||||
T createPublication(boolean pretend);
|
||||
|
||||
String getTypeName();
|
||||
|
||||
B createBundle(T publication, boolean pretend);
|
||||
|
||||
void processTitle(final BibTeXEntry bibTeXEntry,
|
||||
|
|
|
|||
|
|
@ -4,18 +4,28 @@ import com.arsdigita.categorization.Category;
|
|||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.importer.bibtex.util.BibTeXUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.RisImporter;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.Filter;
|
||||
import com.arsdigita.persistence.FilterFactory;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jbibtex.BibTeXEntry;
|
||||
import org.jbibtex.ParseException;
|
||||
|
||||
/**
|
||||
* Central access point for retrieving {@link BibTeXConverter}s for importing publication data in the BibTeX format.
|
||||
|
|
@ -26,7 +36,8 @@ import org.jbibtex.BibTeXEntry;
|
|||
public class BibTeXConverters {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(BibTeXConverters.class);
|
||||
private final Map<String, BibTeXConverter<Publication, PublicationBundle>> converters = new HashMap<String, BibTeXConverter<Publication, PublicationBundle>>();
|
||||
private final Map<String, BibTeXConverter<Publication, PublicationBundle>> converters =
|
||||
new HashMap<String, BibTeXConverter<Publication, PublicationBundle>>();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private BibTeXConverters() {
|
||||
|
|
@ -54,8 +65,8 @@ public class BibTeXConverters {
|
|||
final ImporterUtil importerUtil,
|
||||
final boolean pretend,
|
||||
final boolean publishNewItems) {
|
||||
final PublicationImportReport report = new PublicationImportReport();
|
||||
|
||||
final PublicationImportReport report = new PublicationImportReport();
|
||||
|
||||
BibTeXConverter<Publication, PublicationBundle> converter = converters.get(bibTeXEntry.
|
||||
getType().getValue().toLowerCase());
|
||||
|
||||
|
|
@ -68,6 +79,10 @@ public class BibTeXConverters {
|
|||
return report;
|
||||
}
|
||||
|
||||
if(isPublicationAlreadyInDatabase(bibTeXEntry, converter.getTypeName(), report)) {
|
||||
return report;
|
||||
}
|
||||
|
||||
try {
|
||||
converter = converter.getClass().newInstance();
|
||||
} catch (InstantiationException ex) {
|
||||
|
|
@ -97,7 +112,7 @@ public class BibTeXConverters {
|
|||
if (!pretend) {
|
||||
publication.setLanguage(Kernel.getConfig().getLanguagesIndependentCode());
|
||||
}
|
||||
final PublicationBundle bundle = converter.createBundle(publication, pretend);
|
||||
final PublicationBundle bundle = converter.createBundle(publication, pretend);
|
||||
|
||||
converter.processFields(bibTeXEntry, publication, importerUtil, report, pretend);
|
||||
|
||||
|
|
@ -146,4 +161,50 @@ public class BibTeXConverters {
|
|||
defaultCat.addChild(bundle);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPublicationAlreadyInDatabase(final BibTeXEntry bibTeXEntry,
|
||||
final String type,
|
||||
final PublicationImportReport importReport) {
|
||||
final String title;
|
||||
final String year;
|
||||
|
||||
try {
|
||||
final BibTeXUtil bibTeXUtil = new BibTeXUtil(null);
|
||||
|
||||
title = bibTeXUtil.toPlainString(bibTeXEntry.getField(BibTeXEntry.KEY_TITLE));
|
||||
year = bibTeXUtil.toPlainString(bibTeXEntry.getField(BibTeXEntry.KEY_YEAR));
|
||||
} catch (IOException ex) {
|
||||
return false;
|
||||
} catch (ParseException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int yearOfPublication;
|
||||
try {
|
||||
yearOfPublication = Integer.parseInt(year);
|
||||
} catch (NumberFormatException ex) {
|
||||
yearOfPublication = 0;
|
||||
}
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
final DataCollection collection = session.retrieve(Publication.BASE_DATA_OBJECT_TYPE);
|
||||
final FilterFactory filterFactory = collection.getFilterFactory();
|
||||
final Filter titleFilter = filterFactory.equals("title", title);
|
||||
final Filter yearFilter = filterFactory.equals("yearOfPublication", yearOfPublication);
|
||||
collection.addFilter(titleFilter);
|
||||
collection.addFilter(yearFilter);
|
||||
|
||||
final boolean result = !collection.isEmpty();
|
||||
collection.close();
|
||||
|
||||
if (result) {
|
||||
importReport.setTitle(title);
|
||||
importReport.setType(type);
|
||||
importReport.addField(new FieldImportReport(Publication.YEAR_OF_PUBLICATION, year));
|
||||
importReport.setAlreadyInDatabase(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class ArticleConverter implements BibTeXConverter<ArticleInJournal, Artic
|
|||
return new ArticleInJournal();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return ArticleInJournal.class.getName();
|
||||
}
|
||||
|
||||
public ArticleInJournalBundle createBundle(final ArticleInJournal publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ public class BookConverter implements BibTeXConverter<Monograph, PublicationWith
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class BookletConverter implements BibTeXConverter<Monograph, PublicationW
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class InBookConverter implements BibTeXConverter<ArticleInCollectedVolume
|
|||
return new ArticleInCollectedVolume();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return ArticleInCollectedVolume.class.getName();
|
||||
}
|
||||
|
||||
public ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||
final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class InCollectionConverter implements BibTeXConverter<ArticleInCollected
|
|||
return new ArticleInCollectedVolume();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return ArticleInCollectedVolume.class.getName();
|
||||
}
|
||||
|
||||
public ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||
final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class InProceedingsConverter implements BibTeXConverter<InProceedings, In
|
|||
return new InProceedings();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return InProceedings.class.getName();
|
||||
}
|
||||
|
||||
public InProceedingsBundle createBundle(final InProceedings publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class ManualConverter implements BibTeXConverter<Monograph, PublicationWi
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class MasterThesisConverter implements BibTeXConverter<GreyLiterature, Un
|
|||
return new GreyLiterature();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class MiscConverter implements BibTeXConverter<GreyLiterature, UnPublishe
|
|||
return new GreyLiterature();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class PhdThesisConverter implements BibTeXConverter<Monograph, Publicatio
|
|||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
public PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public class ProceedingsConverter implements BibTeXConverter<Proceedings, Procee
|
|||
return new Proceedings();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return Proceedings.class.getName();
|
||||
}
|
||||
|
||||
public ProceedingsBundle createBundle(final Proceedings publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class TechReportConverter implements BibTeXConverter<GreyLiterature, UnPu
|
|||
return new GreyLiterature();
|
||||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class UnPublishedConverter implements BibTeXConverter<GreyLiterature, UnP
|
|||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
public UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -467,7 +467,7 @@ public class BibTeXUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private String toPlainString(final Value value) throws IOException, ParseException {
|
||||
public String toPlainString(final Value value) throws IOException, ParseException {
|
||||
return toPlainString(value.toUserString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public interface RisConverter {
|
|||
ImporterUtil importerUtil,
|
||||
boolean pretend,
|
||||
boolean publishNewItems);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The RIS type supported by the converter implementation.
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class RisImporter implements SciPublicationsImporter {
|
|||
processPublication(dataset, report, importerUtil, pretend, publishNewItems);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
|
||||
return report;
|
||||
|
|
|
|||
|
|
@ -28,11 +28,15 @@ public class RisParser {
|
|||
RisFieldValue field;
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
|
||||
if ((lines[i] == null) || lines[i].isEmpty()) {
|
||||
if ((lines[i] == null) || (skipBom(lines[i]) == null) || skipBom(lines[i]).isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
field = parseRisLine(lines[i], i);
|
||||
|
||||
if (field == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (RisField.TY.equals(field.getName())) {
|
||||
if (openDataset) {
|
||||
|
|
@ -83,8 +87,10 @@ public class RisParser {
|
|||
try {
|
||||
fieldName = RisField.valueOf(tokens[0]);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new SciPublicationsImportException(String.format("Unkwown tag '%s' in line %d. Aborting import.",
|
||||
tokens[0], index + 1), ex);
|
||||
// throw new SciPublicationsImportException(String.format("Unkwown tag '%s' in line %d. Aborting import.",
|
||||
// tokens[0], index + 1), ex);
|
||||
//Ignore unknown none standard fields
|
||||
return null;
|
||||
}
|
||||
|
||||
return new RisFieldValue(fieldName, tokens[1]);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.arsdigita.categorization.Category;
|
|||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.PublicationBundle;
|
||||
import com.arsdigita.cms.scipublications.imexporter.ris.RisField;
|
||||
import com.arsdigita.cms.scipublications.importer.report.FieldImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.report.PublicationImportReport;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.RisConverter;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.RisDataset;
|
||||
|
|
@ -11,7 +13,13 @@ import com.arsdigita.cms.scipublications.importer.ris.RisImporter;
|
|||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisFieldUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.Filter;
|
||||
import com.arsdigita.persistence.FilterFactory;
|
||||
import com.arsdigita.persistence.Session;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -24,7 +32,18 @@ public abstract class AbstractRisConverter<T extends Publication, B extends Publ
|
|||
|
||||
protected abstract T createPublication(boolean pretend);
|
||||
|
||||
protected abstract String getTypeName();
|
||||
|
||||
protected abstract B createBundle(T publication, boolean pretend);
|
||||
|
||||
protected String getYear(final RisDataset dataset) {
|
||||
final List<String> values = dataset.getValues().get(RisField.PY);
|
||||
if ((values == null) || values.isEmpty()) {
|
||||
return "0";
|
||||
} else {
|
||||
return values.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void processFields(final RisDataset dataset,
|
||||
final T publication,
|
||||
|
|
@ -38,9 +57,13 @@ public abstract class AbstractRisConverter<T extends Publication, B extends Publ
|
|||
final boolean publishNewItems) {
|
||||
final PublicationImportReport importReport = new PublicationImportReport();
|
||||
|
||||
if (isPublicationAlreadyInDatabase(dataset, getTypeName(), importReport)) {
|
||||
return importReport;
|
||||
}
|
||||
|
||||
final T publication = createPublication(pretend);
|
||||
final RisFieldUtil fieldUtil = new RisFieldUtil(pretend);
|
||||
fieldUtil.processTitle(dataset, publication, importReport);
|
||||
fieldUtil.processTitle(dataset, publication, importReport);
|
||||
if (!pretend) {
|
||||
publication.setLanguage(Kernel.getConfig().getLanguagesIndependentCode());
|
||||
}
|
||||
|
|
@ -55,7 +78,7 @@ public abstract class AbstractRisConverter<T extends Publication, B extends Publ
|
|||
publication.setLanguage(Kernel.getConfig().getLanguagesIndependentCode());
|
||||
|
||||
publication.save();
|
||||
|
||||
|
||||
assignFolder(publication, bundle);
|
||||
assignCategories(bundle);
|
||||
|
||||
|
|
@ -95,4 +118,39 @@ public abstract class AbstractRisConverter<T extends Publication, B extends Publ
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isPublicationAlreadyInDatabase(final RisDataset dataset,
|
||||
final String type,
|
||||
final PublicationImportReport importReport) {
|
||||
final RisFieldUtil fieldUtil = new RisFieldUtil(true);
|
||||
final String title = fieldUtil.getTitle(dataset);
|
||||
final String year = getYear(dataset);
|
||||
|
||||
int yearOfPublication;
|
||||
try {
|
||||
yearOfPublication = Integer.parseInt(year);
|
||||
} catch (NumberFormatException ex) {
|
||||
yearOfPublication = 0;
|
||||
}
|
||||
|
||||
final Session session = SessionManager.getSession();
|
||||
final DataCollection collection = session.retrieve(type);
|
||||
final FilterFactory filterFactory = collection.getFilterFactory();
|
||||
final Filter titleFilter = filterFactory.equals(Publication.TITLE, title);
|
||||
final Filter yearFilter = filterFactory.equals(Publication.YEAR_OF_PUBLICATION, yearOfPublication);
|
||||
collection.addFilter(titleFilter);
|
||||
collection.addFilter(yearFilter);
|
||||
|
||||
final boolean result = !collection.isEmpty();
|
||||
collection.close();
|
||||
|
||||
if (result) {
|
||||
importReport.setTitle(title);
|
||||
importReport.setType(type);
|
||||
importReport.addField(new FieldImportReport(Publication.YEAR_OF_PUBLICATION, year));
|
||||
importReport.setAlreadyInDatabase(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class BlogConverter extends AbstractRisConverter<InternetArticle, Interne
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return InternetArticle.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InternetArticleBundle createBundle(final InternetArticle publication,
|
||||
final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ public class BookConverter extends AbstractRisConverter<Monograph, PublicationBu
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class ChapConverter extends AbstractRisConverter<ArticleInCollectedVolume
|
|||
return new ArticleInCollectedVolume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return ArticleInCollectedVolume.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisFieldU
|
|||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisOrgaUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisSeriesUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -29,6 +28,11 @@ public class ConfConverter extends AbstractRisConverter<Proceedings, Proceedings
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return Proceedings.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProceedingsBundle createBundle(final Proceedings publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
@ -51,7 +55,7 @@ public class ConfConverter extends AbstractRisConverter<Proceedings, Proceedings
|
|||
|
||||
fieldUtil.processTitle(dataset, publication, importReport);
|
||||
|
||||
fieldUtil.processIntField(dataset, RisField.C2, publication, "yearPublication", importReport);
|
||||
fieldUtil.processIntField(dataset, RisField.C2, publication, "yearOfPublication", importReport);
|
||||
|
||||
authorUtil.processAuthors(dataset, RisField.AU, publication, importReport);
|
||||
authorUtil.processEditors(dataset, RisField.A2, publication, importReport);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class CpaperConverter extends AbstractRisConverter<InProceedings, InProce
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return InProceedings.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InProceedingsBundle createBundle(final InProceedings publication,
|
||||
final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public class EbookConverter extends AbstractRisConverter<Monograph, PublicationW
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationWithPublisherBundle createBundle(final Monograph publication,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public class EdbookConverter extends AbstractRisConverter<CollectedVolume, Colle
|
|||
return new CollectedVolume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return CollectedVolume.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CollectedVolumeBundle createBundle(final CollectedVolume publication,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class EjourConverter extends AbstractRisConverter<ArticleInJournal, Artic
|
|||
return new ArticleInJournal();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return ArticleInJournal.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArticleInJournalBundle createBundle(final ArticleInJournal publication,
|
||||
|
|
@ -60,7 +65,7 @@ public class EjourConverter extends AbstractRisConverter<ArticleInJournal, Artic
|
|||
|
||||
fieldUtil.processPages(dataset, RisField.SP, publication, importReport);
|
||||
|
||||
fieldUtil.processField(dataset, RisField.VL, publication, "volume", importReport);
|
||||
fieldUtil.processIntField(dataset, RisField.VL, publication, "volume", importReport);
|
||||
}
|
||||
|
||||
public RisType getRisType() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class ElecConverter extends AbstractRisConverter<InternetArticle, Interne
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return InternetArticle.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InternetArticleBundle createBundle(final InternetArticle publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ public class EncycConverter extends AbstractRisConverter<ArticleInCollectedVolum
|
|||
return new ArticleInCollectedVolume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return ArticleInCollectedVolume.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArticleInCollectedVolumeBundle createBundle(final ArticleInCollectedVolume publication,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public class GenConverter extends AbstractRisConverter<Monograph, PublicationWit
|
|||
return new Monograph();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return Monograph.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PublicationWithPublisherBundle createBundle(final Monograph publication, final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ public class JourConverter extends AbstractRisConverter<ArticleInJournal, Articl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return ArticleInJournal.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArticleInJournalBundle createBundle(final ArticleInJournal publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public class RprtConverter extends AbstractRisConverter<GreyLiterature, UnPublis
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UnPublishedBundle createBundle(final GreyLiterature publication,
|
||||
final boolean pretend) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisAuthor
|
|||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisFieldUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisOrgaUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -28,6 +27,11 @@ public class ThesConverter extends AbstractRisConverter<GreyLiterature, UnPublis
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UnPublishedBundle createBundle(final GreyLiterature publication, final boolean pretend) {
|
||||
if (pretend) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisFieldU
|
|||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisOrgaUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.ris.converters.utils.RisSeriesUtil;
|
||||
import com.arsdigita.cms.scipublications.importer.util.ImporterUtil;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -27,6 +28,11 @@ public class UnpbConverter extends AbstractRisConverter<GreyLiterature, UnPublis
|
|||
return new GreyLiterature();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return GreyLiterature.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UnPublishedBundle createBundle(final GreyLiterature publication,
|
||||
|
|
@ -37,7 +43,7 @@ public class UnpbConverter extends AbstractRisConverter<GreyLiterature, UnPublis
|
|||
return new UnPublishedBundle(publication);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void processFields(final RisDataset dataset,
|
||||
final GreyLiterature publication,
|
||||
|
|
|
|||
|
|
@ -36,11 +36,11 @@ public class RisColVolUtil {
|
|||
final RisField cvEditionField,
|
||||
final ArticleInCollectedVolume article,
|
||||
final PublicationImportReport report) {
|
||||
final List<String> colVolTitle = dataset.getValues().get(cvTitleField);
|
||||
final List<String> colVolYear = dataset.getValues().get(cvYearField);
|
||||
final List<String> colVolPlace = dataset.getValues().get(cvPlaceField);
|
||||
final List<String> colVolPublisher = dataset.getValues().get(cvPublisherField);
|
||||
final List<String> colVolEdition = dataset.getValues().get(cvEditionField);
|
||||
final List<String> colVolTitleValue = dataset.getValues().get(cvTitleField);
|
||||
final List<String> colVolYearValue = dataset.getValues().get(cvYearField);
|
||||
final List<String> colVolPlaceValue = dataset.getValues().get(cvPlaceField);
|
||||
final List<String> colVolPublisherValue = dataset.getValues().get(cvPublisherField);
|
||||
final List<String> colVolEditionValue = dataset.getValues().get(cvEditionField);
|
||||
|
||||
final List<String> colVolEditors = dataset.getValues().get(cvEditorsField);
|
||||
final List<AuthorData> colVolEditorData = new ArrayList<AuthorData>();
|
||||
|
|
@ -53,14 +53,37 @@ public class RisColVolUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if ((colVolTitle != null) && !colVolTitle.isEmpty()) {
|
||||
if ((colVolTitleValue != null) && !colVolTitleValue.isEmpty()) {
|
||||
final String colVolTitle = colVolTitleValue.get(0);
|
||||
final String colVolYear = colVolYearValue.get(0);
|
||||
final String colVolPlace;
|
||||
final String colVolPublisher;
|
||||
final String colVolEdition;
|
||||
|
||||
if ((colVolPlaceValue == null) || colVolPlaceValue.isEmpty()) {
|
||||
colVolPlace = "";
|
||||
} else {
|
||||
colVolPlace = colVolPlaceValue.get(0);
|
||||
}
|
||||
if ((colVolPublisherValue == null) || colVolPublisherValue.isEmpty()) {
|
||||
colVolPublisher = "";
|
||||
} else {
|
||||
colVolPublisher = colVolPublisherValue.get(0);
|
||||
}
|
||||
if ((colVolEditionValue == null) || colVolEditionValue.isEmpty()) {
|
||||
colVolEdition = "";
|
||||
} else {
|
||||
colVolEdition = colVolEditionValue.get(0);
|
||||
}
|
||||
|
||||
|
||||
final CollectedVolumeImportReport colVolReport = importerUtil.processCollectedVolume(article,
|
||||
colVolTitle.get(0),
|
||||
colVolYear.get(0),
|
||||
colVolTitle,
|
||||
colVolYear,
|
||||
colVolEditorData,
|
||||
colVolPublisher.get(0),
|
||||
colVolPlace.get(0),
|
||||
colVolEdition.get(0),
|
||||
colVolPublisher,
|
||||
colVolPlace,
|
||||
colVolEdition,
|
||||
pretend);
|
||||
report.setCollectedVolume(colVolReport);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ public class RisFieldUtil {
|
|||
}
|
||||
|
||||
@SuppressWarnings("PMD.ConfusingTernary")
|
||||
public void processTitle(final RisDataset dataset,
|
||||
final Publication publication,
|
||||
final PublicationImportReport report) {
|
||||
public String getTitle(final RisDataset dataset) {
|
||||
final String title;
|
||||
|
||||
|
||||
if ((dataset.getValues().get(RisField.TI) != null) && !dataset.getValues().get(RisField.TI).isEmpty()) {
|
||||
title = dataset.getValues().get(RisField.TI).get(0);
|
||||
} else if ((dataset.getValues().get(RisField.BT) != null) && !dataset.getValues().get(RisField.BT).isEmpty()) {
|
||||
|
|
@ -36,6 +34,15 @@ public class RisFieldUtil {
|
|||
} else {
|
||||
title = "Unknown";
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
public void processTitle(final RisDataset dataset,
|
||||
final Publication publication,
|
||||
final PublicationImportReport report) {
|
||||
final String title = getTitle(dataset);
|
||||
|
||||
if (!pretend) {
|
||||
publication.setTitle(title);
|
||||
|
|
|
|||
|
|
@ -215,7 +215,13 @@ public class ImporterUtil {
|
|||
final Session session = SessionManager.getSession();
|
||||
final DataCollection collection = session.retrieve(CollectedVolume.BASE_DATA_OBJECT_TYPE);
|
||||
collection.addEqualsFilter("title", title);
|
||||
collection.addEqualsFilter("yearOfPublication", year);
|
||||
int yearOfPublication;
|
||||
try {
|
||||
yearOfPublication = Integer.parseInt(year);
|
||||
} catch(NumberFormatException ex) {
|
||||
yearOfPublication = 0;
|
||||
}
|
||||
collection.addEqualsFilter("yearOfPublication", yearOfPublication);
|
||||
report.setCollectedVolumeTitle(title);
|
||||
if (collection.isEmpty()) {
|
||||
if (!pretend) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue