| 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 "CFlattenedObjectPropertySourcesQuery.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Query { |
| 29 |
|
| 30 |
|
| 31 |
CFlattenedObjectPropertySourcesQuery::CFlattenedObjectPropertySourcesQuery(CConcreteOntology* ontology, CConfigurationBase* configuration, const CIndividualReference& individualReference, const QString& individualName, CRole* role, const QString& objectPropertyTargetQueryName) |
| 32 |
: CRealizationPremisingQuery(ontology,configuration) { |
| 33 |
mIndividualReference = individualReference; |
| 34 |
mRole = role; |
| 35 |
|
| 36 |
mIndividualName = individualName; |
| 37 |
mRoleName = CIRIName::getRecentIRIName(role->getPropertyNameLinker()); |
| 38 |
|
| 39 |
queryName = objectPropertyTargetQueryName; |
| 40 |
if (queryName.isEmpty()) { |
| 41 |
if (!mIndividualName.isEmpty() && !mRoleName.isEmpty()) { |
| 42 |
queryString = QString("Get Flattened Object Property Sources"); |
| 43 |
} else { |
| 44 |
queryString = QString("Get Flattened Object Property Sources for Individual '%1'").arg(mIndividualName); |
| 45 |
} |
| 46 |
} |
| 47 |
mResult = nullptr; |
| 48 |
|
| 49 |
mUseAbbreviatedIRIs = CConfigDataReader::readConfigBoolean(configuration, "Konclude.OWLlink.AbbreviatedIRIs", false); |
| 50 |
mAnonymousIndividuals = CConfigDataReader::readConfigBoolean(configuration, "Konclude.OWLlink.ResultAnonymousIndividualsIntegration", false); |
| 51 |
|
| 52 |
mRealizationCalcError = false; |
| 53 |
mQueryConstructError = false; |
| 54 |
|
| 55 |
mRequiresRoleRealisation = true; |
| 56 |
mRequiresSameIndividualRealisation = true; |
| 57 |
mDynamicRealisation = true; |
| 58 |
|
| 59 |
mCalcConfig = configuration; |
| 60 |
} |
| 61 |
|
| 62 |
CFlattenedObjectPropertySourcesQuery::~CFlattenedObjectPropertySourcesQuery() { |
| 63 |
if (mResult) { |
| 64 |
delete mResult; |
| 65 |
} |
| 66 |
delete mCalcConfig; |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
CQueryResult* CFlattenedObjectPropertySourcesQuery::getQueryResult() { |
| 71 |
return mResult; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
CQueryResult *CFlattenedObjectPropertySourcesQuery::constructResult(CRealization* realization) { |
| 76 |
return constructIndividualsResult(realization); |
| 77 |
} |
| 78 |
|
| 79 |
CIndividualsResult *CFlattenedObjectPropertySourcesQuery::constructIndividualsResult(CRealization* realization) { |
| 80 |
if (mResult) { |
| 81 |
delete mResult; |
| 82 |
mResult = 0; |
| 83 |
} |
| 84 |
if (realization) { |
| 85 |
CRoleRealization* roleRealization = realization->getRoleRealization(); |
| 86 |
if (roleRealization) { |
| 87 |
mResult = new CIndividualsResult(); |
| 88 |
CIndividualsResultVisitorGenerator resultGenerator(mResult,mUseAbbreviatedIRIs, mAnonymousIndividuals, mOntology->getIndividualNameResolver()); |
| 89 |
roleRealization->visitSourceIndividuals(mIndividualReference,mRole,&resultGenerator); |
| 90 |
} |
| 91 |
} |
| 92 |
return mResult; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
QString CFlattenedObjectPropertySourcesQuery::getQueryName() { |
| 97 |
return queryName; |
| 98 |
} |
| 99 |
|
| 100 |
QString CFlattenedObjectPropertySourcesQuery::getQueryString() { |
| 101 |
return queryString; |
| 102 |
} |
| 103 |
|
| 104 |
bool CFlattenedObjectPropertySourcesQuery::hasAnswer() { |
| 105 |
return mResult != 0; |
| 106 |
} |
| 107 |
|
| 108 |
QString CFlattenedObjectPropertySourcesQuery::getAnswerString() { |
| 109 |
if (!mResult) { |
| 110 |
return QString("Unknown Individuals"); |
| 111 |
} else { |
| 112 |
return mResult->getQueryResultString(); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
bool CFlattenedObjectPropertySourcesQuery::hasError() { |
| 117 |
return mRealizationCalcError || mQueryConstructError || CQuery::hasError(); |
| 118 |
} |
| 119 |
|
| 120 |
COntologyProcessingDynamicRealizationRequirement* CFlattenedObjectPropertySourcesQuery::getDynamicRealizationRequirement() { |
| 121 |
return new COntologyProcessingRoleRealizationRequirement(mRole, true, mIndividualReference); |
| 122 |
} |
| 123 |
|
| 124 |
}; // end namespace Query |
| 125 |
|
| 126 |
}; // end namespace Reasoner |
| 127 |
|
| 128 |
}; // end namespace Konclude |