Commit 26828de8 authored by Figue Orange's avatar Figue Orange
Browse files

log configuration + fix validator

parent 7e69065f
......@@ -4,13 +4,17 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import javax.annotation.PostConstruct;
@Getter
@Setter
@ToString
@NoArgsConstructor
@ConfigurationProperties(prefix = "clea.batch.cluster")
@Slf4j
public class BatchProperties {
/**
......@@ -29,4 +33,9 @@ public class BatchProperties {
private int indexationStepChunkSize;
private int prefixesComputingStepChunkSize;
@PostConstruct
private void logConfiguration() {
log.info(this.toString());
}
}
package fr.gouv.clea.scoring.configuration.exposure;
import fr.gouv.clea.scoring.configuration.ScoringConfiguration;
import fr.gouv.clea.scoring.configuration.ScoringRule;
import fr.gouv.clea.scoring.configuration.validators.CheckDefaultRulePresence;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import fr.gouv.clea.scoring.configuration.ScoringConfiguration;
import fr.gouv.clea.scoring.configuration.ScoringRule;
import fr.gouv.clea.scoring.configuration.validators.CheckDefaultRulePresence;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Validated
@Configuration
@ConfigurationProperties(prefix="clea.conf.exposure")
@ConfigurationProperties(prefix = "clea.conf.exposure")
@ConditionalOnProperty(value = "clea.conf.exposure.enabled", havingValue = "true")
@Slf4j
public class ExposureTimeConfiguration extends ScoringConfiguration {
@Setter
......@@ -24,6 +26,11 @@ public class ExposureTimeConfiguration extends ScoringConfiguration {
@CheckDefaultRulePresence
protected List<ExposureTimeRule> rules;
@PostConstruct
private void logConfiguration() {
log.info(this.toString());
}
public List<? extends ScoringRule> getScorings() {
return rules;
}
......
package fr.gouv.clea.scoring.configuration.risk;
import fr.gouv.clea.scoring.configuration.ScoringConfiguration;
import fr.gouv.clea.scoring.configuration.ScoringRule;
import fr.gouv.clea.scoring.configuration.validators.CheckDefaultRulePresence;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import fr.gouv.clea.scoring.configuration.ScoringConfiguration;
import fr.gouv.clea.scoring.configuration.ScoringRule;
import fr.gouv.clea.scoring.configuration.validators.CheckDefaultRulePresence;
import javax.annotation.PostConstruct;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Validated
@Configuration
@ConfigurationProperties(prefix="clea.conf.risk")
@ConfigurationProperties(prefix = "clea.conf.risk")
@ConditionalOnProperty(value = "clea.conf.risk.enabled", havingValue = "true")
@Slf4j
public class RiskConfiguration extends ScoringConfiguration {
@Setter
......@@ -24,6 +26,11 @@ public class RiskConfiguration extends ScoringConfiguration {
@CheckDefaultRulePresence
protected List<RiskRule> rules;
@PostConstruct
private void logConfiguration() {
log.info(this.toString());
}
public List<? extends ScoringRule> getScorings() {
return rules;
}
......
package fr.gouv.clea.scoring.configuration.validators;
import fr.gouv.clea.scoring.configuration.ScoringRule;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import fr.gouv.clea.scoring.configuration.ScoringRule;
public class VenueTypeValidator implements ConstraintValidator<ValidateWildcards, Object> {
@Override
......@@ -19,9 +19,7 @@ public class VenueTypeValidator implements ConstraintValidator<ValidateWildcards
}
private boolean venueTypeIsNotWildcarded(ScoringRule scoringRule) {
return scoringRule.getVenueType() != ScoringRule.WILDCARD_VALUE ||
(scoringRule.getVenueCategory1() != ScoringRule.WILDCARD_VALUE &&
scoringRule.getVenueCategory2() != ScoringRule.WILDCARD_VALUE);
return scoringRule.getVenueType() != ScoringRule.WILDCARD_VALUE;
}
private boolean allFieldsAreWildcards(ScoringRule scoringRule) {
......
package fr.gouv.clea.consumer.configuration;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Positive;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.annotation.PostConstruct;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Positive;
@Data
@NoArgsConstructor
......@@ -22,6 +23,7 @@ import lombok.NoArgsConstructor;
@RefreshScope
@Configuration
@ConfigurationProperties(prefix = "clea.conf")
@Slf4j
public class VenueConsumerConfiguration {
@Min(value = 600)
private long durationUnitInSeconds;
......@@ -34,4 +36,9 @@ public class VenueConsumerConfiguration {
@Min(value = 10)
@Max(value = 30)
private int retentionDurationInDays;
@PostConstruct
private void logConfiguration() {
log.info(this.toString());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment