3#include <Cyqlops/Crypto/Hash.h>
4#include <Cyqlops/Crypto/RSAAlgorithm.h>
6#include <knowCore/Timestamp.h>
7#include <knowCore/TypeDefinitions.h>
9#include <kDB/Repository/DatabaseInterface/PostgreSQL/SQLInterface_p.h>
10#include <kDB/Repository/TripleStore_p.h>
12namespace kDB::Repository::VersionControl::Utils
14 inline QByteArray computeDeltaHash(
const QByteArray& _diff)
16 return Cyqlops::Crypto::Hash::md5(_diff);
18 inline QByteArray computeRevisionHash(
const QByteArray& _content_hash,
int _historicity)
20 return Cyqlops::Crypto::Hash::md5(_content_hash, _historicity);
23 inline QByteArray computeSignature(
const Cyqlops::Crypto::RSAAlgorithm& _signature_algortihm,
24 const QUuid& _author,
const knowCore::Timestamp& _time,
25 const QByteArray& _hash)
27 QByteArray hash = Cyqlops::Crypto::Hash::md5(
28 _author.toByteArray(), _time.toEpoch<knowCore::NanoSeconds>().count(), _hash);
29 return _signature_algortihm.sign(hash, Cyqlops::Crypto::Hash::Algorithm::RAW);
35 QSharedPointer<TripleStore::Definition> _definition,
int _revisionId,
36 const QByteArray& _hash)
38 knowCore::ValueHash new_head_map;
39 new_head_map.insert(
"id", _revisionId);
40 new_head_map.insert(
"hash", QString::fromLatin1(_hash.toHex()));
41 _definition->setMeta(QStringList() <<
"versioning" <<
"head",
42 knowCore::Value::fromValue(new_head_map), _transaction);
44 static inline cres_qresult<QByteArray>
46 QSharedPointer<TripleStore::Definition> _definition)
48 cres_try(knowCore::Value hash_var, DatabaseInterface::PostgreSQL::SQLInterface::getMeta(
49 _connection_info, _definition->name,
50 QStringList() <<
"versioning" <<
"head" <<
"hash"));
51 cres_try(QString hash_str, hash_var.value<QString>());
52 return cres_success(QByteArray::fromHex(hash_str.toLatin1()));
Definition QueryConnectionInfo.h:8
Definition Transaction.h:19