- Fix missing import in groovy test.

- Code polishing.
This commit is contained in:
Lampros Smyrnaios 2023-07-14 14:26:11 +03:00
parent b63f09bfc4
commit 8b4da5c4eb
3 changed files with 9 additions and 13 deletions

View File

@ -32,13 +32,11 @@ public final class SyntheticGuideline extends AbstractGuideline<Document> {
String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty"));
// Here we define a guideline with a specific elementSpec as origin, we cannot allow null
if (elementSpec == null) {
if ( elementSpec == null )
throw new IllegalArgumentException("ElementSpec cannot be empty");
}
if (weight < 0) {
if ( weight < 0 )
throw new IllegalArgumentException("Weight cannot be negative");
}
SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight);
guideline.compilationResult = new ElementSpecCompiler().compile(elementSpec, evaluation::get);
@ -49,17 +47,14 @@ public final class SyntheticGuideline extends AbstractGuideline<Document> {
public static SyntheticGuideline of(String name, int weight, RequirementLevel requirementLevel, Rule<Document> rule) {
String canonical = Helper.ensureNonEmpty(name, () -> new IllegalArgumentException("Name cannot be empty"));
if (weight < 0) {
if ( weight < 0 )
throw new IllegalArgumentException("Weight cannot be negative");
}
if (requirementLevel == null) {
if ( requirementLevel == null )
throw new IllegalArgumentException("Requirement level cannot be empty");
}
if (rule == null) {
if ( rule == null )
throw new IllegalArgumentException("Rule cannot be empty");
}
SyntheticGuideline guideline = new SyntheticGuideline(canonical, weight);
CompilationResult compilationResult = new CompilationResult();

View File

@ -42,7 +42,7 @@ public abstract class AbstractOpenAireProfile implements XMLApplicationProfile {
final Map<String, Guideline.Result> results = new HashMap<>();
// Validate the document against all guideline-elements.
for (Guideline<Document> guidelineElement : guidelines())
for ( Guideline<Document> guidelineElement : guidelines() )
{
String guidelineElementName = guidelineElement.getName();
if ( logger.isTraceEnabled() )
@ -79,10 +79,10 @@ public abstract class AbstractOpenAireProfile implements XMLApplicationProfile {
// The nodes contain all the elementName nodes
int len = nodes.getLength();
if (len == 0) { return false; } // element is not present
for(int i = 0; i < len; i++) {
for ( int i = 0; i < len; i++ ) {
Node elem = nodes.item(i);
String value = Helper.getAttributeValue(elem, attrName);
if (!attrValue.equals(value)) { return false; }
if ( !attrValue.equals(value) ) { return false; }
}
return true;
});

View File

@ -1,5 +1,6 @@
package eu.dnetlib.validator2.engine
import eu.dnetlib.validator2.engine.Helper
import groovy.xml.DOMBuilder
import groovy.xml.FactorySupport
import org.w3c.dom.Document