code formatting

This commit is contained in:
Claudio Atzori 2020-05-23 10:21:19 +02:00
parent 6b56cae57d
commit de108f54d6
3 changed files with 21 additions and 19 deletions

View File

@ -1,10 +1,10 @@
package eu.dnetlib.dhp.schema.common; package eu.dnetlib.dhp.schema.common;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import java.util.Comparator; import java.util.Comparator;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
public class LicenseComparator implements Comparator<Qualifier> { public class LicenseComparator implements Comparator<Qualifier> {
@Override @Override

View File

@ -15,13 +15,13 @@ import static eu.dnetlib.dhp.schema.common.ModelConstants.DNET_ACCESS_MODES;
import java.util.*; import java.util.*;
import eu.dnetlib.dhp.schema.common.LicenseComparator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentFactory; import org.dom4j.DocumentFactory;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Node; import org.dom4j.Node;
import eu.dnetlib.dhp.schema.common.LicenseComparator;
import eu.dnetlib.dhp.schema.oaf.Author; import eu.dnetlib.dhp.schema.oaf.Author;
import eu.dnetlib.dhp.schema.oaf.Context; import eu.dnetlib.dhp.schema.oaf.Context;
import eu.dnetlib.dhp.schema.oaf.DataInfo; import eu.dnetlib.dhp.schema.oaf.DataInfo;
@ -361,9 +361,9 @@ public abstract class AbstractMdRecordToOafMapper {
protected static Qualifier getBestAccessRights(List<Instance> instanceList) { protected static Qualifier getBestAccessRights(List<Instance> instanceList) {
if (instanceList != null) { if (instanceList != null) {
final Optional<Qualifier> min = instanceList final Optional<Qualifier> min = instanceList
.stream() .stream()
.map(i -> i.getAccessright()) .map(i -> i.getAccessright())
.min(new LicenseComparator()); .min(new LicenseComparator());
final Qualifier rights = min.isPresent() ? min.get() : new Qualifier(); final Qualifier rights = min.isPresent() ? min.get() : new Qualifier();
@ -371,7 +371,7 @@ public abstract class AbstractMdRecordToOafMapper {
rights.setClassid(UNKNOWN); rights.setClassid(UNKNOWN);
} }
if (StringUtils.isBlank(rights.getClassname()) if (StringUtils.isBlank(rights.getClassname())
|| UNKNOWN.equalsIgnoreCase(rights.getClassname())) { || UNKNOWN.equalsIgnoreCase(rights.getClassname())) {
rights.setClassname(NOT_AVAILABLE); rights.setClassname(NOT_AVAILABLE);
} }
if (StringUtils.isBlank(rights.getSchemeid())) { if (StringUtils.isBlank(rights.getSchemeid())) {

View File

@ -88,12 +88,13 @@ public class MappersTest {
assertNotNull(p.getInstance()); assertNotNull(p.getInstance());
assertTrue(p.getInstance().size() > 0); assertTrue(p.getInstance().size() > 0);
p.getInstance() p
.stream() .getInstance()
.forEach(i -> { .stream()
assertNotNull(i.getAccessright()); .forEach(i -> {
assertEquals("OPEN", i.getAccessright().getClassid()); assertNotNull(i.getAccessright());
}); assertEquals("OPEN", i.getAccessright().getClassid());
});
assertNotNull(p.getBestaccessright()); assertNotNull(p.getBestaccessright());
assertEquals("OPEN", p.getBestaccessright().getClassid()); assertEquals("OPEN", p.getBestaccessright().getClassid());
@ -176,12 +177,13 @@ public class MappersTest {
assertNotNull(d.getInstance()); assertNotNull(d.getInstance());
assertTrue(d.getInstance().size() > 0); assertTrue(d.getInstance().size() > 0);
d.getInstance() d
.stream() .getInstance()
.forEach(i -> { .stream()
assertNotNull(i.getAccessright()); .forEach(i -> {
assertEquals("OPEN", i.getAccessright().getClassid()); assertNotNull(i.getAccessright());
}); assertEquals("OPEN", i.getAccessright().getClassid());
});
assertValidId(r1.getSource()); assertValidId(r1.getSource());
assertValidId(r1.getTarget()); assertValidId(r1.getTarget());