| 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 "CRequirementConfigPreprocessingItem.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Preprocess { |
| 29 |
|
| 30 |
|
| 31 |
CRequirementConfigPreprocessingItem::CRequirementConfigPreprocessingItem() { |
| 32 |
} |
| 33 |
|
| 34 |
CRequirementConfigPreprocessingItem* CRequirementConfigPreprocessingItem::initRequirementConfigPreprocessingItem(CConcreteOntology* ontology, CConfigurationBase* config) { |
| 35 |
COntologyPreprocessingItem::initPreprocessingItem(ontology,config); |
| 36 |
mPreprocessing = nullptr; |
| 37 |
mCalculationConfig = new CCalculationConfigurationExtension(config,0); |
| 38 |
COntologyProcessingStepDataVector* ontProStepDataVec = mOntology->getProcessingSteps()->getOntologyProcessingStepDataVector(); |
| 39 |
mTriplesMappingProcessingStep = new CPreprocessingTestingStep(CPreprocessingTestingStep::TRIPLESMAPPINGPREPROCESSINGSTEP, ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSTRIPLESMAPPING), this); |
| 40 |
mActiveCountingProcessingStep = new CPreprocessingTestingStep(CPreprocessingTestingStep::ACTIVECOUNTINGPREPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSACTIVECOUNT),this); |
| 41 |
mBuildProcessingStep = new CPreprocessingTestingStep(CPreprocessingTestingStep::BUILDPREPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSBUILD),this); |
| 42 |
mPreprocessProcessingStep = new CPreprocessingTestingStep(CPreprocessingTestingStep::PREPROCESSPREPROCESSINGSTEP,ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSPREPROCESS),this); |
| 43 |
mTriplesIndexingProcessingStep = new CPreprocessingTestingStep(CPreprocessingTestingStep::TRIPLESINDEXINGPREPROCESSINGSTEP, ontProStepDataVec->getProcessingStepData(COntologyProcessingStep::OPSTRIPLESINDEXING), this); |
| 44 |
mProcessingSteps.append(mPreprocessProcessingStep); |
| 45 |
mProcessingSteps.append(mBuildProcessingStep); |
| 46 |
mProcessingSteps.append(mActiveCountingProcessingStep); |
| 47 |
mProcessingSteps.append(mTriplesMappingProcessingStep); |
| 48 |
mProcessingSteps.append(mTriplesIndexingProcessingStep); |
| 49 |
|
| 50 |
mFailAfterPreprocessing = CConfigDataReader::readConfigBoolean(config,"Konclude.Debug.FailAfterPreprocessing",false); |
| 51 |
mFailAfterBuilt = CConfigDataReader::readConfigBoolean(config,"Konclude.Debug.FailAfterBuilt",false); |
| 52 |
|
| 53 |
return this; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
CRequirementConfigPreprocessingItem::~CRequirementConfigPreprocessingItem() { |
| 58 |
delete mCalculationConfig; |
| 59 |
delete mActiveCountingProcessingStep; |
| 60 |
delete mBuildProcessingStep; |
| 61 |
delete mTriplesMappingProcessingStep; |
| 62 |
delete mPreprocessProcessingStep; |
| 63 |
delete mTriplesIndexingProcessingStep; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
bool CRequirementConfigPreprocessingItem::failAfterPreprocessing() { |
| 69 |
return mFailAfterPreprocessing; |
| 70 |
} |
| 71 |
|
| 72 |
bool CRequirementConfigPreprocessingItem::failAfterBuilt() { |
| 73 |
return mFailAfterBuilt; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
COntologyPreprocessingItem* CRequirementConfigPreprocessingItem::addProcessingRequirement(COntologyProcessingRequirement* ontoRequirement) { |
| 78 |
bool supportRequirement = false; |
| 79 |
COntologyProcessingStepRequirement* stepProcRequirement = dynamic_cast<COntologyProcessingStepRequirement*>(ontoRequirement); |
| 80 |
if (stepProcRequirement) { |
| 81 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSTRIPLESMAPPING) { |
| 82 |
mTriplesMappingProcessingStep->addProcessingRequirement(stepProcRequirement); |
| 83 |
supportRequirement = true; |
| 84 |
} |
| 85 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSTRIPLESINDEXING) { |
| 86 |
mTriplesIndexingProcessingStep->addProcessingRequirement(stepProcRequirement); |
| 87 |
supportRequirement = true; |
| 88 |
} |
| 89 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSBUILD) { |
| 90 |
mBuildProcessingStep->addProcessingRequirement(stepProcRequirement); |
| 91 |
supportRequirement = true; |
| 92 |
} |
| 93 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSACTIVECOUNT) { |
| 94 |
mActiveCountingProcessingStep->addProcessingRequirement(stepProcRequirement); |
| 95 |
supportRequirement = true; |
| 96 |
} |
| 97 |
if (stepProcRequirement->getRequiredProcessingStep()->getOntologyProcessingType() == COntologyProcessingStep::OPSPREPROCESS) { |
| 98 |
mPreprocessProcessingStep->addProcessingRequirement(stepProcRequirement); |
| 99 |
supportRequirement = true; |
| 100 |
} |
| 101 |
} |
| 102 |
if (!supportRequirement) { |
| 103 |
stepProcRequirement->submitRequirementUpdate(COntologyProcessingStatus::PSCOMPLETELYYPROCESSED, COntologyProcessingStatus::PSFAILED | COntologyProcessingStatus::PSUNSUPPORTED); |
| 104 |
} |
| 105 |
return this; |
| 106 |
} |
| 107 |
|
| 108 |
|
| 109 |
CCalculationConfigurationExtension* CRequirementConfigPreprocessingItem::getCalculationConfiguration() { |
| 110 |
return mCalculationConfig; |
| 111 |
} |
| 112 |
|
| 113 |
CRequirementConfigPreprocessingItem* CRequirementConfigPreprocessingItem::setPreprocessing(CPreprocessing* preprocessing) { |
| 114 |
mPreprocessing = preprocessing; |
| 115 |
return this; |
| 116 |
} |
| 117 |
|
| 118 |
CPreprocessing* CRequirementConfigPreprocessingItem::getPreprocessing() { |
| 119 |
return mPreprocessing; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
CPreprocessingTestingStep* CRequirementConfigPreprocessingItem::getBuildProcessingStep() { |
| 124 |
return mBuildProcessingStep; |
| 125 |
} |
| 126 |
|
| 127 |
CPreprocessingTestingStep* CRequirementConfigPreprocessingItem::getActiveCountingProcessingStep() { |
| 128 |
return mActiveCountingProcessingStep; |
| 129 |
} |
| 130 |
|
| 131 |
CPreprocessingTestingStep* CRequirementConfigPreprocessingItem::getPreprocessProcessingStep() { |
| 132 |
return mPreprocessProcessingStep; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
bool CRequirementConfigPreprocessingItem::isBuildStepFinished() { |
| 137 |
return mBuildProcessingStep->isStepFinished(); |
| 138 |
} |
| 139 |
|
| 140 |
bool CRequirementConfigPreprocessingItem::isBuildStepRequired() { |
| 141 |
return mBuildProcessingStep->hasRequirements(); |
| 142 |
} |
| 143 |
|
| 144 |
|
| 145 |
bool CRequirementConfigPreprocessingItem::isActiveCountingStepFinished() { |
| 146 |
return mActiveCountingProcessingStep->isStepFinished(); |
| 147 |
} |
| 148 |
|
| 149 |
bool CRequirementConfigPreprocessingItem::isActiveCountingStepRequired() { |
| 150 |
return mActiveCountingProcessingStep->hasRequirements(); |
| 151 |
} |
| 152 |
|
| 153 |
bool CRequirementConfigPreprocessingItem::isPreprocessStepFinished() { |
| 154 |
return mPreprocessProcessingStep->isStepFinished(); |
| 155 |
} |
| 156 |
|
| 157 |
bool CRequirementConfigPreprocessingItem::isPreprocessStepRequired() { |
| 158 |
return mPreprocessProcessingStep->hasRequirements(); |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
CPreprocessingTestingStep* CRequirementConfigPreprocessingItem::getTriplesMappingProcessingStep() { |
| 167 |
return mTriplesMappingProcessingStep; |
| 168 |
} |
| 169 |
|
| 170 |
bool CRequirementConfigPreprocessingItem::isTriplesMappingStepFinished() { |
| 171 |
return mTriplesMappingProcessingStep->isStepFinished(); |
| 172 |
} |
| 173 |
|
| 174 |
bool CRequirementConfigPreprocessingItem::isTriplesMappingStepRequired() { |
| 175 |
return mTriplesMappingProcessingStep->hasRequirements(); |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
bool CRequirementConfigPreprocessingItem::areTriplesMappingStepProcessingRequirementSatisfied() { |
| 180 |
return mTriplesMappingProcessingStep->areStepProcessingRequirementSatisfied(); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
CPreprocessingTestingStep* CRequirementConfigPreprocessingItem::getTriplesIndexingProcessingStep() { |
| 191 |
return mTriplesIndexingProcessingStep; |
| 192 |
} |
| 193 |
|
| 194 |
bool CRequirementConfigPreprocessingItem::isTriplesIndexingStepFinished() { |
| 195 |
return mTriplesIndexingProcessingStep->isStepFinished(); |
| 196 |
} |
| 197 |
|
| 198 |
bool CRequirementConfigPreprocessingItem::isTriplesIndexingStepRequired() { |
| 199 |
return mTriplesIndexingProcessingStep->hasRequirements(); |
| 200 |
} |
| 201 |
|
| 202 |
|
| 203 |
bool CRequirementConfigPreprocessingItem::areTriplesIndexingStepProcessingRequirementSatisfied() { |
| 204 |
return mTriplesIndexingProcessingStep->areStepProcessingRequirementSatisfied(); |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
bool CRequirementConfigPreprocessingItem::areBuildStepProcessingRequirementSatisfied() { |
| 211 |
return mBuildProcessingStep->areStepProcessingRequirementSatisfied(); |
| 212 |
} |
| 213 |
|
| 214 |
bool CRequirementConfigPreprocessingItem::areActiveCountingStepProcessingRequirementSatisfied() { |
| 215 |
return mActiveCountingProcessingStep->areStepProcessingRequirementSatisfied(); |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
bool CRequirementConfigPreprocessingItem::arePreprocessStepProcessingRequirementSatisfied() { |
| 220 |
return mPreprocessProcessingStep->areStepProcessingRequirementSatisfied(); |
| 221 |
} |
| 222 |
|
| 223 |
bool CRequirementConfigPreprocessingItem::areAllStepFinished() { |
| 224 |
for (QList<CPreprocessingTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 225 |
if (!(*it)->isStepFinished()) { |
| 226 |
return false; |
| 227 |
} |
| 228 |
} |
| 229 |
return true; |
| 230 |
} |
| 231 |
|
| 232 |
bool CRequirementConfigPreprocessingItem::hasRemainingProcessingRequirements() { |
| 233 |
for (QList<CPreprocessingTestingStep*>::const_iterator it = mProcessingSteps.constBegin(), itEnd = mProcessingSteps.constEnd(); it != itEnd; ++it) { |
| 234 |
if ((*it)->hasRequirements()) { |
| 235 |
return true; |
| 236 |
} |
| 237 |
} |
| 238 |
return false; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
}; // end namespace Preprocess |
| 243 |
|
| 244 |
}; // end namespace Reasoner |
| 245 |
|
| 246 |
}; // end namespace Konclude |