Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Bibtexml exporter #2017

Merged
merged 5 commits into from
Sep 22, 2016
Merged

Conversation

tschechlovdev
Copy link
Contributor

@tschechlovdev tschechlovdev commented Sep 20, 2016

Since the importer is written with a JAXB parser, I've rewritten the exporter with a jaxb parser as well. The exporter is now written in a similar way to the importer.
This should also fix #1337.

  • internal QS
  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef

@tschechlovdev tschechlovdev changed the title Rewrite Bibtexml exporter [WIP] Rewrite Bibtexml exporter Sep 20, 2016
Copy link
Contributor

@boceckts boceckts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only minor comments from my side.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class BibTeXMLExportFormat extends ExportFormat {
Copy link
Contributor

@boceckts boceckts Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a javadoc comment.

Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

marshaller.marshal(file, new java.io.File(resultFile));
Copy link
Contributor

@boceckts boceckts Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong import or why do you need java.io.File here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not wrong, but there is also a class File that is generated by JAXB. Thats is why this is needed.

}

/**
* Contains same logic as the parse method, but inbook needs a special treatment, because
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it contains the same logic, please use a {@link} annotation.

editor = {Maxima Musterfrau},
volume = {1},
number = {1},
chapter = {3},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally not being exported or is it missing in the exported xml file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is intentionally, because the schema doesn't have something like chapter in the InCollection type.

<file xmlns="http://bibtexml.sf.net/">
<entry id="Mustermann2016">
<inbook>
<bibtexkey>Mustermann2016</bibtexkey>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it beeing exported to a new node here but not in the previous test files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only inbook has the field key, that can be set. You can look at the generated Inbook class, there's a field key. Also in the other test for Inbook there's a bibtexkey as well.

@boceckts
Copy link
Contributor

boceckts commented Sep 21, 2016

Regarding the parameterized tests, something seems to be wrong with the path of the resource files because when I run the test class in IntelliJ it doesn't show any executed tests.

For me the following classes are affected:

net.sf.jabref.logic.exporter
    BibTeXMLExporterTestFiles.java
    MSBibExportFormatTestFiles.java
net.sf.jabref.logic.importer.fileformat
    BibTeXMLImporterTest.java
    BibTeXMLImporterTestFiles.java
    CopacImporterTest.java
    CopacImporterTestFiles.java
    MedlineImporterTest.java
    MedlineImporterTestFiles.java
    MsBibImporterTestfiles.java

I think it is best to move this issue to a new pr.

@@ -141,7 +140,7 @@ private void createMarshallerAndWriteToFile(File file, String resultFile) throws
}

/**
* Contains same logic as the parse method, but inbook needs a special treatment, because
* Contains same logic as the {@link parse()} method, but inbook needs a special treatment, because
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To link to a method you need to use the following annotation {@link #parse()}, But the rest is good to me.

@boceckts boceckts added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed stupro-ready-for-internal-review labels Sep 22, 2016
@boceckts boceckts changed the title [WIP] Rewrite Bibtexml exporter Rewrite Bibtexml exporter Sep 22, 2016
Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! I merge it in!

@Siedlerchr Siedlerchr merged commit daedc8e into JabRef:master Sep 22, 2016
@tschechlovdev tschechlovdev deleted the fix-bibtexml-export branch September 23, 2016 10:40
zesaro pushed a commit to zesaro/jabref that referenced this pull request Nov 22, 2016
* rewrite exporter with jaxb parser

* add test

* fix codacy and some code refactorings

* delete old layout files

* adress comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

corrupt BibTeXML export
3 participants