Skip to content

Commit

Permalink
#8491 : Address Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
addak committed Mar 9, 2022
1 parent 7345b32 commit 9af8533
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the search box in preview preferences closer to the available citation styles list. [#8370](https://github.com/JabRef/jabref/pull/8370)
- Changing the preference to show the preview panel as a separate tab now has effect without restarting JabRef. [#8370](https://github.com/JabRef/jabref/pull/8370)
- We enabled switching themes in JabRef without the need to restart JabRef. [#7335](https://github.com/JabRef/jabref/pull/7335)
- We added support for the field `day`, `rights`, `coverage` and `language` when reading XMP data in Dublin Core format[#8491](https://github.com/JabRef/jabref/issues/8491)
- We added support for the field `day`, `rights`, `coverage` and `language` when reading XMP data in Dublin Core format. [#8491](https://github.com/JabRef/jabref/issues/8491)

### Fixed

Expand Down
7 changes: 0 additions & 7 deletions src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ private void fillCoverage(String coverage) {

/**
* BibTex Field : language ; DC Field : dc:language
*
* @param languages
*/
private void fillLanguages(String languages) {
Arrays.stream(languages.split(","))
Expand All @@ -386,17 +384,13 @@ private void fillLanguages(String languages) {

/**
* BibTex : Rights (Custom Field); DC Field : dc:rights
*
* @param rights
*/
private void fillRights(String rights) {
dcSchema.addRights(null, rights.split(",")[0]);
}

/**
* BibTex : Source (Custom Field); DC Field : Source
*
* @param source
*/
private void fillSource(String source) {
dcSchema.setSource(source);
Expand Down Expand Up @@ -463,7 +457,6 @@ public void fillDublinCoreSchema() {
this.fillCustomField(field.getKey(), field.getValue());
}
} else {

if (DC_COVERAGE.equals(fieldEntry.getName())) {
this.fillCoverage(field.getValue());
} else if (DC_RIGHTS.equals(fieldEntry.getName())) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/entry/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Date {
private static final DateTimeFormatter SIMPLE_DATE_FORMATS;
static {
List<String> formatStrings = Arrays.asList(
"uuuu-MM-dd'T'HH:mm:ss[xxx][xx][X]", // covers 2018-10-03T07:24:14+03:00
"uuuu-MM-dd'T'HH:mm:ss[xxx][xx][X]", // covers 2018-10-03T07:24:14+03:00
"uuuu-M-d", // covers 2009-1-15
"uuuu-M", // covers 2009-11
"d-M-uuuu", // covers 15-1-2012
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/**
* A DublinCoreSchema extension Class.
* In case anyone intends to alter standard behaviour.
*
*/
@StructuredType(preferedPrefix = "dc", namespace = "http://purl.org/dc/elements/1.1/")
public class DublinCoreSchemaCustom extends DublinCoreSchema {
Expand All @@ -29,7 +28,6 @@ public DublinCoreSchemaCustom(XMPMetadata metadata) {
}

public static DublinCoreSchema copyDublinCoreSchema(DublinCoreSchema dcSchema) {

if (Objects.isNull(dcSchema)) {
return null;
}
Expand All @@ -39,9 +37,7 @@ public static DublinCoreSchema copyDublinCoreSchema(DublinCoreSchema dcSchema) {
FieldUtils.writeField(dublinCoreSchemaCustom, "container", dcSchema.getContainer(), true);
FieldUtils.writeField(dublinCoreSchemaCustom, "attributes",
FieldUtils.readField(dcSchema, "attributes", true), true);

return dublinCoreSchemaCustom;

} catch (Exception e) {
LOGGER.error("Error making custom DC Schema. Using the default", e);
return dcSchema;
Expand All @@ -51,9 +47,6 @@ public static DublinCoreSchema copyDublinCoreSchema(DublinCoreSchema dcSchema) {
/**
* Overloaded XMP Schema method
* Behaviour is same except when seqName is "Date". Will return raw value instead
*
* @param seqName
* @return
*/
@Override
public List<String> getUnqualifiedSequenceValueList(String seqName) {
Expand All @@ -66,7 +59,6 @@ public List<String> getUnqualifiedSequenceValueList(String seqName) {
.map(field -> (String) ((DateType) field).getRawValue())
.collect(Collectors.toList());
}

return ((ArrayProperty) abstractProperty).getElementsAsString();
}
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/jabref/logic/xmp/XmpUtilReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ void setUp() {
* Tests reading of dublinCore metadata.
*/
@Test
void testReadArticleDublinCoreReadRawXmp() throws IOException, URISyntaxException, ParseException {
Path path = Path.of(XmpUtilShared.class.getResource("article_dublinCore.pdf").toURI());
void testReadArticleDublinCoreReadRawXmp() throws IOException, URISyntaxException {
Path path = Path.of(XmpUtilShared.class.getResource("article_dublinCore_without_day.pdf").toURI());
List<XMPMetadata> meta = XmpUtilReader.readRawXmp(path);

DublinCoreSchema dcSchema = DublinCoreSchemaCustom.copyDublinCoreSchema(meta.get(0).getDublinCoreSchema());
DublinCoreExtractor dcExtractor = new DublinCoreExtractor(dcSchema, xmpPreferences, new BibEntry());
Optional<BibEntry> entry = dcExtractor.extractBibtexEntry();

Path bibFile = Path.of(XmpUtilShared.class.getResource("article_dublinCore.bib").toURI());
Path bibFile = Path.of(XmpUtilShared.class.getResource("article_dublinCore_without_day.bib").toURI());
List<BibEntry> expected = testImporter.importDatabase(bibFile, StandardCharsets.UTF_8).getDatabase().getEntries();

assertEquals(expected, Collections.singletonList(entry.get()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@Article{,
coverage = {coverageField},
language = {English,Japanese},
month = {#jan#},
month = jan,
rights = {Right To X},
source = {JabRef},
year = {2005},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@Article{Olly2018,
author = {Olly and Johannes},
title = {Stefan's palace},
journal = {Test Journal},
year = {2018},
volume = {1},
number = {1},
pages = {1-2},
month = mar,
issn = {978-123-123},
note = {That's a note},
abstract = {That's an abstract},
comment = {That's a comment},
doi = {10/3212.3123},
file = {:paper.pdf:PDF},
groups = {NO},
howpublished = {Online},
keywords = {Keyword1, Keyword2},
owner = {Me},
review = {Here are the reviews},
timestamp = {2018-02-15},
url = {https://www.olly2018.edu},
}
Binary file not shown.

0 comments on commit 9af8533

Please sign in to comment.