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,
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);
36 const QByteArray& _hash)
39 new_head_map.
insert(
"id", _revisionId);
40 new_head_map.
insert(
"hash", QString::fromLatin1(_hash.toHex()));
41 _definition->setMeta(
QStringList() <<
"versioning" <<
"head",
44 static inline cres_qresult<QByteArray>
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
Definition Timestamp.h:39
_unit_ toEpoch() const
Definition Timestamp.h:161
Definition ValueHash.h:13
ValueHash & insert(const QString &_key, const _T_ &_value)
Definition ValueHash.h:147
static Value fromValue(const _T_ &_value)
Definition Value.h:241
cres_qresult< _T_ > value(TypeCheckingMode _conversion=TypeCheckingMode::Safe) const
Definition Value.h:353