From d37ed2a07ba7d0bbbdd3524c7ddc358474e8e8d0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Mon, 22 Aug 2016 22:09:56 +0200 Subject: [PATCH] Export number as issue, when issue field not present Rework some test files --- .../sf/jabref/logic/msbib/MSBibConverter.java | 10 ++-- .../sf/jabref/logic/msbib/MSBibMapping.java | 2 +- .../fileformat/MsBibImporterTest.java | 8 --- .../fileformat/MsBibImporterTestfiles.java | 4 +- .../logic/exporter/MsBibExportFormatTest1.bib | 20 +------ .../logic/exporter/MsBibExportFormatTest1.xml | 53 ++++------------- .../logic/exporter/MsBibExportFormatTest2.bib | 4 +- .../logic/exporter/MsBibExportFormatTest2.xml | 20 +++---- .../logic/exporter/MsBibExportFormatTest4.bib | 1 - .../logic/exporter/MsBibExportFormatTest4.xml | 19 +++---- .../logic/exporter/MsBibExportFormatTest7.bib | 1 + .../logic/exporter/MsBibExportFormatTest7.xml | 1 - .../MsBibImporterMsBibFieldsTest.bib | 25 ++++++++ .../MsBibImporterMsBibFieldsTest.xml | 27 +++++++++ .../fileformat/MsBibImporterTest1.bib | 14 ----- .../fileformat/MsBibImporterTest1.xml | 18 ------ .../fileformat/MsBibImporterTest2.bib | 41 ------------- .../fileformat/MsBibImporterTest2.xml | 57 ------------------- .../fileformat/MsBibImporterTitleTest.bib | 3 + .../fileformat/MsBibImporterTitleTest.xml | 10 ++++ 20 files changed, 107 insertions(+), 231 deletions(-) create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.bib create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.xml delete mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.bib delete mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.xml delete mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.bib delete mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.xml create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.bib create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.xml diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java index 25a8c69c3b3b..a92c4235e8f9 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java @@ -55,23 +55,25 @@ public static MSBibEntry convert(BibEntry entry) { result.journalName = entry.getFieldOrAlias(FieldName.JOURNAL).orElse(null); result.month = entry.getFieldOrAlias(FieldName.MONTH).orElse(null); + if (!entry.getFieldOptional(FieldName.YEAR).isPresent()) { result.year = entry.getFieldOrAlias(FieldName.YEAR).orElse(null); } - + if (!entry.getFieldOptional(FieldName.ISSUE).isPresent()) { + result.number = entry.getFieldOptional(FieldName.NUMBER).orElse(null); + } // Value must be converted //Currently only english is supported - entry.getFieldOptional(FieldName.LANGUAGE) .ifPresent(lang -> result.fields.put("LCID", String.valueOf(MSBibMapping.getLCID(lang)))); - result.standardNumber = ""; - entry.getFieldOptional(FieldName.ISBN).ifPresent(isbn -> result.standardNumber += " ISBN: " + isbn); entry.getFieldOptional(FieldName.ISSN).ifPresent(issn -> result.standardNumber += " ISSN: " + issn); entry.getFieldOptional("lccn").ifPresent(lccn -> result.standardNumber += " LCCN: " + lccn); entry.getFieldOptional("mrnumber").ifPresent(mrnumber -> result.standardNumber += " MRN: " + mrnumber); + + if (result.standardNumber.isEmpty()) { result.standardNumber = null; } diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java index d9d64de80944..d1752c127c25 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java @@ -59,7 +59,7 @@ public class MSBibMapping { bibtexToMSBib.put(MSBIB_PREFIX + "numberofvolume", "NumberVolumes"); bibtexToMSBib.put(MSBIB_PREFIX + "periodical", "PeriodicalTitle"); //bibtexToMSBib.put(MSBIB_PREFIX + "day", "Day"); - //bibtexToMSBib.put(PREFIX + "accessed", "Accessed"); + bibtexToMSBib.put(MSBIB_PREFIX + "accessed", "Accessed"); bibtexToMSBib.put(MSBIB_PREFIX + "medium", "Medium"); bibtexToMSBib.put(MSBIB_PREFIX + "recordingnumber", "RecordingNumber"); bibtexToMSBib.put(MSBIB_PREFIX + "theater", "Theater"); diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.java index 09f9c28c30eb..1093b0ae7419 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.java @@ -9,12 +9,9 @@ import java.util.Collections; import java.util.List; -import net.sf.jabref.Globals; import net.sf.jabref.logic.util.FileExtensions; import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.preferences.JabRefPreferences; -import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -22,11 +19,6 @@ public class MsBibImporterTest { - @Before - public void setUp() throws Exception { - Globals.prefs = JabRefPreferences.getInstance(); - } - @Test public void testsGetExtensions() { MsBibImporter importer = new MsBibImporter(); diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTestfiles.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTestfiles.java index 185313b49d2f..6e27da83aa85 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTestfiles.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/MsBibImporterTestfiles.java @@ -34,6 +34,7 @@ public class MsBibImporterTestfiles { @Before public void setUp() { + //currently still necessary as it throws an NPE otherwise Globals.prefs = JabRefPreferences.getInstance(); } @@ -62,8 +63,7 @@ public void testImportEntries() throws Exception { Path xmlFile = Paths.get(PATH_TO_FILE, fileName); - List result = testImporter.importDatabase(xmlFile, StandardCharsets.UTF_8).getDatabase() - .getEntries(); + List result = testImporter.importDatabase(xmlFile, StandardCharsets.UTF_8).getDatabase().getEntries(); BibEntryAssert.assertEquals(MsBibImporterTest.class, bibFileName, result); } diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib index 98932e7c9f08..cb202e6c730a 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib @@ -1,23 +1,6 @@ % Encoding: UTF-8 @Unpublished{, - author = {Hanns-Jörg Stoß}, - howpublished = {how}, - note = {a Note}, - month = {July}, - abstract = {here should stand something about the content}, - address = {Stuttgart Bawue Deutschland}, - affiliation = {aff}, - booktitle = {Turingmaschinen}, - chapter = {3}, - contents = {con}, - copyright = {cop}, - crossref = {cross}, - edition = {10}, - editor = {Alfred}, - institution = {Institution}, - intype = {intype}, - isbn = {‎978-3-16-148410-0}, msbib-abbreviatedcasenumber = {abb}, msbib-accessed = {12.10.2015}, msbib-broadcaster = {broad}, @@ -34,8 +17,7 @@ @Unpublished{ msbib-station = {stat}, msbib-theater = {th}, msbib-type = {type}, - organization = {Besondere Turingmaschinen}, - owner = {Christoph Schwentker}, + owner = {Ich}, paper = {paper}, price = {10}, school = {Gymnasium Unterrieden}, diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml index 8ad42135c5dc..a7d2c801f2b2 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml @@ -5,62 +5,29 @@ ser unpublished Report -3 -Institution -Turingmaschinen +rep +12.10.2015 court record -Gymnasium Unterrieden -Turing -produktion -paper -case -broad -here should stand something about the content -how -abb -intype -cop -a Note -rep -aff -10 stat th peri type +Gymnasium Unterrieden dist -cross +Turing med +produktion +paper +case +broad 10 +abb 1000 -con 12 10 2015 - - - - -Stoß -Hanns-Jörg - - - - - - -Alfred - - - - -July - ISBN: ‎978-3-16-148410-0 -Turingmaschinen -Stuttgart -Bawue -Deutschland + unpublished diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.bib index 5b771c4c5912..30ffd8244b92 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.bib @@ -1,3 +1,4 @@ +% Encoding: UTF-8 @phdthesis{2002, title = {Agile Entwicklung Web-basierter Systeme}, year = {2002}, @@ -5,7 +6,6 @@ @phdthesis{2002 number = {3}, address = {a}, journal = {Wirtschaftsinformatik}, - keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, pages = {237--248}, publisher = {Gabler Verlag}, @@ -13,3 +13,5 @@ @phdthesis{2002 url = {http://dx.doi.org/10.1007/BF03250842}, volume = {44}, } + +@Comment{jabref-meta: databaseType:biblatex;} diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml index 409f4eb352ea..54b1476c210a 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml @@ -1,22 +1,20 @@ -Report -phdthesis -2002 0 -Agile Entwicklung Web-basierter Systeme 2002 - -237-248 44 - DOI: 10.1007/BF03250842 +phdthesis +Report +Agile Entwicklung Web-basierter Systeme +2002 Gabler Verlag -a +http://dx.doi.org/10.1007/BF03250842 +10.1007/BF03250842 + +237-248 Wirtschaftsinformatik +a type -10.1007/BF03250842 -http://dx.doi.org/10.1007/BF03250842 -software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib index 266082895b97..56fe54ca28d4 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib @@ -1,7 +1,6 @@ @inbook{raey, issn = {0937-6429}, journal = {Wirtschaftsinformatik}, - keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, pages = {237--248}, publisher = {Gabler Verlag}, diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml index a87bc12e9c13..6d0d9efb5d98 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml @@ -1,20 +1,19 @@ -BookSection -inbook -raey 0 -Agile Entwicklung Web-basierter Systeme 2002 - -237-248 44 - ISSN: 0937-6429 DOI: 10.1000/182 +inbook +BookSection +Agile Entwicklung Web-basierter Systeme +raey Gabler Verlag -Wirtschaftsinformatik -10.1000/182 http://dx.doi.org/10.1007/BF03250842 -software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development +10.1000/182 + +237-248 +Wirtschaftsinformatik + ISSN: 0937-6429 diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib index 2010ffbb3718..ac469ca8a329 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib @@ -9,4 +9,5 @@ @article{Orlowski;2011 doi = {10.13140/2.1.3259.2169}, journaltitle = {Information Systems Architecture and Technology: Service Oriented Networked Systems}, } + @Comment{jabref-meta: databaseType:biblatex;} diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.xml index 9ddab21a17f7..4126bf24e766 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.xml @@ -21,6 +21,5 @@ 99-108 Information Systems Architecture and Technology: Service Oriented Networked Systems - DOI: 10.13140/2.1.3259.2169 diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.bib new file mode 100644 index 000000000000..60157c7651bc --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.bib @@ -0,0 +1,25 @@ +% Encoding: UTF-8 + +@Article{, + series = {ser}, + msbib-abbreviatedcasenumber = {abb}, + msbib-accessed = {July 3, 2010}, + msbib-broadcaster = {broad}, + msbib-casenumber = {case}, + msbib-court = {court}, + msbib-distributor = {dist}, + msbib-medium = {med}, + msbib-numberofvolume = {10}, + msbib-periodical = {Besondere Turingmaschinen}, + msbib-productioncompany = {produktion}, + msbib-recordingnumber = {record}, + msbib-reporter = {rep}, + msbib-station = {stat}, + msbib-theater = {th}, + msbib-type = {type}, + price = {10}, + school = {Gymnasium Unterrieden}, + size = {1000}, +} + +@Comment{jabref-meta: databaseType:bibtex;} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.xml new file mode 100644 index 000000000000..7f59b422a5d4 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterMsBibFieldsTest.xml @@ -0,0 +1,27 @@ + + + +10 +ser +article +JournalArticle +rep +July 3, 2010 +court +record +stat +th +Besondere Turingmaschinen +type +Gymnasium Unterrieden +dist +med +produktion +case +broad +10 +abb +1000 + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.bib deleted file mode 100644 index d3d39fc84933..000000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.bib +++ /dev/null @@ -1,14 +0,0 @@ -@inproceedings{raey, - Title = {Agile Entwicklung Web-basierter Systeme}, - isbn = {0937-6429}, - journaltitle = {Wirtschaftsinformatik}, - Year = {2002}, - issue = {3}, - Pages = {237--248}, - Volume = {44}, - - Keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, - Language = {english}, - Publisher = {Gabler Verlag}, - Url = {http://dx.doi.org/10.1007/BF03250842} -} \ No newline at end of file diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.xml deleted file mode 100644 index 0b5670840fec..000000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - -ConferenceProceedings -raey -0 -Agile Entwicklung Web-basierter Systeme -2002 -237-248 -44 -:ISBN:0937-6429 -Gabler Verlag -Wirtschaftsinformatik -3 -http://dx.doi.org/10.1007/BF03250842 -software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development - - diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.bib deleted file mode 100644 index 24637a1f39e8..000000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.bib +++ /dev/null @@ -1,41 +0,0 @@ -% Encoding: UTF-8 - -@Article{, - author = {Hanns-Jörg Stoß}, - month = {jul}, - note = {a Note}, - abstract = {Es werdenTuring-Maschinen mitk unabhängigen Lese-Schreib-Köpfen auf einem Band undTuring-Maschinen mit je einem Kopf aufk Bändern betrachtet. Es wird gezeigt, daß sich ohne Verändern der Rechenzeit jede Maschine von einem Typ durch eine Maschine vom andern Typ simulieren läßt. Daraus wird gefolgert, daß es für die Rechengeschwindigkeit vonTuring-Maschinen nur auf die Zahl der Köpfe, nicht aber auf deren Verteilung auf einzelne Bänder ankommt.}, - address = {Stuttgart, Bawü Deutschland}, - affiliation = {aff}, - booktitle = {Turingmaschinen}, - chapter = {3}, - contents = {con}, - copyright = {cop}, - crossref = {cross}, - edition = {10}, - language = {english}, - howpublished = {how}, - institution = {Institution}, - shorttitle = {Turing}, - msbib-abbreviatedcasenumber = {abb}, - msbib-accessed = {July 3, 2010}, - msbib-broadcaster = {broad}, - msbib-casenumber = {case}, - msbib-court = {court}, - msbib-distributor = {dist}, - msbib-medium = {med}, - msbib-numberofvolume = {10}, - msbib-productioncompany = {produktion}, - msbib-recordingnumber = {record}, - msbib-reporter = {rep}, - msbib-station = {stat}, - msbib-theater = {th}, - msbib-type = {type}, - msbib-periodical = {Besondere Turingmaschinen}, - organization = {Besondere Turingmaschinen}, - price = {10}, - school = {Gymnasium Unterrieden}, - series = {ser}, - size = {1000} -} - diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.xml deleted file mode 100644 index 8a475457cfd2..000000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - -JournalArticle -a Note - - - - -Stoß -Hanns-Jörg - - - - -10 - ISSN: 0010-485X DOI: 10.1007/BF02238815 -10 -Turing -July -Stuttgart -Bawü -Deutschland -0 -July -3 -2010 -Turingmaschinen -3 -Besondere Turingmaschinen -Besondere Turingmaschinen -Gymnasium Unterrieden -Institution -produktion -med -record -th -dist -broad -stat -type -pat -court -rep -case -abb -ser -cross -how -aff -con -cop -10 -1000 -Es werdenTuring-Maschinen mitk unabhängigen Lese-Schreib-Köpfen auf einem Band undTuring-Maschinen mit je einem Kopf aufk Bändern betrachtet. Es wird gezeigt, daß sich ohne Verändern der Rechenzeit jede Maschine von einem Typ durch eine Maschine vom andern Typ simulieren läßt. Daraus wird gefolgert, daß es für die Rechengeschwindigkeit vonTuring-Maschinen nur auf die Zahl der Köpfe, nicht aber auf deren Verteilung auf einzelne Bänder ankommt. - - diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.bib new file mode 100644 index 000000000000..901935f81eef --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.bib @@ -0,0 +1,3 @@ +@inproceedings{raey, + Title = {Agile Entwicklung Web-basierter Systeme}, +} \ No newline at end of file diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.xml new file mode 100644 index 000000000000..dbece53202a1 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.xml @@ -0,0 +1,10 @@ + + + +inproceedings +ConferenceProceedings +Agile Entwicklung Web-basierter Systeme +raey + + +