| 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 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 21 |
|
| 22 |
#include "CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper.h" |
| 23 |
|
| 24 |
|
| 25 |
namespace Konclude { |
| 26 |
|
| 27 |
namespace Reasoner { |
| 28 |
|
| 29 |
namespace Generator { |
| 30 |
|
| 31 |
|
| 32 |
CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper(COntologyBuilder* ontologyBuilder) : CConcreteOntologyRedlandTriplesDataExpressionMapper(ontologyBuilder) { |
| 33 |
mConfExtractSimpleABoxAssertions = true; |
| 34 |
} |
| 35 |
|
| 36 |
CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::~CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper() { |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper* CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::useEntitiesVariableExpressionMapping(const QHash<QString, CBuildExpression*>& freshEntityUseVariableExpressionHash, CTriplesData* tripleData) { |
| 43 |
|
| 44 |
CRedlandStoredTriplesData* redlandTriplesData = dynamic_cast<CRedlandStoredTriplesData*>(tripleData); |
| 45 |
|
| 46 |
librdf_model* model = redlandTriplesData->getRedlandIndexedModel(); |
| 47 |
librdf_statement *partial_statement = librdf_new_statement(redlandTriplesData->getRedlandWorld()); |
| 48 |
librdf_world* world = redlandTriplesData->getRedlandWorld(); |
| 49 |
|
| 50 |
|
| 51 |
for (QHash<QString, CBuildExpression*>::const_iterator it = freshEntityUseVariableExpressionHash.constBegin(), itEnd = freshEntityUseVariableExpressionHash.constEnd(); it != itEnd; ++it) { |
| 52 |
const QString& entityString = it.key(); |
| 53 |
CBuildExpression* buildExp = it.value(); |
| 54 |
if (dynamic_cast<CClassVariableExpression*>(buildExp)) { |
| 55 |
insertEntityUsingVariableExpression(buildExp, entityString, world, mClassNodeIdentifierDataHash, mClassNodeHandlingList); |
| 56 |
} else if (dynamic_cast<CObjectPropertyVariableExpression*>(buildExp)) { |
| 57 |
insertEntityUsingVariableExpression(buildExp, entityString, world, mObjectPropertyNodeIdentifierDataHash, mObjectPropertyNodeHandlingList); |
| 58 |
} else if (dynamic_cast<CDataPropertyVariableExpression*>(buildExp)) { |
| 59 |
insertEntityUsingVariableExpression(buildExp, entityString, world, mDataPropertyNodeIdentifierDataHash, mDataPropertyNodeHandlingList); |
| 60 |
} else if (dynamic_cast<CIndividualVariableExpression*>(buildExp)) { |
| 61 |
insertEntityUsingVariableExpression(buildExp, entityString, world, mNamedIndividualNodeIdentifierDataHash, mNamedIndividualNodeHandlingList); |
| 62 |
} else if (dynamic_cast<CDataLiteralVariableExpression*>(buildExp)) { |
| 63 |
QList<CRedlandNodeProcessingData*> nodeHandlingList; |
| 64 |
insertEntityUsingVariableExpression(buildExp, entityString, world, mDataLiteralNodeIdentifierDataHash, nodeHandlingList); |
| 65 |
} |
| 66 |
} |
| 67 |
return this; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper* CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::insertEntityUsingVariableExpression(CBuildExpression* expression, const QString& entityUri, librdf_world* world, QHash<CRedlandNodeHasher, CRedlandNodeProcessingData*>& nodeIdentifierDataHash, QList<CRedlandNodeProcessingData*>& nodeHandlingList) { |
| 73 |
QByteArray uriData = entityUri.toUtf8(); |
| 74 |
librdf_uri* uri = librdf_new_uri(world, (const unsigned char*)uriData.constData()); |
| 75 |
librdf_node* classNode = librdf_new_node_from_uri(world, uri); |
| 76 |
|
| 77 |
CRedlandNodeProcessingData*& processingData = nodeIdentifierDataHash[CRedlandNodeHasher(classNode)]; |
| 78 |
if (!processingData) { |
| 79 |
processingData = new CRedlandNodeProcessingData(classNode, expression); |
| 80 |
nodeHandlingList.append(processingData); |
| 81 |
processingData->mExpression = expression; |
| 82 |
} |
| 83 |
return this; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
QList<CAxiomExpression*> CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::takeQueryingCollectedAxiomExpressions() { |
| 89 |
QList<CAxiomExpression*> tmpList = mQueryingCollectedAxiomExpList; |
| 90 |
mQueryingCollectedAxiomExpList.clear(); |
| 91 |
return tmpList; |
| 92 |
} |
| 93 |
|
| 94 |
CConcreteOntologyRedlandTriplesDataExpressionMapper* CConcreteOntologyRedlandTriplesDataQueryingExpressionMapper::handleParsedOntologyAxiomExpression(CAxiomExpression* axiomExpression) { |
| 95 |
mQueryingCollectedAxiomExpList.append(axiomExpression); |
| 96 |
return this; |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
}; // end namespace Generator |
| 103 |
|
| 104 |
}; // end namespace Reasoner |
| 105 |
|
| 106 |
}; // end namespace Konclude |
| 107 |
|
| 108 |
#endif // !KONCLUDE_REDLAND_INTEGRATION |