Change the type of the "warnings" and "errors" fields of "Guideline.Result" to "List<String>", in order to be encoded by Spark.

This commit is contained in:
Lampros Smyrnaios 2024-01-25 12:54:24 +02:00
parent 156ffbeec4
commit 8d3c8324ae
4 changed files with 22 additions and 23 deletions

View File

@ -3,6 +3,7 @@ package eu.dnetlib.validator2.validation.guideline;
import eu.dnetlib.validator2.engine.Status; import eu.dnetlib.validator2.engine.Status;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
public interface Guideline<T> { public interface Guideline<T> {
@ -36,14 +37,14 @@ public interface Guideline<T> {
// When status == SUCCESS, potential warnings are held here // When status == SUCCESS, potential warnings are held here
// This may also contain messages when status == FAILURE // This may also contain messages when status == FAILURE
Iterable<String> getWarnings(); List<String> getWarnings();
void setWarnings(Iterable<String> warnings); void setWarnings(List<String> warnings);
// When status == FAILURE, the errors are held here // When status == FAILURE, the errors are held here
// We currently hold a single error (and fail fast) // We currently hold a single error (and fail fast)
Iterable<String> getErrors(); List<String> getErrors();
void setErrors(Iterable<String> errors); void setErrors(List<String> errors);
// When status == ERROR, the internal error is held here // When status == ERROR, the internal error is held here

View File

@ -1,6 +1,5 @@
package eu.dnetlib.validator2.validation.guideline; package eu.dnetlib.validator2.validation.guideline;
import com.google.common.collect.Lists;
import eu.dnetlib.validator2.engine.Status; import eu.dnetlib.validator2.engine.Status;
import java.io.Serializable; import java.io.Serializable;
@ -50,23 +49,23 @@ public final class StandardResult implements Guideline.Result, Serializable {
} }
@Override @Override
public Iterable<String> getWarnings() { public List<String> getWarnings() {
return warnings; return warnings;
} }
@Override @Override
public void setWarnings(Iterable<String> warnings) { public void setWarnings(List<String> warnings) {
this.warnings = Lists.newArrayList(warnings); this.warnings = warnings;
} }
@Override @Override
public Iterable<String> getErrors() { public List<String> getErrors() {
return errors; return errors;
} }
@Override @Override
public void setErrors(Iterable<String> errors) { public void setErrors(List<String> errors) {
this.errors = Lists.newArrayList(errors); this.errors = errors;
} }
@Override @Override

View File

@ -2,7 +2,6 @@ package eu.dnetlib.validator2.validation.guideline.openaire;
//import com.google.gson.Gson; //import com.google.gson.Gson;
import com.google.common.collect.Lists;
import eu.dnetlib.validator2.validation.XMLApplicationProfile; import eu.dnetlib.validator2.validation.XMLApplicationProfile;
import eu.dnetlib.validator2.validation.guideline.*; import eu.dnetlib.validator2.validation.guideline.*;
import eu.dnetlib.validator2.validation.utils.ResultUtils; import eu.dnetlib.validator2.validation.utils.ResultUtils;
@ -397,7 +396,7 @@ class F2_01M_SPEC_LIT extends AbstractGuideline<Document> {
final Result ress = getResult(warnings2, errors2, score); final Result ress = getResult(warnings2, errors2, score);
return new StandardResult(ress.getScore(), ress.getStatus(), Lists.newArrayList(ress.getWarnings()), Lists.newArrayList(ress.getErrors()), ress.getInternalError()); return new StandardResult(ress.getScore(), ress.getStatus(), ress.getWarnings(), ress.getErrors(), ress.getInternalError());
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);
@ -454,7 +453,7 @@ class F3_01M_SPEC_LIT extends AbstractGuideline<Document> {
final Result ress = getResult(warnings2, errors2, MaxScoreF3_01M_LIT_SPEC); final Result ress = getResult(warnings2, errors2, MaxScoreF3_01M_LIT_SPEC);
return new StandardResult(ress.getScore(), ress.getStatus(), Lists.newArrayList(ress.getWarnings()), Lists.newArrayList(ress.getErrors()), ress.getInternalError()); return new StandardResult(ress.getScore(), ress.getStatus(), ress.getWarnings(), ress.getErrors(), ress.getInternalError());
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);
@ -509,7 +508,7 @@ class I2_01M_SPEC_LIT extends AbstractGuideline<Document> {
final Result ress = getResult(warnings2, errors2, MaxScoreI2_01M_LIT_SPEC); final Result ress = getResult(warnings2, errors2, MaxScoreI2_01M_LIT_SPEC);
return new StandardResult(ress.getScore(), ress.getStatus(), Lists.newArrayList(ress.getWarnings()), Lists.newArrayList(ress.getErrors()), ress.getInternalError()); return new StandardResult(ress.getScore(), ress.getStatus(), ress.getWarnings(), ress.getErrors(), ress.getInternalError());
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);
@ -561,7 +560,7 @@ class R1_01M_SPEC_LIT extends AbstractGuideline<Document> {
final Result ress = getResult(warnings2, errors2, score); final Result ress = getResult(warnings2, errors2, score);
return new StandardResult(ress.getScore(), ress.getStatus(), Lists.newArrayList(ress.getWarnings()), Lists.newArrayList(ress.getErrors()), ress.getInternalError()); return new StandardResult(ress.getScore(), ress.getStatus(), ress.getWarnings(), ress.getErrors(), ress.getInternalError());
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);
@ -613,7 +612,7 @@ class R1_2_01M_SPEC_LIT extends AbstractGuideline<Document> {
final Result ress = getResult(warnings2, errors2, score); final Result ress = getResult(warnings2, errors2, score);
return new StandardResult(ress.getScore(), ress.getStatus(), Lists.newArrayList(ress.getWarnings()), Lists.newArrayList(ress.getErrors()), ress.getInternalError()); return new StandardResult(ress.getScore(), ress.getStatus(), ress.getWarnings(), ress.getErrors(), ress.getInternalError());
} catch (Exception e) { } catch (Exception e) {
logger.error("", e); logger.error("", e);

View File

@ -14,8 +14,8 @@ public class ResultUtils {
private int score; private int score;
private Status status; private Status status;
private Iterable<String> warnings; private List<String> warnings;
private Iterable<String> errors; private List<String> errors;
private String internalError; private String internalError;
@ -40,22 +40,22 @@ public class ResultUtils {
} }
@Override @Override
public Iterable<String> getWarnings() { public List<String> getWarnings() {
return this.warnings; return this.warnings;
} }
@Override @Override
public void setWarnings(Iterable<String> warnings) { public void setWarnings(List<String> warnings) {
this.warnings = warnings; this.warnings = warnings;
} }
@Override @Override
public Iterable<String> getErrors() { public List<String> getErrors() {
return this.errors; return this.errors;
} }
@Override @Override
public void setErrors(Iterable<String> errors) { public void setErrors(List<String> errors) {
this.errors = errors; this.errors = errors;
} }