| 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 "COWLlinkProcessor.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Control { |
| 27 |
|
| 28 |
namespace Interface { |
| 29 |
|
| 30 |
namespace OWLlink { |
| 31 |
|
| 32 |
|
| 33 |
COWLlinkProcessor::COWLlinkProcessor(bool immediatelyStartThread) : CThread("OWLlinkProcessor"), CLogIdentifier("::Konclude::Control::Interface::OWLlink::OWLlinkProcessor",this) { |
| 34 |
preSynchronizer = new CPreconditionSynchronizer(this); |
| 35 |
|
| 36 |
reasonerCommander = 0; |
| 37 |
|
| 38 |
mConfLoadOntologiesSAXParsing = true; |
| 39 |
mConfLoadOntologiesStreamParsing = true; |
| 40 |
|
| 41 |
defaultCommandDelegater = preSynchronizer; |
| 42 |
|
| 43 |
mConfLogProcessingTimes = false; |
| 44 |
|
| 45 |
mNetworkManager = nullptr; |
| 46 |
|
| 47 |
if (immediatelyStartThread) { |
| 48 |
startThread(); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
COWLlinkProcessor::~COWLlinkProcessor() { |
| 55 |
stopThread(); |
| 56 |
delete preSynchronizer; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
COWLlinkProcessor *COWLlinkProcessor::startProcessing() { |
| 63 |
postEvent(new CInitializeEvent()); |
| 64 |
return this; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
CCommandDelegater *COWLlinkProcessor::delegateCommand(CCommand *command) { |
| 70 |
postEvent(new CRealizeCommandEvent(command)); |
| 71 |
return this; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
bool COWLlinkProcessor::parseOntology(QIODevice* device, const QString& ontoIRI, const QString& resolvedIRI, CConcreteOntology *ont, COntologyConfigurationExtension *ontConfig, QList<QString>& importOntologiesList, QStringList& parserErrorList, CCommandRecordRouter& commandRecordRouter) { |
| 77 |
|
| 78 |
|
| 79 |
COntologyMultiAutoParsingLoader loader; |
| 80 |
bool loaded = loader.parseOntology(device, ontoIRI, resolvedIRI, ont, ontConfig, importOntologiesList, parserErrorList, commandRecordRouter); |
| 81 |
|
| 82 |
|
| 83 |
return loaded; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
CQtHttpTransactionManager* COWLlinkProcessor::getNetworkTransactionManager() { |
| 90 |
if (!mNetworkManager) { |
| 91 |
mNetworkManager = new CQtHttpTransactionManager(30 * 60 * 1000); |
| 92 |
} |
| 93 |
return mNetworkManager; |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
bool COWLlinkProcessor::createDownloadParseCommands(const QString& knowledgeBaseNameString, CCommand* parentCommand, CKnowledgeBaseRevisionCommandProvider* kbProviderCommand, const QMap<QString,QString>& ontoIRIMapping, const QStringList& ontoIRIStringList, CCommandRecordRouter& commandRecordRouter) { |
| 99 |
QList<CLoadKnowledgeBaseData*> loadDataList; |
| 100 |
QList<CCommand*> preconditionsList; |
| 101 |
|
| 102 |
cint64 downloadRequiredCount = 0; |
| 103 |
|
| 104 |
foreach (const QString& ontoIRIString, ontoIRIStringList) { |
| 105 |
|
| 106 |
QString resolvedString = ontoIRIString; |
| 107 |
for (QMap<QString,QString>::const_iterator resolveIRIIt = ontoIRIMapping.constBegin(), resolveIRIItEnd = ontoIRIMapping.constEnd(); resolveIRIIt != resolveIRIItEnd; ++resolveIRIIt) { |
| 108 |
QString identifyIRI(resolveIRIIt.key()); |
| 109 |
QString resolvingIRI(resolveIRIIt.value()); |
| 110 |
if (resolvedString.startsWith(identifyIRI)) { |
| 111 |
resolvedString = resolvedString.mid(identifyIRI.length()); |
| 112 |
resolvedString = resolvingIRI + resolvedString; |
| 113 |
} |
| 114 |
} |
| 115 |
if (resolvedString != ontoIRIString) { |
| 116 |
CUnspecifiedMessageInformationRecord::makeRecord(QString("Redirecting '%1' to '%2'.").arg(ontoIRIString).arg(resolvedString),&commandRecordRouter); |
| 117 |
} |
| 118 |
|
| 119 |
if (resolvedString.startsWith("http:") || resolvedString.startsWith("https:") || resolvedString.startsWith("ftp:")) { |
| 120 |
QBuffer* tmpBuffer = new QBuffer(); |
| 121 |
|
| 122 |
CLoadKnowledgeBaseFinishDownloadCommand* finishDownloadCommand = new CLoadKnowledgeBaseFinishDownloadCommand(resolvedString,tmpBuffer,preSynchronizer); |
| 123 |
parentCommand->makeToSubCommand(finishDownloadCommand); |
| 124 |
|
| 125 |
CLoadKnowledgeBaseStartDownloadCommand* startDownloadCommand = new CLoadKnowledgeBaseStartDownloadCommand(resolvedString,finishDownloadCommand); |
| 126 |
parentCommand->makeToSubCommand(startDownloadCommand); |
| 127 |
preSynchronizer->delegateCommand(startDownloadCommand); |
| 128 |
|
| 129 |
preconditionsList.append(startDownloadCommand); |
| 130 |
preconditionsList.append(finishDownloadCommand); |
| 131 |
++downloadRequiredCount; |
| 132 |
|
| 133 |
CLoadKnowledgeBaseData* loadData = new CLoadKnowledgeBaseData(tmpBuffer,ontoIRIString,resolvedString); |
| 134 |
loadDataList.append(loadData); |
| 135 |
|
| 136 |
} else { |
| 137 |
|
| 138 |
QString iriFileString = resolvedString; |
| 139 |
if (iriFileString.startsWith("file:")) { |
| 140 |
iriFileString.replace("file:",""); |
| 141 |
} |
| 142 |
while (!QFile::exists(iriFileString) && iriFileString.startsWith("/")) { |
| 143 |
iriFileString = iriFileString.remove(0,1); |
| 144 |
} |
| 145 |
|
| 146 |
if (!QFile::exists(iriFileString)) { |
| 147 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("File '%1' not found.").arg(resolvedString),&commandRecordRouter); |
| 148 |
} else { |
| 149 |
QFile* file = new QFile(iriFileString); |
| 150 |
CLoadKnowledgeBaseData* loadData = new CLoadKnowledgeBaseData(file,ontoIRIString,resolvedString); |
| 151 |
loadDataList.append(loadData); |
| 152 |
} |
| 153 |
|
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
CChooseParseInstallKnowledgeBaseOWLAutoOntologyCommand* chPaInKBOntComm = new CChooseParseInstallKnowledgeBaseOWLAutoOntologyCommand(knowledgeBaseNameString,loadDataList,ontoIRIMapping,kbProviderCommand); |
| 158 |
parentCommand->makeToSubCommand(chPaInKBOntComm); |
| 159 |
for (QList<CCommand*>::const_iterator it = preconditionsList.constBegin(), itEnd = preconditionsList.constEnd(); it != itEnd; ++it) { |
| 160 |
CCommand* preconditionCommand = *it; |
| 161 |
chPaInKBOntComm->addCommandPrecondition(new CCommandProcessedPrecondition(preconditionCommand)); |
| 162 |
} |
| 163 |
if (kbProviderCommand->getCommand() != parentCommand) { |
| 164 |
chPaInKBOntComm->addCommandPrecondition(new CCommandProcessedPrecondition(kbProviderCommand->getCommand())); |
| 165 |
} |
| 166 |
preSynchronizer->delegateCommand(chPaInKBOntComm); |
| 167 |
return true; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
bool COWLlinkProcessor::processCustomsEvents(QEvent::Type type, CCustomEvent *event) { |
| 173 |
if (!CThread::processCustomsEvents(type,event)) { |
| 174 |
if (type == EVENTREALIZECOMMAND) { |
| 175 |
CRealizeCommandEvent *commandEvent = (CRealizeCommandEvent *)event; |
| 176 |
if (commandEvent) { |
| 177 |
CCommand *command = commandEvent->getCommand(); |
| 178 |
if (command) { |
| 179 |
if (dynamic_cast<CTellKnowledgeBaseOWL2XMLNodeCommand *>(command)) { |
| 180 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 181 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 182 |
CTellKnowledgeBaseOWL2XMLNodeCommand *tellKBC = (CTellKnowledgeBaseOWL2XMLNodeCommand *)command; |
| 183 |
|
| 184 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(tellKBC->getKnowledgeBaseName()); |
| 185 |
tellKBC->makeToSubCommand(crKBRevUpC); |
| 186 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 187 |
|
| 188 |
CParseOWL2XMLOntologyCommand *pOWLOntC = new CParseOWL2XMLOntologyCommand(tellKBC->getOWL2Node(),crKBRevUpC); |
| 189 |
tellKBC->makeToSubCommand(pOWLOntC); |
| 190 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 191 |
|
| 192 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(tellKBC->getKnowledgeBaseName(),pOWLOntC); |
| 193 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(pOWLOntC)); |
| 194 |
tellKBC->makeToSubCommand(inKBRevUpC); |
| 195 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 196 |
|
| 197 |
CPrepareKnowledgeBaseForRevisionCommand* prepareKBC = new CPrepareKnowledgeBaseForRevisionCommand(crKBRevUpC); |
| 198 |
tellKBC->makeToSubCommand(prepareKBC); |
| 199 |
prepareKBC->addCommandPrecondition(new CCommandProcessedPrecondition(inKBRevUpC)); |
| 200 |
preSynchronizer->delegateCommand(prepareKBC); |
| 201 |
|
| 202 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 203 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 204 |
|
| 205 |
} else if (dynamic_cast<CLoadKnowledgeBaseKRSSTestConceptCommand *>(command)) { |
| 206 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 207 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 208 |
CLoadKnowledgeBaseKRSSTestConceptCommand *loadKBC = (CLoadKnowledgeBaseKRSSTestConceptCommand *)command; |
| 209 |
|
| 210 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(loadKBC->getKnowledgeBaseName()); |
| 211 |
loadKBC->makeToSubCommand(crKBRevUpC); |
| 212 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 213 |
|
| 214 |
CReadTextCommand *readTextC = new CReadTextCommand(loadKBC->getLoadIRIString()); |
| 215 |
loadKBC->makeToSubCommand(readTextC); |
| 216 |
preSynchronizer->delegateCommand(readTextC); |
| 217 |
|
| 218 |
CParseKRSSTestConceptOntologyCommand *pOWLOntC = new CParseKRSSTestConceptOntologyCommand(readTextC,crKBRevUpC,loadKBC->getTestConceptNameString()); |
| 219 |
loadKBC->makeToSubCommand(pOWLOntC); |
| 220 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 221 |
|
| 222 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(loadKBC->getKnowledgeBaseName(),pOWLOntC); |
| 223 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(pOWLOntC)); |
| 224 |
loadKBC->makeToSubCommand(inKBRevUpC); |
| 225 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 226 |
|
| 227 |
CPrepareKnowledgeBaseForRevisionCommand* prepareKBC = new CPrepareKnowledgeBaseForRevisionCommand(crKBRevUpC); |
| 228 |
loadKBC->makeToSubCommand(prepareKBC); |
| 229 |
prepareKBC->addCommandPrecondition(new CCommandProcessedPrecondition(inKBRevUpC)); |
| 230 |
preSynchronizer->delegateCommand(prepareKBC); |
| 231 |
|
| 232 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 233 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 234 |
|
| 235 |
} else if (dynamic_cast<CPrepareKnowledgeBaseForRevisionCommand *>(command)) { |
| 236 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 237 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 238 |
CPrepareKnowledgeBaseForRevisionCommand *prepareKBC = (CPrepareKnowledgeBaseForRevisionCommand *)command; |
| 239 |
|
| 240 |
COntologyRevision* ontoRev = prepareKBC->getOntologyRevision(); |
| 241 |
bool preparingOntology = false; |
| 242 |
if (ontoRev) { |
| 243 |
CConfigurationBase* config = ontoRev->getOntologyConfiguration(); |
| 244 |
|
| 245 |
COntologyProcessingStepVector* ontProStepVec = COntologyProcessingStepVector::getProcessingStepVectorInstance(); |
| 246 |
bool build = CConfigDataReader::readConfigBoolean(config,"Konclude.Ontology.Revision.BuildAfterModification"); |
| 247 |
if (build) { |
| 248 |
prepareKBC->addOntologyProcessingStepRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSBUILD), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 249 |
} |
| 250 |
bool preprocess = CConfigDataReader::readConfigBoolean(config,"Konclude.Ontology.Revision.PreprocessAfterModification"); |
| 251 |
if (preprocess) { |
| 252 |
prepareKBC->addOntologyProcessingStepRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSPREPROCESS), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 253 |
} |
| 254 |
bool consistency = CConfigDataReader::readConfigBoolean(config,"Konclude.Ontology.Revision.ConsistencyPrecomputationAfterModification"); |
| 255 |
if (consistency) { |
| 256 |
prepareKBC->addOntologyProcessingStepRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSCONSISTENCY), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 257 |
} |
| 258 |
bool cycles = CConfigDataReader::readConfigBoolean(config,"Konclude.Ontology.Revision.CyclesPrecomputationAfterModification"); |
| 259 |
if (cycles) { |
| 260 |
prepareKBC->addOntologyProcessingStepRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSPRECOMPUTECYCLES), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 261 |
} |
| 262 |
bool classify = CConfigDataReader::readConfigBoolean(config,"Konclude.Ontology.Revision.ClassifyAfterModification"); |
| 263 |
if (classify) { |
| 264 |
prepareKBC->addOntologyProcessingStepRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSCLASSCLASSIFY), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 265 |
} |
| 266 |
|
| 267 |
if (!prepareKBC->getOntologyProcessingRequirementList()->isEmpty() && reasonerCommander) { |
| 268 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 269 |
preparingOntology = true; |
| 270 |
reasonerCommander->realizeCommand(command); |
| 271 |
} |
| 272 |
} |
| 273 |
|
| 274 |
if (!preparingOntology) { |
| 275 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 276 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
} else if (dynamic_cast<CLoadKnowledgeBaseOWLFunctionalOntologyCommand *>(command)) { |
| 282 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 283 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 284 |
CLoadKnowledgeBaseOWLFunctionalOntologyCommand *loadKBOWLXMLOnto = (CLoadKnowledgeBaseOWLFunctionalOntologyCommand *)command; |
| 285 |
|
| 286 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(loadKBOWLXMLOnto->getKnowledgeBaseName()); |
| 287 |
loadKBOWLXMLOnto->makeToSubCommand(crKBRevUpC); |
| 288 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 289 |
|
| 290 |
CCommand* lastWaitCommand = crKBRevUpC; |
| 291 |
CKnowledgeBaseRevisionCommandProvider *ontologyRevisionProviderCommand = nullptr; |
| 292 |
|
| 293 |
QStringList ontoIRIs(loadKBOWLXMLOnto->getLoadIRIStrings()); |
| 294 |
foreach (QString ontoIRI, ontoIRIs) { |
| 295 |
|
| 296 |
CStreamParseOWL2FunctionalOntologyCommand *pOWLOntC = new CStreamParseOWL2FunctionalOntologyCommand(ontoIRI,crKBRevUpC); |
| 297 |
if (lastWaitCommand) { |
| 298 |
pOWLOntC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 299 |
} |
| 300 |
|
| 301 |
loadKBOWLXMLOnto->makeToSubCommand(pOWLOntC); |
| 302 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 303 |
|
| 304 |
ontologyRevisionProviderCommand = pOWLOntC; |
| 305 |
lastWaitCommand = pOWLOntC; |
| 306 |
} |
| 307 |
|
| 308 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(loadKBOWLXMLOnto->getKnowledgeBaseName(),ontologyRevisionProviderCommand); |
| 309 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 310 |
loadKBOWLXMLOnto->makeToSubCommand(inKBRevUpC); |
| 311 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 312 |
|
| 313 |
CPrepareKnowledgeBaseForRevisionCommand* prepareKBC = new CPrepareKnowledgeBaseForRevisionCommand(ontologyRevisionProviderCommand); |
| 314 |
loadKBOWLXMLOnto->makeToSubCommand(prepareKBC); |
| 315 |
prepareKBC->addCommandPrecondition(new CCommandProcessedPrecondition(inKBRevUpC)); |
| 316 |
preSynchronizer->delegateCommand(prepareKBC); |
| 317 |
|
| 318 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 319 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
} else if (dynamic_cast<CLoadKnowledgeBaseOWLXMLOntologyCommand *>(command)) { |
| 325 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 326 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 327 |
CLoadKnowledgeBaseOWLXMLOntologyCommand *loadKBOWLXMLOnto = (CLoadKnowledgeBaseOWLXMLOntologyCommand *)command; |
| 328 |
|
| 329 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(loadKBOWLXMLOnto->getKnowledgeBaseName()); |
| 330 |
loadKBOWLXMLOnto->makeToSubCommand(crKBRevUpC); |
| 331 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 332 |
|
| 333 |
QStringList ontoIRIs(loadKBOWLXMLOnto->getLoadIRIStrings()); |
| 334 |
|
| 335 |
CChooseParseInstallKnowledgeBaseOWLXMLOntologyCommand* chPaInKBOntComm = new CChooseParseInstallKnowledgeBaseOWLXMLOntologyCommand(loadKBOWLXMLOnto->getKnowledgeBaseName(),ontoIRIs,crKBRevUpC); |
| 336 |
loadKBOWLXMLOnto->makeToSubCommand(chPaInKBOntComm); |
| 337 |
preSynchronizer->delegateCommand(chPaInKBOntComm); |
| 338 |
|
| 339 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 340 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
} else if (dynamic_cast<CConnectKnowledgeBaseExternalTriplesDSNCommand *>(command)) { |
| 347 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 348 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(), getLogDomain(), command); |
| 349 |
CConnectKnowledgeBaseExternalTriplesDSNCommand *cKBETDSNC = (CConnectKnowledgeBaseExternalTriplesDSNCommand *)command; |
| 350 |
|
| 351 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(cKBETDSNC->getKnowledgeBaseName()); |
| 352 |
cKBETDSNC->makeToSubCommand(crKBRevUpC); |
| 353 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 354 |
|
| 355 |
|
| 356 |
CParseInstallKnowledgeBaseExternalTriplesDSNConnectionCommand* paInKBExTrDSNCoComm = new CParseInstallKnowledgeBaseExternalTriplesDSNConnectionCommand(cKBETDSNC->getKnowledgeBaseName(), cKBETDSNC->getTriplesDBName(), cKBETDSNC->getConfigDSNString(), crKBRevUpC); |
| 357 |
cKBETDSNC->makeToSubCommand(paInKBExTrDSNCoComm); |
| 358 |
preSynchronizer->delegateCommand(paInKBExTrDSNCoComm); |
| 359 |
|
| 360 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(paInKBExTrDSNCoComm->getKnowledgeBaseName(), crKBRevUpC); |
| 361 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(paInKBExTrDSNCoComm)); |
| 362 |
cKBETDSNC->makeToSubCommand(inKBRevUpC); |
| 363 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 364 |
|
| 365 |
|
| 366 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 367 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
} else if (dynamic_cast<CParseInstallKnowledgeBaseExternalTriplesDSNConnectionCommand *>(command)) { |
| 372 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 373 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(), getLogDomain(), command); |
| 374 |
|
| 375 |
CParseInstallKnowledgeBaseExternalTriplesDSNConnectionCommand* pIKBETDSNCComm = (CParseInstallKnowledgeBaseExternalTriplesDSNConnectionCommand *)command; |
| 376 |
|
| 377 |
CConfigData* data = nullptr; |
| 378 |
COntologyRevision* ontoRev = pIKBETDSNCComm->getOntologyRevision(); |
| 379 |
if (ontoRev) { |
| 380 |
COntologyConfigurationExtension* ontoConfExt = ontoRev->getOntologyConfiguration(); |
| 381 |
|
| 382 |
CConcreteOntology* ont = ontoRev->getOntology(); |
| 383 |
|
| 384 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 385 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 386 |
builder->initializeBuilding(); |
| 387 |
|
| 388 |
CRDFRedlandExternalTriplesDSNConnectingParser* parser = new CRDFRedlandExternalTriplesDSNConnectingParser(builder, ontoConfExt); |
| 389 |
bool connectionSuccessfullyEstablished = parser->connectExternalTriples(pIKBETDSNCComm->getTriplesDBName(), pIKBETDSNCComm->getConfigDSNString()); |
| 390 |
if (!connectionSuccessfullyEstablished) { |
| 391 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Failed to establish DSN connection to external triples for knowledge base '%1'.").arg(pIKBETDSNCComm->getKnowledgeBaseName()), &commandRecordRouter); |
| 392 |
} |
| 393 |
|
| 394 |
CConcreteOntologyRedlandTriplesDataExpressionMapper* triplesMapper = new CConcreteOntologyRedlandTriplesDataExpressionMapper(builder); |
| 395 |
triplesMapper->mapTriples(ont, ont->getOntologyTriplesData()); |
| 396 |
if (connectionSuccessfullyEstablished) { |
| 397 |
builder->completeBuilding(); |
| 398 |
} |
| 399 |
|
| 400 |
delete parser; |
| 401 |
|
| 402 |
|
| 403 |
#else |
| 404 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Cannot establish DSN connection for knowledge base '%1' without Redland libraries.").arg(pIKBETDSNCComm->getKnowledgeBaseName()), &commandRecordRouter); |
| 405 |
|
| 406 |
#endif // !KONCLUDE_REDLAND_INTEGRATION |
| 407 |
|
| 408 |
} else { |
| 409 |
CUnspecifiedMessageErrorRecord::makeRecord("Ontology revision not available.", &commandRecordRouter); |
| 410 |
} |
| 411 |
|
| 412 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 413 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
} else if (dynamic_cast<CChooseParseInstallKnowledgeBaseOWLXMLOntologyCommand *>(command)) { |
| 418 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 419 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 420 |
CChooseParseInstallKnowledgeBaseOWLXMLOntologyCommand* chPaInKBOntComm = (CChooseParseInstallKnowledgeBaseOWLXMLOntologyCommand *)command; |
| 421 |
|
| 422 |
CConfigData* data = nullptr; |
| 423 |
COntologyRevision* ontoRev = chPaInKBOntComm->getOntologyRevision(); |
| 424 |
if (ontoRev) { |
| 425 |
COntologyConfigurationExtension* ontoConfExt = chPaInKBOntComm->getOntologyRevision()->getOntologyConfiguration(); |
| 426 |
|
| 427 |
bool confLoadOntologiesStreamParsing = mConfLoadOntologiesStreamParsing; |
| 428 |
bool confLoadOntologiesSAXParsing = mConfLoadOntologiesSAXParsing; |
| 429 |
data = ontoConfExt->getRelatedConfigChange("Konclude.OWLlink.StreamBasedLoadOntologiesParsing"); |
| 430 |
if (data) { |
| 431 |
confLoadOntologiesStreamParsing = data->getBoolean(); |
| 432 |
} |
| 433 |
data = ontoConfExt->getRelatedConfigChange("Konclude.OWLlink.SAXBasedLoadOntologiesParsing"); |
| 434 |
if (data) { |
| 435 |
confLoadOntologiesSAXParsing = data->getBoolean(); |
| 436 |
} |
| 437 |
|
| 438 |
QStringList ontoIRIs(chPaInKBOntComm->getLoadIRIStrings()); |
| 439 |
|
| 440 |
CCommand* lastWaitCommand = nullptr; |
| 441 |
CKnowledgeBaseRevisionCommandProvider *ontologyRevisionProviderCommand = nullptr; |
| 442 |
|
| 443 |
foreach (QString ontoIRI, ontoIRIs) { |
| 444 |
if (confLoadOntologiesStreamParsing) { |
| 445 |
CStreamParseOWL2XMLOntologyCommand *pOWLOntC = new CStreamParseOWL2XMLOntologyCommand(ontoIRI,chPaInKBOntComm); |
| 446 |
if (lastWaitCommand) { |
| 447 |
pOWLOntC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 448 |
} |
| 449 |
|
| 450 |
chPaInKBOntComm->makeToSubCommand(pOWLOntC); |
| 451 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 452 |
|
| 453 |
ontologyRevisionProviderCommand = pOWLOntC; |
| 454 |
lastWaitCommand = pOWLOntC; |
| 455 |
} else if (confLoadOntologiesSAXParsing) { |
| 456 |
CSAXParseOWL2XMLOntologyCommand *pOWLOntC = new CSAXParseOWL2XMLOntologyCommand(ontoIRI,chPaInKBOntComm); |
| 457 |
if (lastWaitCommand) { |
| 458 |
pOWLOntC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 459 |
} |
| 460 |
chPaInKBOntComm->makeToSubCommand(pOWLOntC); |
| 461 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 462 |
|
| 463 |
ontologyRevisionProviderCommand = pOWLOntC; |
| 464 |
lastWaitCommand = pOWLOntC; |
| 465 |
} else { |
| 466 |
CReadXMLCommand *readXMLC = new CReadXMLCommand(ontoIRI); |
| 467 |
chPaInKBOntComm->makeToSubCommand(readXMLC); |
| 468 |
preSynchronizer->delegateCommand(readXMLC); |
| 469 |
|
| 470 |
CParseOWL2XMLOntologyCommand *pOWLOntC = new CParseOWL2XMLOntologyCommand(readXMLC,chPaInKBOntComm); |
| 471 |
if (lastWaitCommand) { |
| 472 |
pOWLOntC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 473 |
} |
| 474 |
chPaInKBOntComm->makeToSubCommand(pOWLOntC); |
| 475 |
preSynchronizer->delegateCommand(pOWLOntC); |
| 476 |
|
| 477 |
ontologyRevisionProviderCommand = pOWLOntC; |
| 478 |
lastWaitCommand = pOWLOntC; |
| 479 |
} |
| 480 |
|
| 481 |
} |
| 482 |
|
| 483 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(chPaInKBOntComm->getKnowledgeBaseName(),ontologyRevisionProviderCommand); |
| 484 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(lastWaitCommand)); |
| 485 |
chPaInKBOntComm->makeToSubCommand(inKBRevUpC); |
| 486 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 487 |
|
| 488 |
CPrepareKnowledgeBaseForRevisionCommand* prepareKBC = new CPrepareKnowledgeBaseForRevisionCommand(ontologyRevisionProviderCommand); |
| 489 |
chPaInKBOntComm->makeToSubCommand(prepareKBC); |
| 490 |
prepareKBC->addCommandPrecondition(new CCommandProcessedPrecondition(inKBRevUpC)); |
| 491 |
preSynchronizer->delegateCommand(prepareKBC); |
| 492 |
} else { |
| 493 |
CUnspecifiedMessageErrorRecord::makeRecord("Ontology revision not available.",&commandRecordRouter); |
| 494 |
} |
| 495 |
|
| 496 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 497 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
} else if (dynamic_cast<CLoadKnowledgeBaseStartDownloadCommand *>(command)) { |
| 506 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 507 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 508 |
CLoadKnowledgeBaseStartDownloadCommand* loadKBStartDownload = (CLoadKnowledgeBaseStartDownloadCommand *)command; |
| 509 |
|
| 510 |
CLoadKnowledgeBaseFinishDownloadCommand* finishCommand = loadKBStartDownload->getFinishCommand(); |
| 511 |
QByteArray* destinationDataArray = new QByteArray(); |
| 512 |
|
| 513 |
CQtHttpTransactionManager* transMan = getNetworkTransactionManager(); |
| 514 |
CHttpRequest* request = transMan->createRequest(loadKBStartDownload->getDownloadIRIString()); |
| 515 |
CHttpResponse* response = transMan->getResponse(request); |
| 516 |
transMan->callbackResponseData(response,destinationDataArray,finishCommand); |
| 517 |
|
| 518 |
finishCommand->setTemporaryDataPointer(destinationDataArray); |
| 519 |
finishCommand->setResponse(response); |
| 520 |
|
| 521 |
LOG(INFO,getLogDomain(),logTr("Downloading '%1'.").arg(loadKBStartDownload->getDownloadIRIString()),this); |
| 522 |
|
| 523 |
|
| 524 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 525 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
} else if (dynamic_cast<CLoadKnowledgeBaseFinishDownloadCommand *>(command)) { |
| 530 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 531 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 532 |
CLoadKnowledgeBaseFinishDownloadCommand* loadKBFinishDownload = (CLoadKnowledgeBaseFinishDownloadCommand *)command; |
| 533 |
|
| 534 |
CQtHttpTransactionManager* transMan = getNetworkTransactionManager(); |
| 535 |
CHttpResponse* response = loadKBFinishDownload->getResponse(); |
| 536 |
QString iriString = loadKBFinishDownload->getDownloadString(); |
| 537 |
QByteArray* dataArray = loadKBFinishDownload->getTemporaryDataPointer(true); |
| 538 |
|
| 539 |
|
| 540 |
if (!transMan->hasFinishedSucecssfully(response)) { |
| 541 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Download of '%1' has failed.").arg(iriString),&commandRecordRouter); |
| 542 |
} else { |
| 543 |
cint64 downloadSize = dataArray->count(); |
| 544 |
QString unitString = "Bytes"; |
| 545 |
if (downloadSize > 10000) { |
| 546 |
downloadSize /= 1024; |
| 547 |
unitString = "KBytes"; |
| 548 |
} |
| 549 |
if (downloadSize > 10000) { |
| 550 |
downloadSize /= 1024; |
| 551 |
unitString = "MBytes"; |
| 552 |
} |
| 553 |
LOG(INFO,getLogDomain(),logTr("Successfully downloaded '%1', received %2 %3.").arg(iriString).arg(downloadSize).arg(unitString),this); |
| 554 |
//CUnspecifiedMessageInformationRecord::makeRecord(QString("Successfully downloaded '%1', received %2 MBytes.").arg(iriString).arg(downloadSize),&commandRecordRouter); |
| 555 |
QIODevice* writeDevice = loadKBFinishDownload->getWriteIODevice(); |
| 556 |
if (writeDevice) { |
| 557 |
if (writeDevice->open(QIODevice::WriteOnly)) { |
| 558 |
writeDevice->write(*dataArray); |
| 559 |
writeDevice->close(); |
| 560 |
} |
| 561 |
} |
| 562 |
} |
| 563 |
delete dataArray; |
| 564 |
transMan->releaseResponse(response); |
| 565 |
|
| 566 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 567 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
} else if (dynamic_cast<CLoadKnowledgeBaseOWLAutoOntologyCommand *>(command)) { |
| 575 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 576 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 577 |
CLoadKnowledgeBaseOWLAutoOntologyCommand *loadKBOWLAutoOnto = (CLoadKnowledgeBaseOWLAutoOntologyCommand *)command; |
| 578 |
|
| 579 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(loadKBOWLAutoOnto->getKnowledgeBaseName()); |
| 580 |
loadKBOWLAutoOnto->makeToSubCommand(crKBRevUpC); |
| 581 |
preSynchronizer->delegateCommand(crKBRevUpC); |
| 582 |
|
| 583 |
|
| 584 |
QMap<QString,QString> ontoIRIMapping = loadKBOWLAutoOnto->getOntologieIRIMappings(); |
| 585 |
|
| 586 |
QStringList ontoIRIStringList(loadKBOWLAutoOnto->getLoadIRIStrings()); |
| 587 |
|
| 588 |
createDownloadParseCommands(loadKBOWLAutoOnto->getKnowledgeBaseName(),loadKBOWLAutoOnto,crKBRevUpC,ontoIRIMapping,ontoIRIStringList,commandRecordRouter); |
| 589 |
|
| 590 |
|
| 591 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 592 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
} else if (dynamic_cast<CImportKnowledgeBaseOWLAutoOntologyCommand *>(command)) { |
| 600 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 601 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 602 |
CImportKnowledgeBaseOWLAutoOntologyCommand *importKBOWLAutoOnto = (CImportKnowledgeBaseOWLAutoOntologyCommand *)command; |
| 603 |
|
| 604 |
|
| 605 |
QMap<QString,QString> ontoIRIMapping = importKBOWLAutoOnto->getOntologieIRIMappings(); |
| 606 |
|
| 607 |
QStringList ontoIRIStringList(importKBOWLAutoOnto->getLoadIRIStrings()); |
| 608 |
|
| 609 |
createDownloadParseCommands(importKBOWLAutoOnto->getKnowledgeBaseName(),importKBOWLAutoOnto,importKBOWLAutoOnto,ontoIRIMapping,ontoIRIStringList,commandRecordRouter); |
| 610 |
|
| 611 |
|
| 612 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 613 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
} else if (dynamic_cast<CChooseParseInstallKnowledgeBaseOWLAutoOntologyCommand *>(command)) { |
| 622 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 623 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 624 |
CChooseParseInstallKnowledgeBaseOWLAutoOntologyCommand* chPaInKBOntComm = (CChooseParseInstallKnowledgeBaseOWLAutoOntologyCommand *)command; |
| 625 |
|
| 626 |
CConfigData* data = nullptr; |
| 627 |
COntologyRevision* ontoRev = chPaInKBOntComm->getOntologyRevision(); |
| 628 |
if (ontoRev) { |
| 629 |
COntologyConfigurationExtension* ontoConfExt = chPaInKBOntComm->getOntologyRevision()->getOntologyConfiguration(); |
| 630 |
|
| 631 |
COntologyConfigurationExtension *ontConfig = ontoRev->getOntologyConfiguration(); |
| 632 |
CConcreteOntology* ont = ontoRev->getOntology(); |
| 633 |
|
| 634 |
|
| 635 |
QList<QString> importOntologiesList; |
| 636 |
|
| 637 |
QList<CLoadKnowledgeBaseData*> loadDataList(chPaInKBOntComm->getLoadDataList()); |
| 638 |
|
| 639 |
bool allParsingSucceeded = true; |
| 640 |
|
| 641 |
for (QList<CLoadKnowledgeBaseData*>::const_iterator loadDataIt = loadDataList.constBegin(), loadDataItEnd = loadDataList.constEnd(); loadDataIt != loadDataItEnd; ++loadDataIt) { |
| 642 |
CLoadKnowledgeBaseData* loadData = *loadDataIt; |
| 643 |
|
| 644 |
QIODevice* device = loadData->getLoadDevice(); |
| 645 |
QString ontoIRI = loadData->getOriginalDataName(); |
| 646 |
QString resolvedIRI = loadData->getResolvedDataName(); |
| 647 |
|
| 648 |
|
| 649 |
QTime parsingTime; |
| 650 |
if (mConfLogProcessingTimes) { |
| 651 |
parsingTime.start(); |
| 652 |
} |
| 653 |
|
| 654 |
QStringList parserErrorList; |
| 655 |
|
| 656 |
|
| 657 |
bool parsingSucceeded = parseOntology(device, ontoIRI, resolvedIRI, ont, ontConfig, importOntologiesList, parserErrorList, commandRecordRouter); |
| 658 |
|
| 659 |
|
| 660 |
if (!parsingSucceeded) { |
| 661 |
allParsingSucceeded = false; |
| 662 |
parserErrorList.append(QString("All parsers failed for '%1'.").arg(resolvedIRI)); |
| 663 |
for (QStringList::const_iterator errorIt = parserErrorList.constBegin(), errorItEnd = parserErrorList.constEnd(); errorIt != errorItEnd; ++errorIt) { |
| 664 |
CUnspecifiedMessageErrorRecord::makeRecord(*errorIt,&commandRecordRouter); |
| 665 |
} |
| 666 |
} else { |
| 667 |
ont->getLoadData()->addLoadedOntologyIRI(ontoIRI, resolvedIRI); |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
if (mConfLogProcessingTimes) { |
| 672 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 673 |
QString ontologieCountString = "Ontology"; |
| 674 |
if (loadDataList.count() > 1) { |
| 675 |
ontologieCountString = "Ontologies"; |
| 676 |
} |
| 677 |
LOG(INFO,getLogDomain(),logTr("%1 parsed in %2 ms.").arg(ontologieCountString).arg(parsingMilliSeconds),this); |
| 678 |
} |
| 679 |
|
| 680 |
} |
| 681 |
|
| 682 |
if (importOntologiesList.isEmpty()) { |
| 683 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(chPaInKBOntComm->getKnowledgeBaseName(),chPaInKBOntComm); |
| 684 |
chPaInKBOntComm->makeToSubCommand(inKBRevUpC); |
| 685 |
preSynchronizer->delegateCommand(inKBRevUpC); |
| 686 |
|
| 687 |
CPrepareKnowledgeBaseForRevisionCommand* prepareKBC = new CPrepareKnowledgeBaseForRevisionCommand(chPaInKBOntComm); |
| 688 |
chPaInKBOntComm->makeToSubCommand(prepareKBC); |
| 689 |
prepareKBC->addCommandPrecondition(new CCommandProcessedPrecondition(inKBRevUpC)); |
| 690 |
preSynchronizer->delegateCommand(prepareKBC); |
| 691 |
} else { |
| 692 |
if (importOntologiesList.count() > 1) { |
| 693 |
LOG(INFO,getLogDomain(),logTr("Scheduling the import of %1 ontologies.").arg(importOntologiesList.count()),this); |
| 694 |
} else { |
| 695 |
LOG(INFO,getLogDomain(),logTr("Scheduling the import of '%1'.").arg(importOntologiesList.first()),this); |
| 696 |
} |
| 697 |
CImportKnowledgeBaseOWLAutoOntologyCommand* importKBsCommand = new CImportKnowledgeBaseOWLAutoOntologyCommand(chPaInKBOntComm->getKnowledgeBaseName(),importOntologiesList,chPaInKBOntComm->getOntologieIRIMappings(),chPaInKBOntComm); |
| 698 |
chPaInKBOntComm->makeToSubCommand(importKBsCommand); |
| 699 |
preSynchronizer->delegateCommand(importKBsCommand); |
| 700 |
} |
| 701 |
} else { |
| 702 |
CUnspecifiedMessageErrorRecord::makeRecord("Ontology revision not available.",&commandRecordRouter); |
| 703 |
} |
| 704 |
|
| 705 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 706 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
} else if (dynamic_cast<CSaveOWL2XMLExtractedKnowledgeBaseCommand *>(command)) { |
| 714 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 715 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 716 |
CSaveOWL2XMLExtractedKnowledgeBaseCommand *saveKBC = (CSaveOWL2XMLExtractedKnowledgeBaseCommand *)command; |
| 717 |
|
| 718 |
CGetCurrentKnowledgeBaseRevisionCommand *gcKBRevUpC = new CGetCurrentKnowledgeBaseRevisionCommand(saveKBC->getKnowledgeBaseName()); |
| 719 |
saveKBC->makeToSubCommand(gcKBRevUpC); |
| 720 |
preSynchronizer->delegateCommand(gcKBRevUpC); |
| 721 |
|
| 722 |
COntologyOWL2QtXMLRenderer* renderer = new COntologyOWL2QtXMLRenderer(); |
| 723 |
|
| 724 |
CExtractToldExpressionsOntologyCommand *extTEOC = new CExtractToldExpressionsOntologyCommand(renderer,gcKBRevUpC,saveKBC->getExtractEntitiyList()); |
| 725 |
saveKBC->makeToSubCommand(extTEOC); |
| 726 |
preSynchronizer->delegateCommand(extTEOC); |
| 727 |
|
| 728 |
CWriteOWL2XMLOntologyCommand *writeOntC = new CWriteOWL2XMLOntologyCommand(renderer,saveKBC->getSaveIRIString()); |
| 729 |
writeOntC->addCommandPrecondition(new CCommandProcessedPrecondition(extTEOC)); |
| 730 |
saveKBC->makeToSubCommand(writeOntC); |
| 731 |
preSynchronizer->delegateCommand(writeOntC); |
| 732 |
|
| 733 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 734 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 735 |
|
| 736 |
} else if (dynamic_cast<CSaveOWLlinkOWL2XMLSatisfiableTestExtractedKnowledgeBaseCommand *>(command)) { |
| 737 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 738 |
CStartProcessCommandRecord::makeRecord(command->getRecorder(),getLogDomain(),command); |
| 739 |
CSaveOWLlinkOWL2XMLSatisfiableTestExtractedKnowledgeBaseCommand *saveKBC = (CSaveOWLlinkOWL2XMLSatisfiableTestExtractedKnowledgeBaseCommand *)command; |
| 740 |
|
| 741 |
CGetCurrentKnowledgeBaseRevisionCommand *gcKBRevUpC = new CGetCurrentKnowledgeBaseRevisionCommand(saveKBC->getKnowledgeBaseName()); |
| 742 |
saveKBC->makeToSubCommand(gcKBRevUpC); |
| 743 |
preSynchronizer->delegateCommand(gcKBRevUpC); |
| 744 |
|
| 745 |
COntologyOWL2QtXMLRenderer* renderer = new COntologyOWL2QtXMLRenderer(); |
| 746 |
|
| 747 |
CExtractToldExpressionsOntologyCommand *extTEOC = new CExtractToldExpressionsOntologyCommand(renderer,gcKBRevUpC,saveKBC->getExtractEntitiyList()); |
| 748 |
saveKBC->makeToSubCommand(extTEOC); |
| 749 |
preSynchronizer->delegateCommand(extTEOC); |
| 750 |
|
| 751 |
CWriteOWLlinkOWL2XMLSatisfiableTestCommand *writeOntC = new CWriteOWLlinkOWL2XMLSatisfiableTestCommand(renderer,saveKBC->getSaveIRIString(),saveKBC->getExtractEntitiyList(),saveKBC->getTestKBName()); |
| 752 |
writeOntC->addCommandPrecondition(new CCommandProcessedPrecondition(extTEOC)); |
| 753 |
saveKBC->makeToSubCommand(writeOntC); |
| 754 |
preSynchronizer->delegateCommand(writeOntC); |
| 755 |
|
| 756 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 757 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 758 |
|
| 759 |
|
| 760 |
} else if (dynamic_cast<CExtractOntologyCommand *>(command)) { |
| 761 |
COntologyExtractionManager exMan; |
| 762 |
exMan.realizeCommand(command); |
| 763 |
|
| 764 |
} else if (dynamic_cast<CWriteOntologyCommand *>(command)) { |
| 765 |
CRenderWriteManager writeMan; |
| 766 |
writeMan.realizeCommand(command); |
| 767 |
|
| 768 |
} else if (dynamic_cast<CReadTextCommand *>(command)) { |
| 769 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 770 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 771 |
CReadTextCommand* readTextC = (CReadTextCommand *)command; |
| 772 |
|
| 773 |
QString iriString = readTextC->getIRIString(); |
| 774 |
QFile file(iriString); |
| 775 |
if (file.open(QIODevice::ReadOnly)) { |
| 776 |
CUnspecifiedMessageInformationRecord::makeRecord(QString("Read file '%1'.").arg(iriString),&commandRecordRouter); |
| 777 |
readTextC->setReadText(file.readAll()); |
| 778 |
file.close(); |
| 779 |
} else { |
| 780 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("File '%1' not found.").arg(iriString),&commandRecordRouter); |
| 781 |
} |
| 782 |
|
| 783 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 784 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
} else if (dynamic_cast<CReadXMLCommand *>(command)) { |
| 789 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 790 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 791 |
CReadXMLCommand* readXMLC = (CReadXMLCommand *)command; |
| 792 |
|
| 793 |
QString iriString = readXMLC->getIRIString(); |
| 794 |
if (iriString.startsWith("file:")) { |
| 795 |
iriString.replace("file:",""); |
| 796 |
} |
| 797 |
while (!QFile::exists(iriString) && iriString.startsWith("/")) { |
| 798 |
iriString = iriString.remove(0,1); |
| 799 |
} |
| 800 |
QFile file(iriString); |
| 801 |
if (file.open(QIODevice::ReadOnly)) { |
| 802 |
CUnspecifiedMessageInformationRecord::makeRecord(QString("Read file '%1'.").arg(iriString),&commandRecordRouter); |
| 803 |
|
| 804 |
QDomDocument document; |
| 805 |
QString errorMessage; |
| 806 |
int errorLine = 0, errorColumn = 0; |
| 807 |
if (document.setContent(file.readAll(),true,&errorMessage,&errorLine,&errorColumn)) { |
| 808 |
readXMLC->setReadXMLNode(document.documentElement()); |
| 809 |
} |
| 810 |
|
| 811 |
file.close(); |
| 812 |
} else { |
| 813 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("File '%1' not found.").arg(iriString),&commandRecordRouter); |
| 814 |
} |
| 815 |
|
| 816 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 817 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 818 |
|
| 819 |
|
| 820 |
} else if (dynamic_cast<CParseKRSSTestConceptOntologyCommand *>(command)) { |
| 821 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 822 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 823 |
CParseKRSSTestConceptOntologyCommand *krssTCOntC = (CParseKRSSTestConceptOntologyCommand *)command; |
| 824 |
|
| 825 |
|
| 826 |
COntologyRevision *ontRev = krssTCOntC->getOntologyRevision(); |
| 827 |
if (ontRev) { |
| 828 |
CConcreteOntology *ont = ontRev->getOntology(); |
| 829 |
|
| 830 |
QTime parsingTime; |
| 831 |
if (mConfLogProcessingTimes) { |
| 832 |
parsingTime.start(); |
| 833 |
} |
| 834 |
|
| 835 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 836 |
|
| 837 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 838 |
CKRSSOntologyParser *krssParser = new CKRSSOntologyParser(builder,krssTCOntC->getTestConceptNameString(),&commandRecordRouter); |
| 839 |
QString krssText = krssTCOntC->getOntologyKRSSText(); |
| 840 |
builder->initializeBuilding(); |
| 841 |
krssParser->parseOntologyText(krssText); |
| 842 |
builder->completeBuilding(); |
| 843 |
delete builder; |
| 844 |
delete krssParser; |
| 845 |
|
| 846 |
//COntologyConfigDependedPreProcesser *ontConDepPreProcessor = new COntologyConfigDependedPreProcesser(commandRecordRouter); |
| 847 |
//ontConDepPreProcessor->preprocess(ont,ontConfig); |
| 848 |
//delete ontConDepPreProcessor; |
| 849 |
|
| 850 |
|
| 851 |
if (mConfLogProcessingTimes) { |
| 852 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 853 |
LOG(INFO,getLogDomain(),logTr("Ontology parsed in %1 ms.").arg(parsingMilliSeconds),this); |
| 854 |
} |
| 855 |
} else { |
| 856 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."),&commandRecordRouter); |
| 857 |
} |
| 858 |
|
| 859 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 860 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
} else if (dynamic_cast<CParseSPARQLQueryCommand *>(command)) { |
| 869 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 870 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 871 |
CParseSPARQLQueryCommand *pSPARQLQueryC = (CParseSPARQLQueryCommand*)command; |
| 872 |
|
| 873 |
|
| 874 |
COntologyRevision *ontRev = pSPARQLQueryC->getOntologyRevision(); |
| 875 |
if (ontRev) { |
| 876 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 877 |
CConcreteOntology* baseOnt = ontRev->getPreviousOntologyRevision()->getOntology(); |
| 878 |
|
| 879 |
QTime parsingTime; |
| 880 |
if (mConfLogProcessingTimes) { |
| 881 |
parsingTime.start(); |
| 882 |
} |
| 883 |
|
| 884 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 885 |
|
| 886 |
bool confRedlandRasqalSPARQLQueryProcessing = CConfigDataReader::readConfigBoolean(ontConfig, "Konclude.Answering.RedlandRasqalSPARQLQueryProcessing", true); |
| 887 |
|
| 888 |
QStringList queryStringList = pSPARQLQueryC->getSPARQLQueryTextList(); |
| 889 |
QList<CQuery*> queryList; |
| 890 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 891 |
if (confRedlandRasqalSPARQLQueryProcessing) { |
| 892 |
QString queryName = QString("%1-Rasqal-Query-Nr-%2").arg(mQueryPrefix).arg(++mQueryNumber); |
| 893 |
CSPARQLRedlandRasqalQueryParser* sparqlQueryParser = new CSPARQLRedlandRasqalQueryParser(baseOnt, onto, ontConfig); |
| 894 |
sparqlQueryParser->parseQueryTextList(queryStringList, queryName); |
| 895 |
CQuery* query = sparqlQueryParser->getQuery(); |
| 896 |
if (query) { |
| 897 |
queryList.append(query); |
| 898 |
} |
| 899 |
delete sparqlQueryParser; |
| 900 |
} else { |
| 901 |
#endif |
| 902 |
CConcreteOntologyUpdateSeparateHashingCollectorBuilder *builder = new CConcreteOntologyUpdateSeparateHashingCollectorBuilder(onto); |
| 903 |
CConcreteOntologyQueryExtendedBuilder* queryBuilderGen = new CConcreteOntologyQueryExtendedBuilder(baseOnt, onto, ontConfig, builder); |
| 904 |
CSPARQLQueryParser* sparqlQueryParser = sparqlQueryParser = new CSPARQLSimpleQueryParser(queryBuilderGen, builder, onto); |
| 905 |
|
| 906 |
|
| 907 |
builder->initializeBuilding(); |
| 908 |
sparqlQueryParser->parseQueryTextList(queryStringList); |
| 909 |
builder->completeBuilding(); |
| 910 |
queryList = queryBuilderGen->generateQuerys(); |
| 911 |
|
| 912 |
delete builder; |
| 913 |
delete queryBuilderGen; |
| 914 |
delete sparqlQueryParser; |
| 915 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 916 |
} |
| 917 |
#endif |
| 918 |
if (queryList.isEmpty()) { |
| 919 |
LOG(WARN, getLogDomain(), logTr("SPARQL query not found or not parsable from request."), this); |
| 920 |
} |
| 921 |
pSPARQLQueryC->setQueryList(queryList); |
| 922 |
|
| 923 |
if (mConfLogProcessingTimes) { |
| 924 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 925 |
LOG(INFO, getLogDomain(), logTr("SPARQL Query parsed in %1 ms.").arg(parsingMilliSeconds), this); |
| 926 |
} |
| 927 |
} else { |
| 928 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."), &commandRecordRouter); |
| 929 |
} |
| 930 |
|
| 931 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 932 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
} else if (dynamic_cast<CGetQueryDependentKnowledgeBaseRevisionUpdatesCommand*>(command)) { |
| 937 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 938 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 939 |
CGetQueryDependentKnowledgeBaseRevisionUpdatesCommand *gQDKBRUC = (CGetQueryDependentKnowledgeBaseRevisionUpdatesCommand*)command; |
| 940 |
|
| 941 |
QList<CQuery*> queryList = gQDKBRUC->getQueryList(); |
| 942 |
for (CQuery* query : queryList) { |
| 943 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 944 |
CRedlandRasqalBGPsCompositionQuery* rrcq = dynamic_cast<CRedlandRasqalBGPsCompositionQuery*>(query); |
| 945 |
if (rrcq) { |
| 946 |
QList<CKnowledgeBaseRevisionCommandProvider*> kbProviderList; |
| 947 |
for (QString kbName : *rrcq->getDependentKnowledgeBaseNames()) { |
| 948 |
CCreateKnowledgeBaseRevisionUpdateCommand* revUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(kbName, false, false, gQDKBRUC); |
| 949 |
kbProviderList.append(revUpC); |
| 950 |
preSynchronizer->delegateCommand(revUpC); |
| 951 |
rrcq->setDependentKnowledgeBaseRevision(kbName, nullptr, nullptr); |
| 952 |
} |
| 953 |
CInstallQueryDependentKnowledgeBaseRevisionUpdatesCommand* insKBRUC = new CInstallQueryDependentKnowledgeBaseRevisionUpdatesCommand(kbProviderList, query, gQDKBRUC); |
| 954 |
preSynchronizer->delegateCommand(insKBRUC); |
| 955 |
} |
| 956 |
#endif // KONCLUDE_REDLAND_INTEGRATION |
| 957 |
} |
| 958 |
|
| 959 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 960 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 961 |
|
| 962 |
} else if (dynamic_cast<CInstallQueryDependentKnowledgeBaseRevisionUpdatesCommand*>(command)) { |
| 963 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 964 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 965 |
CInstallQueryDependentKnowledgeBaseRevisionUpdatesCommand *iQDKBRUC = (CInstallQueryDependentKnowledgeBaseRevisionUpdatesCommand*)command; |
| 966 |
|
| 967 |
CQuery* query = iQDKBRUC->getQuery(); |
| 968 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 969 |
CRedlandRasqalBGPsCompositionQuery* rrcq = dynamic_cast<CRedlandRasqalBGPsCompositionQuery*>(query); |
| 970 |
if (rrcq) { |
| 971 |
QList<CKnowledgeBaseRevisionCommandProvider*>* kbRCPList = iQDKBRUC->getDependentKnowledgeBasesProviderCommandList(); |
| 972 |
for (CKnowledgeBaseRevisionCommandProvider* kbRCP : *kbRCPList) { |
| 973 |
COntologyRevision* ontRev = kbRCP->getOntologyRevision(); |
| 974 |
if (ontRev) { |
| 975 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 976 |
CConcreteOntology* baseOnt = ontRev->getPreviousOntologyRevision()->getOntology(); |
| 977 |
rrcq->setDependentKnowledgeBaseRevision(ontRev->getOntology()->getOntologyName(), baseOnt, onto); |
| 978 |
} |
| 979 |
} |
| 980 |
} |
| 981 |
#endif // KONCLUDE_REDLAND_INTEGRATION |
| 982 |
|
| 983 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 984 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 985 |
|
| 986 |
} else if (dynamic_cast<CParseProcessSPARQLUpdateTextCommand *>(command)) { |
| 987 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 988 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 989 |
CParseProcessSPARQLUpdateTextCommand *pSPARQLUpdateC = (CParseProcessSPARQLUpdateTextCommand*)command; |
| 990 |
|
| 991 |
|
| 992 |
COntologyRevision *ontRev = pSPARQLUpdateC->getOntologyRevision(); |
| 993 |
if (ontRev) { |
| 994 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 995 |
CConcreteOntology* baseOnt = ontRev->getPreviousOntologyRevision()->getOntology(); |
| 996 |
|
| 997 |
QTime parsingTime; |
| 998 |
if (mConfLogProcessingTimes) { |
| 999 |
parsingTime.start(); |
| 1000 |
} |
| 1001 |
|
| 1002 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1003 |
|
| 1004 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(onto); |
| 1005 |
|
| 1006 |
CSPARQLSimpleUpdateParser* sparqlUpdateParser = new CSPARQLSimpleUpdateParser(builder, onto); |
| 1007 |
builder->initializeBuilding(); |
| 1008 |
if (pSPARQLUpdateC->isUpdateTextSplitted()) { |
| 1009 |
QStringList updateStringList = pSPARQLUpdateC->getSPARQLUpdateTextList(); |
| 1010 |
sparqlUpdateParser->parseUpdateTextList(updateStringList); |
| 1011 |
} else { |
| 1012 |
QString updateString = pSPARQLUpdateC->getSPARQLUpdateText(); |
| 1013 |
sparqlUpdateParser->parseUpdateText(updateString); |
| 1014 |
} |
| 1015 |
builder->completeBuilding(); |
| 1016 |
delete builder; |
| 1017 |
delete sparqlUpdateParser; |
| 1018 |
|
| 1019 |
if (mConfLogProcessingTimes) { |
| 1020 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 1021 |
LOG(INFO, getLogDomain(), logTr("SPARQL Update parsed in %1 ms.").arg(parsingMilliSeconds), this); |
| 1022 |
} |
| 1023 |
} else { |
| 1024 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."), &commandRecordRouter); |
| 1025 |
} |
| 1026 |
|
| 1027 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1028 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
} else if (dynamic_cast<CParseProcessSPARQLManageTextCommand *>(command)) { |
| 1033 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 1034 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1035 |
CParseProcessSPARQLManageTextCommand *pSPARQLUpdateC = (CParseProcessSPARQLManageTextCommand*)command; |
| 1036 |
|
| 1037 |
|
| 1038 |
CSPARQLSimpleManagementParser managementParser(preSynchronizer, pSPARQLUpdateC->getKnowlegeBaseString(), pSPARQLUpdateC); |
| 1039 |
managementParser.parseUpdateTextList(pSPARQLUpdateC->getSPARQLUpdateTextList()); |
| 1040 |
|
| 1041 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1042 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1043 |
|
| 1044 |
|
| 1045 |
} else if (dynamic_cast<CCalculateQueriesCommand*>(command)) { |
| 1046 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 1047 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1048 |
CCalculateQueriesCommand *calcQueriesC = (CCalculateQueriesCommand*)command; |
| 1049 |
|
| 1050 |
for (CQuery* query : calcQueriesC->getQueryList()) { |
| 1051 |
if (query) { |
| 1052 |
CCalculateQueryCommand* calcQueryC = new CCalculateQueryCommand(query, calcQueriesC); |
| 1053 |
preSynchronizer->delegateCommand(calcQueryC); |
| 1054 |
} |
| 1055 |
} |
| 1056 |
|
| 1057 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1058 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1059 |
|
| 1060 |
|
| 1061 |
} else if (dynamic_cast<CParseProcessSPARQLTextCommand *>(command)) { |
| 1062 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 1063 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1064 |
CParseProcessSPARQLTextCommand *pSPARQLQueryC = (CParseProcessSPARQLTextCommand *)command; |
| 1065 |
|
| 1066 |
CConfiguration* configuration = getConfiguration(); |
| 1067 |
bool ignoreFromClause = CConfigDataReader::readConfigBoolean(configuration, "Konclude.SPARQL.AlwaysResolveToDefault"); |
| 1068 |
bool waitForQueriesForNextUpdates = CConfigDataReader::readConfigBoolean(configuration, "Konclude.SPARQL.WaitQueryCalculationBeforeContinuingUpdateProcessing"); |
| 1069 |
|
| 1070 |
|
| 1071 |
CSPARQLKnowledgeBaseSplittingOperationParser* sparqlSplittingParser = new CSPARQLKnowledgeBaseSplittingOperationParser(); |
| 1072 |
const QString& queryString = pSPARQLQueryC->getSPARQLQueryText(); |
| 1073 |
sparqlSplittingParser->parseQueryText(queryString); |
| 1074 |
bool foundSparqlOperation = false; |
| 1075 |
for (QString kbString : sparqlSplittingParser->getKnowlegdeBaseList()) { |
| 1076 |
QList<CSPARQLKnowledgeBaseSplittingOperationData*> queryStringList = sparqlSplittingParser->getKnowlegdeBaseSPARQLOperationList(kbString); |
| 1077 |
|
| 1078 |
if (ignoreFromClause || kbString.trimmed().isEmpty()) { |
| 1079 |
kbString = CConfigDataReader::readConfigString(configuration, "Konclude.SPARQL.DefaultResolvingOntology"); |
| 1080 |
} |
| 1081 |
|
| 1082 |
CCreateKnowledgeBaseRevisionUpdateCommand* lastGetCurrKBRevC = nullptr; |
| 1083 |
CParseSPARQLQueryCommand* lastSparqlQC = nullptr; |
| 1084 |
CCalculateQueriesCommand* lastCalcQC = nullptr; |
| 1085 |
|
| 1086 |
CCommand* lastNonQueryC = nullptr; |
| 1087 |
|
| 1088 |
QList<CCommand*> commandList; |
| 1089 |
|
| 1090 |
while (!queryStringList.isEmpty()) { |
| 1091 |
CSPARQLKnowledgeBaseSplittingOperationData* splitKBOperationData(queryStringList.takeLast()); |
| 1092 |
QStringList textList = splitKBOperationData->getOperationPartStringList(); |
| 1093 |
CSPARQLKnowledgeBaseSplittingOperationData::SPARQL_COMMAND_TYPE operationType = splitKBOperationData->getOperationType(); |
| 1094 |
if (operationType == CSPARQLKnowledgeBaseSplittingOperationData::SPARQL_QUERY) { |
| 1095 |
foundSparqlOperation = true; |
| 1096 |
if (!lastGetCurrKBRevC) { |
| 1097 |
lastGetCurrKBRevC = new CCreateKnowledgeBaseRevisionUpdateCommand(kbString, pSPARQLQueryC); |
| 1098 |
if (lastNonQueryC) { |
| 1099 |
lastGetCurrKBRevC->addCommandPrecondition(new CCommandProcessedPrecondition(lastNonQueryC)); |
| 1100 |
} |
| 1101 |
lastNonQueryC = lastGetCurrKBRevC; |
| 1102 |
commandList.append(lastGetCurrKBRevC); |
| 1103 |
lastNonQueryC = lastGetCurrKBRevC; |
| 1104 |
} |
| 1105 |
if (!lastSparqlQC) { |
| 1106 |
lastSparqlQC = new CParseSPARQLQueryCommand(textList, lastGetCurrKBRevC, pSPARQLQueryC); |
| 1107 |
commandList.append(lastSparqlQC); |
| 1108 |
CGetQueryDependentKnowledgeBaseRevisionUpdatesCommand* getDepKBRevUpdateC = new CGetQueryDependentKnowledgeBaseRevisionUpdatesCommand(lastSparqlQC, pSPARQLQueryC); |
| 1109 |
commandList.append(getDepKBRevUpdateC); |
| 1110 |
lastNonQueryC = getDepKBRevUpdateC; |
| 1111 |
CCalculateQueriesCommand* calcQueriesC = new CCalculateQueriesCommand(getDepKBRevUpdateC, pSPARQLQueryC); |
| 1112 |
commandList.append(calcQueriesC); |
| 1113 |
lastCalcQC = calcQueriesC; |
| 1114 |
if (waitForQueriesForNextUpdates) { |
| 1115 |
// may be necessary for avoiding concurrent access to redland rdf nodes/triples (if persistence is enabled/used) |
| 1116 |
lastNonQueryC = calcQueriesC; |
| 1117 |
} |
| 1118 |
lastSparqlQC = nullptr; |
| 1119 |
} |
| 1120 |
} else if (operationType == CSPARQLKnowledgeBaseSplittingOperationData::SPARQL_UPDATE_MANAGE) { |
| 1121 |
foundSparqlOperation = true; |
| 1122 |
lastGetCurrKBRevC = nullptr; |
| 1123 |
|
| 1124 |
// some SPARQL update commands may have dependencies to several graphs/knowledge bases, e.g., COPY, i.e., we need a more sophisticated mechanism at some point |
| 1125 |
CParseProcessSPARQLManageTextCommand* ppSPARQLUTC = new CParseProcessSPARQLManageTextCommand(textList, kbString, pSPARQLQueryC); |
| 1126 |
commandList.append(ppSPARQLUTC); |
| 1127 |
if (lastNonQueryC) { |
| 1128 |
ppSPARQLUTC->addCommandPrecondition(new CCommandProcessedPrecondition(lastNonQueryC)); |
| 1129 |
} |
| 1130 |
|
| 1131 |
lastNonQueryC = ppSPARQLUTC; |
| 1132 |
|
| 1133 |
} else if (operationType == CSPARQLKnowledgeBaseSplittingOperationData::SPARQL_UPDATE_MODIFY) { |
| 1134 |
foundSparqlOperation = true; |
| 1135 |
lastGetCurrKBRevC = nullptr; |
| 1136 |
lastSparqlQC = nullptr; |
| 1137 |
|
| 1138 |
CCreateKnowledgeBaseRevisionUpdateCommand* getCurrKBRevC = new CCreateKnowledgeBaseRevisionUpdateCommand(kbString, true, pSPARQLQueryC); |
| 1139 |
if (lastNonQueryC) { |
| 1140 |
getCurrKBRevC->addCommandPrecondition(new CCommandProcessedPrecondition(lastNonQueryC)); |
| 1141 |
} |
| 1142 |
commandList.append(getCurrKBRevC); |
| 1143 |
|
| 1144 |
CParseProcessSPARQLUpdateTextCommand* ppSPARQLUTC = new CParseProcessSPARQLUpdateTextCommand(textList, getCurrKBRevC, pSPARQLQueryC); |
| 1145 |
commandList.append(ppSPARQLUTC); |
| 1146 |
|
| 1147 |
CInstallKnowledgeBaseRevisionUpdateCommand *inKBRevUpC = new CInstallKnowledgeBaseRevisionUpdateCommand(kbString, ppSPARQLUTC, pSPARQLQueryC); |
| 1148 |
inKBRevUpC->addCommandPrecondition(new CCommandProcessedPrecondition(ppSPARQLUTC)); |
| 1149 |
commandList.append(inKBRevUpC); |
| 1150 |
lastNonQueryC = inKBRevUpC; |
| 1151 |
} |
| 1152 |
} |
| 1153 |
|
| 1154 |
for (CCommand* command : commandList) { |
| 1155 |
preSynchronizer->delegateCommand(command); |
| 1156 |
} |
| 1157 |
} |
| 1158 |
delete sparqlSplittingParser; |
| 1159 |
|
| 1160 |
if (!foundSparqlOperation) { |
| 1161 |
LOG(WARN, getLogDomain(), logTr("No SPARQL command found in request."), this); |
| 1162 |
} |
| 1163 |
|
| 1164 |
|
| 1165 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1166 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
} else if (dynamic_cast<CParseOWL2XMLOntologyCommand *>(command)) { |
| 1172 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1173 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1174 |
CParseOWL2XMLOntologyCommand *pOWLOntC = (CParseOWL2XMLOntologyCommand *)command; |
| 1175 |
|
| 1176 |
|
| 1177 |
COntologyRevision *ontRev = pOWLOntC->getOntologyRevision(); |
| 1178 |
if (ontRev) { |
| 1179 |
CConcreteOntology *ont = ontRev->getOntology(); |
| 1180 |
|
| 1181 |
QTime parsingTime; |
| 1182 |
if (mConfLogProcessingTimes) { |
| 1183 |
parsingTime.start(); |
| 1184 |
} |
| 1185 |
|
| 1186 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1187 |
|
| 1188 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 1189 |
COWL2QtXMLOntologyParser *owl2Parser = new COWL2QtXMLOntologyParser(builder,&commandRecordRouter); |
| 1190 |
QDomElement domEl = pOWLOntC->getOntologyNode(); |
| 1191 |
builder->initializeBuilding(); |
| 1192 |
owl2Parser->parseOntologyNode(&domEl); |
| 1193 |
builder->completeBuilding(); |
| 1194 |
delete builder; |
| 1195 |
delete owl2Parser; |
| 1196 |
|
| 1197 |
if (mConfLogProcessingTimes) { |
| 1198 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 1199 |
LOG(INFO,getLogDomain(),logTr("Ontology parsed in %1 ms.").arg(parsingMilliSeconds),this); |
| 1200 |
} |
| 1201 |
} else { |
| 1202 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."),&commandRecordRouter); |
| 1203 |
} |
| 1204 |
|
| 1205 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1206 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1207 |
|
| 1208 |
|
| 1209 |
} else if (dynamic_cast<CSAXParseOWL2XMLOntologyCommand *>(command)) { |
| 1210 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1211 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1212 |
CSAXParseOWL2XMLOntologyCommand *pOWLOntC = (CSAXParseOWL2XMLOntologyCommand *)command; |
| 1213 |
|
| 1214 |
QString iriString = pOWLOntC->getSourceString(); |
| 1215 |
if (iriString.startsWith("file:")) { |
| 1216 |
iriString.replace("file:",""); |
| 1217 |
} |
| 1218 |
while (!QFile::exists(iriString) && iriString.startsWith("/")) { |
| 1219 |
iriString = iriString.remove(0,1); |
| 1220 |
} |
| 1221 |
|
| 1222 |
|
| 1223 |
COntologyRevision *ontRev = pOWLOntC->getOntologyRevision(); |
| 1224 |
if (ontRev) { |
| 1225 |
CConcreteOntology *ont = ontRev->getOntology(); |
| 1226 |
|
| 1227 |
QTime parsingTime; |
| 1228 |
if (mConfLogProcessingTimes) { |
| 1229 |
parsingTime.start(); |
| 1230 |
} |
| 1231 |
|
| 1232 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1233 |
|
| 1234 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 1235 |
COWL2QtXMLOntologySAXParser *owl2Parser = new COWL2QtXMLOntologySAXParser(builder); |
| 1236 |
builder->initializeBuilding(); |
| 1237 |
LOG(INFO,getLogDomain(),logTr("Starting SAX-based ontology parsing for '%1'.").arg(iriString),this); |
| 1238 |
owl2Parser->parseOntology(iriString); |
| 1239 |
LOG(INFO,getLogDomain(),logTr("Finished SAX-based ontology parsing for '%1'.").arg(iriString),this); |
| 1240 |
|
| 1241 |
builder->completeBuilding(); |
| 1242 |
delete builder; |
| 1243 |
delete owl2Parser; |
| 1244 |
|
| 1245 |
if (mConfLogProcessingTimes) { |
| 1246 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 1247 |
LOG(INFO,getLogDomain(),logTr("Ontology parsed in %1 ms.").arg(parsingMilliSeconds),this); |
| 1248 |
} |
| 1249 |
} else { |
| 1250 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."),&commandRecordRouter); |
| 1251 |
} |
| 1252 |
|
| 1253 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1254 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1255 |
|
| 1256 |
|
| 1257 |
} else if (dynamic_cast<CStreamParseOWL2XMLOntologyCommand *>(command)) { |
| 1258 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1259 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1260 |
CStreamParseOWL2XMLOntologyCommand *pOWLOntC = (CStreamParseOWL2XMLOntologyCommand *)command; |
| 1261 |
|
| 1262 |
QString iriString = pOWLOntC->getSourceString(); |
| 1263 |
if (iriString.startsWith("file:")) { |
| 1264 |
iriString.replace("file:",""); |
| 1265 |
} |
| 1266 |
while (!QFile::exists(iriString) && iriString.startsWith("/")) { |
| 1267 |
iriString = iriString.remove(0,1); |
| 1268 |
} |
| 1269 |
|
| 1270 |
|
| 1271 |
COntologyRevision *ontRev = pOWLOntC->getOntologyRevision(); |
| 1272 |
if (ontRev) { |
| 1273 |
CConcreteOntology *ont = ontRev->getOntology(); |
| 1274 |
|
| 1275 |
QTime parsingTime; |
| 1276 |
if (mConfLogProcessingTimes) { |
| 1277 |
parsingTime.start(); |
| 1278 |
} |
| 1279 |
|
| 1280 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1281 |
|
| 1282 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 1283 |
bool enforceUTF8ConvertingParsing = CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Parser.UTF8CompatibilityEnforcedXMLStreamParsing"); |
| 1284 |
COWL2QtXMLOntologyStreamParser *owl2Parser = nullptr; |
| 1285 |
if (enforceUTF8ConvertingParsing) { |
| 1286 |
owl2Parser = new COWL2QtXMLOntologyStableStreamParser(builder); |
| 1287 |
} else { |
| 1288 |
owl2Parser = new COWL2QtXMLOntologyStreamParser(builder); |
| 1289 |
} |
| 1290 |
builder->initializeBuilding(); |
| 1291 |
LOG(INFO,getLogDomain(),logTr("Starting stream-based OWL2/XML ontology parsing for '%1'.").arg(iriString),this); |
| 1292 |
if (owl2Parser->parseOntology(iriString)) { |
| 1293 |
LOG(INFO,getLogDomain(),logTr("Finished stream-based OWL2/XML ontology parsing for '%1'.").arg(iriString),this); |
| 1294 |
builder->completeBuilding(); |
| 1295 |
} else { |
| 1296 |
if (owl2Parser->hasError()) { |
| 1297 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Stream-based OWL2/XML ontology parsing error: '%1'.").arg(owl2Parser->getErrorString()),&commandRecordRouter); |
| 1298 |
} |
| 1299 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Stream-based OWL2/XML ontology parsing for '%1' failed.").arg(iriString),&commandRecordRouter); |
| 1300 |
} |
| 1301 |
|
| 1302 |
delete builder; |
| 1303 |
delete owl2Parser; |
| 1304 |
|
| 1305 |
if (mConfLogProcessingTimes) { |
| 1306 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 1307 |
LOG(INFO,getLogDomain(),logTr("Ontology parsed in %1 ms.").arg(parsingMilliSeconds),this); |
| 1308 |
} |
| 1309 |
} else { |
| 1310 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."),&commandRecordRouter); |
| 1311 |
} |
| 1312 |
|
| 1313 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1314 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
} else if (dynamic_cast<CStreamParseOWL2FunctionalOntologyCommand *>(command)) { |
| 1325 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1326 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1327 |
CStreamParseOWL2FunctionalOntologyCommand *pOWLOntC = (CStreamParseOWL2FunctionalOntologyCommand *)command; |
| 1328 |
|
| 1329 |
QString iriString = pOWLOntC->getSourceString(); |
| 1330 |
if (iriString.startsWith("file:")) { |
| 1331 |
iriString.replace("file:",""); |
| 1332 |
} |
| 1333 |
while (!QFile::exists(iriString) && iriString.startsWith("/")) { |
| 1334 |
iriString = iriString.remove(0,1); |
| 1335 |
} |
| 1336 |
|
| 1337 |
|
| 1338 |
COntologyRevision *ontRev = pOWLOntC->getOntologyRevision(); |
| 1339 |
if (ontRev) { |
| 1340 |
CConcreteOntology *ont = ontRev->getOntology(); |
| 1341 |
|
| 1342 |
QTime parsingTime; |
| 1343 |
if (mConfLogProcessingTimes) { |
| 1344 |
parsingTime.start(); |
| 1345 |
} |
| 1346 |
|
| 1347 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1348 |
|
| 1349 |
CConcreteOntologyUpdateCollectorBuilder *builder = new CConcreteOntologyUpdateCollectorBuilder(ont); |
| 1350 |
COWL2FunctionalJAVACCOntologyStreamParser *owl2Parser = new COWL2FunctionalJAVACCOntologyStreamParser(builder); |
| 1351 |
builder->initializeBuilding(); |
| 1352 |
LOG(INFO,getLogDomain(),logTr("Starting stream-based OWL2/Functional ontology parsing for '%1'.").arg(iriString),this); |
| 1353 |
if (owl2Parser->parseOntology(iriString)) { |
| 1354 |
LOG(INFO,getLogDomain(),logTr("Finished stream-based OWL2/Functional ontology parsing for '%1'.").arg(iriString),this); |
| 1355 |
builder->completeBuilding(); |
| 1356 |
} else { |
| 1357 |
if (owl2Parser->hasError()) { |
| 1358 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Stream-based OWL2/Functional ontology parsing error: '%1'.").arg(owl2Parser->getErrorString()),&commandRecordRouter); |
| 1359 |
} |
| 1360 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Stream-based OWL2/Functional ontology parsing for '%1' failed.").arg(iriString),&commandRecordRouter); |
| 1361 |
} |
| 1362 |
|
| 1363 |
delete builder; |
| 1364 |
delete owl2Parser; |
| 1365 |
|
| 1366 |
|
| 1367 |
if (mConfLogProcessingTimes) { |
| 1368 |
cint64 parsingMilliSeconds = parsingTime.elapsed(); |
| 1369 |
LOG(INFO,getLogDomain(),logTr("Ontology parsed in %1 ms.").arg(parsingMilliSeconds),this); |
| 1370 |
} |
| 1371 |
} else { |
| 1372 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Knowledge base revision not available."),&commandRecordRouter); |
| 1373 |
} |
| 1374 |
|
| 1375 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1376 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
} else if (dynamic_cast<CProcessQueryOWL2XMLNodeCommand *>(command)) { |
| 1387 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1388 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1389 |
CProcessQueryOWL2XMLNodeCommand *pqOWLC = (CProcessQueryOWL2XMLNodeCommand *)command; |
| 1390 |
|
| 1391 |
CBuildQueryCommand *buildQC = pqOWLC->getBuildQueryCommand(); |
| 1392 |
|
| 1393 |
CKnowledgeBaseRevisionCommandProvider* cKBRevCP = nullptr; |
| 1394 |
|
| 1395 |
bool complexQuery = pqOWLC->isComplexQuery(); |
| 1396 |
if (complexQuery) { |
| 1397 |
CCreateKnowledgeBaseRevisionUpdateCommand *crKBRevUpC = new CCreateKnowledgeBaseRevisionUpdateCommand(pqOWLC->getKnowledgeBaseName()); |
| 1398 |
buildQC->makeToSubCommand(crKBRevUpC); |
| 1399 |
cKBRevCP = crKBRevUpC; |
| 1400 |
} else { |
| 1401 |
CGetCurrentKnowledgeBaseRevisionCommand *crKBRevGet = new CGetCurrentKnowledgeBaseRevisionCommand(pqOWLC->getKnowledgeBaseName()); |
| 1402 |
buildQC->makeToSubCommand(crKBRevGet); |
| 1403 |
cKBRevCP = crKBRevGet; |
| 1404 |
} |
| 1405 |
|
| 1406 |
CParseOWL2XMLQueryCommand *pOWLQC = new CParseOWL2XMLQueryCommand(pqOWLC->getQueryNode(),cKBRevCP); |
| 1407 |
buildQC->makeToSubCommand(pOWLQC); |
| 1408 |
pOWLQC->setQueryComplexity(complexQuery); |
| 1409 |
|
| 1410 |
|
| 1411 |
CPrepareKnowledgeBaseForQueryCommand* prepKBForQueryC = new CPrepareKnowledgeBaseForQueryCommand(cKBRevCP,pOWLQC); |
| 1412 |
buildQC->makeToSubCommand(prepKBForQueryC); |
| 1413 |
prepKBForQueryC->addCommandPrecondition(new CCommandProcessedPrecondition(pOWLQC)); |
| 1414 |
|
| 1415 |
CGenerateQueryCommand* genQC = new CGenerateQueryCommand(pOWLQC); |
| 1416 |
buildQC->makeToSubCommand(genQC); |
| 1417 |
buildQC->setQueryCommandProvider(genQC); |
| 1418 |
genQC->addCommandPrecondition(new CCommandProcessedPrecondition(prepKBForQueryC)); |
| 1419 |
|
| 1420 |
CCalculateQueryCommand *calcQC = pqOWLC->getCalculateQueryCommand(); |
| 1421 |
|
| 1422 |
preSynchronizer->delegateCommand(buildQC); |
| 1423 |
preSynchronizer->delegateCommand(calcQC); |
| 1424 |
|
| 1425 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1426 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1427 |
|
| 1428 |
} else if (dynamic_cast<CPrepareKnowledgeBaseForQueryCommand*>(command)) { |
| 1429 |
CCommandRecordRouter commandRecordRouter(command, this); |
| 1430 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1431 |
CPrepareKnowledgeBaseForQueryCommand *pKBFQC = (CPrepareKnowledgeBaseForQueryCommand *)command; |
| 1432 |
|
| 1433 |
CQueryGenerator* queryGenerator = pKBFQC->getQueryGenerator(); |
| 1434 |
if (queryGenerator->requiresPreprocessedOntology()) { |
| 1435 |
CPreprocessKnowledgeBaseRequirementsForQueryCommand* prepKBForQueryC = new CPreprocessKnowledgeBaseRequirementsForQueryCommand(pKBFQC->getOntologyRevisionProvider()); |
| 1436 |
pKBFQC->makeToSubCommand(prepKBForQueryC); |
| 1437 |
preSynchronizer->delegateCommand(prepKBForQueryC); |
| 1438 |
} |
| 1439 |
|
| 1440 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1441 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1442 |
|
| 1443 |
|
| 1444 |
} else if (dynamic_cast<CProcessClassNameSatisfiableQueryCommand*>(command)) { |
| 1445 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1446 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1447 |
CProcessClassNameSatisfiableQueryCommand *pqOWLC = (CProcessClassNameSatisfiableQueryCommand *)command; |
| 1448 |
|
| 1449 |
|
| 1450 |
CBuildQueryCommand *buildQC = pqOWLC->getBuildQueryCommand(); |
| 1451 |
if (!buildQC) { |
| 1452 |
buildQC = new CBuildQueryCommand(0,pqOWLC); |
| 1453 |
pqOWLC->setBuildQueryCommand(buildQC); |
| 1454 |
} |
| 1455 |
|
| 1456 |
CCalculateQueryCommand *calcQC = pqOWLC->getCalculateQueryCommand(); |
| 1457 |
if (!calcQC) { |
| 1458 |
calcQC = new CCalculateQueryCommand(buildQC,pqOWLC); |
| 1459 |
pqOWLC->setCalculateQueryCommand(calcQC); |
| 1460 |
} |
| 1461 |
|
| 1462 |
|
| 1463 |
CGetCurrentKnowledgeBaseRevisionCommand *crKBRevGet = new CGetCurrentKnowledgeBaseRevisionCommand(pqOWLC->getKnowledgeBaseName()); |
| 1464 |
buildQC->makeToSubCommand(crKBRevGet); |
| 1465 |
|
| 1466 |
CPreprocessKnowledgeBaseRequirementsForQueryCommand* prepKBForQueryC = new CPreprocessKnowledgeBaseRequirementsForQueryCommand(crKBRevGet); |
| 1467 |
buildQC->makeToSubCommand(prepKBForQueryC); |
| 1468 |
prepKBForQueryC->addCommandPrecondition(new CCommandProcessedPrecondition(crKBRevGet)); |
| 1469 |
|
| 1470 |
CConstructClassSatisfiableQueryCommand *pOWLQC = new CConstructClassSatisfiableQueryCommand(pqOWLC->getClassName(),crKBRevGet); |
| 1471 |
buildQC->makeToSubCommand(pOWLQC); |
| 1472 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1473 |
pOWLQC->addCommandPrecondition(new CCommandProcessedPrecondition(prepKBForQueryC)); |
| 1474 |
|
| 1475 |
preSynchronizer->delegateCommand(buildQC); |
| 1476 |
preSynchronizer->delegateCommand(calcQC); |
| 1477 |
|
| 1478 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1479 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1480 |
|
| 1481 |
|
| 1482 |
} else if (dynamic_cast<CBuildQueryCommand *>(command)) { |
| 1483 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1484 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1485 |
|
| 1486 |
CLinker<CCommand *> *subComIt = command->getSubCommandLinker(); |
| 1487 |
while (subComIt) { |
| 1488 |
CCommand *supCommand = subComIt->getData(); |
| 1489 |
preSynchronizer->delegateCommand(supCommand); |
| 1490 |
subComIt = subComIt->getNext(); |
| 1491 |
} |
| 1492 |
|
| 1493 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1494 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1495 |
|
| 1496 |
} else if (dynamic_cast<CInsertResponseCommentCommand *>(command)) { |
| 1497 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1498 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1499 |
|
| 1500 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1501 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1502 |
|
| 1503 |
} else if (dynamic_cast<CParseTestsuiteXMLNodeCommand *>(command)) { |
| 1504 |
CParseTestsuiteXMLNodeCommand *parseTestsuiteComm = (CParseTestsuiteXMLNodeCommand *)command; |
| 1505 |
CXMLTestsuiteCommandParser *testsuiteParser = new CXMLTestsuiteCommandParser(); |
| 1506 |
testsuiteParser->realizeCommand(parseTestsuiteComm,preSynchronizer); |
| 1507 |
delete testsuiteParser; |
| 1508 |
|
| 1509 |
|
| 1510 |
} else if (dynamic_cast<CTestTestsuiteCommand *>(command)) { |
| 1511 |
CTestTestsuiteCommand *testTestsuiteComm = (CTestTestsuiteCommand *)command; |
| 1512 |
CConfiguration *config = getConfiguration(); |
| 1513 |
CReasonerTestsuiteTester *testsuiteTester = new CReasonerTestsuiteTester(config); |
| 1514 |
testsuiteTester->realizeTestCommand(testTestsuiteComm); |
| 1515 |
delete testsuiteTester; |
| 1516 |
|
| 1517 |
|
| 1518 |
} else if (dynamic_cast<CEvaluateTestsuiteCommand *>(command)) { |
| 1519 |
CEvaluateTestsuiteCommand* evalTestsuiteComm = (CEvaluateTestsuiteCommand*)command; |
| 1520 |
CConfiguration *config = getConfiguration(); |
| 1521 |
|
| 1522 |
CReasonerEvaluationManagerThread* evalManager = new CReasonerEvaluationManagerThread(config);; |
| 1523 |
evalManager->realizeEvaluationCommand(evalTestsuiteComm); |
| 1524 |
evalManager->waitSynchronization(); |
| 1525 |
delete evalManager; |
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
} else if (dynamic_cast<CWriteFunctionalSubClassHierarchyQueryCommand *>(command)) { |
| 1530 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1531 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1532 |
CWriteFunctionalSubClassHierarchyQueryCommand *wFSCHC = (CWriteFunctionalSubClassHierarchyQueryCommand *)command; |
| 1533 |
|
| 1534 |
CBuildQueryCommand *buildQC = wFSCHC->getBuildQueryCommand(); |
| 1535 |
if (!buildQC) { |
| 1536 |
buildQC = new CBuildQueryCommand(0,wFSCHC); |
| 1537 |
wFSCHC->setBuildQueryCommand(buildQC); |
| 1538 |
} |
| 1539 |
|
| 1540 |
CCalculateQueryCommand *calcQC = wFSCHC->getCalculateQueryCommand(); |
| 1541 |
if (!calcQC) { |
| 1542 |
calcQC = new CCalculateQueryCommand(buildQC,wFSCHC); |
| 1543 |
wFSCHC->setCalculateQueryCommand(calcQC); |
| 1544 |
} |
| 1545 |
|
| 1546 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(wFSCHC->getKnowledgeBaseName()); |
| 1547 |
buildQC->makeToSubCommand(getCKBRC); |
| 1548 |
|
| 1549 |
CConstructWriteFunctionalSubClassHirarchyQueryCommand *pOWLQC = new CConstructWriteFunctionalSubClassHirarchyQueryCommand(getCKBRC,wFSCHC->getOutputFileString()); |
| 1550 |
buildQC->makeToSubCommand(pOWLQC); |
| 1551 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1552 |
|
| 1553 |
|
| 1554 |
preSynchronizer->delegateCommand(buildQC); |
| 1555 |
preSynchronizer->delegateCommand(calcQC); |
| 1556 |
|
| 1557 |
|
| 1558 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1559 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
} else if (dynamic_cast<CWriteCustomQueryCommand *>(command)) { |
| 1564 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1565 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1566 |
CWriteCustomQueryCommand *wCQC = (CWriteCustomQueryCommand *)command; |
| 1567 |
|
| 1568 |
CBuildQueryCommand *buildQC = wCQC->getBuildQueryCommand(); |
| 1569 |
if (!buildQC) { |
| 1570 |
buildQC = new CBuildQueryCommand(0,wCQC); |
| 1571 |
wCQC->setBuildQueryCommand(buildQC); |
| 1572 |
} |
| 1573 |
|
| 1574 |
CCalculateQueryCommand *calcQC = wCQC->getCalculateQueryCommand(); |
| 1575 |
if (!calcQC) { |
| 1576 |
calcQC = new CCalculateQueryCommand(buildQC,wCQC); |
| 1577 |
wCQC->setCalculateQueryCommand(calcQC); |
| 1578 |
} |
| 1579 |
|
| 1580 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(wCQC->getKnowledgeBaseName()); |
| 1581 |
buildQC->makeToSubCommand(getCKBRC); |
| 1582 |
|
| 1583 |
CConstructWriteCustomQueryCommand *pOWLQC = new CConstructWriteCustomQueryCommand(getCKBRC,wCQC->getWriteQueryType(),wCQC->getWriteQuerySerializer(),wCQC->getEntityRestrictionString()); |
| 1584 |
buildQC->makeToSubCommand(pOWLQC); |
| 1585 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1586 |
|
| 1587 |
|
| 1588 |
preSynchronizer->delegateCommand(buildQC); |
| 1589 |
preSynchronizer->delegateCommand(calcQC); |
| 1590 |
|
| 1591 |
|
| 1592 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1593 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
} else if (dynamic_cast<CClassifyQueryCommand *>(command)) { |
| 1601 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1602 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1603 |
CClassifyQueryCommand* cqC = (CClassifyQueryCommand*)command; |
| 1604 |
|
| 1605 |
CBuildQueryCommand *buildQC = cqC->getBuildQueryCommand(); |
| 1606 |
if (!buildQC) { |
| 1607 |
buildQC = new CBuildQueryCommand(0,cqC); |
| 1608 |
cqC->setBuildQueryCommand(buildQC); |
| 1609 |
} |
| 1610 |
|
| 1611 |
CCalculateQueryCommand *calcQC = cqC->getCalculateQueryCommand(); |
| 1612 |
if (!calcQC) { |
| 1613 |
calcQC = new CCalculateQueryCommand(buildQC,cqC); |
| 1614 |
cqC->setCalculateQueryCommand(calcQC); |
| 1615 |
} |
| 1616 |
|
| 1617 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(cqC->getKnowledgeBaseName()); |
| 1618 |
buildQC->makeToSubCommand(getCKBRC); |
| 1619 |
|
| 1620 |
CConstructClassifyQueryCommand *pOWLQC = new CConstructClassifyQueryCommand(getCKBRC); |
| 1621 |
buildQC->makeToSubCommand(pOWLQC); |
| 1622 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1623 |
|
| 1624 |
|
| 1625 |
preSynchronizer->delegateCommand(buildQC); |
| 1626 |
preSynchronizer->delegateCommand(calcQC); |
| 1627 |
|
| 1628 |
|
| 1629 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1630 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
} else if (dynamic_cast<CRealizeQueryCommand *>(command)) { |
| 1635 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1636 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1637 |
CRealizeQueryCommand* rqC = (CRealizeQueryCommand*)command; |
| 1638 |
|
| 1639 |
CBuildQueryCommand *buildQC = rqC->getBuildQueryCommand(); |
| 1640 |
if (!buildQC) { |
| 1641 |
buildQC = new CBuildQueryCommand(0,rqC); |
| 1642 |
rqC->setBuildQueryCommand(buildQC); |
| 1643 |
} |
| 1644 |
|
| 1645 |
CCalculateQueryCommand *calcQC = rqC->getCalculateQueryCommand(); |
| 1646 |
if (!calcQC) { |
| 1647 |
calcQC = new CCalculateQueryCommand(buildQC,rqC); |
| 1648 |
rqC->setCalculateQueryCommand(calcQC); |
| 1649 |
} |
| 1650 |
|
| 1651 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(rqC->getKnowledgeBaseName()); |
| 1652 |
buildQC->makeToSubCommand(getCKBRC); |
| 1653 |
|
| 1654 |
CConstructRealizeQueryCommand *pOWLQC = new CConstructRealizeQueryCommand(getCKBRC); |
| 1655 |
buildQC->makeToSubCommand(pOWLQC); |
| 1656 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1657 |
|
| 1658 |
|
| 1659 |
preSynchronizer->delegateCommand(buildQC); |
| 1660 |
preSynchronizer->delegateCommand(calcQC); |
| 1661 |
|
| 1662 |
|
| 1663 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1664 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1665 |
|
| 1666 |
} else if (dynamic_cast<CGetKnowledgeBaseEntitiesCommand *>(command)) { |
| 1667 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1668 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1669 |
CGetKnowledgeBaseEntitiesCommand* gKBEC = (CGetKnowledgeBaseEntitiesCommand*)command; |
| 1670 |
|
| 1671 |
if (!gKBEC->getExtractedEntityContainer()) { |
| 1672 |
gKBEC->setExtractedEntityContainer(new CExtractedKnowledgeBaseEntitiesContainer()); |
| 1673 |
} |
| 1674 |
|
| 1675 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(gKBEC->getKnowledgeBaseName()); |
| 1676 |
gKBEC->makeToSubCommand(getCKBRC); |
| 1677 |
|
| 1678 |
CPrepareKnowledgeBaseCommand* prepKBC = new CPrepareKnowledgeBaseCommand(getCKBRC); |
| 1679 |
prepKBC->addCommandPrecondition(new CCommandProcessedPrecondition(getCKBRC)); |
| 1680 |
gKBEC->makeToSubCommand(prepKBC); |
| 1681 |
|
| 1682 |
COntologyProcessingStepVector* ontProStepVec = COntologyProcessingStepVector::getProcessingStepVectorInstance(); |
| 1683 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSACTIVECOUNT), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1684 |
|
| 1685 |
preSynchronizer->delegateCommand(prepKBC); |
| 1686 |
|
| 1687 |
|
| 1688 |
CExtractKnowledgeBaseEntitiesCommand *eKBEC = new CExtractKnowledgeBaseEntitiesCommand(gKBEC->getExtractedEntityContainer(),gKBEC->getEntityExtractionSpecification(),getCKBRC); |
| 1689 |
eKBEC->addCommandPrecondition(new CCommandProcessedPrecondition(prepKBC)); |
| 1690 |
gKBEC->makeToSubCommand(eKBEC); |
| 1691 |
|
| 1692 |
preSynchronizer->delegateCommand(getCKBRC); |
| 1693 |
preSynchronizer->delegateCommand(eKBEC); |
| 1694 |
|
| 1695 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1696 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1697 |
|
| 1698 |
|
| 1699 |
} else if (dynamic_cast<CGetKnowledgeBaseLanguageCommand *>(command)) { |
| 1700 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1701 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1702 |
CGetKnowledgeBaseLanguageCommand* gKBLC = (CGetKnowledgeBaseLanguageCommand*)command; |
| 1703 |
|
| 1704 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(gKBLC->getKnowledgeBaseName()); |
| 1705 |
gKBLC->makeToSubCommand(getCKBRC); |
| 1706 |
|
| 1707 |
CPrepareKnowledgeBaseCommand* prepKBC = new CPrepareKnowledgeBaseCommand(getCKBRC); |
| 1708 |
prepKBC->addCommandPrecondition(new CCommandProcessedPrecondition(getCKBRC)); |
| 1709 |
gKBLC->makeToSubCommand(prepKBC); |
| 1710 |
|
| 1711 |
COntologyProcessingStepVector* ontProStepVec = COntologyProcessingStepVector::getProcessingStepVectorInstance(); |
| 1712 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSPREPROCESS), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1713 |
|
| 1714 |
preSynchronizer->delegateCommand(prepKBC); |
| 1715 |
|
| 1716 |
|
| 1717 |
CExtractKnowledgeBaseLanguageCommand *eKBEC = new CExtractKnowledgeBaseLanguageCommand(gKBLC->getLanguageStringPointer(),getCKBRC); |
| 1718 |
eKBEC->addCommandPrecondition(new CCommandProcessedPrecondition(prepKBC)); |
| 1719 |
gKBLC->makeToSubCommand(eKBEC); |
| 1720 |
|
| 1721 |
preSynchronizer->delegateCommand(getCKBRC); |
| 1722 |
preSynchronizer->delegateCommand(eKBEC); |
| 1723 |
|
| 1724 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1725 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1726 |
|
| 1727 |
|
| 1728 |
} else if (dynamic_cast<CGetSubClassHierarchyQueryOWL2XMLNodeCommand *>(command)) { |
| 1729 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1730 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1731 |
CGetSubClassHierarchyQueryOWL2XMLNodeCommand *gSCHOWLC = (CGetSubClassHierarchyQueryOWL2XMLNodeCommand *)command; |
| 1732 |
|
| 1733 |
CBuildQueryCommand *buildQC = gSCHOWLC->getBuildQueryCommand(); |
| 1734 |
|
| 1735 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(gSCHOWLC->getKnowledgeBaseName()); |
| 1736 |
buildQC->makeToSubCommand(getCKBRC); |
| 1737 |
|
| 1738 |
CConstructSubClassHirarchyQueryCommand *pOWLQC = new CConstructSubClassHirarchyQueryCommand(getCKBRC,gSCHOWLC->getQueryNode()); |
| 1739 |
buildQC->makeToSubCommand(pOWLQC); |
| 1740 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1741 |
|
| 1742 |
CCalculateQueryCommand *calcQC = gSCHOWLC->getCalculateQueryCommand(); |
| 1743 |
|
| 1744 |
preSynchronizer->delegateCommand(buildQC); |
| 1745 |
preSynchronizer->delegateCommand(calcQC); |
| 1746 |
|
| 1747 |
|
| 1748 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1749 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
} else if (dynamic_cast<CIsConsistentQueryCommand *>(command)) { |
| 1754 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1755 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1756 |
CIsConsistentQueryCommand* iCQC = (CIsConsistentQueryCommand*)command; |
| 1757 |
|
| 1758 |
CBuildQueryCommand *buildQC = iCQC->getBuildQueryCommand(); |
| 1759 |
if (!buildQC) { |
| 1760 |
buildQC = new CBuildQueryCommand(0,iCQC); |
| 1761 |
iCQC->setBuildQueryCommand(buildQC); |
| 1762 |
} |
| 1763 |
|
| 1764 |
CCalculateQueryCommand *calcQC = iCQC->getCalculateQueryCommand(); |
| 1765 |
if (!calcQC) { |
| 1766 |
calcQC = new CCalculateQueryCommand(buildQC,iCQC); |
| 1767 |
iCQC->setCalculateQueryCommand(calcQC); |
| 1768 |
} |
| 1769 |
|
| 1770 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(iCQC->getKnowledgeBaseName()); |
| 1771 |
buildQC->makeToSubCommand(getCKBRC); |
| 1772 |
|
| 1773 |
CConstructIsConsistentQueryCommand *pOWLQC = new CConstructIsConsistentQueryCommand(getCKBRC); |
| 1774 |
buildQC->makeToSubCommand(pOWLQC); |
| 1775 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1776 |
|
| 1777 |
|
| 1778 |
preSynchronizer->delegateCommand(buildQC); |
| 1779 |
preSynchronizer->delegateCommand(calcQC); |
| 1780 |
|
| 1781 |
|
| 1782 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1783 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
} else if (dynamic_cast<CIsTriviallyConsistentQueryCommand *>(command)) { |
| 1790 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1791 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1792 |
CIsTriviallyConsistentQueryCommand* iCQC = (CIsTriviallyConsistentQueryCommand*)command; |
| 1793 |
|
| 1794 |
CBuildQueryCommand *buildQC = iCQC->getBuildQueryCommand(); |
| 1795 |
if (!buildQC) { |
| 1796 |
buildQC = new CBuildQueryCommand(0,iCQC); |
| 1797 |
iCQC->setBuildQueryCommand(buildQC); |
| 1798 |
} |
| 1799 |
|
| 1800 |
CCalculateQueryCommand *calcQC = iCQC->getCalculateQueryCommand(); |
| 1801 |
if (!calcQC) { |
| 1802 |
calcQC = new CCalculateQueryCommand(buildQC,iCQC); |
| 1803 |
iCQC->setCalculateQueryCommand(calcQC); |
| 1804 |
} |
| 1805 |
|
| 1806 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(iCQC->getKnowledgeBaseName()); |
| 1807 |
buildQC->makeToSubCommand(getCKBRC); |
| 1808 |
|
| 1809 |
CConstructIsTriviallyConsistentQueryCommand *pOWLQC = new CConstructIsTriviallyConsistentQueryCommand(getCKBRC); |
| 1810 |
buildQC->makeToSubCommand(pOWLQC); |
| 1811 |
buildQC->setQueryCommandProvider(pOWLQC); |
| 1812 |
|
| 1813 |
|
| 1814 |
preSynchronizer->delegateCommand(buildQC); |
| 1815 |
preSynchronizer->delegateCommand(calcQC); |
| 1816 |
|
| 1817 |
|
| 1818 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1819 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
} else if (dynamic_cast<CKnowledgeBaseProcessCommand *>(command)) { |
| 1826 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1827 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1828 |
CKnowledgeBaseProcessCommand* kbPC = (CKnowledgeBaseProcessCommand *)command; |
| 1829 |
|
| 1830 |
CGetCurrentKnowledgeBaseRevisionCommand *getCKBRC = new CGetCurrentKnowledgeBaseRevisionCommand(kbPC->getKnowledgeBaseName()); |
| 1831 |
kbPC->makeToSubCommand(getCKBRC); |
| 1832 |
|
| 1833 |
CPrepareKnowledgeBaseCommand* prepKBC = new CPrepareKnowledgeBaseCommand(getCKBRC); |
| 1834 |
prepKBC->addCommandPrecondition(new CCommandProcessedPrecondition(getCKBRC)); |
| 1835 |
kbPC->makeToSubCommand(prepKBC); |
| 1836 |
COntologyProcessingStepVector* ontProStepVec = COntologyProcessingStepVector::getProcessingStepVectorInstance(); |
| 1837 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSPREPROCESS), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1838 |
|
| 1839 |
if (dynamic_cast<CKnowledgeBaseClassifyCommand*>(kbPC) != nullptr) { |
| 1840 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSCLASSCLASSIFY), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1841 |
} |
| 1842 |
if (dynamic_cast<CKnowledgeBaseRealizeCommand*>(kbPC) != nullptr) { |
| 1843 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSCONCEPTREALIZE), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1844 |
prepKBC->addRequirement( new COntologyProcessingStepRequirement(ontProStepVec->getProcessingStep(COntologyProcessingStep::OPSSAMEINDIVIDUALSREALIZE), COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, 0, COntologyProcessingStatus::PSSUCESSFULL, 0) ); |
| 1845 |
} |
| 1846 |
|
| 1847 |
preSynchronizer->delegateCommand(getCKBRC); |
| 1848 |
preSynchronizer->delegateCommand(prepKBC); |
| 1849 |
|
| 1850 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1851 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1852 |
|
| 1853 |
} else if (dynamic_cast<CConstructSubClassHirarchyQueryCommand *>(command)) { |
| 1854 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1855 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1856 |
|
| 1857 |
CConstructSubClassHirarchyQueryCommand *cSCHQC = (CConstructSubClassHirarchyQueryCommand *)command; |
| 1858 |
COntologyRevision *ontRev = cSCHQC->getOntologyRevision(); |
| 1859 |
if (ontRev) { |
| 1860 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1861 |
COWLlinkQueryExtensionParser quExtParser; |
| 1862 |
CSubClassHierarchyQuery *query = new CSubClassHierarchyQuery(ontRev->getOntology(),nullptr,ontConfig); |
| 1863 |
if (CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Query.Statistics.CollectStatistics",false)) { |
| 1864 |
query->setQueryStatistics(new CQueryStatisticsCollectionStrings()); |
| 1865 |
} |
| 1866 |
cSCHQC->setQuery(query); |
| 1867 |
} else { |
| 1868 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 1869 |
} |
| 1870 |
|
| 1871 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1872 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1873 |
|
| 1874 |
} else if (dynamic_cast<CExtractKnowledgeBaseEntitiesCommand *>(command)) { |
| 1875 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1876 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1877 |
|
| 1878 |
CExtractKnowledgeBaseEntitiesCommand* eKBEC = (CExtractKnowledgeBaseEntitiesCommand*)command; |
| 1879 |
COntologyRevision *ontRev = eKBEC->getOntologyRevision(); |
| 1880 |
if (ontRev) { |
| 1881 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1882 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 1883 |
|
| 1884 |
CKnowledgeBaseEntitiesExtractionSpecification* extractSpec = eKBEC->getEntitiesExtractionSpecification(); |
| 1885 |
CExtractedKnowledgeBaseEntitiesContainer* extractionContainer = eKBEC->getExtractionContainer(); |
| 1886 |
|
| 1887 |
CActiveEntityCountVector* activeEntityVector = onto->getDataBoxes()->getExpressionDataBoxMapping()->getActiveEntityVector(); |
| 1888 |
if (activeEntityVector) { |
| 1889 |
CActiveEntityIterator activeEntityIterator(activeEntityVector->getActiveEntityIterator()); |
| 1890 |
while (activeEntityIterator.hasNextActiveEntity()) { |
| 1891 |
CExpressionEntity* entity = activeEntityIterator.getNextActiveEntity(); |
| 1892 |
|
| 1893 |
if (extractSpec->hasPartialEntityExtractionFlags(CKnowledgeBaseEntitiesExtractionSpecification::EXTRACTCLASSENTITIES)) { |
| 1894 |
CClassExpression* classEntity = dynamic_cast<CClassExpression*>(entity); |
| 1895 |
if (classEntity) { |
| 1896 |
extractionContainer->addExtractedEntity(classEntity->getName()); |
| 1897 |
} |
| 1898 |
} |
| 1899 |
|
| 1900 |
if (extractSpec->hasPartialEntityExtractionFlags(CKnowledgeBaseEntitiesExtractionSpecification::EXTRACTOBJECTPROPERTYENTITIES)) { |
| 1901 |
CObjectPropertyExpression* propertyEntity = dynamic_cast<CObjectPropertyExpression*>(entity); |
| 1902 |
if (propertyEntity) { |
| 1903 |
extractionContainer->addExtractedEntity(propertyEntity->getName()); |
| 1904 |
} |
| 1905 |
} |
| 1906 |
|
| 1907 |
if (extractSpec->hasPartialEntityExtractionFlags(CKnowledgeBaseEntitiesExtractionSpecification::EXTRACTINDIVIDUALSENTITIES)) { |
| 1908 |
CNamedIndividualExpression* individualEntity = dynamic_cast<CNamedIndividualExpression*>(entity); |
| 1909 |
if (individualEntity) { |
| 1910 |
extractionContainer->addExtractedEntity(individualEntity->getName()); |
| 1911 |
} |
| 1912 |
} |
| 1913 |
} |
| 1914 |
} |
| 1915 |
|
| 1916 |
|
| 1917 |
} else { |
| 1918 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 1919 |
} |
| 1920 |
|
| 1921 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1922 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1923 |
|
| 1924 |
} else if (dynamic_cast<CExtractKnowledgeBaseLanguageCommand *>(command)) { |
| 1925 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1926 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1927 |
|
| 1928 |
CExtractKnowledgeBaseLanguageCommand* eKBLC = (CExtractKnowledgeBaseLanguageCommand*)command; |
| 1929 |
COntologyRevision *ontRev = eKBLC->getOntologyRevision(); |
| 1930 |
if (ontRev) { |
| 1931 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1932 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 1933 |
|
| 1934 |
if (onto) { |
| 1935 |
eKBLC->setKBLanguageString(onto->getStructureSummary()->getExpressivenessString()); |
| 1936 |
} |
| 1937 |
|
| 1938 |
|
| 1939 |
} else { |
| 1940 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 1941 |
} |
| 1942 |
|
| 1943 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1944 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
} else if (dynamic_cast<CConstructIsConsistentQueryCommand *>(command)) { |
| 1949 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1950 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1951 |
|
| 1952 |
CConstructIsConsistentQueryCommand *cICQC = (CConstructIsConsistentQueryCommand *)command; |
| 1953 |
COntologyRevision *ontRev = cICQC->getOntologyRevision(); |
| 1954 |
if (ontRev) { |
| 1955 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1956 |
CIsConsistentQuery *query = new CIsConsistentQuery(ontRev->getOntology(),ontConfig); |
| 1957 |
if (CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Query.Statistics.CollectStatistics",false)) { |
| 1958 |
query->setQueryStatistics(new CQueryStatisticsCollectionStrings()); |
| 1959 |
} |
| 1960 |
cICQC->setQuery(query); |
| 1961 |
} else { |
| 1962 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 1963 |
} |
| 1964 |
|
| 1965 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1966 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
} else if (dynamic_cast<CConstructIsTriviallyConsistentQueryCommand *>(command)) { |
| 1972 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1973 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1974 |
|
| 1975 |
CConstructIsTriviallyConsistentQueryCommand *cITCQC = (CConstructIsTriviallyConsistentQueryCommand *)command; |
| 1976 |
COntologyRevision *ontRev = cITCQC->getOntologyRevision(); |
| 1977 |
if (ontRev) { |
| 1978 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 1979 |
CIsTriviallyConsistentQuery *query = new CIsTriviallyConsistentQuery(ontRev->getOntology(),ontConfig); |
| 1980 |
if (CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Query.Statistics.CollectStatistics",false)) { |
| 1981 |
query->setQueryStatistics(new CQueryStatisticsCollectionStrings()); |
| 1982 |
} |
| 1983 |
cITCQC->setQuery(query); |
| 1984 |
} else { |
| 1985 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 1986 |
} |
| 1987 |
|
| 1988 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1989 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1990 |
|
| 1991 |
|
| 1992 |
} else if (dynamic_cast<CConstructClassSatisfiableQueryCommand *>(command)) { |
| 1993 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 1994 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 1995 |
|
| 1996 |
CConstructClassSatisfiableQueryCommand *cCSQC = (CConstructClassSatisfiableQueryCommand *)command; |
| 1997 |
COntologyRevision *ontRev = cCSQC->getOntologyRevision(); |
| 1998 |
if (ontRev) { |
| 1999 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2000 |
CIsClassSatisfiableQuery *query = new CIsClassSatisfiableQuery(cCSQC->getClassName()); |
| 2001 |
|
| 2002 |
CCalculationConfigurationExtension *calcConfig = new CCalculationConfigurationExtension(ontConfig,0); |
| 2003 |
CConcept* concept = ontRev->getOntology()->getStringMapping()->getClassNameConceptMappingHash()->value(cCSQC->getClassName(),nullptr); |
| 2004 |
if (concept) { |
| 2005 |
CSatisfiableCalculationJobGenerator* satCalcJobGenerator = new CSatisfiableCalculationJobGenerator(ontRev->getOntology()); |
| 2006 |
CSatisfiableCalculationJob* satCalcJob = satCalcJobGenerator->getSatisfiableCalculationJob(concept,false); |
| 2007 |
delete satCalcJobGenerator; |
| 2008 |
|
| 2009 |
//CQueryStatisticsCollectionStrings* queryStats = nullptr; |
| 2010 |
//if (true) { |
| 2011 |
// queryStats = new CQueryStatisticsCollectionStrings(); |
| 2012 |
// satCalcJob->setCalclulationStatisticsCollector(queryStats->createCalculationStatisticsCollection()); |
| 2013 |
//} |
| 2014 |
//query->setQueryStatistics(queryStats); |
| 2015 |
satCalcJob->setCalculationConfiguration(calcConfig); |
| 2016 |
query->setCalculationConfiguration(calcConfig); |
| 2017 |
query->addTestSatisfiableCalculationJob(satCalcJob,true); |
| 2018 |
|
| 2019 |
cCSQC->setQuery(query); |
| 2020 |
} else { |
| 2021 |
CUnspecifiedMessageErrorRecord::makeRecord(QString("Concept '%1' cannot be resolved in ontology '%2'.").arg(cCSQC->getClassName()).arg(ontRev->getOntology()->getOntologyName()),&commandRecordRouter); |
| 2022 |
} |
| 2023 |
} else { |
| 2024 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2025 |
} |
| 2026 |
|
| 2027 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2028 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
} else if (dynamic_cast<CConstructWriteFunctionalSubClassHirarchyQueryCommand *>(command)) { |
| 2033 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2034 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2035 |
|
| 2036 |
CConstructWriteFunctionalSubClassHirarchyQueryCommand *cWFSCHQC = (CConstructWriteFunctionalSubClassHirarchyQueryCommand *)command; |
| 2037 |
COntologyRevision *ontRev = cWFSCHQC->getOntologyRevision(); |
| 2038 |
if (ontRev) { |
| 2039 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2040 |
CWriteOREFunctionalClassSubsumptionsHierarchyQuery *query = new CWriteOREFunctionalClassSubsumptionsHierarchyQuery(ontRev->getOntology(),ontConfig,cWFSCHQC->getOutputFileName()); |
| 2041 |
cWFSCHQC->setQuery(query); |
| 2042 |
} else { |
| 2043 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2044 |
} |
| 2045 |
|
| 2046 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2047 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2048 |
|
| 2049 |
|
| 2050 |
} else if (dynamic_cast<CConstructWriteCustomQueryCommand *>(command)) { |
| 2051 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2052 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2053 |
|
| 2054 |
CConstructWriteCustomQueryCommand *cWCQC = (CConstructWriteCustomQueryCommand *)command; |
| 2055 |
COntologyRevision *ontRev = cWCQC->getOntologyRevision(); |
| 2056 |
if (ontRev) { |
| 2057 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2058 |
CWriteQuery::WRITEQUERYTYPE queryType = cWCQC->getWriteQueryType(); |
| 2059 |
CWriteQuerySerializer* serializer = cWCQC->getWriteQuerySerializer(); |
| 2060 |
const QString& entityRestrictionString = cWCQC->getEntityRestrictionString(); |
| 2061 |
if (queryType == CWriteQuery::WRITESUBCLASSHIERARCHY) { |
| 2062 |
CWriteSerializerClassSubsumptionsHierarchyQuery *query = new CWriteSerializerClassSubsumptionsHierarchyQuery(ontRev->getOntology(),ontConfig,serializer,entityRestrictionString); |
| 2063 |
cWCQC->setQuery(query); |
| 2064 |
} else if (queryType == CWriteQuery::WRITESUBOBJECTPROPERTYHIERARCHY) { |
| 2065 |
CWriteSerializerPropertySubsumptionsHierarchyQuery *query = new CWriteSerializerPropertySubsumptionsHierarchyQuery(ontRev->getOntology(),ontConfig,serializer,false,entityRestrictionString); |
| 2066 |
cWCQC->setQuery(query); |
| 2067 |
} else if (queryType == CWriteQuery::WRITESUBDATAPROPERTYHIERARCHY) { |
| 2068 |
CWriteSerializerPropertySubsumptionsHierarchyQuery *query = new CWriteSerializerPropertySubsumptionsHierarchyQuery(ontRev->getOntology(),ontConfig,serializer,true,entityRestrictionString); |
| 2069 |
cWCQC->setQuery(query); |
| 2070 |
} else if (queryType == CWriteQuery::WRITEINDIVIDUALFLATTENEDTYPES) { |
| 2071 |
CWriteSerializerIndividualFlattenedTypesQuery *query = new CWriteSerializerIndividualFlattenedTypesQuery(ontRev->getOntology(),ontConfig,serializer,entityRestrictionString); |
| 2072 |
cWCQC->setQuery(query); |
| 2073 |
} |
| 2074 |
|
| 2075 |
} else { |
| 2076 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2077 |
} |
| 2078 |
|
| 2079 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2080 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
} else if (dynamic_cast<CConstructClassifyQueryCommand *>(command)) { |
| 2086 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2087 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2088 |
|
| 2089 |
CConstructClassifyQueryCommand *cCQC = (CConstructClassifyQueryCommand*)command; |
| 2090 |
COntologyRevision *ontRev = cCQC->getOntologyRevision(); |
| 2091 |
if (ontRev) { |
| 2092 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2093 |
CClassifyQuery *query = new CClassifyQuery(ontRev->getOntology(),ontConfig); |
| 2094 |
if (CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Query.Statistics.CollectStatistics",false)) { |
| 2095 |
query->setQueryStatistics(new CQueryStatisticsCollectionStrings()); |
| 2096 |
} |
| 2097 |
cCQC->setQuery(query); |
| 2098 |
} else { |
| 2099 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2100 |
} |
| 2101 |
|
| 2102 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2103 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2104 |
|
| 2105 |
} else if (dynamic_cast<CConstructRealizeQueryCommand *>(command)) { |
| 2106 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2107 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2108 |
|
| 2109 |
CConstructRealizeQueryCommand *cRQC = (CConstructRealizeQueryCommand*)command; |
| 2110 |
COntologyRevision *ontRev = cRQC->getOntologyRevision(); |
| 2111 |
if (ontRev) { |
| 2112 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2113 |
CRealizeQuery *query = new CRealizeQuery(ontRev->getOntology(),ontConfig); |
| 2114 |
if (CConfigDataReader::readConfigBoolean(ontConfig,"Konclude.Query.Statistics.CollectStatistics",false)) { |
| 2115 |
query->setQueryStatistics(new CQueryStatisticsCollectionStrings()); |
| 2116 |
} |
| 2117 |
cRQC->setQuery(query); |
| 2118 |
} else { |
| 2119 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2120 |
} |
| 2121 |
|
| 2122 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2123 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2124 |
|
| 2125 |
|
| 2126 |
} else if (dynamic_cast<CGenerateQueryCommand *>(command)) { |
| 2127 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2128 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2129 |
|
| 2130 |
CGenerateQueryCommand* gQC = (CGenerateQueryCommand *)command; |
| 2131 |
CQueryBuilderGenerator* queryGenerator = gQC->getQueryGenerator(); |
| 2132 |
QList<CQuery*> queryList; |
| 2133 |
if (queryGenerator) { |
| 2134 |
queryList = queryGenerator->generateQuerys(); |
| 2135 |
} else { |
| 2136 |
CUnspecifiedMessageErrorRecord::makeRecord("No query generated.",&commandRecordRouter); |
| 2137 |
} |
| 2138 |
|
| 2139 |
CQuery *query = 0; |
| 2140 |
if (queryList.count() > 0) { |
| 2141 |
query = queryList.first(); |
| 2142 |
} else { |
| 2143 |
CUnspecifiedMessageErrorRecord::makeRecord("Query couldn't be parsed.",&commandRecordRouter); |
| 2144 |
} |
| 2145 |
gQC->setQuery(query); |
| 2146 |
|
| 2147 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2148 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2149 |
|
| 2150 |
} else if (dynamic_cast<CParseOWL2XMLQueryCommand *>(command)) { |
| 2151 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2152 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2153 |
CParseOWL2XMLQueryCommand *pOWLQC = (CParseOWL2XMLQueryCommand *)command; |
| 2154 |
|
| 2155 |
QDomElement queryNode = pOWLQC->getQueryNode(); |
| 2156 |
COntologyRevision *ontRev = pOWLQC->getOntologyRevision(); |
| 2157 |
|
| 2158 |
if (ontRev) { |
| 2159 |
|
| 2160 |
bool complex = pOWLQC->isComplexQuery(); |
| 2161 |
|
| 2162 |
CConcreteOntology* onto = ontRev->getOntology(); |
| 2163 |
|
| 2164 |
COntologyConfigurationExtension *ontConfig = ontRev->getOntologyConfiguration(); |
| 2165 |
|
| 2166 |
CQueryBuilderGenerator* queryBuilderGen = nullptr; |
| 2167 |
|
| 2168 |
QList<CQuery *> queryList; |
| 2169 |
if (complex) { |
| 2170 |
CConcreteOntology* baseOnto = ontRev->getPreviousOntologyRevision()->getOntology(); |
| 2171 |
|
| 2172 |
COWLlinkQueryParser *queryParser = nullptr; |
| 2173 |
CConcreteOntologyUpdateSeparateHashingCollectorBuilder *ontoBuilder = new CConcreteOntologyUpdateSeparateHashingCollectorBuilder(onto); |
| 2174 |
queryBuilderGen = new CConcreteOntologyQueryExtendedBuilder(baseOnto,onto,ontConfig,ontoBuilder); |
| 2175 |
COWL2QtXMLOntologyParser *owl2Parser = new COWL2QtXMLOntologyParser(ontoBuilder,&commandRecordRouter); |
| 2176 |
queryParser = new COWLlinkQtXMLComplexQueryParser(queryBuilderGen,owl2Parser); |
| 2177 |
ontoBuilder->initializeBuilding(); |
| 2178 |
queryParser->parseQueryNode(&queryNode); |
| 2179 |
ontoBuilder->completeBuilding(); |
| 2180 |
|
| 2181 |
//COntologyConfigDependedPreProcesser *ontConDepPreProcessor = new COntologyConfigDependedPreProcesser(commandRecordRouter); |
| 2182 |
//ontConDepPreProcessor->preprocess(onto,ontConfig); |
| 2183 |
//delete ontConDepPreProcessor; |
| 2184 |
|
| 2185 |
|
| 2186 |
delete ontoBuilder; |
| 2187 |
delete queryParser; |
| 2188 |
} else { |
| 2189 |
COWLlinkQueryParser *queryParser = nullptr; |
| 2190 |
queryBuilderGen = new CConcreteOntologyQuerySimpleBuilder(onto,ontConfig); |
| 2191 |
queryParser = new COWLlinkQtXMLSimpleQueryParser(queryBuilderGen,onto); |
| 2192 |
|
| 2193 |
queryParser->parseQueryNode(&queryNode); |
| 2194 |
delete queryParser; |
| 2195 |
} |
| 2196 |
|
| 2197 |
|
| 2198 |
pOWLQC->setQueryGenerator(queryBuilderGen); |
| 2199 |
|
| 2200 |
} else { |
| 2201 |
CUnspecifiedMessageErrorRecord::makeRecord("Knowledge base revision not available.",&commandRecordRouter); |
| 2202 |
} |
| 2203 |
|
| 2204 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2205 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2206 |
|
| 2207 |
} else { |
| 2208 |
if (reasonerCommander) { |
| 2209 |
reasonerCommander->realizeCommand(command); |
| 2210 |
} else { |
| 2211 |
CCommandRecordRouter commandRecordRouter(command,this); |
| 2212 |
CStartProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2213 |
CUnspecifiedMessageErrorRecord::makeRecord("Reasoner Commander missing.",&commandRecordRouter); |
| 2214 |
CStopProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2215 |
CFinishProcessCommandRecord::makeRecord(&commandRecordRouter); |
| 2216 |
LOG(ERROR,getLogDomain(),logTr("Reasoner Commander missing."),this); |
| 2217 |
} |
| 2218 |
} |
| 2219 |
} |
| 2220 |
} |
| 2221 |
return true; |
| 2222 |
} else if (type == EVENTINITIALIZE) { |
| 2223 |
initializeOWLlinkContent(); |
| 2224 |
return true; |
| 2225 |
} else if (type == EVENTCOMMANDPROCESSEDCALLBACK) { |
| 2226 |
CCommandProcessedCallbackEvent *commProCallbackEvent = (CCommandProcessedCallbackEvent *)event; |
| 2227 |
concludeOWLlinkContent(); |
| 2228 |
return true; |
| 2229 |
} |
| 2230 |
|
| 2231 |
} else { |
| 2232 |
return true; |
| 2233 |
} |
| 2234 |
return false; |
| 2235 |
} |
| 2236 |
|
| 2237 |
|
| 2238 |
|
| 2239 |
|
| 2240 |
}; // end namespace OWLlink |
| 2241 |
|
| 2242 |
}; // end namespace Interface |
| 2243 |
|
| 2244 |
}; // end namespace Control |
| 2245 |
|
| 2246 |
}; // end namespace Konclude |