Commit aee48592 authored by Salva5297's avatar Salva5297

Solved problems with OOPS

parent 147bc843
......@@ -26,6 +26,8 @@
package fr.emse.gitlab.saref.checkers;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
......@@ -129,9 +131,10 @@ public class Clause_9_4_5_Checker extends AbstractClauseChecker {
onto = out.toString().replaceAll("]]", "] ]");
String xmlRequest = "<?xml version='1.0' encoding='UTF-8'?>" + "<OOPSRequest>" + "<OntologyURI></OntologyURI>"
+ "<OntologyContent><![CDATA[" + onto + "]]></OntologyContent>" + "<Pitfalls>10</Pitfalls>"
+ "<OntologyContent><![CDATA[" + onto + "]]></OntologyContent>" + "<Pitfalls></Pitfalls>"
+ "<OutputFormat>RDF/XML</OutputFormat>" + "</OOPSRequest>";
Object[] arrayData = new Object[0];
try {
......@@ -153,13 +156,12 @@ public class Clause_9_4_5_Checker extends AbstractClauseChecker {
String result = response.body().string();
String[] results = result.split("\\n");
System.out.println(result);
List<String> pureData = new ArrayList<String>();
for (int i = 0; i < results.length; i++) {
if (results[i].startsWith("<")) {
for (int j = i; j < results.length; j++) {
pureData.add(results[j]);
}
}
pureData.add(results[i]);
}
arrayData = pureData.toArray(); // response into array
......@@ -174,10 +176,12 @@ public class Clause_9_4_5_Checker extends AbstractClauseChecker {
int s = 0;
System.out.println( result.get(3));
ArrayList<String> results = new ArrayList<String>();
while (s < count) {
String data = result.get(0).get(s) + result.get(1).get(s) + result.get(2).get(s);
String data = result.get(0).get(s).concat("-") + result.get(1).get(s).concat(".") + result.get(2).get(s) + "Affected Elements: " + result.get(3).get(s);
results.add(data);
s++;
}
......
......@@ -25,11 +25,7 @@
*/
package fr.emse.gitlab.saref.checkers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.PathMatcher;
......@@ -64,7 +60,7 @@ import okhttp3.Response;
/**
* Checks TS 103 673 Clause 9.5: Ontology tests
*
*
*/
public class Clause_9_5_Checker extends AbstractClauseChecker {
......@@ -100,9 +96,9 @@ public class Clause_9_5_Checker extends AbstractClauseChecker {
logError(getMessage(MESSAGE.line));
return;
}
testsRDFaGenerator();
readTests();
callThemis();
testsRDFaGenerator();
} catch (IOException ex) {
logError(getMessage(MESSAGE.ioexception));
}
......@@ -140,16 +136,19 @@ public class Clause_9_5_Checker extends AbstractClauseChecker {
StringWriter requirementsRDFXML = new StringWriter();
version.getRequirements().write(requirementsRDFXML);
OkHttpClient httpClient = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
String jsonRequest = "{\"ontologiesCode\":[\""
+ versionRDFXML.toString().replaceAll("\\\"", "\\\\\"").replaceAll("\"", "\\\"").replaceAll("\t", " ")
+ "\"]," + "\"testfile\":[\"" + requirementsRDFXML.toString().replaceAll("\\\"", "\\\\\"")
.replaceAll("\"", "\\\"").replaceAll("\t", " ")
+ versionRDFXML.toString().replace("\\\"", "\\\\\"").replace("\"", "\\\"").replace("\t", " ")
+ "\"]," + "\"testfile\":[\"" + requirementsRDFXML.toString().replace("\\\"", "\\\\\"")
.replace("\"", "\\\"").replace("\t", " ")
+ "\"]," + "\"format\":\"junit\"}";
RequestBody body = RequestBody.create(jsonRequest, mediaType);
Request request = new Request.Builder().url("http://themis.linkeddata.es/rest/api/results").method("POST", body)
.addHeader("accept", "application/json").addHeader("Content-Type", "application/json").build();
try {
Response response = httpClient.newCall(request).execute();
if (response.code() != 200) {
......
......@@ -33,13 +33,20 @@ public class OopsManager {
ArrayList<String> getID = new ArrayList<String>();
ArrayList<String> getName = new ArrayList<String>();
ArrayList<String> getInfo = new ArrayList<String>();
ArrayList<String> affectedElements = new ArrayList<String>();
ArrayList<ArrayList<String>> elements = new ArrayList<ArrayList<String>>();
elements.add(getID);
elements.add(getName);
elements.add(getInfo);
elements.add(affectedElements);
String affected = "";
for (int i = 0; i < data.length; i++) {
String data2 = data[i].toString().replaceAll(" ", "");
if (data2.startsWith("<oops:hasCode")) {
String[] data3 = data2.split("(<|>)");
getID.add(data3[2]);
......@@ -53,6 +60,30 @@ public class OopsManager {
getInfo.add(data3[2]);
elements.set(2, getInfo);
}
if (i>0 && i < data.length-1) {
String prove = data[i - 1].toString().replaceAll(" ", "");
String prove2 = data[i + 1].toString().replaceAll(" ", "");
if (data2.startsWith("<oops:hasAffectedElement")) {
if (!prove.startsWith("<oops:hasAffectedElement")) {
String[] data3 = data2.split("(<|>)");
affected += data3[2];
}
else if (!prove2.startsWith("<oops:hasAffectedElement")){
String[] data3 = data2.split("(<|>)");
affected += ", " + data3[2];
affectedElements.add(affected);
elements.set(3, affectedElements);
affected = "";
}
else{
String[] data3 = data2.split("(<|>)");
affected += ", " + data3[2];
}
}
}
}
return elements;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment