Search in sources :

Example 1 with ConfigurationKey

use of org.hisp.dhis.external.conf.ConfigurationKey in project dhis2-core by dhis2.

the class AuditMatrixConfigurer method configure.

public Map<AuditScope, Map<AuditType, Boolean>> configure() {
    Map<AuditScope, Map<AuditType, Boolean>> matrix = new HashMap<>();
    for (AuditScope value : AuditScope.values()) {
        Optional<ConfigurationKey> confKey = ConfigurationKey.getByKey(PROPERTY_PREFIX + value.name().toLowerCase());
        if (confKey.isPresent() && !StringUtils.isEmpty(config.getProperty(confKey.get()))) {
            String[] configuredTypes = config.getProperty(confKey.get()).split(AUDIT_TYPE_STRING_SEPAR);
            Map<AuditType, Boolean> matrixAuditTypes = new HashMap<>();
            for (AuditType auditType : AuditType.values()) {
                matrixAuditTypes.put(auditType, ArrayUtils.contains(configuredTypes, auditType.name()));
            }
            matrix.put(value, matrixAuditTypes);
        } else {
            matrix.put(value, DEFAULT_AUDIT_CONFIGURATION);
        }
    }
    return matrix;
}
Also used : ConfigurationKey(org.hisp.dhis.external.conf.ConfigurationKey) HashMap(java.util.HashMap) AuditType(org.hisp.dhis.audit.AuditType) AuditScope(org.hisp.dhis.audit.AuditScope) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ConfigurationKey

use of org.hisp.dhis.external.conf.ConfigurationKey in project dhis2-core by dhis2.

the class MetricsEnabler method matches.

@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
    ConfigurationKey key = getConfigKey();
    boolean isEnabled = !isTestRun(conditionContext) && getBooleanValue(getConfigKey());
    log.info(String.format("Monitoring metric for key %s is %s", key.getKey(), isEnabled ? "enabled" : "disabled"));
    return isEnabled;
}
Also used : ConfigurationKey(org.hisp.dhis.external.conf.ConfigurationKey)

Aggregations

ConfigurationKey (org.hisp.dhis.external.conf.ConfigurationKey)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AuditScope (org.hisp.dhis.audit.AuditScope)1 AuditType (org.hisp.dhis.audit.AuditType)1