All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui.common.violaton.ftl Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
<#macro valueMacro placeholderName placeholders>
<#-- @ftlvariable name="placeholders" type="java.util.Map" -->
    <#assign placeholder = placeholders[placeholderName]><#t>
    <#t>
    <#assign valueRaw><#t>
        <#if !(placeholder.value??)><#t>
            null<#t>
        <#elseif placeholder.value?is_string><#t>
            ${placeholder.value}<#t>
        <#elseif placeholder.value?is_sequence><#t>
            [${placeholder.value?join(", ")}]<#t>
        <#else><#t>
            ${placeholder.value?c}<#t>
        <#t>
    <#t>${valueRaw}<#t>
    <#t>


<#macro richMessage message placeholders>
<#-- @ftlvariable name="message" type="java.lang.String" -->
<#-- @ftlvariable name="placeholders" type="java.util.Map" -->
    <#assign messageTemplate = message?replace(
    "%(\\w+)%",
    "<@valueMacro placeholderName='$1' placeholders=placeholders/>",
    "r"
    )?interpret placeholders = placeholders>
    <@messageTemplate/>


<#function severityClass severity>
    <#switch severity>
        <#case "NONE">
            <#return "badge-success">
        <#case "MINOR">
            <#return "badge-info">
        <#case "WARNING">
            <#return "badge-warning">
        <#case "CRITICAL">
        <#case "ERROR">
            <#return "badge-danger">
        <#default>
            <#return "badge-secondary">
    


<#macro interpretMessage violation>
<#-- @ftlvariable name="violation" type="com.infobip.kafkistry.service.RuleViolation" -->
    <#assign ruleSimpleName = violation.ruleClassName?substring(violation.ruleClassName?last_index_of(".") + 1)>
    Rule: ${ruleSimpleName}
Severity: ${violation.severity}
Message: <@richMessage message=violation.message placeholders = violation.placeholders/>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy