Debian Codegraph @

Source/Reasoner/Query/CFlattenedTypesQuery.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 "CFlattenedTypesQuery.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Query {
29
30
31 CFlattenedTypesQuery::CFlattenedTypesQuery(CConcreteOntology* ontology, CConfigurationBase* configuration, const CIndividualReference& indi, bool direct, const QString& individualName, const QString& flatternedTypeQueryName)
32 : CRealizationPremisingQuery(ontology,configuration) {
33 mIndividualName = individualName;
34 mIndividual = indi;
35 queryName = flatternedTypeQueryName;
36 if (mIndividualName.isEmpty()) {
37 queryString = QString("Get Flattened Types");
38 } else {
39 queryString = QString("Get Flattened Types for individual '%1'").arg(mIndividualName);
40 }
41 mResult = nullptr;
42
43 mUseAbbreviatedIRIs = CConfigDataReader::readConfigBoolean(configuration,"Konclude.OWLlink.AbbreviatedIRIs",false);
44
45 mRealizationCalcError = false;
46 mQueryConstructError = false;
47 mDirect = direct;
48 mCalcConfig = configuration;
49
50 mRequiresConceptRealisation = true;
51 mRequiresSameIndividualRealisation = true;
52 mDynamicRealisation = true;
53
54
55 }
56
57 CFlattenedTypesQuery::~CFlattenedTypesQuery() {
58 if (mResult) {
59 delete mResult;
60 }
61 delete mCalcConfig;
62 }
63
64
65 CQueryResult* CFlattenedTypesQuery::getQueryResult() {
66 return mResult;
67 }
68
69
70 CQueryResult *CFlattenedTypesQuery::constructResult(CRealization* realization) {
71 return constructClassesResult(realization);
72 }
73
74 CClassesResult *CFlattenedTypesQuery::constructClassesResult(CRealization* realization) {
75 if (mResult) {
76 delete mResult;
77 mResult = 0;
78 }
79 if (realization) {
80 CConceptRealization* conRealization = realization->getConceptRealization();
81 if (conRealization) {
82 mResult = new CClassesResult();
83 CClassesResultVisitorGenerator resultGenerator(mResult,mUseAbbreviatedIRIs);
84 conRealization->visitTypes(mIndividual,mDirect,&resultGenerator);
85 }
86 }
87 return mResult;
88 }
89
90
91 QString CFlattenedTypesQuery::getQueryName() {
92 return queryName;
93 }
94
95 QString CFlattenedTypesQuery::getQueryString() {
96 return queryString;
97 }
98
99 bool CFlattenedTypesQuery::hasAnswer() {
100 return mResult != 0;
101 }
102
103 QString CFlattenedTypesQuery::getAnswerString() {
104 if (!mResult) {
105 return QString("Unknown Classes");
106 } else {
107 return mResult->getQueryResultString();
108 }
109 }
110
111 bool CFlattenedTypesQuery::hasError() {
112 return mRealizationCalcError || mQueryConstructError || CQuery::hasError();
113 }
114
115 bool CFlattenedTypesQuery::isDirect() {
116 return mDirect;
117 }
118
119
120 COntologyProcessingDynamicRealizationRequirement* CFlattenedTypesQuery::getDynamicRealizationRequirement() {
121 return new COntologyProcessingConceptRealizationRequirement(mIndividual, (CConcept*)nullptr);
122 }
123
124
125 }; // end namespace Query
126
127 }; // end namespace Reasoner
128
129 }; // end namespace Konclude