Skip to content
Snippets Groups Projects
Commit 9bc6d909 authored by Maxime Lefrançois's avatar Maxime Lefrançois
Browse files

updated report output management, HTTP POST

parent c06a8ba6
No related branches found
No related tags found
No related merge requests found
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
nbactions.xml nbactions.xml
.classpath .classpath
.settings .settings
bin/
\ No newline at end of file
...@@ -88,6 +88,11 @@ ...@@ -88,6 +88,11 @@
<dependency>
<groupId>com.atlassian.commonmark</groupId>
<artifactId>commonmark</artifactId>
<version>0.14.0</version>
</dependency>
</dependencies> </dependencies>
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testsuite name="Report for commit af93d289 of SAREF4EHAW">
<testcase name="The directory structure is conformant to TS 103 673 Clause x" status="success">
</testcase>
<testcase name="The syntax of `ontology/saref4ehaw.ttl` is correct" status="success">
</testcase>
<testcase name="The ontology lack the dcterms:abstract metadata. The documentation will be incomplete" status="warning">
<info>See http://saref.etsi.org/guidelines.html#dcterms:abstract for guidelines.</info>
</testcase>
<testcase name="The term `s4ehaw:BAN` does not have a label and a comment. The documentation will be incomplete" status="warning">
<info>See [http://saref.etsi.org/guidelines.html#terms](http://saref.etsi.org/guidelines.html#terms) for guidelines.</info>
</testcase>
<testcase name="The term `s4ehaw:faultTolerence` does not have a label and a comment. The documentation will be incomplete" status="warning">
<info>See http://saref.etsi.org/guidelines.html#terms for guidelines.</info>
</testcase>
<testcase name="Ontology pitfall #P06: Including cycles in a class hierarchy" status="danger">
<info>See [http://oops.linkeddata.es/catalogue.jsp](http://oops.linkeddata.es/catalogue.jsp)</info>
</testcase>
<testcase name="The syntax of `example/myFakeExample.ttl` is incorrect" status="danger">
<info>Line 4 column 35, Prefix `:` is not defined</info>
</testcase>
<testcase name="In `example/myFakeExample2.ttl` is incorrect" status="warning">
<info>Term `saref:Sansor` does not exist in the SAREF ontology</info>
</testcase>
<testcase name="Errors while generating the documentation" status="danger">
<info>Query https://saref.etsi.org/documentation/function/processLines.rqg could not be found</info>
<systemErr>25:16,361 main TRACE fr.emse.ci.sparqlext.SPARQLExt:141 - initializing SPARQLGenerate
25:16,550 main DEBUG Jena:212 - Jena initialization
25:17,413 main INFO fr.emse.ci.sparqlext.engine.RootPlan:386 - Starting execution
25:17,428 main INFO fr.emse.ci.sparqlext.engine.QueryExecutor:86 - Loading https://saref.etsi.org/documentation/ontology/main.rqg
25:17,916 main INFO fr.emse.ci.sparqlext.engine.QueryExecutor:86 - Loading https://saref.etsi.org/documentation/header.rqg
25:18,009 main INFO fr.emse.ci.sparqlext.function.SPARQLExtFunctionRegistry:121 - attempting load https://saref.etsi.org/documentation/function/href.rqg
25:18,070 main INFO fr.emse.ci.sparqlext.engine.QueryExecutor:86 - Loading https://saref.etsi.org/documentation/function/formatText.rqg
25:18,105 main INFO fr.emse.ci.sparqlext.function.SPARQLExtFunctionRegistry:121 - attempting load https://saref.etsi.org/documentation/function/processLines.rqg
25:18,115 main ERROR fr.emse.ci.sparqlext.function.SPARQLExtFunctionRegistry:121 - Query https://saref.etsi.org/documentation/function/processLines.rqg could not be found</systemErr>
</testcase>
<testcase name="Fake test" status="soldnfbslpegb">
<info>Fake test</info>
</testcase>
</testsuite>
...@@ -7,17 +7,24 @@ import javax.xml.bind.annotation.XmlAttribute; ...@@ -7,17 +7,24 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.apache.jena.sparql.expr.nodevalue.NodeValueString;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
/** /**
* @author Omar Qawasmeh * @author Omar Qawasmeh
* *
* *
*/ */
@XmlRootElement(name = "testcase") @XmlRootElement(name = "testcase")
@XmlType(propOrder = { "systemErr", "systemOut", "info" }) @XmlType(propOrder = { "systemErr", "systemOut", "info" })
public class TestCase { public class TestCase {
public enum Status {
SUCCESS, WARNING, DANGER, UNKNOWN;
}
private String name; private String name;
private String className; private String className;
...@@ -25,7 +32,7 @@ public class TestCase { ...@@ -25,7 +32,7 @@ public class TestCase {
private String systemOut; private String systemOut;
private String status; // either pass or failure private String status; // either pass or failure
private String info; private String info;
private boolean statusFlag; private Status statusObj;
/** /**
* @return the status * @return the status
...@@ -36,30 +43,49 @@ public class TestCase { ...@@ -36,30 +43,49 @@ public class TestCase {
} }
/** /**
* @param status the status to set * @param status
* the status to set
*/ */
public void setStatus(String status) { public void setStatus(String status) {
this.status = status; this.status = status;
} }
public boolean isSuccess() {
return statusObj == Status.SUCCESS;
}
public boolean getStatusFlag() { public boolean isDanger() {
return statusFlag; return statusObj == Status.DANGER;
} }
/** public boolean isWarning() {
* @param status the status to set return statusObj == Status.WARNING;
*/ }
public void setStatusFlag(String status) {
if(status.equals("fail"))
this.statusFlag = false;
else if(status.equals("pass"))
this.statusFlag = true;
public boolean isUnknown() {
return statusObj == Status.UNKNOWN;
} }
/**
* @param status
* the status to set
*/
public void setStatusFlag(String status) {
switch (status) {
case "danger":
this.statusObj = Status.DANGER;
break;
case "success":
this.statusObj = Status.SUCCESS;
break;
case "warning":
this.statusObj = Status.WARNING;
break;
default:
this.statusObj = Status.UNKNOWN;
}
}
@XmlAttribute @XmlAttribute
public String getClassName() { public String getClassName() {
...@@ -67,16 +93,22 @@ public class TestCase { ...@@ -67,16 +93,22 @@ public class TestCase {
} }
/** /**
* @param className the className to set * @param className
* the className to set
*/ */
public void setClassName(String className) { public void setClassName(String className) {
this.className = className; this.className = className;
} }
@XmlAttribute @XmlAttribute
public String getName() { public String getName() {
return name; if(name != null) {
Parser parser = Parser.builder().build();
Node document = parser.parse(name);
HtmlRenderer renderer = HtmlRenderer.builder().build();
return renderer.render(document);
}
return null;
} }
/** /**
...@@ -87,7 +119,6 @@ public class TestCase { ...@@ -87,7 +119,6 @@ public class TestCase {
this.name = name; this.name = name;
} }
/** /**
* @return the systemErr * @return the systemErr
*/ */
...@@ -96,7 +127,8 @@ public class TestCase { ...@@ -96,7 +127,8 @@ public class TestCase {
} }
/** /**
* @param systemErr the systemErr to set * @param systemErr
* the systemErr to set
*/ */
public void setSystemErr(String systemErr) { public void setSystemErr(String systemErr) {
this.systemErr = systemErr; this.systemErr = systemErr;
...@@ -110,7 +142,8 @@ public class TestCase { ...@@ -110,7 +142,8 @@ public class TestCase {
} }
/** /**
* @param systemOut the systemOut to set * @param systemOut
* the systemOut to set
*/ */
public void setSystemOut(String systemOut) { public void setSystemOut(String systemOut) {
this.systemOut = systemOut; this.systemOut = systemOut;
...@@ -120,11 +153,18 @@ public class TestCase { ...@@ -120,11 +153,18 @@ public class TestCase {
* @return the info * @return the info
*/ */
public String getInfo() { public String getInfo() {
return info; if(info != null) {
Parser parser = Parser.builder().build();
Node document = parser.parse(info);
HtmlRenderer renderer = HtmlRenderer.builder().build();
return renderer.render(document);
}
return null;
} }
/** /**
* @param info the info to set * @param info
* the info to set
*/ */
public void setInfo(String info) { public void setInfo(String info) {
this.info = info; this.info = info;
......
...@@ -44,6 +44,7 @@ public class TestSuite implements Serializable { ...@@ -44,6 +44,7 @@ public class TestSuite implements Serializable {
private float time; private float time;
private String name; private String name;
private TestCase[] testCase; private TestCase[] testCase;
private int nbWarning=-1, nbDanger=-1;
public TestCase[] getTestcase() { public TestCase[] getTestcase() {
...@@ -62,7 +63,30 @@ public class TestSuite implements Serializable { ...@@ -62,7 +63,30 @@ public class TestSuite implements Serializable {
public void setTests(int tests) { public void setTests(int tests) {
this.tests = tests; this.tests = tests;
}
public int getNbDanger() {
if(nbDanger == -1) {
nbDanger = 0;
for (int i = 0; i < testCase.length; i++) {
if(testCase[i].isDanger()) {
nbDanger++;
};
}
}
return nbDanger;
}
public int getNbWarning() {
if(nbWarning == -1) {
nbWarning = 0;
for (int i = 0; i < testCase.length; i++) {
if(testCase[i].isWarning()) {
nbWarning++;
};
}
}
return nbWarning;
} }
@XmlAttribute @XmlAttribute
......
...@@ -7,12 +7,16 @@ import java.io.IOException; ...@@ -7,12 +7,16 @@ import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response.Status;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
...@@ -32,10 +36,8 @@ public class Report { ...@@ -32,10 +36,8 @@ public class Report {
@GET @GET
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
@Template(name = "/report") @Template(name = "/report")
public TestSuite fillReportPage(@QueryParam("q") String url) public TestSuite fillReportPage(@QueryParam("q") String url)
throws WebApplicationException, JAXBException, IOException { throws WebApplicationException, JAXBException, IOException {
// url=getRedirectedLink(url).replaceAll("https://gitlab.emse.fr/saref/", // url=getRedirectedLink(url).replaceAll("https://gitlab.emse.fr/saref/",
// "http://saref.gitlab.emse.fr/-/"); // "http://saref.gitlab.emse.fr/-/");
// url=url.replaceAll("/file/", "/"); // url=url.replaceAll("/file/", "/");
...@@ -46,37 +48,29 @@ public class Report { ...@@ -46,37 +48,29 @@ public class Report {
// To access the xml file directly // To access the xml file directly
// https://gitlab.emse.fr/saref/saref4abcd/-/jobs/artifacts/master/file/report_output.xml?job=checkshacl // https://gitlab.emse.fr/saref/saref4abcd/-/jobs/artifacts/master/file/report_output.xml?job=checkshacl
JAXBContext jaxbContext; JAXBContext jaxbContext;
jaxbContext = JAXBContext.newInstance(TestSuite.class); jaxbContext = JAXBContext.newInstance(TestSuite.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
TestSuite tstSuite = (TestSuite) jaxbUnmarshaller.unmarshal(new URL(url)); TestSuite tstSuite = (TestSuite) jaxbUnmarshaller.unmarshal(new URL(url));
// .unmarshal(new
// URL("http://saref.gitlab.emse.fr/-/saref4abcd/-/jobs/5654/artifacts/report_output.xml"));
System.out.println(tstSuite.getDisabled());
System.out.println(tstSuite.getTime());
// System.out.println(tstSuite.getTestcase());
TestCase[] tstCase = tstSuite.getTestcase(); TestCase[] tstCase = tstSuite.getTestcase();
for (int i = 0; i < tstCase.length; i++) { for (int i = 0; i < tstCase.length; i++) {
System.out.println(tstCase[i].getStatus());
tstCase[i].setStatusFlag(tstCase[i].getStatus()); tstCase[i].setStatusFlag(tstCase[i].getStatus());
}
System.out.println("Status Flag\t\t" + tstCase[i].getStatusFlag()); return tstSuite;
// System.out.println("Status\t" + tstCase[i].getStatus());
// System.out.println("Name\t" + tstCase[i].getName());
// System.out.println("System Error\t" + tstCase[i].getSystemErr());
// System.out.println("System Error\t" + tstCase[i].getSystemOut());
} }
// ReportResults reportResults= new ReportResults(); @POST
@Produces(MediaType.TEXT_HTML)
// reportResults.report="asdqwe123"; @Consumes(MediaType.APPLICATION_XML)
@Template(name = "/report")
public TestSuite fillReportPageForPost(TestSuite tstSuite)
throws WebApplicationException, JAXBException, IOException {
if(tstSuite == null) {
throw new ServerErrorException(Status.BAD_REQUEST);
}
TestCase[] tstCase = tstSuite.getTestcase();
for (int i = 0; i < tstCase.length; i++) {
tstCase[i].setStatusFlag(tstCase[i].getStatus());
}
return tstSuite; return tstSuite;
} }
......
...@@ -46,6 +46,11 @@ ...@@ -46,6 +46,11 @@
</div> </div>
</footer> </footer>
</div> </div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body> </body>
</html> </html>
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<meta name="generator" content="Ontogit" /> <meta name="generator" content="Ontogit" />
<title>SAREF - portal</title> <title>SAREF - portal</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="static/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /> <link href="static/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<link href="static/media/gantry5/assets/css/font-awesome.min.css" rel="stylesheet" /> <link href="static/media/gantry5/assets/css/font-awesome.min.css" rel="stylesheet" />
<link href="static/media/gantry5/engines/nucleus/css-compiled/nucleus.css" rel="stylesheet" /> <link href="static/media/gantry5/engines/nucleus/css-compiled/nucleus.css" rel="stylesheet" />
...@@ -18,10 +19,6 @@ ...@@ -18,10 +19,6 @@
<link href="static/media/jui/css/icomoon.css" rel="stylesheet" /> <link href="static/media/jui/css/icomoon.css" rel="stylesheet" />
<link href="static/templates/g5_helium/custom/css-compiled/helium-joomla_19.css" rel="stylesheet" /> <link href="static/templates/g5_helium/custom/css-compiled/helium-joomla_19.css" rel="stylesheet" />
<link href="static/templates/g5_helium/custom/css-compiled/custom_19.css" rel="stylesheet" /> <link href="static/templates/g5_helium/custom/css-compiled/custom_19.css" rel="stylesheet" />
<!-- <link rel="stylesheet" href="lode/primer.css" media="screen" /> -->
<link rel="stylesheet" href="lode/rec.css" media="screen" />
<!-- <link rel="stylesheet" href="lode/extra.css" media="screen" /> -->
<!-- <link rel="stylesheet" href="lode/owl.css" media="screen" /> -->
<script src="static/templates/g5_helium/js/jui/jquery.min.js?06eedc97766b70aa1fa0e80231495faa"></script> <script src="static/templates/g5_helium/js/jui/jquery.min.js?06eedc97766b70aa1fa0e80231495faa"></script>
<script src="static/media/jui/js/jquery-noconflict.js?06eedc97766b70aa1fa0e80231495faa"></script> <script src="static/media/jui/js/jquery-noconflict.js?06eedc97766b70aa1fa0e80231495faa"></script>
<script src="static/media/jui/js/jquery-migrate.min.js?06eedc97766b70aa1fa0e80231495faa"></script> <script src="static/media/jui/js/jquery-migrate.min.js?06eedc97766b70aa1fa0e80231495faa"></script>
...@@ -140,17 +137,3 @@ ...@@ -140,17 +137,3 @@
</div> </div>
</div> </div>
</section> </section>
<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>Smart Applications REFerence Ontology, and extensions</h1>
<p><strong>Official ETSI portal for SAREF</strong><br>This page contains pointers to the SAREF ontologies and SAREF-related work items</p>
<p><em><strong>Note:</strong> This portal is under construction. It was drafted in the context of <a href="https://portal.etsi.org//STF/STFs/STFHomePages/STF556" rel="nofollow">ETSI Specialist Task Force 556</a>. More effort is required
to automatize the portal content generation and deployment workflow.</em></p>
</div>
</div>
</div>
</header>
{{> header}} {{> header}}
<section id="introduction" class="g-wrapper"> <header id="g-header">
<section id="introduction" class="g-wrapper">
<div class="g-container"> <div class="g-container">
<div class="alert alert-warning" role="alert"> <div class="g-block size-100">
<h4><strong>This page is generated automatically as an output of the pipeline's report (report.xml)</strong></h4> <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>{{name}}</h1>
</div> </div>
</div> </div>
</div>
</header>
<section id="introduction" class="g-wrapper">
<div class="g-container"> <div class="g-container">
<h3> <p>There are {{nbDanger}} errors and {{nbWarning}} warnings</p>
In the pipeline {{tests}} tests were applied on your ontology:
</h3>
<table class="table">
<thead>
<tr>
<th scope="col">Test name</th>
<th scope="col">Status</th>
<th scope="col">Error</th>
<th scope="col">More information</th>
</tr>
</thead>
<tbody>
{{#testcase}} {{#testcase}}
<div class="alert {{#success}}alert-success{{/success}}{{#danger}}alert-danger{{/danger}}{{#warning}}alert-warning{{/warning}}{{#unknown}}alert-dark{{/unknown}}">
{{#statusFlag}} <p>{{{name}}}</p>
<tr> {{#info}}
<td>{{name}}</td> {{#systemErr}}
<td>{{status}}</td> <details><summary>{{{info}}}</summary><pre>{{systemErr}}</pre></details>
<td>--</td> {{/systemErr}}
<td>All is passed</td> {{^systemErr}}
</tr> <p>{{{info}}}</p>
{{/statusFlag}} {{/systemErr}}
{{/info}}
{{^statusFlag}}
<tr class="warning">
<td>{{name}}</td>
<td>{{status}}</td>
<td>{{systemErr}}</td>
<td>{{info}}</td>
</tr>
{{/statusFlag}}
</div>
</div> </div>
{{/testcase}} {{/testcase}}
</tbody>
</table>
</div> </div>
</section>
{{> footer}} {{> footer}}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment