| 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 "COWLFilesIncompatibleAxiomChangerLoader.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Control { |
| 27 |
|
| 28 |
namespace Loader { |
| 29 |
|
| 30 |
|
| 31 |
COWLFilesIncompatibleAxiomChangerLoader::COWLFilesIncompatibleAxiomChangerLoader() { |
| 32 |
loaderConfig = nullptr; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
COWLFilesIncompatibleAxiomChangerLoader::~COWLFilesIncompatibleAxiomChangerLoader() { |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
CLoader *COWLFilesIncompatibleAxiomChangerLoader::init(CLoaderFactory *loaderFactory, CConfiguration *config) { |
| 42 |
loaderConfig = config; |
| 43 |
CConfigData *data = config->getLastConfigChange("Konclude.Test.Converter.InputDirectory"); |
| 44 |
if (data) { |
| 45 |
mInputDir = data->getString(); |
| 46 |
} |
| 47 |
|
| 48 |
data = config->getLastConfigChange("Konclude.Test.Converter.OutputDirectory"); |
| 49 |
if (data) { |
| 50 |
mOutputDir = data->getString(); |
| 51 |
} |
| 52 |
|
| 53 |
return this; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
CLoader *COWLFilesIncompatibleAxiomChangerLoader::load() { |
| 59 |
COWLFileAxiomRemover* changer = new COWLFileAxiomRemover(loaderConfig); |
| 60 |
|
| 61 |
QDir inputDir(mInputDir); |
| 62 |
QDir outputDir(mOutputDir); |
| 63 |
outputDir.mkpath("."); |
| 64 |
foreach (QString fileString, inputDir.entryList(QDir::Files)) { |
| 65 |
QString absoluteFileString = inputDir.absoluteFilePath(fileString); |
| 66 |
QString outFileString = fileString; |
| 67 |
cint64 fiIn = outFileString.lastIndexOf(".owl.xml"); |
| 68 |
if (fiIn == -1) { |
| 69 |
fiIn = outFileString.lastIndexOf(".xml"); |
| 70 |
} |
| 71 |
if (fiIn == -1) { |
| 72 |
fiIn = outFileString.lastIndexOf(".owl"); |
| 73 |
} |
| 74 |
if (fiIn == -1) { |
| 75 |
fiIn = outFileString.lastIndexOf("."); |
| 76 |
} |
| 77 |
if (fiIn != -1) { |
| 78 |
outFileString.replace(fiIn,1,"-A."); |
| 79 |
} |
| 80 |
if (mOutputDir.endsWith("/")) { |
| 81 |
outFileString = mOutputDir+outFileString; |
| 82 |
} else { |
| 83 |
outFileString = mOutputDir+"/"+outFileString; |
| 84 |
} |
| 85 |
outFileString.replace(".obo",""); |
| 86 |
if (!outFileString.contains(".owl.xml")) { |
| 87 |
outFileString.replace(".owl",".owl.xml"); |
| 88 |
} |
| 89 |
changer->loadRemoveAxiomsAndSave(absoluteFileString,outFileString); |
| 90 |
} |
| 91 |
|
| 92 |
LOG(INFO,"::Konclude::Converter::FileAxiomChanger",logTr("Converted all files in %1 to %2.").arg(mInputDir).arg(mOutputDir),this); |
| 93 |
|
| 94 |
delete changer; |
| 95 |
return this; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
CLoader *COWLFilesIncompatibleAxiomChangerLoader::exit() { |
| 102 |
return this; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
}; // end namespace Loader |
| 108 |
|
| 109 |
}; // end namespace Control |
| 110 |
|
| 111 |
}; // end namespace Konclude |