-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 mods exporter and add test for it #1989
Conversation
for (Map.Entry<String, String> entry : fieldMap.entrySet()) { | ||
String key = entry.getKey(); | ||
String value = entry.getValue(); | ||
if (FieldName.AUTHOR.equals(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split the author handling code in a new method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, even net.sf.jabref.model.entry.AuthorList#parse
can be directly used?
} | ||
} | ||
mods.getModsGroup().add(name); | ||
} else if ("affiliation".equals(key)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here a switch statement could be useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
|
||
@Override | ||
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) { | ||
if ("http://www.loc.gov/mods/v3".equals(namespaceUri)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pleas consider extracting those as String constants, so in case of change they could be easily changed..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
//formate the output | ||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); | ||
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, | ||
"http://www.loc.gov/standards/mods/v3/mods-3-6.xsd"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
6e0956f
to
2c31d3d
Compare
a756032
to
b5e6183
Compare
b5e6183
to
5878b95
Compare
For some reason codecov doesn't run the class |
9b8b1d1
to
63c471e
Compare
@tschechlovdev Codecov seems to work again: codecov/project — 28.28% (+0.42%) compared to a8e1488 |
No, I have two test classes. I tried to rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some work is still required. I would first fix the test files and once your tests are failing rework the appropriate methods.
In my opinionen it would also be a good idea to create a test to see if an mods exported xml file can be imported by the mods importer and if it produces the same bib entry.
|
||
switch (key) { | ||
|
||
case FieldName.AUTHOR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent the cases please.
case FieldName.JOURNAL: | ||
addJournal(value, relatedItem); | ||
break; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default
case is unnecessary here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No! Codecov will complain about a case with no default. There always shoold be a default in a switch case
JAXBElement<ModsCollectionDefinition> jaxbElement = new JAXBElement<>(new QName("modsCollection"), | ||
ModsCollectionDefinition.class, modsCollection); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there so many empty lines here, please use max one empty line to separate different code elements to groups.
} | ||
}; | ||
|
||
//formate the output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "format"
if (MODS_NAMESPACE_URI.equals(namespaceUri)) { | ||
return "mods"; | ||
} | ||
return ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rplace with return MODS_NAMESPACE_URI.equals(namespaceUri) ? "mods" : "";
@@ -0,0 +1,6 @@ | |||
@Book{ | |||
isbn = {123456789}, | |||
issn = {123456789}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use different numbers for isbn and issn.
pmid = {123456789}, | ||
created = {2000-10-10}, | ||
modified = {2000-10-10}, | ||
captured = {2000-10-10}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use different dates.
<mods:genre>book</mods:genre> | ||
<mods:identifier type="issn">123456789</mods:identifier> | ||
<mods:subject> | ||
<topic>note; and another note;</topic> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the keywords should be separated and a new topic node should be created for each one instead of writing them in one node. Same as for the ModsExportFormatTestAllFields.xml.
pages = {1234}, | ||
author = {Mustermann}, | ||
isbn = {123456789}, | ||
issn = {12345678}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use different test numbers for isbn and issn here, too.
<namePart type="given"></namePart> | ||
<namePart type="given">know</namePart> | ||
<namePart type="family">Realy</namePart> | ||
<namePart type="given"></namePart> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there empty given name fields?
Regarding the test coverage. I have no idea, but maybe it is related to the fact that it's a parameterized test? |
int minusIndex = value.indexOf(minus); | ||
String startPage = value.substring(0, minusIndex); | ||
String endPage = ""; | ||
if ("-".equals(minus)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please extrac thte Singe "-" and the double "--" to constants?
Regarding the not executed tests #2017 (comment). |
} | ||
} else { | ||
//no "," indicates that there should only be a family name | ||
namePart.setAtType("family"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no test coverage?
|
||
private void addIdentifier(String key, String value, ModsDefinition mods) { | ||
if ("citekey".equals(key)) { | ||
mods.setID(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no test coverage?
if ("-".equals(minus)) { | ||
endPage = value.substring(minusIndex + 1); | ||
} else if ("--".equals(minus)) { | ||
endPage = value.substring(minusIndex + 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no test coverage?
Please increase test coverage. I did not see a roundtrip test: bibtex -> mods -> bibtex and mods -> bibtex -> mods. Is that possible? |
@koppor Regarding test coverage: It's still the same problem that the parameterized test are not run by codecov. I will take care of this in a separate PR. |
I remove the "ready-for-review" for the moment until the comments are addressed. Please add it again afterwards. Thanks. |
# Conflicts: # src/main/java/net/sf/jabref/logic/mods/MODSEntry.java # src/main/java/net/sf/jabref/logic/msbib/MSBibEntry.java
Good! I merge in! |
I'm getting the following error:
OS data:
|
I'll take a quick look |
@obraliar Works fine. Did you run ./gradlew eclipse (or build whatever youride is) ? |
@Siedlerchr What OS are you using? |
@obraliar Now it get the same. Seems like my local repo was not update to date. I will revert that commit here. Problem is the internal class stuff. @tschechlovdev Sorry, but you have to fix this |
* rewrite mods exporter and add test for it * some code refactorings and editing the test * add test case * delete old mods helper classes and move other used classes * rename testfiles test class * address comments * address comments
* rewrite mods exporter and add test for it * some code refactorings and editing the test * add test case * delete old mods helper classes and move other used classes * rename testfiles test class * address comments * address comments
Regarding: #1920
Rewrite the MODS exporter with a JAXB parser.
Details on the format and the newest xml schema can be found here.
I've used the newest schema (version 3.6).
This PR uses the same gradle script and schema as in #1942 .