Debian Codegraph @

Source/Control/Interface/JNI/CJNICommandProcessor.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CJNICommandProcessor.h"
22
23
24 namespace Konclude {
25
26 namespace Control {
27
28 namespace Interface {
29
30 namespace JNI {
31
32
33 CJNICommandProcessor::CJNICommandProcessor(CConfiguration* loaderConfig) : COWLlinkProcessor(false) {
34 mLoaderConfig = loaderConfig;
35 reasonerCommander = CConfigManagerReader::readCommanderManagerConfig(mLoaderConfig);
36 mProcessingCommand = nullptr;
37 startThread();
38 }
39
40
41 CJNICommandProcessor::~CJNICommandProcessor() {
42 }
43
44 void CJNICommandProcessor::threadStarted() {
45 COWLlinkProcessor::threadStarted();
46
47 }
48
49 void CJNICommandProcessor::threadStopped() {
50 COWLlinkProcessor::threadStopped();
51 }
52
53
54
55 CJNICommandProcessor* CJNICommandProcessor::processCommand(CCommand* command, bool blockUntilProcessed) {
56 CBlockingCallbackData* blockingCallback = nullptr;
57 if (blockUntilProcessed) {
58 blockingCallback = new CBlockingCallbackData();
59 command->addProcessedCallback(blockingCallback);
60 }
61 LOG(INFO,"::Konclude::JNI::CommandProcessor",QString("Starting processing command '%1'.").arg(command->getBriefCommandDescription()),0);
62 delegateCommand(command);
63 LOG(INFO,"::Konclude::JNI::CommandProcessor",QString("Finished processing command '%1'.").arg(command->getBriefCommandDescription()),0);
64 if (blockingCallback) {
65 blockingCallback->waitForCallback();
66 delete blockingCallback;
67 }
68 return this;
69 }
70
71
72
73
74 COntologyRevision* CJNICommandProcessor::getNewlyCreatedAnonymousOntologyRevision() {
75 CCreateKnowledgeBaseCommand* ckbc = new CCreateKnowledgeBaseCommand("");
76 processCommand(ckbc);
77 QString kbString = ckbc->getKnowledgeBaseName();
78 delete ckbc;
79 CCreateKnowledgeBaseRevisionUpdateCommand* ckbruc = new CCreateKnowledgeBaseRevisionUpdateCommand(kbString);
80 processCommand(ckbruc);
81 COntologyRevision* ontRev = ckbruc->getOntologyRevision();
82 delete ckbruc;
83 return ontRev;
84 }
85
86 COntologyRevision* CJNICommandProcessor::getNewOntologyRevision(COntologyRevision* prevOntRev) {
87 CCreateKnowledgeBaseRevisionUpdateCommand* ckbruc = new CCreateKnowledgeBaseRevisionUpdateCommand(prevOntRev->getOntology()->getOntologyName());
88 processCommand(ckbruc);
89 COntologyRevision* ontRev = ckbruc->getOntologyRevision();
90 delete ckbruc;
91 return ontRev;
92
93 }
94
95
96 bool CJNICommandProcessor::prepareOntologyQuerying(COntologyRevision* ontRev) {
97 CPreprocessKnowledgeBaseRequirementsForQueryCommand* pkbfqc = new CPreprocessKnowledgeBaseRequirementsForQueryCommand(ontRev->getOntology());
98 processCommand(pkbfqc);
99 delete pkbfqc;
100 return true;
101 }
102
103
104 COntologyRevision* CJNICommandProcessor::installNewOntologyRevision(COntologyRevision* ontRev) {
105 CInstallKnowledgeBaseRevisionUpdateCommand* ikbruc = new CInstallKnowledgeBaseRevisionUpdateCommand(ontRev->getOntology()->getOntologyName(),ontRev);
106 processCommand(ikbruc);
107 delete ikbruc;
108 CGetCurrentKnowledgeBaseRevisionCommand* gckbrc = new CGetCurrentKnowledgeBaseRevisionCommand(ontRev->getOntology()->getOntologyName());
109 processCommand(gckbrc);
110 ontRev = gckbrc->getOntologyRevision();
111 return ontRev;
112 }
113
114
115
116 CJNICommandProcessor* CJNICommandProcessor::calculateOntologyQuery(CQuery* query) {
117 CCalculateQueryCommand* cqc = new CCalculateQueryCommand(query);
118 processCommand(cqc);
119 delete cqc;
120 return this;
121 }
122
123
124
125 COWLlinkProcessor* CJNICommandProcessor::initializeOWLlinkContent() {
126 return this;
127 }
128
129
130
131 COWLlinkProcessor* CJNICommandProcessor::concludeOWLlinkContent() {
132 return this;
133 }
134
135
136 CConfiguration* CJNICommandProcessor::getConfiguration() {
137 if (!reasonerCommander) {
138 return mLoaderConfig;
139 } else {
140 CGetDescriptionCommand *getDesComm = new CGetDescriptionCommand();
141 reasonerCommander->delegateCommand(getDesComm);
142 CCommandExecutedBlocker commExeBlocker;
143 commExeBlocker.waitExecutedCommand(getDesComm);
144 CConfiguration *config = getDesComm->getConfiguration();
145 return config;
146 }
147 }
148
149
150 }; // end namespace JNI
151
152 }; // end namespace Interface
153
154 }; // end namespace Control
155
156 }; // end namespace Konclude