Debian Codegraph @

Source/Reasoner/Query/CEquivalentClassesQuery.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 "CEquivalentClassesQuery.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Query {
29
30
31 CEquivalentClassesQuery::CEquivalentClassesQuery(CConcreteOntology* ontology, CConfigurationBase* configuration, CConcept* concept, const QString& className, const QString& queryName)
32 : CTaxonomyPremisingQuery(ontology,configuration) {
33 mClassName = className;
34 mConcept = concept;
35 mQueryName = queryName;
36 if (mClassName.isEmpty()) {
37 mQueryString = QString("Get Equivalent Classes");
38 } else {
39 mQueryString = QString("Get Equivalent Classes for concept '%1'").arg(mClassName);
40 }
41 mResult = nullptr;
42
43 mUseAbbreviatedIRIs = CConfigDataReader::readConfigBoolean(configuration,"Konclude.OWLlink.AbbreviatedIRIs",false);
44
45 mTaxonomyCalcError = false;
46 mQueryConstructError = false;
47
48 mCalcConfig = configuration;
49 }
50
51 CEquivalentClassesQuery::~CEquivalentClassesQuery() {
52 if (mResult) {
53 delete mResult;
54 }
55 delete mCalcConfig;
56 }
57
58
59 CQueryResult* CEquivalentClassesQuery::getQueryResult() {
60 return mResult;
61 }
62
63
64 CQueryResult *CEquivalentClassesQuery::constructResult(CTaxonomy *taxonomy) {
65 return constructClassesResult(taxonomy);
66 }
67
68 CClassSetResult *CEquivalentClassesQuery::constructClassesResult(CTaxonomy *taxonomy) {
69 if (mResult) {
70 delete mResult;
71 mResult = 0;
72 }
73 if (taxonomy) {
74 CHierarchyNode* node = taxonomy->getHierarchyNode(mConcept);
75 if (node) {
76 mResult = new CClassSetResult();
77 foreach (const QString& className, node->getEquivalentConceptStringList(mUseAbbreviatedIRIs)) {
78 mResult->addClass(className);
79 }
80 }
81 }
82 return mResult;
83 }
84
85
86 QString CEquivalentClassesQuery::getQueryName() {
87 return mQueryName;
88 }
89
90 QString CEquivalentClassesQuery::getQueryString() {
91 return mQueryString;
92 }
93
94 bool CEquivalentClassesQuery::hasAnswer() {
95 return mResult != 0;
96 }
97
98 QString CEquivalentClassesQuery::getAnswerString() {
99 if (!mResult) {
100 return QString("Unknown Classes");
101 } else {
102 return mResult->getQueryResultString();
103 }
104 }
105
106 bool CEquivalentClassesQuery::hasError() {
107 return mTaxonomyCalcError || mQueryConstructError || CQuery::hasError();
108 }
109
110 }; // end namespace Query
111
112 }; // end namespace Reasoner
113
114 }; // end namespace Konclude