Skip to content

Commit

Permalink
JabRef#8491 : Fix Check Style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
addak committed Feb 26, 2022
1 parent dcaa63e commit 98e71b9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
24 changes: 12 additions & 12 deletions src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

public class DublinCoreExtractor {

public static final String DC_COVERAGE="coverage";
public static final String DC_RIGHTS="rights";
public static final String DC_SOURCE="source";
public static final String DC_COVERAGE = "coverage";
public static final String DC_RIGHTS = "rights";
public static final String DC_SOURCE = "source";

private static final Logger LOGGER = LoggerFactory.getLogger(DublinCoreExtractor.class);

Expand Down Expand Up @@ -269,7 +269,7 @@ private void extractType() {

private void extractCoverage() {
String coverage = dcSchema.getCoverage();
if( !StringUtils.isEmpty(coverage) ){
if (!StringUtils.isEmpty(coverage)) {
bibEntry.setField(FieldFactory.parseField(DC_COVERAGE), coverage);
}
}
Expand Down Expand Up @@ -355,14 +355,14 @@ private void fillDate() {
dcSchema.addUnqualifiedSequenceValue("date", publicationDate);
String[] f = publicationDate.split("-");
String format;
if(f.length == 3){
if (f.length == 3) {
format = "YYYY-MM-DD";
} else if (f.length == 2){
} else if (f.length == 2) {
format = "YYYY-MM";
} else{
} else {
format = "YYYY";
}
((DublinCoreSchemaCustom)dcSchema).setDateAttributeFormatQualifier(format);
((DublinCoreSchemaCustom) dcSchema).setDateAttributeFormatQualifier(format);
});
}

Expand Down Expand Up @@ -438,7 +438,7 @@ private void fillLanguages(String languages) {
}
dcSchema.addLanguage(language);
}
);
);
}

/**
Expand Down Expand Up @@ -482,8 +482,8 @@ public void fillDublinCoreSchema() {

Field fieldEntry = field.getKey();

if( fieldEntry instanceof StandardField){
switch((StandardField)fieldEntry){
if (fieldEntry instanceof StandardField) {
switch ((StandardField) fieldEntry) {
case EDITOR:
this.fillContributor(field.getValue());
break;
Expand Down Expand Up @@ -526,7 +526,7 @@ public void fillDublinCoreSchema() {
this.fillRights(field.getValue());
} else if (DC_SOURCE.equals(fieldEntry.getName())) {
this.fillSource(field.getValue());
} else{
} else {
this.fillCustomField(field.getKey(), field.getValue());
}
}
Expand Down
33 changes: 14 additions & 19 deletions src/main/java/org/jabref/model/schema/DublinCoreSchemaCustom.java
Original file line number Diff line number Diff line change
@@ -1,55 +1,50 @@
package org.jabref.model.schema;

import com.fasterxml.jackson.databind.util.BeanUtil;
import com.microsoft.applicationinsights.internal.config.ReflectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.xmpbox.XMPMetadata;
import org.apache.xmpbox.XmpConstants;
import org.apache.xmpbox.schema.DublinCoreSchema;
import org.apache.xmpbox.type.*;
import org.jabref.logic.xmp.XmpUtilReader;
import org.apache.xmpbox.type.AbstractField;
import org.apache.xmpbox.type.ArrayProperty;
import org.apache.xmpbox.type.Attribute;
import org.apache.xmpbox.type.StructuredType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.XMLConstants;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@StructuredType(preferedPrefix = "dc", namespace = "http://purl.org/dc/elements/1.1/")
public class DublinCoreSchemaCustom extends DublinCoreSchema {

private static final Logger LOGGER = LoggerFactory.getLogger(DublinCoreSchemaCustom.class);

public DublinCoreSchemaCustom(XMPMetadata metadata)
{
public DublinCoreSchemaCustom(XMPMetadata metadata) {
super(metadata);
}

public static DublinCoreSchemaCustom copyDublinCoreSchema(DublinCoreSchema dcSchema){
public static DublinCoreSchemaCustom copyDublinCoreSchema(DublinCoreSchema dcSchema) {

if( Objects.isNull(dcSchema) )
if (Objects.isNull(dcSchema))
return null;

DublinCoreSchemaCustom dublinCoreSchemaCustom = new DublinCoreSchemaCustom(dcSchema.getMetadata());

try{
try {
FieldUtils.writeField(dublinCoreSchemaCustom, "container", dcSchema.getContainer(), true);
FieldUtils.writeField(dublinCoreSchemaCustom, "attributes", FieldUtils.readField(dcSchema, "attributes", true), true);
System.out.println("lol");
} catch (Exception e){
} catch (Exception e) {
LOGGER.error("Error making custom DC Schema\n {}", ExceptionUtils.getStackTrace(e));
}

return dublinCoreSchemaCustom;
}

public String getDateAttributeFormatQualifier(){
public String getDateAttributeFormatQualifier() {
AbstractField abstractProperty = getAbstractProperty("date");

if(abstractProperty instanceof ArrayProperty){
if (abstractProperty instanceof ArrayProperty) {
return ((ArrayProperty) abstractProperty)
.getContainer()
.getAllProperties()
Expand All @@ -59,14 +54,14 @@ public String getDateAttributeFormatQualifier(){
return null;
}

public void setDateAttributeFormatQualifier(String value){
public void setDateAttributeFormatQualifier(String value) {
AbstractField abstractProperty = getAbstractProperty("date");

if(abstractProperty instanceof ArrayProperty){
if (abstractProperty instanceof ArrayProperty) {
var properties = ((ArrayProperty) abstractProperty)
.getContainer()
.getAllProperties();
properties.get(properties.size()-1).setAttribute(new Attribute(XMLConstants.XML_NS_URI, "format", value));
properties.get(properties.size() - 1).setAttribute(new Attribute(XMLConstants.XML_NS_URI, "format", value));
}
}
}

0 comments on commit 98e71b9

Please sign in to comment.