Debian Codegraph @

Source/Test/COWLFileOWLlinkConsistencyRequestGenerator.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "COWLFileOWLlinkConsistencyRequestGenerator.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28
29
30 COWLFileOWLlinkConsistencyRequestGenerator::COWLFileOWLlinkConsistencyRequestGenerator(CConfiguration *config)
31 : CLogIdentifier("::Konclude::Test::OWLFileOWLlinkClassifyRequestGenerator",this),mConfig(config) {
32
33
34 mReasonerTestKBName = "http://www.konclude.com/evaluation-testsuite/test-ontology";
35 }
36
37
38 COWLFileOWLlinkConsistencyRequestGenerator::~COWLFileOWLlinkConsistencyRequestGenerator() {
39 }
40
41
42
43 QDomDocument COWLFileOWLlinkConsistencyRequestGenerator::createRequestDocument() {
44 QDomDocument document;
45
46 QString owllinkNS = "http://www.owllink.org/owllink#";
47 QString owlNS = "http://www.w3.org/2002/07/owl#";
48
49 QDomElement rootNode;
50
51 rootNode = document.createElementNS(owllinkNS,"RequestMessage");
52 //rootNode.setAttributeNS("xsi:schemaLocation","http://www.owllink.org/owllink# http://www.owllink.org/owllink-20091116.xsd");
53 rootNode.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance","xsi:schemaLocation","http://www.owllink.org/owllink# http://www.owllink.org/owllink-20091116.xsd");
54 rootNode.setAttribute("xmlns:owl",owlNS);
55 document.appendChild(rootNode);
56
57 return document;
58 }
59
60
61 bool COWLFileOWLlinkConsistencyRequestGenerator::generateOWLlinkConsistencyRequest(const QString& requestFileName, const QString& responseFileName) {
62
63 QDomDocument requestDocument = createRequestDocument();
64 QDomElement rootElement = requestDocument.documentElement();
65
66 QDomElement cKBElement = requestDocument.createElement("CreateKB");
67 cKBElement.setAttribute("kb",mReasonerTestKBName);
68 rootElement.appendChild(cKBElement);
69
70 QDomElement loadElement = requestDocument.createElement("LoadOntologies");
71 loadElement.setAttribute("kb",mReasonerTestKBName);
72 QDomElement ontoIRIElement = requestDocument.createElement("OntologyIRI");
73 ontoIRIElement.setAttribute("IRI",QString("file:%1").arg(requestFileName));
74 loadElement.appendChild(ontoIRIElement);
75 rootElement.appendChild(loadElement);
76
77 QDomElement getSubClassHirElement = requestDocument.createElement("IsKBSatisfiable");
78 getSubClassHirElement.setAttribute("kb",mReasonerTestKBName);
79 rootElement.appendChild(getSubClassHirElement);
80
81 QDomElement releaseKBElement = requestDocument.createElement("ReleaseKB");
82 releaseKBElement.setAttribute("kb",mReasonerTestKBName);
83 rootElement.appendChild(releaseKBElement);
84
85 QFile outFile(responseFileName);
86 if (outFile.open(QIODevice::WriteOnly)) {
87 outFile.write(requestDocument.toByteArray());
88 outFile.close();
89 }
90
91 LOG(INFO,getLogDomain(),logTr("Generated OWLlink consistency request '%1' for ontology '%2'.").arg(responseFileName).arg(requestFileName),this);
92
93 return false;
94 }
95
96
97 }; // end namespace Test
98
99 }; // end namespace Konclude