main.rqg 3.55 KB
Newer Older
Maxime Lefrançois's avatar
Maxime Lefrançois committed
PREFIX st:   <http://ns.inria.fr/sparql-template/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX fun: <http://w3id.org/sparql-generate/fn/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX iter: <http://w3id.org/sparql-generate/iter/>
PREFIX fun:  <http://w3id.org/sparql-generate/fn/>

 
TEMPLATE <report/main.rqg>( ?testsuites ) { 

  TEMPLATE <header.rqg>( "SAREF pipeline report", "static" , false ).

""" 
  <header id="g-header">
    <div class="g-container">
      <div class="g-block size-100">
        <div class="g-content g-particle">
          <h1><a id="user-content-smart-applications-reference-ontology-and-extensions" class="anchor" href="#smart-applications-reference-ontology-and-extensions" aria-hidden="true"><span aria-hidden="true"
                class="octicon octicon-link"></span></a>SAREF Pipeline report { fun:XPath( ?testsuites, "/testsuites/@name") }</h1>
          <p>There are <span class="alert-danger">{ fun:XPath( ?testsuites, "/testsuites/@errors") } errors</span> and <span class="alert-warning">{ fun:XPath( ?testsuites, "/testsuites/@failures") } warnings</span></p>
        </div>
      </div>
    </div>
  </header>   
  <section id="introduction" class="g-wrapper">
    <div class="g-container">
"""      

TEMPLATE {
  "<div>" BOX { 
    """<h2>{ fun:markdownToHTML( fun:XPath( ?testsuite , "/testsuite/@name" ) ) }</h2><details><summary>There are <span class="alert-danger">{ fun:XPath( ?testsuite, "/testsuite/@errors") } errors</span> and <span class="alert-warning">{ fun:XPath( ?testsuite, "/testsuite/@failures") } warnings</span></summary>"""


    TEMPLATE {
    """<div class="alert { ?class }">
      <p>{ fun:markdownToHTML( fun:XPath(?testcase, "/testcase/@name") ) }</p>
      { TEMPLATE { 
          fun:markdownToHTML( "Failure: { fun:XPath( ?failure, "/failure/@type" )} - {fun:XPath( ?failure, "/failure/@message" )}" ) 
        } WHERE { BIND( fun:XPath(?testcase, "/testcase/failure") AS ?failure ) } . 
      }
      { TEMPLATE { 
          fun:markdownToHTML( "Error: { fun:XPath( ?error, "/error/@type" )} - {fun:XPath( ?error, "/error/@message" )}" ) 
        }
        WHERE { BIND( fun:XPath(?testcase, "/testcase/error") AS ?error ) } . 
      }
      { TEMPLATE {
        "<details><summary>See error details:</summary><pre>{ ?output }</pre></details>"
        } WHERE { BIND( fun:XPath(?testcase, "/testcase/system-err" ) AS ?output ) } .
      }
      { TEMPLATE {
        "<details><summary>See output details:</summary><pre>{ ?output }</pre></details>"
        } WHERE { BIND( fun:XPath(?testcase, "/testcase/system-out" ) AS ?output ) } .
      }
    </div>"""
    } ITERATOR iter:XPath( ?testsuite , "/testsuite/testcase")  AS ?testcase ?pos
Maxime Lefrançois's avatar
Maxime Lefrançois committed
    WHERE {
      VALUES ( ?status ?class ?priority ) {
       ("success" "alert-success" 1)
       ("warning" "alert-warning" 1)
       ("failure" "alert-warning" 1)
       ("error" "alert-danger" 2 )
       ("unknown" "alert-dark" 1 ) }
Maxime Lefrançois's avatar
Maxime Lefrançois committed
       FILTER( str(fun:XPath (?testcase , "/testcase/@status" )) = ?status )
    } ORDER BY ?pos .
Maxime Lefrançois's avatar
Maxime Lefrançois committed
  } "</details></div>\n" 
} ITERATOR iter:XPath( ?testsuites , "/testsuites/testsuite")  AS ?testsuite .

"""
    </div>
</section>
"""

  TEMPLATE <footer.rqg>( "static", false ) .

}
WHERE {
}