Skip to content

Commit

Permalink
Resolves #973 Add DOI field for English version of MS Office 2007 XML (
Browse files Browse the repository at this point in the history
…#1410)

* Resolves #973 Add DOI field for English version of MS Office 2007 XML

* Changelog

* Fix tests
  • Loading branch information
stefan-kolb authored and matthiasgeiger committed May 19, 2016
1 parent c695dfe commit ed638e2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- Fixed sourceforge bug 1000: shorttitleINI can generate the initials of the shorttitle
- Fixed [#1394](https://github.com/JabRef/jabref/issues/1394): Personal journal abbrevations could not be saved
- Fixed [#1400](https://github.com/JabRef/jabref/issues/1400): Detect path constructs wrong path for Windows
- Fixed [#973](https://github.com/JabRef/jabref/issues/973): Add additional DOI field for English version of MS Office 2007 XML

### Removed
- Removed possibility to export entries/databases to an `.sql` file, as the logic cannot easily use the correct escape logic
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/net/sf/jabref/exporter/MSBibExportFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,24 @@ public void performExport(final BibDatabaseContext databaseContext, final String
Objects.requireNonNull(databaseContext);
Objects.requireNonNull(entries);

if (entries.isEmpty()) { // Only export if entries exist
if (entries.isEmpty()) {
return;
}
// forcing to use UTF8 output format for some problems with
// xml export in other encodings
SaveSession ss = new SaveSession(StandardCharsets.UTF_8, false);
MSBibDatabase md = new MSBibDatabase(databaseContext.getDatabase(), entries);
try (VerifyingWriter ps = ss.getWriter()) {

// PS: DOES NOT SUPPORT EXPORTING ONLY A SET OF ENTRIES
// forcing to use UTF8 output format for some problems with xml export in other encodings
SaveSession session = new SaveSession(StandardCharsets.UTF_8, false);
MSBibDatabase msBibDatabase = new MSBibDatabase(databaseContext.getDatabase(), entries);

try (VerifyingWriter ps = session.getWriter()) {
try {
DOMSource source = new DOMSource(md.getDOMrepresentation());
DOMSource source = new DOMSource(msBibDatabase.getDOMrepresentation());
StreamResult result = new StreamResult(ps);
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.transform(source, result);
} catch (TransformerException | IllegalArgumentException | TransformerFactoryConfigurationError e) {
throw new Error(e);
}
finalizeSaveSession(ss, new File(file));
finalizeSaveSession(session, new File(file));
} catch (SaveException | IOException ex) {
throw new IOException(ex.getMessage());
}
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MSBibEntry {
private String thesisType;
private String internetSiteTitle;
private String dateAccessed;
private String doi;
private String url;
private String productionCompany;
private String publicationTitle;
Expand Down Expand Up @@ -267,6 +268,7 @@ private void populateFromXml(Element entry, String bcol) {
dateAccessed = null;
}

doi = getFromXml(bcol + "DOI", entry);
url = getFromXml(bcol + "URL", entry);
productionCompany = getFromXml(bcol + "ProductionCompany", entry);

Expand Down Expand Up @@ -434,8 +436,11 @@ private void populateFromBibtex(BibEntry bibtex) {
if (bibtex.hasField(MSBIB + "accessed")) {
dateAccessed = bibtex.getField(MSBIB + "accessed");
}
if (bibtex.hasField("doi")) {
doi = bibtex.getField("doi");
}
if (bibtex.hasField("url")) {
url = bibtex.getField("url"); /* SM: 2010.10: lower case */
url = bibtex.getField("url");
}
if (bibtex.hasField(MSBIB + "productioncompany")) {
productionCompany = bibtex.getField(MSBIB + "productioncompany");
Expand Down Expand Up @@ -539,14 +544,12 @@ private void populateFromBibtex(BibEntry bibtex) {
// http://www.microsoft.com/globaldev/reference/lcid-all.mspx
private int getLCID(String language) {
// TODO: add language to LCID mapping

return 0;
}

// http://www.microsoft.com/globaldev/reference/lcid-all.mspx
private String getLanguage(int LCID) {
// TODO: add language to LCID mapping

return "english";
}

Expand Down Expand Up @@ -797,6 +800,7 @@ public Element getDOMrepresentation(Document document) {
/* SM 2010.10 added month export */
addField(document, msbibEntry, "Month", month);

addField(document, msbibEntry, "DOI", doi);
addField(document, msbibEntry, "URL", url);
addField(document, msbibEntry, "ProductionCompany", productionCompany);
addField(document, msbibEntry, "PublicationTitle", publicationTitle);
Expand Down Expand Up @@ -1007,6 +1011,9 @@ public BibEntry getBibtexRepresentation() {
if (dateAccessed != null) {
hm.put(MSBIB + "accessed", dateAccessed);
}
if (doi != null) {
hm.put("doi", doi);
}
if (url != null) {
hm.put("url", url);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@phdthesis{2002,
title = {Agile Entwicklung Web-basierter Systeme},
year = {2002},
type = {type},
type = {type},
number = {3},
address = {a},
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},
doi = {10.1007/BF03250842},
url = {http://dx.doi.org/10.1007/BF03250842},
volume = {44},
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
<b:Author/>
<b:Pages>237-248</b:Pages>
<b:Volume>44</b:Volume>
<b:StandardNumber> DOI: 10.1007/BF03250842</b:StandardNumber>
<b:Publisher>Gabler Verlag</b:Publisher>
<b:City>a</b:City>
<b:JournalName>Wirtschaftsinformatik</b:JournalName>
<b:Issue>3</b:Issue>
<b:ThesisType>type</b:ThesisType>
<b:DOI>10.1007/BF03250842</b:DOI>
<b:URL>http://dx.doi.org/10.1007/BF03250842</b:URL>
<b:BIBTEX_KeyWords>software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development</b:BIBTEX_KeyWords>
</b:Source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<b:Publisher>Gabler Verlag</b:Publisher>
<b:JournalName>Wirtschaftsinformatik</b:JournalName>
<b:Issue>3</b:Issue>
<b:DOI>10.1000/182</b:DOI>
<b:URL>http://dx.doi.org/10.1007/BF03250842</b:URL>
<b:BIBTEX_KeyWords>software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development</b:BIBTEX_KeyWords>
</b:Source>
Expand Down
16 changes: 16 additions & 0 deletions src/test/resources/net/sf/jabref/exporter/test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</b:Author>
</b:Author>
<b:Pages>3075-3080</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1358628.1358810</b:DOI>
<b:StandardNumber> ISBN: 978-1-60558-012-X DOI: http://doi.acm.org/10.1145/1358628.1358810</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand All @@ -40,6 +41,7 @@
</b:Author>
<b:Pages>13-14</b:Pages>
<b:Volume>34</b:Volume>
<b:DOI>http://doi.acm.org/10.1145/820127.820136</b:DOI>
<b:StandardNumber> ISSN: 0097-8418 DOI: http://doi.acm.org/10.1145/820127.820136</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -72,6 +74,7 @@
</b:Author>
<b:Pages>10-12</b:Pages>
<b:Volume>12</b:Volume>
<b:DOI>http://dx.doi.org/10.1109/MIC.2008.67</b:DOI>
<b:StandardNumber> ISSN: 1089-7801 DOI: http://dx.doi.org/10.1109/MIC.2008.67</b:StandardNumber>
<b:Publisher>IEEE Educational Activities Department</b:Publisher>
<b:City>Piscataway</b:City>
Expand Down Expand Up @@ -126,6 +129,7 @@
</b:Author>
<b:Pages>25-31</b:Pages>
<b:Volume>2</b:Volume>
<b:DOI>http://dx.doi.org/10.1109/MSP.2004.81</b:DOI>
<b:StandardNumber> ISSN: 1540-7993 DOI: http://dx.doi.org/10.1109/MSP.2004.81</b:StandardNumber>
<b:Publisher>IEEE Educational Activities Department</b:Publisher>
<b:City>Piscataway</b:City>
Expand All @@ -151,6 +155,7 @@
</b:Author>
<b:Pages>357-367</b:Pages>
<b:Volume>9</b:Volume>
<b:DOI>http://dx.doi.org/10.1007/s00779-005-0347-6</b:DOI>
<b:StandardNumber> ISSN: 1617-4909 DOI: http://dx.doi.org/10.1007/s00779-005-0347-6</b:StandardNumber>
<b:Publisher>Springer-Verlag</b:Publisher>
<b:City>London</b:City>
Expand Down Expand Up @@ -192,6 +197,7 @@
</b:Author>
</b:Author>
<b:Pages>11-18</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1137627.1137631</b:DOI>
<b:StandardNumber> ISBN: 1-59593-411-1 DOI: http://doi.acm.org/10.1145/1137627.1137631</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -219,6 +225,7 @@
</b:Author>
</b:Author>
<b:Pages>529-530</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1233341.1233448</b:DOI>
<b:StandardNumber> ISBN: 978-1-59593-629-5 DOI: http://doi.acm.org/10.1145/1233341.1233448</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -257,6 +264,7 @@
</b:Author>
<b:Pages>25-31</b:Pages>
<b:Volume>2</b:Volume>
<b:DOI>http://dx.doi.org/10.1109/MSP.2004.81</b:DOI>
<b:StandardNumber> ISSN: 1540-7993 DOI: http://dx.doi.org/10.1109/MSP.2004.81</b:StandardNumber>
<b:Publisher>IEEE Educational Activities Department</b:Publisher>
<b:City>Piscataway</b:City>
Expand Down Expand Up @@ -286,6 +294,7 @@
</b:Author>
</b:Author>
<b:Pages>199-203</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1132736.1132768</b:DOI>
<b:StandardNumber> ISBN: 1-59593-350-6 DOI: http://doi.acm.org/10.1145/1132736.1132768</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -350,6 +359,7 @@
</b:Author>
</b:Author>
<b:Pages>429-432</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1182475.1182529</b:DOI>
<b:StandardNumber> ISBN: 1-59593-325-5 DOI: http://doi.acm.org/10.1145/1182475.1182529</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -378,6 +388,7 @@
</b:Author>
</b:Author>
<b:Pages>51-58</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1137627.1137636</b:DOI>
<b:StandardNumber> ISBN: 1-59593-411-1 DOI: http://doi.acm.org/10.1145/1137627.1137636</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -406,6 +417,7 @@
</b:Author>
</b:Author>
<b:Pages>90-94</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1314276.1314293</b:DOI>
<b:StandardNumber> ISBN: 978-1-59593-884-8 DOI: http://doi.acm.org/10.1145/1314276.1314293</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -438,6 +450,7 @@
</b:Author>
</b:Author>
<b:Pages>1-2</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1137627.1137628</b:DOI>
<b:StandardNumber> ISBN: 1-59593-411-1 DOI: http://doi.acm.org/10.1145/1137627.1137628</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -494,6 +507,7 @@
</b:Author>
</b:Author>
<b:Pages>25-34</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1073001.1073004</b:DOI>
<b:StandardNumber> ISBN: 1-59593-178-3 DOI: http://doi.acm.org/10.1145/1073001.1073004</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -526,6 +540,7 @@
</b:Author>
</b:Author>
<b:Pages>27-34</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1137627.1137633</b:DOI>
<b:StandardNumber> ISBN: 1-59593-411-1 DOI: http://doi.acm.org/10.1145/1137627.1137633</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down Expand Up @@ -576,6 +591,7 @@
</b:Author>
</b:Author>
<b:Pages>1-7</b:Pages>
<b:DOI>http://doi.acm.org/10.1145/1143120.1143122</b:DOI>
<b:StandardNumber> ISBN: 1-59593-448-0 DOI: http://doi.acm.org/10.1145/1143120.1143122</b:StandardNumber>
<b:Publisher>ACM</b:Publisher>
<b:City>New York, NY, USA</b:City>
Expand Down

0 comments on commit ed638e2

Please sign in to comment.