Debian Codegraph @

Source/Reasoner/Revision/Persistence/COntologyRevisionDirectoryOWLRDFFilePersistencer.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 #ifdef KONCLUDE_REDLAND_INTEGRATION
21
22 #include "COntologyRevisionDirectoryOWLRDFFilePersistencer.h"
23
24
25 namespace Konclude {
26
27 namespace Reasoner {
28
29 namespace Revision {
30
31 namespace Persistence {
32
33 COntologyRevisionDirectoryOWLRDFFilePersistencer::COntologyRevisionDirectoryOWLRDFFilePersistencer(CConfiguration* config) : COntologyRevisionDirectoryFilePersistencerBase(config) {
34 QString confOWLRDFBaseDirectory = CConfigDataReader::readConfigString(mConfig, "Konclude.Persistence.DirectoryOWLRDFFilePersistencer.BaseDirectory","./Data/Ontologies/Persistence/");
35 if (!confOWLRDFBaseDirectory.isEmpty()) {
36 mConfBaseDirectory = confOWLRDFBaseDirectory;
37 }
38 mFileEndingWritingName = CConfigDataReader::readConfigString(mConfig, "Konclude.Persistence.DirectoryOWLRDFFilePersistencer.WritingFileEnding");
39 mSerializingFormat = CConfigDataReader::readConfigString(mConfig, "Konclude.Persistence.DirectoryOWLRDFFilePersistencer.SerializationFormat");
40 }
41
42 COntologyRevisionDirectoryOWLRDFFilePersistencer::~COntologyRevisionDirectoryOWLRDFFilePersistencer() {
43 }
44
45
46
47
48 bool COntologyRevisionDirectoryOWLRDFFilePersistencer::writeOntologyToFile(QFile* file, COntologyRevision* ontoRev) {
49
50 CConcreteOntology* ontology = ontoRev->getOntology();
51
52 COntologyAxiomExpressionsRenderVisitor renderer;
53 COntologyRedlandRDFRenderer rdfRenderer(nullptr);
54
55
56 CONTOLOGYAXIOMSET<CAxiomExpression*>* currAxiomSet = ontology->getBuildData()->getTellAxiomSet();
57 CQtList<CAxiomExpression*> axiomList;
58 for (CAxiomExpression* axiomExp : *currAxiomSet) {
59 axiomList.append(axiomExp);
60 }
61
62 renderer.visitAndRender(axiomList, ontology, &rdfRenderer);
63
64 QList<CTriplesData*> triplesDataList;
65 COntologyTriplesData* ontTriplesData = ontoRev->getOntology()->getOntologyTriplesData();
66 if (ontTriplesData) {
67 for (CTriplesData* tripleData : *ontTriplesData->getAllTriplesData()) {
68 triplesDataList.append(tripleData);
69 }
70 }
71
72 renderer.visitAndRender(&triplesDataList, ontology, &rdfRenderer);
73
74
75 CRedlandStoredTriplesData* triplesData = rdfRenderer.getRenderedTripleData(nullptr);
76 if (triplesData) {
77
78 QByteArray serFormByteArray = mSerializingFormat.toUtf8();
79
80 unsigned char* modelString = librdf_model_to_string(triplesData->getRedlandIndexedModel(), nullptr, serFormByteArray.constData(), nullptr, nullptr);
81 file->write((const char*)modelString);
82
83 delete triplesData;
84
85 return true;
86 }
87
88 return false;
89 }
90
91
92
93
94 }; // end namespace Persistence
95
96 }; // end namespace Revision
97
98 }; // end namespace Reasoner
99
100 }; // end namespace Konclude
101
102 #endif // !KONCLUDE_REDLAND_INTEGRATION