<%-- 
    Document   : validationResultOnly
    Created on : 18.11.2017, 16:33:31
    Author     : themi
--%>
<%@page import="cz.csu.sdmx.validation.model.LogicCondition"%>
<%@page import="cz.csu.sdmx.Utils"%>
<%@ page import="cz.csu.sdmx.constants.URL"%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <c:if test="${validationResult ne null}" >
        <div class="well">
            <h4>Filename: ${validationResult.dataFilename}</h4>
            <h4>DSD detected: ${validationResult.dsds}</h4>
            <h4>Validation date: ${validationResult.date}</h4>
        </div>
        <c:if test="${conditions ne null}" >
            <ul class="nav nav-tabs">
            <c:forEach var="condition" items="${conditions}" varStatus = "status">
                <li <c:if test="${status.first}">class="active"</c:if>><a data-toggle="tab" href="#c${condition.id}">${condition.id}</a></li>
            </c:forEach>    
            </ul>

            <div class="tab-content">
            <c:forEach var="condition" items="${conditions}" varStatus = "status">
                <div id="c${condition.id}" class="tab-pane fade <c:if test="${status.first}">in active</c:if>">
                    <table class="tableList col-lg-12">
                    <tr><th class="col-lg-4">Condition</th><th class="col-lg-2">Obs attr value name</th><th class="col-lg-6">Common dimensions</th></tr>
                        <tr>
                            <td><c:out value="${condition.expression}"/></td>
                            <td><c:out value="${condition.obsValAttrName}"/></td>
                            <td><% 
                                LogicCondition lc = (LogicCondition)pageContext.getAttribute("condition");
                                String joined = Utils.join(lc.getCommonDimensions() , ",");
                                out.print(joined);
                                %></td>
                        </tr>
                    </table>
                </div>
            </c:forEach>    
            </div>
        </c:if>
        <h2>Errors</h2>      
        <table class="table table-striped">
            <thead>
                <tr>
                  <th>Level</th>
                  <th>File</th>
                  <th>ErrorCode</th>
                  <th>Text</th>
                  <th>Line number</th>
                </tr>
            </thead>
            <c:forEach var="error" items="${validationResult.errors}">
                <tr>
                  <td>${error.type}</td>
                  <td>${error.filename}</td>
                  <td>${error.errorCode}</td>
                  <td>${error.text}</td>
                  <td>${error.lineNumber}</td>
                </tr>     
            </c:forEach> 
        </table>
        <c:if test="${validationResult.errorCount == 0}" >
            <div class="well">
                Validation found no errors.
            </div>
        </c:if>
    </c:if>
