Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f4845591 authored by alassane gaye's avatar alassane gaye
Browse files

add rules

parent 996e1947
No related branches found
No related tags found
No related merge requests found
......@@ -113,9 +113,10 @@ public class CBOREncoderDecoderV130 implements EncoderDecoder<EncodedCBORDCC, Eu
for(TestEntry testEntry : eudcc.getT()){
validateTg(testEntry.getTg(), jsonReportBuilder);
validateCo(testEntry.getCo(), jsonReportBuilder);
validateMaTest(testEntry.getMa(), jsonReportBuilder);
validateTr(testEntry.getTr(), jsonReportBuilder);
validateTt(testEntry.getTt(), jsonReportBuilder);
validateMaTest(testEntry.getMa(), jsonReportBuilder);
}
} else if(eudcc.getR() != null && !eudcc.getR().isEmpty()){
for(RecoveryEntry recoveryEntry : eudcc.getR()){
......@@ -135,68 +136,46 @@ public class CBOREncoderDecoderV130 implements EncoderDecoder<EncodedCBORDCC, Eu
}
public void validateTg(String tg, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(tg, dccValueSets.get(DCCValueSet.DISEASE_AGENT_TARGETED))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, tg, DCCValueSet.DISEASE_AGENT_TARGETED), ConstraintPriority.MANDATORY);
public void validateValueInField(String value, String field, DCCValueSet valueSet, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(value, dccValueSets.get(valueSet))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, field, valueSet), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, tg, DCCValueSet.DISEASE_AGENT_TARGETED), ConstraintPriority.MANDATORY);
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, field, valueSet), ConstraintPriority.MANDATORY);
}
}
public void validateVp(String vp, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(vp, dccValueSets.get(DCCValueSet.VACCINE_PROPHYLAXIS))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, vp, DCCValueSet.VACCINE_PROPHYLAXIS), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, vp, DCCValueSet.VACCINE_PROPHYLAXIS), ConstraintPriority.MANDATORY);
public void validateTg(String tg, ValidationSubReportBuilder jsonReportBuilder){
if(DCCValueSet.DISEASE_AGENT_TARGETED != null){
validateValueInField(tg, "tg", DCCValueSet.DISEASE_AGENT_TARGETED, jsonReportBuilder);
}
}
public void validateVp(String vp, ValidationSubReportBuilder jsonReportBuilder){
validateValueInField(vp, "vp", DCCValueSet.VACCINE_PROPHYLAXIS, jsonReportBuilder);
}
public void validateMp(String mp, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(mp, dccValueSets.get(DCCValueSet.VACCINE_MEDICINAL_PRODUCT))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, mp, DCCValueSet.VACCINE_MEDICINAL_PRODUCT), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, mp, DCCValueSet.VACCINE_MEDICINAL_PRODUCT), ConstraintPriority.MANDATORY);
}
validateValueInField(mp, "mp", DCCValueSet.VACCINE_MEDICINAL_PRODUCT, jsonReportBuilder);
}
public void validateMaVaccine(String ma, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(ma, dccValueSets.get(DCCValueSet.VACCINE_MAH_MANF))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, ma, DCCValueSet.VACCINE_MAH_MANF), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, ma, DCCValueSet.VACCINE_MAH_MANF), ConstraintPriority.MANDATORY);
}
validateValueInField(ma, "ma", DCCValueSet.VACCINE_MAH_MANF, jsonReportBuilder);
}
public void validateMaTest(String ma, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(ma, dccValueSets.get(DCCValueSet.TEST_MANF))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, ma, DCCValueSet.TEST_MANF), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, ma, DCCValueSet.TEST_MANF), ConstraintPriority.MANDATORY);
}
validateValueInField(ma, "ma", DCCValueSet.TEST_MANF, jsonReportBuilder);
}
public void validateCo(String co, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(co, dccValueSets.get(DCCValueSet.COUNTRY_2_CODE))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, co, DCCValueSet.COUNTRY_2_CODE), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, co, DCCValueSet.COUNTRY_2_CODE), ConstraintPriority.MANDATORY);
}
validateValueInField(co, "co", DCCValueSet.COUNTRY_2_CODE, jsonReportBuilder);
}
public void validateTr(String tr, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(tr, dccValueSets.get(DCCValueSet.TEST_RESULT))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, tr, DCCValueSet.TEST_RESULT), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, tr, DCCValueSet.TEST_RESULT), ConstraintPriority.MANDATORY);
}
validateValueInField(tr, "tr", DCCValueSet.TEST_RESULT, jsonReportBuilder);
}
public void validateTt(String tt, ValidationSubReportBuilder jsonReportBuilder){
if(isValueInValueSet(tt, dccValueSets.get(DCCValueSet.TEST_TYPE))){
jsonReportBuilder.addPassedConstraintValidation(String.format(VALUE_CONSTRAINT_PASSED, tt, DCCValueSet.TEST_TYPE), ConstraintPriority.MANDATORY);
} else {
jsonReportBuilder.addFailedConstraintValidation(String.format(VALUE_CONSTRAINT_FAILED, tt, DCCValueSet.TEST_TYPE), ConstraintPriority.MANDATORY);
}
validateValueInField(tt, "tt", DCCValueSet.TEST_TYPE, jsonReportBuilder);
}
public boolean isValueInValueSet(String value, List<Concept> valueSet){
......@@ -275,12 +254,12 @@ public class CBOREncoderDecoderV130 implements EncoderDecoder<EncodedCBORDCC, Eu
private static final long serialVersionUID = 3929100820024454525L;
public static final CBOREncoderDecoderV130.CustomInstantDeserializer INSTANT = new CBOREncoderDecoderV130.CustomInstantDeserializer(
Instant.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
Instant::from,
a -> Instant.ofEpochMilli(a.value),
a -> Instant.ofEpochSecond(a.integer, a.fraction),
null,
true);
Instant.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
Instant::from,
a -> Instant.ofEpochMilli(a.value),
a -> Instant.ofEpochSecond(a.integer, a.fraction),
null,
true);
protected CustomInstantDeserializer(final Class<Instant> supportedType,
final DateTimeFormatter formatter,
......@@ -293,4 +272,4 @@ public class CBOREncoderDecoderV130 implements EncoderDecoder<EncodedCBORDCC, Eu
super(supportedType, formatter, parsedToValue, fromMilliseconds, fromNanoseconds, adjust, replaceZeroOffsetAsZ);
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment