JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.66k stars 2.59k forks source link

Rewrite code of CitaviImporter to avoid JAXBContext #9539

Open koppor opened 1 year ago

koppor commented 1 year ago

The code of org.jabref.logic.importer.fileformat.CitaviXmlImporter is written OK, but relies on JAXB. It should be rewritten using StAX-Parser and thus getting rid of a JAXB dependency.

The code reads like we do not hit polymorphism in XMLElements (which is not supported by JAXB. See https://github.com/FasterXML/jackson-modules-base/issues/127).

See https://github.com/JabRef/jabref/blob/d21c11337a17af85047d763218c9df4dbc4db1be/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java#L114 for some code hints.

Similar to https://github.com/JabRef/jabref/pull/9673, the gradle build target generateCitaviSource can be removed and the xsd file be removed from the source repository.

Hints

Example file

  1. Open 7Zip gui
  2. Open src/test/resources/org/jabref/logic/importer/fileformat/CitaviXmlImporterTest4.ctv6bak in 7zip.
  3. Open citavi-single.xml using 7 zip

Initial coding

  1. Remove gradle task generateCitaviSource
  2. Remove src/main/resources/xjc/citavi/citavi.xsd
  3. Exectue gradle clean task.
  4. Observe that CitaviXmlImporter does not compile
  5. Try to understand how MedlineImporter handles XML importing
  6. Work on fixing it. -> You have a) an example file (see above) and b) similar code (MedlineImporter )

Negleted Implementation Option

Thus, it seems to be "just" to include the dependency to jackson module jakarta-xmlbind and to use Jackson's XMLMapper. Code examples are at https://stackify.com/java-xml-jackson/.

koppor commented 1 year ago

We should really work on that to get rid off buildSrc

koppor commented 1 year ago

Similar code refactoring: https://github.com/JabRef/jabref/pull/9880

JoleneSun111 commented 1 year ago

Hello, I'm a new contributor, and I will carefully read the contribution guidelines. Could you please assign this issue to me? @koppor

koppor commented 1 year ago

@JoleneSun111 If you want, you can also try https://github.com/FasterXML/StaxMate. However, that piece of library is not well documented. I would assume that basic Java Stax transformation is enough to solve the issue. - It is not straight-forward, but IMHO manageable nevertheless. The code is backed by tests, so there should be check if everything goes smoothely.

I remember we had the discussions that there have to build local data structures for the lookup of IDs.

ShailikaS commented 11 months ago

Hi @koppor, I would like to work on this if this issue is still open?

ThiloteE commented 11 months ago

Since there has not been any activity here since the abandoned pull-request from AvunArasi (#9928), I will assign you @ShailikaS.

koppor commented 10 months ago

@ShailikaS you have been assigned. Are you still working on this? -- It could be a bit hard to implement...

psyren99 commented 4 months ago

like to take on this issue, if possible

koppor commented 1 month ago

Seems to be too hard for programming newcomers, therefore removed from "good first issues".

koppor commented 1 month ago

/assign @psyren99

github-actions[bot] commented 1 month ago

πŸ‘‹ Hey @,

Thanks for your interest in this issue! πŸŽ‰

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

⚠ Note that this issue will become unassigned if it isn't closed within days.

πŸ”§ A maintainer can also add the **** label to prevent it from being unassigned automatically.

Happy coding! πŸš€