diff --git a/CHANGELOG.md b/CHANGELOG.md index 640bc9c0c8b..a019f54f3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,6 +85,9 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed [#1531](https://github.com/JabRef/jabref/issues/1531): `\relax` can be used for abbreviation of author names - Fixed [#1771](https://github.com/JabRef/jabref/issues/1771): Show all supported import types as default - Fixed [#1804](https://github.com/JabRef/jabref/issues/1804): Integrity check no longer removes URL field by mistake +- Fixed [#1750](https://github.com/JabRef/jabref/issues/1750): BibLaTeX `date` field is now correctly exported as `year` in MS-Office 2007 xml format +- Fixed: LaTeX characters in author names are now converted to Unicode before export in MS-Office 2007 xml format +- Fixed: `volume`, `journaltitle`, `issue` and `number`(for patents) fields are now exported correctly in MS-Office 2007 xml format - Fixed [#1687](https://github.com/JabRef/jabref/issues/1687): "month" field ascending/descending sorting swapped diff --git a/src/main/java/net/sf/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/net/sf/jabref/logic/importer/fileformat/BibtexParser.java index 77d5b3e2269..45775c7ea0f 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/net/sf/jabref/logic/importer/fileformat/BibtexParser.java @@ -51,6 +51,7 @@ * Can be used stand-alone. */ public class BibtexParser { + private static final Log LOGGER = LogFactory.getLog(BibtexParser.class); private final PushbackReader pushbackReader; @@ -64,6 +65,7 @@ public class BibtexParser { private final Deque pureTextFromFile = new LinkedList<>(); private final ImportFormatPreferences importFormatPreferences; + public BibtexParser(Reader in, ImportFormatPreferences importFormatPreferences) { Objects.requireNonNull(in); this.importFormatPreferences = Objects.requireNonNull(importFormatPreferences); @@ -77,21 +79,18 @@ public BibtexParser(Reader in, ImportFormatPreferences importFormatPreferences) * @param in the Reader to read from * @throws IOException */ - public static ParserResult parse(Reader in, ImportFormatPreferences importFormatPreferences) - throws IOException { + public static ParserResult parse(Reader in, ImportFormatPreferences importFormatPreferences) throws IOException { BibtexParser parser = new BibtexParser(in, importFormatPreferences); return parser.parse(); } - /** * Parses BibtexEntries from the given string and returns the collection of all entries found. * * @param bibtexString * @return Returns returns an empty collection if no entries where found or if an error occurred. */ - public static List fromString(String bibtexString, - ImportFormatPreferences importFormatPreferences) { + public static List fromString(String bibtexString, ImportFormatPreferences importFormatPreferences) { StringReader reader = new StringReader(bibtexString); BibtexParser parser = new BibtexParser(reader, importFormatPreferences); @@ -103,7 +102,6 @@ public static List fromString(String bibtexString, } } - /** * Parses BibtexEntries from the given string and returns one entry found (or null if none found) *

@@ -149,7 +147,6 @@ public ParserResult parse() throws IOException { } } - private void initializeParserResult() { database = new BibDatabase(); entryTypes = new HashMap<>(); // To store custom entry types parsed. @@ -218,9 +215,10 @@ private void parseAndAddEntry(String type) { BibEntry entry = parseEntry(type); // store comments collected without type definition - entry.setCommentsBeforeEntry(commentsAndEntryTypeDefinition.substring(0,commentsAndEntryTypeDefinition.lastIndexOf('@'))); + entry.setCommentsBeforeEntry( + commentsAndEntryTypeDefinition.substring(0, commentsAndEntryTypeDefinition.lastIndexOf('@'))); // store complete parsed serialization (comments, type definition + type contents) - entry.setParsedSerialization(commentsAndEntryTypeDefinition+dumpTextReadSoFarToString()); + entry.setParsedSerialization(commentsAndEntryTypeDefinition + dumpTextReadSoFarToString()); boolean duplicateKey = database.insertEntry(entry); if (duplicateKey) { @@ -231,8 +229,8 @@ private void parseAndAddEntry(String type) { } } catch (IOException ex) { LOGGER.warn("Could not parse entry", ex); - parserResult.addWarning(Localization.lang("Error occurred when parsing entry") + ": '" - + ex.getMessage() + "'. " + Localization.lang("Skipped entry.")); + parserResult.addWarning(Localization.lang("Error occurred when parsing entry") + ": '" + ex.getMessage() + + "'. " + Localization.lang("Skipped entry.")); } } @@ -251,16 +249,11 @@ private void parseJabRefComment(Map meta) { } String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", ""); - if (comment.substring(0, - Math.min(comment.length(), MetaData.META_FLAG.length())).equals( - MetaData.META_FLAG)) { - + if (comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())).equals(MetaData.META_FLAG)) { - if (comment.substring(0, MetaData.META_FLAG.length()).equals( - MetaData.META_FLAG)) { + if (comment.substring(0, MetaData.META_FLAG.length()).equals(MetaData.META_FLAG)) { String rest = comment.substring(MetaData.META_FLAG.length()); - int pos = rest.indexOf(':'); if (pos > 0) { @@ -282,8 +275,7 @@ private void parseJabRefComment(Map meta) { if (typ.isPresent()) { entryTypes.put(typ.get().getName(), typ.get()); } else { - parserResult.addWarning(Localization.lang("Ill-formed entrytype comment in BIB file") + ": " + - comment); + parserResult.addWarning(Localization.lang("Ill-formed entrytype comment in BIB file") + ": " + comment); } // custom entry types are always re-written by JabRef and not stored in the file @@ -292,7 +284,6 @@ private void parseJabRefComment(Map meta) { } - private void parseBibtexString() throws IOException { BibtexString bibtexString = parseString(); bibtexString.setParsedSerialization(dumpTextReadSoFarToString()); @@ -303,7 +294,6 @@ private void parseBibtexString() throws IOException { } } - /** * Puts all text that has been read from the reader, including newlines, etc., since the last call of this method into a string. * Removes the JabRef file header, if it is found @@ -592,8 +582,7 @@ private String parseFieldContent(String key) throws IOException { String textToken = parseTextToken(); if (textToken.isEmpty()) { throw new IOException("Error in line " + line + " or above: " - + "Empty text token.\nThis could be caused " - + "by a missing comma between two fields."); + + "Empty text token.\nThis could be caused " + "by a missing comma between two fields."); } value.append('#').append(textToken).append('#'); } @@ -652,59 +641,59 @@ private String fixKey() throws IOException { // Restore if possible: switch (currentChar) { - case '=': - // Get entryfieldname, push it back and take rest as key - key = key.reverse(); + case '=': + // Get entryfieldname, push it back and take rest as key + key = key.reverse(); - boolean matchedAlpha = false; - for (int i = 0; i < key.length(); i++) { - currentChar = key.charAt(i); + boolean matchedAlpha = false; + for (int i = 0; i < key.length(); i++) { + currentChar = key.charAt(i); - /// Skip spaces: - if (!matchedAlpha && (currentChar == ' ')) { - continue; - } - matchedAlpha = true; + /// Skip spaces: + if (!matchedAlpha && (currentChar == ' ')) { + continue; + } + matchedAlpha = true; - // Begin of entryfieldname (e.g. author) -> push back: - unread(currentChar); - if ((currentChar == ' ') || (currentChar == '\n')) { + // Begin of entryfieldname (e.g. author) -> push back: + unread(currentChar); + if ((currentChar == ' ') || (currentChar == '\n')) { /* * found whitespaces, entryfieldname completed -> key in * keybuffer, skip whitespaces */ - StringBuilder newKey = new StringBuilder(); - for (int j = i; j < key.length(); j++) { - currentChar = key.charAt(j); - if (!Character.isWhitespace(currentChar)) { - newKey.append(currentChar); - } + StringBuilder newKey = new StringBuilder(); + for (int j = i; j < key.length(); j++) { + currentChar = key.charAt(j); + if (!Character.isWhitespace(currentChar)) { + newKey.append(currentChar); } - - // Finished, now reverse newKey and remove whitespaces: - parserResult.addWarning(Localization.lang("Line %0: Found corrupted BibTeX key.", - String.valueOf(line))); - key = newKey.reverse(); } + + // Finished, now reverse newKey and remove whitespaces: + parserResult.addWarning( + Localization.lang("Line %0: Found corrupted BibTeX key.", String.valueOf(line))); + key = newKey.reverse(); } - break; + } + break; - case ',': - parserResult.addWarning(Localization.lang("Line %0: Found corrupted BibTeX key (contains whitespaces).", - String.valueOf(line))); - break; + case ',': + parserResult.addWarning(Localization.lang("Line %0: Found corrupted BibTeX key (contains whitespaces).", + String.valueOf(line))); + break; - case '\n': - parserResult.addWarning(Localization.lang("Line %0: Found corrupted BibTeX key (comma missing).", - String.valueOf(line))); - break; + case '\n': + parserResult.addWarning( + Localization.lang("Line %0: Found corrupted BibTeX key (comma missing).", String.valueOf(line))); + break; - default: + default: - // No more lookahead, give up: - unreadBuffer(key); - return ""; + // No more lookahead, give up: + unreadBuffer(key); + return ""; } return removeWhitespaces(key).toString(); @@ -775,8 +764,8 @@ private String parseKey() throws IOException { // the entry lacked a comma signifying the end of the key. return token.toString(); } else { - throw new IOException("Error in line " + line + ":" + "Character '" + (char) character - + "' is not " + "allowed in bibtex keys."); + throw new IOException("Error in line " + line + ":" + "Character '" + (char) character + "' is not " + + "allowed in bibtex keys."); } } @@ -900,8 +889,8 @@ private void consume(char expected) throws IOException { int character = read(); if (character != expected) { - throw new IOException("Error in line " + line + ": Expected " + expected - + " but received " + (char) character); + throw new IOException( + "Error in line " + line + ": Expected " + expected + " but received " + (char) character); } } @@ -925,8 +914,8 @@ private void consume(char firstOption, char secondOption) throws IOException { int character = read(); if ((character != firstOption) && (character != secondOption)) { - throw new IOException("Error in line " + line + ": Expected " + firstOption + " or " - + secondOption + " but received " + (char) character); + throw new IOException("Error in line " + line + ": Expected " + firstOption + " or " + secondOption + + " but received " + (char) character); } } } diff --git a/src/main/java/net/sf/jabref/logic/importer/fileformat/MsBibImporter.java b/src/main/java/net/sf/jabref/logic/importer/fileformat/MsBibImporter.java index 90cd3b165cf..77fad942d97 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fileformat/MsBibImporter.java +++ b/src/main/java/net/sf/jabref/logic/importer/fileformat/MsBibImporter.java @@ -33,9 +33,7 @@ public boolean isRecognizedFormat(BufferedReader reader) throws IOException { */ Document docin; try { - DocumentBuilder dbuild = DocumentBuilderFactory. - newInstance(). - newDocumentBuilder(); + DocumentBuilder dbuild = DocumentBuilderFactory.newInstance().newDocumentBuilder(); docin = dbuild.parse(new InputSource(reader)); } catch (Exception e) { return false; diff --git a/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java b/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java index f393f470fbf..824143364ff 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java +++ b/src/main/java/net/sf/jabref/logic/msbib/BibTeXConverter.java @@ -11,20 +11,26 @@ import net.sf.jabref.logic.mods.PersonName; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.FieldName; +import net.sf.jabref.model.entry.MonthUtil; +import net.sf.jabref.model.entry.MonthUtil.Month; public class BibTeXConverter { + private static final String MSBIB_PREFIX = "msbib-"; + public static BibEntry convert(MSBibEntry entry) { BibEntry result; Map fieldValues = new HashMap<>(); + String bibTexEntryType = MSBibMapping.getBibLaTeXEntryType(entry.getType()); if (entry.getCiteKey() == null) { - result = new BibEntry(ImportFormat.DEFAULT_BIBTEXENTRY_ID, MSBibMapping.getBibTeXEntryType(entry.getType())); + result = new BibEntry(ImportFormat.DEFAULT_BIBTEXENTRY_ID, bibTexEntryType); + } else { // TODO: the cite key should not be the ID?! // id assumes an existing database so don't - result = new BibEntry(entry.getCiteKey(), MSBibMapping.getBibTeXEntryType(entry.getType())); + result = new BibEntry(entry.getCiteKey(), bibTexEntryType); } // add String fields @@ -77,6 +83,17 @@ public static BibEntry convert(MSBibEntry entry) { fieldValues.put(MSBIB_PREFIX + "accessed", entry.dateAccessed); } + if (entry.journalName != null) { + fieldValues.put(FieldName.JOURNALTITLE, entry.journalName); + } + if (entry.month != null) { + Month month = MonthUtil.getMonth(entry.month); + fieldValues.put(FieldName.MONTH, month.shortName); + } + if (entry.number != null) { + fieldValues.put(FieldName.NUMBER, entry.number); + } + // set all fields result.setField(fieldValues); @@ -92,7 +109,8 @@ private static void addAuthor(Map map, String type, List map) { + private static void parseSingleStandardNumber(String type, String bibtype, String standardNum, + Map map) { Pattern pattern = Pattern.compile(':' + type + ":(.[^:]+)"); Matcher matcher = pattern.matcher(standardNum); if (matcher.matches()) { 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 f7e9d808944..e70242a2369 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibConverter.java @@ -2,18 +2,20 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import net.sf.jabref.logic.layout.format.LatexToUnicodeFormatter; -import net.sf.jabref.logic.layout.format.RemoveBrackets; import net.sf.jabref.logic.mods.PageNumbers; import net.sf.jabref.logic.mods.PersonName; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.model.entry.FieldName; public class MSBibConverter { + private static final String MSBIB_PREFIX = "msbib-"; private static final String BIBTEX_PREFIX = "BIBTEX_"; + public static MSBibEntry convert(BibEntry entry) { MSBibEntry result = new MSBibEntry(); @@ -24,7 +26,7 @@ public static MSBibEntry convert(BibEntry entry) { for (String field : entry.getFieldNames()) { // clean field - String unicodeField = removeLaTeX(entry.getField(field)); + String unicodeField = removeLaTeX(entry.getFieldOptional(field).orElse("")); if (MSBibMapping.getMSBibField(field) != null) { result.fields.put(MSBibMapping.getMSBibField(field), unicodeField); @@ -32,59 +34,54 @@ public static MSBibEntry convert(BibEntry entry) { } // Duplicate: also added as BookTitle - if (entry.hasField(FieldName.BOOKTITLE)) { - result.conferenceName = entry.getField(FieldName.BOOKTITLE); - } - - if (entry.hasField(FieldName.PAGES)) { - result.pages = new PageNumbers(entry.getField(FieldName.PAGES)); - } - - if (entry.hasField(MSBIB_PREFIX + "accessed")) { - result.dateAccessed = entry.getField(MSBIB_PREFIX + "accessed"); - } + entry.getFieldOptional(FieldName.BOOKTITLE).ifPresent(booktitle -> result.conferenceName = booktitle); + entry.getFieldOptional(FieldName.PAGES).ifPresent(pages -> result.pages = new PageNumbers(pages)); + entry.getFieldOptional(MSBIB_PREFIX + "accessed").ifPresent(accesed -> result.dateAccessed = accesed); // TODO: currently this can never happen - if ("SoundRecording".equals(msbibType) && (entry.hasField(FieldName.TITLE))) { - result.albumTitle = entry.getField(FieldName.TITLE); + if ("SoundRecording".equals(msbibType)) { + result.albumTitle = entry.getFieldOptional(FieldName.TITLE).orElse(null); } // TODO: currently this can never happen - if ("Interview".equals(msbibType) && (entry.hasField(FieldName.TITLE))) { - result.broadcastTitle = entry.getField(FieldName.TITLE); + if ("Interview".equals(msbibType)) { + result.broadcastTitle = entry.getFieldOptional(FieldName.TITLE).orElse(null); } - // Value must be converted - if (entry.hasField(FieldName.LANGUAGE)) { - result.fields.put("LCID", String.valueOf(MSBibMapping.getLCID(entry.getField(FieldName.LANGUAGE)))); + if ("Patent".equalsIgnoreCase(entry.getType())) { + result.patentNumber = entry.getFieldOptional(FieldName.NUMBER).orElse(null); } - result.standardNumber = ""; - if (entry.hasField(FieldName.ISBN)) { - result.standardNumber += " ISBN: " + entry.getField(FieldName.ISBN); - } - if (entry.hasField(FieldName.ISSN)) { - result.standardNumber += " ISSN: " + entry.getField(FieldName.ISSN); - } - if (entry.hasField("lccn")) { - result.standardNumber += " LCCN: " + entry.getField("lccn"); - } - if (entry.hasField("mrnumber")) { - result.standardNumber += " MRN: " + entry.getField("mrnumber"); + 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.hasField(FieldName.DOI)) { - result.standardNumber += " DOI: " + entry.getField(FieldName.DOI); + + 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)))); + StringBuilder sbNumber = new StringBuilder(); + entry.getFieldOptional(FieldName.ISBN).ifPresent(isbn -> sbNumber.append(" ISBN: " + isbn)); + entry.getFieldOptional(FieldName.ISSN).ifPresent(issn -> sbNumber.append(" ISSN: " + issn)); + entry.getFieldOptional("lccn").ifPresent(lccn -> sbNumber.append("LCCN: " + lccn)); + entry.getFieldOptional("mrnumber").ifPresent(mrnumber -> sbNumber.append(" MRN: " + mrnumber)); + + result.standardNumber = sbNumber.toString(); if (result.standardNumber.isEmpty()) { result.standardNumber = null; } - if (entry.hasField(FieldName.ADDRESS)) { - result.address = entry.getField(FieldName.ADDRESS); - } + result.address = entry.getFieldOrAlias(FieldName.ADDRESS).orElse(null); + + if (entry.getFieldOptional(FieldName.TYPE).isPresent()) { + result.thesisType = entry.getFieldOptional(FieldName.TYPE).get(); - if (entry.hasField(FieldName.TYPE)) { - result.thesisType = entry.getField(FieldName.TYPE); } else { if ("techreport".equalsIgnoreCase(entry.getType())) { result.thesisType = "Tech. rep."; @@ -98,23 +95,17 @@ public static MSBibEntry convert(BibEntry entry) { } // TODO: currently this can never happen - if (("InternetSite".equals(msbibType) || "DocumentFromInternetSite".equals(msbibType)) - && (entry.hasField(FieldName.TITLE))) { - result.internetSiteTitle = entry.getField(FieldName.TITLE); + if (("InternetSite".equals(msbibType) || "DocumentFromInternetSite".equals(msbibType))) { + result.internetSiteTitle = entry.getFieldOptional(FieldName.TITLE).orElse(null); } // TODO: currently only Misc can happen - if (("ElectronicSource".equals(msbibType) || "Art".equals(msbibType) || "Misc".equals(msbibType)) - && (entry.hasField(FieldName.TITLE))) { - result.publicationTitle = entry.getField(FieldName.TITLE); + if ("ElectronicSource".equals(msbibType) || "Art".equals(msbibType) || "Misc".equals(msbibType)) { + result.publicationTitle = entry.getFieldOptional(FieldName.TITLE).orElse(null); } - if (entry.hasField(FieldName.AUTHOR)) { - result.authors = getAuthors(entry.getField(FieldName.AUTHOR)); - } - if (entry.hasField(FieldName.EDITOR)) { - result.editors = getAuthors(entry.getField(FieldName.EDITOR)); - } + entry.getFieldOptional(FieldName.AUTHOR).ifPresent(authors -> result.authors = getAuthors(authors)); + entry.getFieldOptional(FieldName.EDITOR).ifPresent(editors -> result.editors = getAuthors(editors)); return result; } @@ -122,9 +113,10 @@ public static MSBibEntry convert(BibEntry entry) { private static List getAuthors(String authors) { List result = new ArrayList<>(); - // TODO: case-insensitive?! - if (authors.contains(" and ")) { - String[] names = authors.split(" and "); + authors = removeLaTeX(authors); + + if (authors.toUpperCase(Locale.ENGLISH).contains(" AND ")) { + String[] names = authors.split(" (?i)and "); for (String name : names) { result.add(new PersonName(name)); } @@ -135,10 +127,6 @@ private static List getAuthors(String authors) { } private static String removeLaTeX(String text) { - // TODO: just use latex free version everywhere in the future - String result = new RemoveBrackets().format(text); - result = new LatexToUnicodeFormatter().format(result); - - return result; + return new LatexToUnicodeFormatter().format(text); } } diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibDatabase.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibDatabase.java index cc20cdd48b8..beb7a954f15 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibDatabase.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibDatabase.java @@ -30,6 +30,7 @@ * See http://www.ecma-international.org/publications/standards/Ecma-376.htm */ public class MSBibDatabase { + private static final Log LOGGER = LogFactory.getLog(MSBibDatabase.class); public static final String NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/bibliography"; @@ -37,6 +38,7 @@ public class MSBibDatabase { private Set entries; + public MSBibDatabase() { entries = new HashSet<>(); } @@ -99,19 +101,18 @@ public Document getDOM() { Element rootNode = document.createElementNS(NAMESPACE, PREFIX + "Sources"); rootNode.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", NAMESPACE); - rootNode.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + PREFIX.substring(0, PREFIX.length() - 1), NAMESPACE); + rootNode.setAttributeNS("http://www.w3.org/2000/xmlns/", + "xmlns:" + PREFIX.substring(0, PREFIX.length() - 1), NAMESPACE); rootNode.setAttribute("SelectedStyle", ""); for (MSBibEntry entry : entries) { Node node = entry.getDOM(document); rootNode.appendChild(node); } - document.appendChild(rootNode); } catch (ParserConfigurationException e) { LOGGER.warn("Could not build XML document", e); } - return document; } } diff --git a/src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java b/src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java index 3be38280b09..f42a5868a56 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java @@ -24,6 +24,7 @@ * @see ECMA Standard */ class MSBibEntry { + // MSBib fields and values public Map fields = new HashMap<>(); @@ -54,6 +55,14 @@ class MSBibEntry { public String publicationTitle; public String albumTitle; public String broadcastTitle; + public String year; + public String month; + public String day; + public String number; + public String patentNumber; + public String journalName; + + private String bibtexEntryType; // reduced subset, supports only "CITY , STATE, COUNTRY" // \b(\w+)\s?[,]?\s?(\w+)\s?[,]?\s?(\w+)\b @@ -65,7 +74,9 @@ class MSBibEntry { // (\d{1,2})\s?[.,-/]\s?(\d{1,2})\s?[.,-/]\s?(\d{2,4}) // 1-2 DIGITS SPACE SEPERATOR SPACE 1-2 DIGITS SPACE SEPERATOR SPACE 2-4 DIGITS // tested using http://www.javaregex.com/test.html - private static final Pattern DATE_PATTERN = Pattern.compile("(\\d{1,2})\\s*[.,-/]\\s*(\\d{1,2})\\s*[.,-/]\\s*(\\d{2,4})"); + private static final Pattern DATE_PATTERN = Pattern + .compile("(\\d{1,2})\\s*[.,-/]\\s*(\\d{1,2})\\s*[.,-/]\\s*(\\d{2,4})"); + public MSBibEntry() { @@ -99,6 +110,9 @@ private void populateFromXml(Element entry) { String key = node.getLocalName(); String value = node.getTextContent(); + if ("SourceType".equals(key)) { + this.bibtexEntryType = value; + } fields.put(key, value); } } @@ -129,21 +143,30 @@ private void populateFromXml(Element entry) { address = null; } + if ("Patent".equalsIgnoreCase(bibtexEntryType)) { + number = getXmlElementTextContent("PatentNumber", entry); + } + journalName = getXmlElementTextContent("JournalName", entry); + month = getXmlElementTextContent("Month", entry); internetSiteTitle = getXmlElementTextContent("InternetSiteTitle", entry); - String month = getXmlElementTextContent("MonthAccessed", entry); - String day = getXmlElementTextContent("DayAccessed", entry); - String year = getXmlElementTextContent("YearAccessed", entry); - dateAccessed = ""; - if (month != null) { - dateAccessed += month + ' '; + + String monthAccessed = getXmlElementTextContent("MonthAccessed", entry); + String dayAccessed = getXmlElementTextContent("DayAccessed", entry); + String yearAccessed = getXmlElementTextContent("YearAccessed", entry); + + StringBuilder sbDateAccesed = new StringBuilder(); + if (monthAccessed != null) { + sbDateAccesed.append(monthAccessed); + sbDateAccesed.append(' '); } - if (day != null) { - dateAccessed += day + ", "; + if (dayAccessed != null) { + sbDateAccesed.append(dayAccessed); + sbDateAccesed.append(", "); } - if (year != null) { - dateAccessed += year; + if (yearAccessed != null) { + sbDateAccesed.append(yearAccessed); } - dateAccessed = dateAccessed.trim(); + dateAccessed = sbDateAccesed.toString().trim(); if (dateAccessed.isEmpty() || ",".equals(dateAccessed)) { dateAccessed = null; } @@ -248,6 +271,12 @@ public Element getDOM(Document document) { if (pages != null) { addField(document, rootNode, "Pages", pages.toString("-")); } + addField(document, rootNode, "Year", year); + addField(document, rootNode, "Month", month); + + addField(document, rootNode, "JournalName", journalName); + addField(document, rootNode, "PatentNumber", patentNumber); + addField(document, rootNode, "StandardNumber", standardNumber); addField(document, rootNode, "ConferenceName", conferenceName); @@ -286,7 +315,6 @@ private void addAuthor(Document document, Element allAuthors, String entryName, nameList.appendChild(person); } authorTop.appendChild(nameList); - allAuthors.appendChild(authorTop); } 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 11f30da029e..1a62f3a2548 100644 --- a/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java +++ b/src/main/java/net/sf/jabref/logic/msbib/MSBibMapping.java @@ -4,82 +4,90 @@ import java.util.TreeMap; import net.sf.jabref.model.entry.BibEntry; +import net.sf.jabref.model.entry.BibLatexEntryTypes; import net.sf.jabref.model.entry.BibtexEntryTypes; import net.sf.jabref.model.entry.FieldName; import com.google.common.collect.HashBiMap; +/** + * Mapping between Msbib and BibLaTeX + * All Fields: List of all MSBib fields + * + */ public class MSBibMapping { + private static final String BIBTEX_PREFIX = "BIBTEX_"; private static final String MSBIB_PREFIX = "msbib-"; - private static final HashBiMap bibtexToMSBib = HashBiMap.create(); + private static final HashBiMap biblatexToMsBib = HashBiMap.create(); static { - bibtexToMSBib.put(BibEntry.KEY_FIELD, "Tag"); - bibtexToMSBib.put(FieldName.TITLE, "Title"); - bibtexToMSBib.put(FieldName.YEAR, "Year"); - bibtexToMSBib.put(FieldName.MONTH, "Month"); - bibtexToMSBib.put(FieldName.NOTE, "Comments"); - bibtexToMSBib.put(FieldName.VOLUME, "Volume"); - bibtexToMSBib.put(FieldName.LANGUAGE, "LCID"); - bibtexToMSBib.put(FieldName.EDITION, "Edition"); - bibtexToMSBib.put(FieldName.PUBLISHER, "Publisher"); - bibtexToMSBib.put(FieldName.BOOKTITLE, "BookTitle"); - //bibtexToMSBib.put(FieldName.BOOKTITLE, "ConferenceName"); - //bibtexToMSBib.put(FieldName.PAGES, "Pages"); - bibtexToMSBib.put(FieldName.CHAPTER, "ChapterNumber"); - bibtexToMSBib.put(FieldName.JOURNAL, "JournalName"); - bibtexToMSBib.put(FieldName.NUMBER, "Issue"); - bibtexToMSBib.put(FieldName.SCHOOL, "Department"); - bibtexToMSBib.put(FieldName.INSTITUTION, "Institution"); - bibtexToMSBib.put(FieldName.DOI, "DOI"); - bibtexToMSBib.put(FieldName.URL, "URL"); + biblatexToMsBib.put(BibEntry.KEY_FIELD, "Tag"); + biblatexToMsBib.put(FieldName.TITLE, "Title"); + biblatexToMsBib.put(FieldName.YEAR, "Year"); + biblatexToMsBib.put(FieldName.NOTE, "Comments"); + biblatexToMsBib.put(FieldName.VOLUME, "Volume"); + biblatexToMsBib.put(FieldName.LANGUAGE, "LCID"); + biblatexToMsBib.put(FieldName.EDITION, "Edition"); + biblatexToMsBib.put(FieldName.PUBLISHER, "Publisher"); + biblatexToMsBib.put(FieldName.BOOKTITLE, "BookTitle"); + //biblatexToMsBib.put(FieldName.BOOKTITLE, "ConferenceName"); + //biblatexToMsBib.put(FieldName.PAGES, "Pages"); + biblatexToMsBib.put(FieldName.CHAPTER, "ChapterNumber"); + + biblatexToMsBib.put(FieldName.ISSUE, "Issue"); + biblatexToMsBib.put(FieldName.SCHOOL, "Department"); + biblatexToMsBib.put(FieldName.INSTITUTION, "Institution"); + biblatexToMsBib.put(FieldName.DOI, "DOI"); + biblatexToMsBib.put(FieldName.URL, "URL"); // BibTeX/Biblatex only fields - bibtexToMSBib.put(FieldName.SERIES, BIBTEX_PREFIX + "Series"); - bibtexToMSBib.put(FieldName.ABSTRACT, BIBTEX_PREFIX + "Abstract"); - bibtexToMSBib.put(FieldName.KEYWORDS, BIBTEX_PREFIX + "KeyWords"); - bibtexToMSBib.put(FieldName.CROSSREF, BIBTEX_PREFIX + "CrossRef"); - bibtexToMSBib.put(FieldName.HOWPUBLISHED, BIBTEX_PREFIX + "HowPublished"); - bibtexToMSBib.put("affiliation", BIBTEX_PREFIX + "Affiliation"); - bibtexToMSBib.put("contents", BIBTEX_PREFIX + "Contents"); - bibtexToMSBib.put("copyright", BIBTEX_PREFIX + "Copyright"); - bibtexToMSBib.put("price", BIBTEX_PREFIX + "Price"); - bibtexToMSBib.put("size", BIBTEX_PREFIX + "Size"); - bibtexToMSBib.put("intype", BIBTEX_PREFIX + "InType"); - bibtexToMSBib.put("paper", BIBTEX_PREFIX + "Paper"); - bibtexToMSBib.put("shorttitle", "ShortTitle"); + biblatexToMsBib.put(FieldName.SERIES, BIBTEX_PREFIX + "Series"); + biblatexToMsBib.put(FieldName.ABSTRACT, BIBTEX_PREFIX + "Abstract"); + biblatexToMsBib.put(FieldName.KEYWORDS, BIBTEX_PREFIX + "KeyWords"); + biblatexToMsBib.put(FieldName.CROSSREF, BIBTEX_PREFIX + "CrossRef"); + biblatexToMsBib.put(FieldName.HOWPUBLISHED, BIBTEX_PREFIX + "HowPublished"); + biblatexToMsBib.put("affiliation", BIBTEX_PREFIX + "Affiliation"); + biblatexToMsBib.put("contents", BIBTEX_PREFIX + "Contents"); + biblatexToMsBib.put("copyright", BIBTEX_PREFIX + "Copyright"); + biblatexToMsBib.put("price", BIBTEX_PREFIX + "Price"); + biblatexToMsBib.put("size", BIBTEX_PREFIX + "Size"); + biblatexToMsBib.put("intype", BIBTEX_PREFIX + "InType"); + biblatexToMsBib.put("paper", BIBTEX_PREFIX + "Paper"); + biblatexToMsBib.put("shorttitle", "ShortTitle"); // MSBib only fields - 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 + "medium", "Medium"); - bibtexToMSBib.put(MSBIB_PREFIX + "recordingnumber", "RecordingNumber"); - bibtexToMSBib.put(MSBIB_PREFIX + "theater", "Theater"); - bibtexToMSBib.put(MSBIB_PREFIX + "distributor", "Distributor"); - bibtexToMSBib.put(MSBIB_PREFIX + "broadcaster", "Broadcaster"); - bibtexToMSBib.put(MSBIB_PREFIX + "station", "Station"); - bibtexToMSBib.put(MSBIB_PREFIX + FieldName.TYPE, "Type"); - bibtexToMSBib.put(MSBIB_PREFIX + "patentnumber", "PatentNumber"); - bibtexToMSBib.put(MSBIB_PREFIX + "court", "Court"); - bibtexToMSBib.put(MSBIB_PREFIX + "reporter", "Reporter"); - bibtexToMSBib.put(MSBIB_PREFIX + "casenumber", "CaseNumber"); - bibtexToMSBib.put(MSBIB_PREFIX + "abbreviatedcasenumber", "AbbreviatedCaseNumber"); - bibtexToMSBib.put(MSBIB_PREFIX + "productioncompany", "ProductionCompany"); + biblatexToMsBib.put(MSBIB_PREFIX + "numberofvolume", "NumberVolumes"); + biblatexToMsBib.put(MSBIB_PREFIX + "periodical", "PeriodicalTitle"); + biblatexToMsBib.put(MSBIB_PREFIX + "day", "Day"); + biblatexToMsBib.put(MSBIB_PREFIX + "accessed", "Accessed"); + biblatexToMsBib.put(MSBIB_PREFIX + "medium", "Medium"); + biblatexToMsBib.put(MSBIB_PREFIX + "recordingnumber", "RecordingNumber"); + biblatexToMsBib.put(MSBIB_PREFIX + "theater", "Theater"); + biblatexToMsBib.put(MSBIB_PREFIX + "distributor", "Distributor"); + biblatexToMsBib.put(MSBIB_PREFIX + "broadcaster", "Broadcaster"); + biblatexToMsBib.put(MSBIB_PREFIX + "station", "Station"); + biblatexToMsBib.put(MSBIB_PREFIX + FieldName.TYPE, "Type"); + biblatexToMsBib.put(MSBIB_PREFIX + "court", "Court"); + biblatexToMsBib.put(MSBIB_PREFIX + "reporter", "Reporter"); + biblatexToMsBib.put(MSBIB_PREFIX + "casenumber", "CaseNumber"); + biblatexToMsBib.put(MSBIB_PREFIX + "abbreviatedcasenumber", "AbbreviatedCaseNumber"); + biblatexToMsBib.put(MSBIB_PREFIX + "productioncompany", "ProductionCompany"); } - public static String getBibTeXEntryType(String msbibType) { + + public static String getBibLaTeXEntryType(String msbibType) { final String defaultType = BibtexEntryTypes.MISC.getName(); Map entryTypeMapping = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - entryTypeMapping.put("Book", BibtexEntryTypes.BOOK.getName()); - entryTypeMapping.put("BookSection", BibtexEntryTypes.INBOOK.getName()); - entryTypeMapping.put("JournalArticle", BibtexEntryTypes.ARTICLE.getName()); - entryTypeMapping.put("ArticleInAPeriodical", BibtexEntryTypes.ARTICLE.getName()); - entryTypeMapping.put("ConferenceProceedings", BibtexEntryTypes.CONFERENCE.getName()); - entryTypeMapping.put("Report", BibtexEntryTypes.TECHREPORT.getName()); + entryTypeMapping.put("Book", BibLatexEntryTypes.BOOK.getName()); + entryTypeMapping.put("BookSection", BibLatexEntryTypes.BOOK.getName()); + entryTypeMapping.put("JournalArticle", BibLatexEntryTypes.ARTICLE.getName()); + entryTypeMapping.put("ArticleInAPeriodical", BibLatexEntryTypes.PERIODICAL.getName()); + entryTypeMapping.put("ConferenceProceedings", BibLatexEntryTypes.INPROCEEDINGS.getName()); + entryTypeMapping.put("Report", BibLatexEntryTypes.TECHREPORT.getName()); + entryTypeMapping.put("Patent", BibLatexEntryTypes.PATENT.getName()); + entryTypeMapping.put("InternetSite", BibLatexEntryTypes.ONLINE.getName()); return entryTypeMapping.getOrDefault(msbibType, defaultType); } @@ -103,29 +111,40 @@ public static MSBibEntryType getMSBibEntryType(String bibtexType) { entryTypeMapping.put("unpublished", MSBibEntryType.Report); entryTypeMapping.put("patent", MSBibEntryType.Patent); entryTypeMapping.put("misc", MSBibEntryType.Misc); - entryTypeMapping.put("electronic", MSBibEntryType.Misc); + entryTypeMapping.put("electronic", MSBibEntryType.ElectronicSource); + entryTypeMapping.put("online", MSBibEntryType.InternetSite); return entryTypeMapping.getOrDefault(bibtexType, MSBibEntryType.Misc); } - // http://www.microsoft.com/globaldev/reference/lcid-all.mspx + /** + * Only English is supported
+ * All LCID codes + * @param language The language to transform + * @return Returns 0 for English + */ public static int getLCID(String language) { // TODO: add language to LCID mapping // 0 is English return 0; } - // http://www.microsoft.com/globaldev/reference/lcid-all.mspx + /** + * Only English is supported
+ * All LCID codes + * @param language + * @return Returns english + */ public static String getLanguage(int LCID) { // TODO: add language to LCID mapping return "english"; } public static String getMSBibField(String bibtexFieldName) { - return bibtexToMSBib.get(bibtexFieldName); + return biblatexToMsBib.get(bibtexFieldName); } public static String getBibTeXField(String msbibFieldName) { - return bibtexToMSBib.inverse().get(msbibFieldName); + return biblatexToMsBib.inverse().get(msbibFieldName); } } diff --git a/src/main/java/net/sf/jabref/model/entry/BibEntry.java b/src/main/java/net/sf/jabref/model/entry/BibEntry.java index c94fdeb084a..76e50464794 100644 --- a/src/main/java/net/sf/jabref/model/entry/BibEntry.java +++ b/src/main/java/net/sf/jabref/model/entry/BibEntry.java @@ -32,6 +32,7 @@ import org.apache.commons.logging.LogFactory; public class BibEntry implements Cloneable { + private static final Log LOGGER = LogFactory.getLog(BibEntry.class); public static final String TYPE_HEADER = "entrytype"; @@ -68,7 +69,6 @@ public class BibEntry implements Cloneable { */ private boolean changed; - private final EventBus eventBus = new EventBus(); @@ -207,9 +207,9 @@ public Set getFieldNames() { } /** - * Returns the contents of the given field, or null if it is not set. + * Use {@link #getFieldOptional} instead */ - @Deprecated //Use getFieldOptional instead + @Deprecated public String getField(String name) { return fields.get(toLowerCase(name)); } @@ -235,20 +235,19 @@ private String toLowerCase(String fieldName) { } /** - * Returns the contents of the given field, its alias or null if both are - * not set. + * Returns the contents of the given field or its alias as an Optional *

* The following aliases are considered (old bibtex <-> new biblatex) based - * on the BibLatex documentation, chapter 2.2.5: - * address <-> location - * annote <-> annotation - * archiveprefix <-> eprinttype - * journal <-> journaltitle - * key <-> sortkey - * pdf <-> file - * primaryclass <-> eprintclass - * school <-> institution - * These work bidirectional. + * on the BibLatex documentation, chapter 2.2.5:
+ * address <-> location
+ * annote <-> annotation
+ * archiveprefix <-> eprinttype
+ * journal <-> journaltitle
+ * key <-> sortkey
+ * pdf <-> file
eprintclass
+ * school <-> institution
+ * These work bidirectional.
*

* Special attention is paid to dates: (see the BibLatex documentation, * chapter 2.3.8) @@ -296,6 +295,7 @@ public Optional getFieldOrAlias(String name) { final SimpleDateFormat sdf1 = new SimpleDateFormat(FORMAT1); final SimpleDateFormat sdf2 = new SimpleDateFormat(FORMAT2); + @Override public StringBuffer format(Date dDate, StringBuffer toAppendTo, FieldPosition fieldPosition) { throw new UnsupportedOperationException(); @@ -526,8 +526,8 @@ public void setGroupHit(boolean groupHit) { * Author1, Author2: Title (Year) */ public String getAuthorTitleYear(int maxCharacters) { - String[] s = new String[] {getFieldOptional(FieldName.AUTHOR).orElse("N/A"), getFieldOptional(FieldName.TITLE).orElse("N/A"), - getFieldOptional(FieldName.YEAR).orElse("N/A")}; + String[] s = new String[] {getFieldOptional(FieldName.AUTHOR).orElse("N/A"), + getFieldOptional(FieldName.TITLE).orElse("N/A"), getFieldOptional(FieldName.YEAR).orElse("N/A")}; String text = s[0] + ": \"" + s[1] + "\" (" + s[2] + ')'; if ((maxCharacters <= 0) || (text.length() <= maxCharacters)) { @@ -558,7 +558,6 @@ public Optional getPublicationDate() { return year; } - public void setParsedSerialization(String parsedSerialization) { changed = false; this.parsedSerialization = parsedSerialization; diff --git a/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java b/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java index f612ea0f9bb..911b01ad133 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java +++ b/src/test/java/net/sf/jabref/logic/exporter/MSBibExportFormatTestFiles.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -14,13 +15,11 @@ import java.util.stream.Stream; import net.sf.jabref.BibDatabaseContext; -import net.sf.jabref.Globals; import net.sf.jabref.logic.importer.ImportFormatPreferences; import net.sf.jabref.logic.importer.fileformat.BibtexImporter; import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; -import com.google.common.base.Charsets; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -41,18 +40,17 @@ public class MSBibExportFormatTestFiles { public MSBibExportFormat msBibExportFormat; public BibtexImporter testImporter; - public static final String PATH_TO_FILE = "src/test/resources/net/sf/jabref/logic/exporter/"; - @Parameter public String filename; + public Path resourceDir; @Rule public TemporaryFolder testFolder = new TemporaryFolder(); @Parameters(name = "{0}") - public static Collection fileNames() throws IOException { - try (Stream stream = Files.list(Paths.get(PATH_TO_FILE))) { + public static Collection fileNames() throws IOException, URISyntaxException { + try (Stream stream = Files.list(Paths.get(MSBibExportFormatTestFiles.class.getResource("").toURI()))) { return stream.map(n -> n.getFileName().toString()).filter(n -> n.endsWith(".bib")) .filter(n -> n.startsWith("MsBib")).collect(Collectors.toList()); } @@ -60,25 +58,25 @@ public static Collection fileNames() throws IOException { @Before public void setUp() throws Exception { - Globals.prefs = JabRefPreferences.getInstance(); + resourceDir = Paths.get(MSBibExportFormatTestFiles.class.getResource("").toURI()); databaseContext = new BibDatabaseContext(); - charset = Charsets.UTF_8; + charset = StandardCharsets.UTF_8; msBibExportFormat = new MSBibExportFormat(); tempFile = testFolder.newFile(); - testImporter = new BibtexImporter(ImportFormatPreferences.fromPreferences(Globals.prefs)); + testImporter = new BibtexImporter(ImportFormatPreferences.fromPreferences(JabRefPreferences.getInstance())); } @Test - public final void testPerformExport() throws IOException, URISyntaxException, SaveException { + public final void testPerformExport() throws IOException, SaveException { String xmlFileName = filename.replace(".bib", ".xml"); - Path importFile = Paths.get(MSBibExportFormatTestFiles.class.getResource(filename).toURI()); + Path importFile = resourceDir.resolve(filename); String tempFilename = tempFile.getCanonicalPath(); - List entries = testImporter.importDatabase(importFile, Charset.defaultCharset()).getDatabase() + List entries = testImporter.importDatabase(importFile, StandardCharsets.UTF_8).getDatabase() .getEntries(); msBibExportFormat.performExport(databaseContext, tempFile.getPath(), charset, entries); - List expected = Files.readAllLines(Paths.get(PATH_TO_FILE + xmlFileName)); + List expected = Files.readAllLines(resourceDir.resolve(xmlFileName)); List exported = Files.readAllLines(Paths.get(tempFilename)); Collections.sort(expected); Collections.sort(exported); diff --git a/src/test/java/net/sf/jabref/logic/exporter/MsBibExportFormatTest.java b/src/test/java/net/sf/jabref/logic/exporter/MsBibExportFormatTest.java index ac30c5f1ce8..43da39fa58f 100644 --- a/src/test/java/net/sf/jabref/logic/exporter/MsBibExportFormatTest.java +++ b/src/test/java/net/sf/jabref/logic/exporter/MsBibExportFormatTest.java @@ -8,9 +8,7 @@ import java.util.List; import net.sf.jabref.BibDatabaseContext; -import net.sf.jabref.Globals; import net.sf.jabref.model.entry.BibEntry; -import net.sf.jabref.preferences.JabRefPreferences; import com.google.common.base.Charsets; import org.junit.Before; @@ -20,7 +18,6 @@ import static org.junit.Assert.assertEquals; - public class MsBibExportFormatTest { public BibDatabaseContext databaseContext; @@ -34,7 +31,6 @@ public class MsBibExportFormatTest { @Before public void setUp() throws Exception { - Globals.prefs = JabRefPreferences.getInstance(); databaseContext = new BibDatabaseContext(); charset = Charsets.UTF_8; msBibExportFormat = new MSBibExportFormat(); 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 6816bbf8911..1093b0ae741 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 @@ -45,7 +45,7 @@ public final void testIsNotRecognizedFormat() throws Exception { @Test public final void testImportEntriesEmpty() throws IOException, URISyntaxException { MsBibImporter testImporter = new MsBibImporter(); - Path file = Paths.get(MsBibImporter.class.getResource("MsBibImporterTest.xml").toURI()); + Path file = Paths.get(MsBibImporter.class.getResource("EmptyMsBib_Test.xml").toURI()); List entries = testImporter.importDatabase(file, Charset.defaultCharset()).getDatabase().getEntries(); assertEquals(Collections.emptyList(), entries); } 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 f937c5f7470..9a4c3d2e743 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 @@ -2,12 +2,14 @@ import java.io.IOException; import java.net.URISyntaxException; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import net.sf.jabref.logic.bibtex.BibEntryAssert; import net.sf.jabref.model.entry.BibEntry; @@ -25,35 +27,39 @@ public class MsBibImporterTestfiles { @Parameter public String fileName; + public Path resourceDir; - private Path xmlFile; @Before - public void setUp() throws URISyntaxException { - xmlFile = Paths.get(MsBibImporter.class.getResource(fileName + ".xml").toURI()); + public void setUp() throws Exception { + resourceDir = Paths.get(MsBibImporterTestfiles.class.getResource("").toURI()); } - @Parameters(name = "{index}: {0}") - public static Collection fileNames() { - Object[][] data = new Object[][] {{"MsBibImporterTest1"}, {"MsBibImporterTest2"}, {"MsBibImporterTest3"}, - {"MsBibImporterTest4"}, {"MsBibImporterTest5"}, {"MsBibImporterTest6"}, {"MsBibLCID"}}; - return Arrays.asList(data); + @Parameters(name = "{0}") + public static Collection fileNames() throws IOException, URISyntaxException { + try (Stream stream = Files.list(Paths.get(MsBibImporterTestfiles.class.getResource("").toURI()))) { + return stream.map(n -> n.getFileName().toString()).filter(n -> n.endsWith(".xml")) + .filter(n -> n.startsWith("MsBib")).collect(Collectors.toList()); + } } - @Test public final void testIsRecognizedFormat() throws Exception { MsBibImporter testImporter = new MsBibImporter(); - Assert.assertTrue(testImporter.isRecognizedFormat(xmlFile, Charset.defaultCharset())); - } + Path xmlFile = resourceDir.resolve(fileName); + Assert.assertTrue(testImporter.isRecognizedFormat(xmlFile, StandardCharsets.UTF_8)); + } @Test - public void testImportEntries() throws IOException { + public void testImportEntries() throws Exception { - String bibFileName = fileName + ".bib"; + String bibFileName = fileName.replace(".xml", ".bib"); MsBibImporter testImporter = new MsBibImporter(); - List result = testImporter.importDatabase(xmlFile, Charset.defaultCharset()).getDatabase().getEntries(); + + Path xmlFile = resourceDir.resolve(fileName); + + 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 7f853424f3a..cb202e6c730 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.bib @@ -1,44 +1,31 @@ -@unpublished{, - author = {Hanns-Jörg Stoß}, - month = {July}, - note = {a Note}, - 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}, - howpublished = {how}, - shorttitle = {Turing}, - isbn = {‎978-3-16-148410-0}, - intype = {intype}, - paper = {paper}, - editor = {Alfred}, - sourceType ={Interview}, - institution = {Institution}, +% Encoding: UTF-8 + +@Unpublished{, msbib-abbreviatedcasenumber = {abb}, - msbib-accessed = {12.10.2015}, - msbib-broadcaster = {broad}, - msbib-day = {5}, - msbib-casenumber = {case}, - msbib-court = {court}, - msbib-distributor = {dist}, - msbib-medium = {med}, - msbib-numberofvolume = {10}, - msbib-patentnumber = {pat}, - msbib-productioncompany = {produktion}, - msbib-recordingnumber = {record}, - msbib-reporter = {rep}, - msbib-periodical = {peri}, - msbib-station = {stat}, - msbib-theater = {th}, - msbib-type = {type}, - organization = {Besondere Turingmaschinen}, - price = {10}, - school = {Gymnasium Unterrieden}, - series = {ser}, - size = {1000} + msbib-accessed = {12.10.2015}, + msbib-broadcaster = {broad}, + msbib-casenumber = {case}, + msbib-court = {court}, + msbib-day = {5}, + msbib-distributor = {dist}, + msbib-medium = {med}, + msbib-numberofvolume = {10}, + msbib-periodical = {peri}, + msbib-productioncompany = {produktion}, + msbib-recordingnumber = {record}, + msbib-reporter = {rep}, + msbib-station = {stat}, + msbib-theater = {th}, + msbib-type = {type}, + owner = {Ich}, + paper = {paper}, + price = {10}, + school = {Gymnasium Unterrieden}, + series = {ser}, + shorttitle = {Turing}, + size = {1000}, + sourcetype = {Interview}, + timestamp = {2016.08.19}, } + +@Comment{jabref-meta: databaseType:biblatex;} 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 ea955c22fb0..960fd22d6b3 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest1.xml @@ -1,67 +1,34 @@ -Report +10 +ser unpublished -Turing -a Note - - - - -Stoß -Hanns-Jörg - - - - - - -Alfred - - - - -10 -10 - ISBN: ‎978-3-16-148410-0 -Stuttgart -Bawue -Deutschland -Turingmaschinen -3 -peri -Turingmaschinen -Gymnasium Unterrieden -Institution -unpublished -12 -10 -2015 -July -produktion -med +Report +rep +12.10.2015 +court record -th -dist -broad stat +th +peri type -pat -court -rep +Gymnasium Unterrieden +dist +Turing +med +produktion +paper case +broad +10 abb -ser -here should stand something about the content -cross -how -aff -con -cop -10 1000 -intype -paper +12 +10 +2015 +5 + +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 5b771c4c591..30ffd8244b9 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 2f47866a2f5..54b1476c210 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest2.xml @@ -1,23 +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 -3 +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/MsBibExportFormatTest3.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml index 58086978ba5..b6855b785e1 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest3.xml @@ -21,7 +21,6 @@ LCCN: 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/exporter/MsBibExportFormatTest4.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib index b61f2321776..56fe54ca28d 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.bib @@ -1,9 +1,7 @@ @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}, - number = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, 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 9719402e2cf..6d0d9efb5d9 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest4.xml @@ -1,21 +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 -3 -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/MsBibExportFormatTest5.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.bib index 0aa2db3f38a..0b62ace41a7 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.bib +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.bib @@ -4,7 +4,7 @@ @techreport{ keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, mrnumber = {0937-6429}, - number = {3}, + issue = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.xml index dbe3e0a0f25..d14983076a8 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest5.xml @@ -1,11 +1,16 @@ -Report -techreport 0 -Agile Entwicklung Web-basierter Systeme +3 2002 +44 +techreport +Report +Agile Entwicklung Web-basierter Systeme +Gabler Verlag +software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development +http://dx.doi.org/10.1007/BF03250842 @@ -19,13 +24,8 @@ 237-248 -44 - MRN: 0937-6429 -Gabler Verlag Wirtschaftsinformatik -3 + MRN: 0937-6429 Tech. rep. -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/MsBibExportFormatTest6.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest6.xml index a096a34ffd8..df5fc50d3b2 100644 --- a/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest6.xml +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest6.xml @@ -12,7 +12,6 @@ MRN: 0937-6429 Gabler Verlag Wirtschaftsinformatik -3 Master's thesis 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/MsBibExportFormatTest7.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib new file mode 100644 index 00000000000..ac469ca8a32 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.bib @@ -0,0 +1,13 @@ +% Encoding: UTF-8 + +@article{Orlowski;2011, + author = {Adam Czarnecki; Cezary Orłowski;}, + title = {Application of Ontology In the ITIL Domain}, + year = {2011}, + publisher = {Oficyna Wydawnicza Politechniki Wrocławskiej}, + pages = {99--108}, + 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 new file mode 100644 index 00000000000..4126bf24e76 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibExportFormatTest7.xml @@ -0,0 +1,25 @@ + + + +2011 +article +JournalArticle +Application of Ontology In the ITIL Domain +Orlowski;2011 +Oficyna Wydawnicza Politechniki Wrocławskiej +10.13140/2.1.3259.2169 + + + + +Czarnecki +and Orłowski, Cezary +Adam + + + + +99-108 +Information Systems Architecture and Technology: Service Oriented Networked Systems + + diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.bib b/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.bib new file mode 100644 index 00000000000..b8ec724001c --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.bib @@ -0,0 +1,12 @@ +% Encoding: UTF-8 + +@Patent{Lincoln1978, + author = {Abraham Lincoln}, + title = {The Vampire hunter}, + number = {12345677}, + year = {1978}, + owner = {Christoph Schwentker}, + timestamp = {2016.08.18}, +} + +@Comment{jabref-meta: databaseType:biblatex;} diff --git a/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.xml b/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.xml new file mode 100644 index 00000000000..ba48d7c980a --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/exporter/MsBibPatent.xml @@ -0,0 +1,21 @@ + + + +1978 +patent +Patent +The Vampire hunter +Lincoln1978 + + + + +Lincoln +Abraham + + + + +12345677 + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/EmptyMsBib_Test.xml similarity index 100% rename from src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest.xml rename to src/test/resources/net/sf/jabref/logic/importer/fileformat/EmptyMsBib_Test.xml diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.bib new file mode 100644 index 00000000000..3ed87286fa7 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.bib @@ -0,0 +1,5 @@ +% Encoding: UTF-8 + +@techreport{, + title = {Umläuts are fünny} +} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.xml new file mode 100644 index 00000000000..c96fa94ee04 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibExportFormatUmlauts.xml @@ -0,0 +1,10 @@ + + + +Report +unpublished +Umläuts are fünny + +unpublished + + 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 00000000000..60157c7651b --- /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 00000000000..7f59b422a5d --- /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 ac0cbc30b7b..00000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest1.bib +++ /dev/null @@ -1,14 +0,0 @@ -@conference{raey, - Title = {Agile Entwicklung Web-basierter Systeme}, - isbn = {0937-6429}, - Journal = {Wirtschaftsinformatik}, - Year = {2002}, - Number = {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 0b5670840fe..00000000000 --- 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 71352ffe0ab..00000000000 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest2.bib +++ /dev/null @@ -1,40 +0,0 @@ -@Article{, - author = {Hanns-Jörg Stoß}, - month = {July}, - 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-patentnumber = {pat}, - 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 8a475457cfd..00000000000 --- 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/MsBibImporterTest3.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest3.bib index f112a19d00e..14c4e0ad467 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest3.bib +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest3.bib @@ -1,10 +1,12 @@ +% Encoding: UTF-8 + @book{raey, author = {5}, - journal = {Wirtschaftsinformatik}, + journaltitle = {Wirtschaftsinformatik}, keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, lccn = {0937-6429}, - number = {3}, + issue = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest4.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest4.bib index 268f12092fb..d555e7433b8 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest4.bib +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest4.bib @@ -1,9 +1,11 @@ -@inbook{raey, +% Encoding: UTF-8 + +@book{raey, issn = {0937-6429}, - journal = {Wirtschaftsinformatik}, + journaltitle = {Wirtschaftsinformatik}, keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, - number = {3}, + issue = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest5.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest5.bib index 17d645d6145..e6aeabad794 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest5.bib +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest5.bib @@ -1,9 +1,11 @@ +% Encoding: UTF-8 + @techreport{, - journal = {Wirtschaftsinformatik}, + journaltitle = {Wirtschaftsinformatik}, keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, mrnumber = {0937-6429}, - number = {3}, + issue = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest6.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest6.bib index 478e16206e1..4eef0936ba0 100644 --- a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest6.bib +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest6.bib @@ -1,9 +1,11 @@ -@misc{, - journal = {Wirtschaftsinformatik}, +% Encoding: UTF-8 + +@online{, + journaltitle = {Wirtschaftsinformatik}, keywords = {software development processes; agile software development environments; time-to-market; Extreme Programming; Crystal methods family; Adaptive Software Development}, language = {english}, mrnumber = {0937-6429}, - number = {3}, + issue = {3}, pages = {237--248}, publisher = {Gabler Verlag}, title = {Agile Entwicklung Web-basierter Systeme}, diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.bib new file mode 100644 index 00000000000..f40d0722788 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.bib @@ -0,0 +1,14 @@ +% Encoding: UTF-8 + +@Article{Orlowski;2011, + author = {Adam and Or{\l}owski, Cezary Czarnecki}, + title = {Application of Ontology In the ITIL Domain}, + journaltitle = {Information Systems Architecture and Technology: Service Oriented Networked Systems}, + year = {2011}, + month = {mar}, + volume = {5}, + issue = {3}, + pages = {99--108}, + doi = {10.13140/2.1.3259.2169}, + publisher = {Oficyna Wydawnicza Politechniki Wrocławskiej}, +} \ No newline at end of file diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.xml new file mode 100644 index 00000000000..a8da9338694 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest7.xml @@ -0,0 +1,29 @@ + + + +3 +5 +article +JournalArticle +Application of Ontology In the ITIL Domain +Orlowski;2011 +Oficyna Wydawnicza Politechniki Wrocławskiej +10.13140/2.1.3259.2169 + + + + +Czarnecki +and Or{\l}owski, Cezary +Adam + + + + +99-108 +2011 +03 +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/MsBibImporterTitleTest.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTitleTest.bib new file mode 100644 index 00000000000..901935f81ee --- /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 00000000000..dbece53202a --- /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 + + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.bib new file mode 100644 index 00000000000..59da8f86d2a --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.bib @@ -0,0 +1,10 @@ +% Encoding: UTF-8 + +@patent{Lincoln1978, + author = {Abraham Lincoln}, + title = {The Vampire hunter}, + number = {12345677}, + year = {1978}, +} + +@Comment{jabref-meta: databaseType:biblatex;} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.xml new file mode 100644 index 00000000000..c85355a6761 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibPatent.xml @@ -0,0 +1,20 @@ + + + +1978 +Patent +The Vampire hunter +Lincoln1978 + + + + +Lincoln +Abraham + + + + +12345677 + + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.bib new file mode 100644 index 00000000000..d7d970da45a --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.bib @@ -0,0 +1,4 @@ +@Article{, + shorttitle = {Title} +} + diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.xml b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.xml new file mode 100644 index 00000000000..195051eef8b --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibShorttitle.xml @@ -0,0 +1,9 @@ + + + +JournalArticle +Title + +article + +