Commit 00662362 authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Using Gov namespace for gov services.

parent 4feca6c7
......@@ -142,7 +142,7 @@ SOURCES += \
src/dialogues/widget_message_dialogue.cpp \
src/files.cpp \
src/global.cpp \
src/gov.cpp \
src/gov_wrapper.cpp \
src/io/filesystem.cpp \
src/isds/isds_conversion.cpp \
src/isds/isds_type_conversion.cpp \
......@@ -264,7 +264,7 @@ HEADERS += \
src/dialogues/widget_message_dialogue.h \
src/files.h \
src/global.h \
src/gov.h \
src/gov_wrapper.h \
src/io/db_tables.h \
src/io/filesystem.h \
src/isds/isds_conversion.h \
......
......@@ -76,7 +76,7 @@ QVariant GovFormListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
const RequiredInput &ri(m_requiredInputList[row]);
const Gov::RequiredInput &ri(m_requiredInputList[row]);
switch (role) {
case ROLE_GOV_SRVC_KEY:
......@@ -102,7 +102,7 @@ QVariant GovFormListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
const QList<RequiredInput> &GovFormListModel::allEntries(void) const
const QList<Gov::RequiredInput> &GovFormListModel::allEntries(void) const
{
return m_requiredInputList;
}
......@@ -112,14 +112,14 @@ Qt::ItemFlags GovFormListModel::flags(const QModelIndex &index) const
return QAbstractListModel::flags(index);
}
void GovFormListModel::appendEntry(const RequiredInput &entry)
void GovFormListModel::appendEntry(const Gov::RequiredInput &entry)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_requiredInputList.append(entry);
endInsertRows();
}
void GovFormListModel::setEntries(const QList<RequiredInput> &entries)
void GovFormListModel::setEntries(const QList<Gov::RequiredInput> &entries)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_requiredInputList = entries;
......@@ -152,7 +152,7 @@ void GovFormListModel::setProperty(int index, const QString &property,
bool GovFormListModel::haveAllMandatory(void) const
{
foreach (const RequiredInput &ri, m_requiredInputList) {
foreach (const Gov::RequiredInput &ri, m_requiredInputList) {
if (ri.mandatory && ri.val.isEmpty()) {
return false;
}
......
......@@ -102,7 +102,7 @@ public:
*
* @return List of all entries.
*/
const QList<RequiredInput> &allEntries(void) const;
const QList<Gov::RequiredInput> &allEntries(void) const;
/*!
* @brief Returns item flags for given index.
......@@ -118,14 +118,14 @@ public:
*
* @param[in] entry Entry to append to model data.
*/
void appendEntry(const RequiredInput &entry);
void appendEntry(const Gov::RequiredInput &entry);
/*!
* @brief Sets all model entries.
*
* @param[in] entryList List of entries.
*/
void setEntries(const QList<RequiredInput> &entries);
void setEntries(const QList<Gov::RequiredInput> &entries);
/*!
* @brief Clears the model.
......@@ -169,7 +169,7 @@ public:
GovFormListModel *fromVariant(const QVariant &modelVariant);
private:
QList<RequiredInput> m_requiredInputList; /*!< Form data description. */
QList<Gov::RequiredInput> m_requiredInputList; /*!< Form data description. */
};
/* QML passes its arguments via QVariant. */
......
......@@ -55,55 +55,55 @@ static const char xml_template[] =
" </d:crr>""\n"
"</d:root>";
GovMvCrrVbh::GovMvCrrVbh(void)
Gov::SrvcMvCrrVbh::SrvcMvCrrVbh(void)
: m_drivingLicenceId()
{
}
const QString &GovMvCrrVbh::internalId(void) const
const QString &Gov::SrvcMvCrrVbh::internalId(void) const
{
static const QString shortName("GovMvCrrVbh");
static const QString shortName("SrvcMvCrrVbh");
return shortName;
}
const QString &GovMvCrrVbh::fullName(void) const
const QString &Gov::SrvcMvCrrVbh::fullName(void) const
{
static const QString fullName(tr("Printout from the driver penalty point system"));
// "Výpis bodového hodnocení z Centrálního registru řidičů"
return fullName;
}
const QString &GovMvCrrVbh::instituteName(void) const
const QString &Gov::SrvcMvCrrVbh::instituteName(void) const
{
static const QString instituteName(GOV_MV_FULL_NAME);
return instituteName;
}
const QString &GovMvCrrVbh::boxId(void) const
const QString &Gov::SrvcMvCrrVbh::boxId(void) const
{
static const QString boxId(GOV_MV_DB_ID);
return boxId;
}
const QString &GovMvCrrVbh::dmAnnotation(void) const
const QString &Gov::SrvcMvCrrVbh::dmAnnotation(void) const
{
static const QString dmAnnotation("CzechPOINT@home - Výpis z Centrálního registru řidičů");
return dmAnnotation;
}
const QString &GovMvCrrVbh::dmSenderIdent(void) const
const QString &Gov::SrvcMvCrrVbh::dmSenderIdent(void) const
{
static const QString dmSenderIdent("CzechPOINT@home - 258");
return dmSenderIdent;
}
const QString &GovMvCrrVbh::dmFileDescr(void) const
const QString &Gov::SrvcMvCrrVbh::dmFileDescr(void) const
{
static const QString dmFileDescr(GOV_MV_XML_FILE_NAME);
return dmFileDescr;
}
bool GovMvCrrVbh::canSend(enum Isds::Type::DbType dbType) const
bool Gov::SrvcMvCrrVbh::canSend(enum Isds::Type::DbType dbType) const
{
/* TODO -- Check all required types. */
return (dbType == Isds::Type::BT_FO);
......@@ -111,7 +111,7 @@ bool GovMvCrrVbh::canSend(enum Isds::Type::DbType dbType) const
#define DRILIC_KEY "drivingLicenceId"
QList<RequiredInput> GovMvCrrVbh::requiredFields(void) const
QList<Gov::RequiredInput> Gov::SrvcMvCrrVbh::requiredFields(void) const
{
QList<RequiredInput> formList;
......@@ -128,7 +128,7 @@ QList<RequiredInput> GovMvCrrVbh::requiredFields(void) const
return formList;
}
bool GovMvCrrVbh::setRequiredField(const QString &key, const QString &val)
bool Gov::SrvcMvCrrVbh::setRequiredField(const QString &key, const QString &val)
{
if (key != DRILIC_KEY) {
return false;
......@@ -139,12 +139,12 @@ bool GovMvCrrVbh::setRequiredField(const QString &key, const QString &val)
return true;
}
bool GovMvCrrVbh::haveAllMandatoryFields(void) const
bool Gov::SrvcMvCrrVbh::haveAllMandatoryFields(void) const
{
return !m_drivingLicenceId.isEmpty();
}
QByteArray GovMvCrrVbh::binaryXmlContent(
QByteArray Gov::SrvcMvCrrVbh::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
{
QString xml(xml_template);
......
......@@ -27,60 +27,63 @@
#include "src/datovka_shared/gov_services/service/gov_service.h"
/*!
* GOV MV service
* Name: Výpis bodového hodnocení z Centrálního registru řidičů
* DS: xhzkdqv - Automat CzP (Ministerstvo vnitra)
* XML: czpathome.xml - nutno doplnit Jméno, Příjmení, Datum narození
* (YYYY-MM-DD) a číslo řidičského průkazu (bez mezer).
* Source DS type: FO
*/
class GovMvCrrVbh : public GovService {
Q_DECLARE_TR_FUNCTIONS(GovMvCrrVbh)
public:
namespace Gov {
/*!
* @brief Constructor.
*/
GovMvCrrVbh(void);
* GOV MV service
* Name: Výpis bodového hodnocení z Centrálního registru řidičů
* DS: xhzkdqv - Automat CzP (Ministerstvo vnitra)
* XML: czpathome.xml - nutno doplnit Jméno, Příjmení, Datum narození
* (YYYY-MM-DD) a číslo řidičského průkazu (bez mezer).
* Source DS type: FO
*/
class SrvcMvCrrVbh : public Service {
Q_DECLARE_TR_FUNCTIONS(SrvcMvCrrVbh)
public:
/*!
* @brief Constructor.
*/
SrvcMvCrrVbh(void);
virtual
const QString &internalId(void) const Q_DECL_OVERRIDE;
virtual
const QString &internalId(void) const Q_DECL_OVERRIDE;
virtual
const QString &fullName(void) const Q_DECL_OVERRIDE;
virtual
const QString &fullName(void) const Q_DECL_OVERRIDE;
virtual
const QString &instituteName(void) const Q_DECL_OVERRIDE;
virtual
const QString &instituteName(void) const Q_DECL_OVERRIDE;
virtual
const QString &boxId(void) const Q_DECL_OVERRIDE;
virtual
const QString &boxId(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmAnnotation(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmAnnotation(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmSenderIdent(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmSenderIdent(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmFileDescr(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmFileDescr(void) const Q_DECL_OVERRIDE;
virtual
bool canSend(enum Isds::Type::DbType dbType) const Q_DECL_OVERRIDE;
virtual
bool canSend(enum Isds::Type::DbType dbType) const Q_DECL_OVERRIDE;
virtual
QList<RequiredInput> requiredFields(void) const Q_DECL_OVERRIDE;
virtual
QList<RequiredInput> requiredFields(void) const Q_DECL_OVERRIDE;
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
private:
QString m_drivingLicenceId; /*!< Driving licence identifier (number) without white spaces. */
};
private:
QString m_drivingLicenceId; /*!< Driving licence identifier (number) without white spaces. */
};
}
......@@ -23,11 +23,11 @@
#include "src/datovka_shared/gov_services/service/gov_service.h"
GovService::~GovService(void)
Gov::Service::~Service(void)
{
}
Isds::Message GovService::dataMessage(
Isds::Message Gov::Service::dataMessage(
const Isds::DbOwnerInfo &dbOwnerInfo) const
{
Isds::Message message;
......
......@@ -40,139 +40,155 @@
#define GOV_MV_DB_ID "xhzkdqv"
#define GOV_MV_XML_FILE_NAME "czpathome.xml"
/*!
* @brief Describes a form field.
*/
class RequiredInput {
public:
RequiredInput(void)
: key(), val(), descr(), placeholder(), mandatory(true)
{ }
QString key; /*!< Internal value identifier. */
QString val; /*!< Supplied value. */
QString descr; /*!< Value description. */
QString placeholder; /*!< Query placeholder text. */
bool mandatory; /*!< True if the value must be supplied. */
};
/*!
* @brief Encapsulates the general gov service request.
*/
class GovService {
public:
/*!
* @brief Destructor.
*/
virtual
~GovService(void);
/*!
* @brief Return application-internal gov service identifier.
*
* @return Internal service identifier.
*/
virtual
const QString &internalId(void) const = 0;
/*!
* @brief Return gov service full name.
*
* @return Full name of service.
*/
virtual
const QString &fullName(void) const = 0;
/*!
* @brief Return gov institute full name.
*
* @return Full name of gov institute.
*/
virtual
const QString &instituteName(void) const = 0;
/*!
* @brief Return data-box ID of the gov institute.
*
* @return Data-box ID.
*/
virtual
const QString &boxId(void) const = 0;
/*!
* @brief Return gov service message subject.
*
* @return Message annotation.
*/
virtual
const QString &dmAnnotation(void) const = 0;
/*!
* @brief Return gov service sender identification.
*
* @return Message sender identification.
*/
virtual
const QString &dmSenderIdent(void) const = 0;
/*!
* @brief Return gov service attachment file name.
*
* @return Message attachment file name.
*/
virtual
const QString &dmFileDescr(void) const = 0;
/*!
* @brief Check whether a box of the given type ran send this request.
*/
virtual
bool canSend(enum Isds::Type::DbType dbType) const = 0;
/*!
* @brief Return gov service additional information.
*
* @return Additional information.
*/
virtual
QList<RequiredInput> requiredFields(void) const = 0;
/*!
* @brief Set service input data.
*
* @param[in] key Key identifying the data.
* @param[in] val Value to be set.
* @return True if data were set, false on any error.
*/
virtual
bool setRequiredField(const QString &key, const QString &val) = 0;
/*!
* @brief Check whether all mandatory data are set.
*
* @return True if all mandatory fields are set.
*/
virtual
bool haveAllMandatoryFields(void) const = 0;
namespace Gov {
/*!
* @brief Create GOV ISDS message.
*
* @param[in] dbOwnerInfo DS owner info.
* @param[in] reqFields Gov service required information.
* @return Message structure, null structure on any error.
* @brief Describes a form field.
*/
virtual
Isds::Message dataMessage(const Isds::DbOwnerInfo &dbOwnerInfo) const;
class RequiredInput {
public:
RequiredInput(void)
: key(), val(), descr(), placeholder(), mandatory(true)
{ }
RequiredInput(const QString &k, const QString &v,
const QString &d, const QString &p, bool m)
: key(k), val(v), descr(d), placeholder(p), mandatory(m)
{ }
QString key; /*!< Internal value identifier. */
QString val; /*!< Supplied value. */
QString descr; /*!< Value description. */
QString placeholder; /*!< Query placeholder text. */
bool mandatory; /*!< True if the value must be supplied. */
};
/*!
* @brief Create and fill XML attachment content.
*
* @param[in] dbOwnerInfo DS owner info.
* @param[in] reqFields Gov service required information.
* @return XML string for attachment.
* @brief Encapsulates the general gov service request.
*/
virtual
QByteArray binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const = 0;
};
class Service {
public:
/*!
* @brief Destructor.
*/
virtual
~Service(void);
/*!
* @brief Return application-internal gov service identifier.
*
* @return Internal service identifier.
*/
virtual
const QString &internalId(void) const = 0;
/*!
* @brief Return gov service full name.
*
* @return Full name of service.
*/
virtual
const QString &fullName(void) const = 0;
/*!
* @brief Return full name of the gov institute providing
* the service.
*
* @return Full name of gov institute.
*/
virtual
const QString &instituteName(void) const = 0;
/*!
* @brief Return data-box ID of the target data box
* of the gov institute.
*
* @return Data-box ID.
*/
virtual
const QString &boxId(void) const = 0;
/*!
* @brief Return gov service data message subject.
*
* @return Message annotation.
*/
virtual
const QString &dmAnnotation(void) const = 0;
/*!
* @brief Return gov service sender identification.
*
* @return Message sender identification.
*/
virtual
const QString &dmSenderIdent(void) const = 0;
/*!
* @brief Return gov service attachment file name.
*
* @return Message attachment file name.
*/
virtual
const QString &dmFileDescr(void) const = 0;
/*!
* @brief Check whether a box of the given type can send
* this request.
*
* @return True if the box of the type can send the request.
*/
virtual
bool canSend(enum Isds::Type::DbType dbType) const = 0;
/*!
* @brief Return list of required fields needed for the gov
* service request.
*
* @return List of required fields.
*/
virtual
QList<RequiredInput> requiredFields(void) const = 0;
/*!
* @brief Set service form field data.
*
* @param[in] key Key identifying the data.
* @param[in] val Value to be set.
* @return True if data were set, false on any error.
*/
virtual
bool setRequiredField(const QString &key, const QString &val) = 0;
/*!
* @brief Check whether all mandatory data are set.
*
* @return True if all mandatory fields are set.
*/
virtual
bool haveAllMandatoryFields(void) const = 0;
/*!
* @brief Create ISDS message containing the request.
*
* @param[in] dbOwnerInfo DS owner info.
* @param[in] reqFields Gov service required information.
* @return Message structure, null structure on any error.
*/
virtual
Isds::Message dataMessage(
const Isds::DbOwnerInfo &dbOwnerInfo) const;
/*!
* @brief Create and fill XML attachment content.
*
* @param[in] dbOwnerInfo DS owner info.
* @param[in] reqFields Gov service required information.
* @return XML string for attachment.
*/
virtual
QByteArray binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const = 0;
};
}
......@@ -30,6 +30,7 @@
#include "src/datovka_shared/gov_services/service/gov_mv_vr_vp.h"
#include "src/datovka_shared/gov_services/service/gov_mv_zr_vp.h"
#include "src/datovka_shared/gov_services/service/gov_mv_rtpo_vt.h"
#include "src/datovka_shared/gov_services/service/gov_service.h"
#include "src/datovka_shared/gov_services/service/gov_szr_rob_vu.h"
#include "src/datovka_shared/gov_services/service/gov_szr_rob_vvu.h"
#include "src/datovka_shared/gov_services/service/gov_szr_ros_vv.h"
......@@ -38,11 +39,12 @@
#include "src/datovka_shared/log/memory_log.h"
#include "src/dialogues/dialogues.h"
#include "src/global.h"
#include "src/gov.h"
#include "src/gov_wrapper.h"
#include "src/models/accountmodel.h"
#include "src/net/isds_wrapper.h"
#include "src/sqlite/account_db.h"
Gov::Gov(IsdsWrapper *isds, QObject *parent)
GovWrapper::GovWrapper(IsdsWrapper *isds, QObject *parent)
: QObject(parent),
m_govServices(),
m_isds(isds)
......@@ -50,7 +52,7 @@ Gov::Gov(IsdsWrapper *isds, QObject *parent)
initGovServices();
}
void Gov::deleteGovServices(void)
void GovWrapper::deleteGovServices(void)
{
debugFuncCall();
......@@ -60,7 +62,7 @@ void Gov::deleteGovServices(void)
}
}
void Gov::initGovServices(void)
void GovWrapper::initGovServices(void)
{
debugFuncCall();
......@@ -79,7 +81,7 @@ void Gov::initGovServices(void)
m_govServices.insert(gs3->serviceId(), gs3);
/* Výpis bodového hodnocení z Centrálního registru řidičů */
GovMvCrrVbh *gs4 = new (std::nothrow) GovMvCrrVbh;
Gov::Service *gs4 = new (std::nothrow) Gov::SrvcMvCrrVbh;
if (gs4 != Q_NULLPTR) {
const QString &key(gs4->internalId());
if (!m_govServices.contains(key)) {
......@@ -116,7 +118,7 @@ void Gov::initGovServices(void)
m_govServices.insert(gs10->serviceId(), gs10);
}
void Gov::loadServicesToModel(const QVariant &srvcModelVariant) const
void GovWrapper::loadServicesToModel(const QVariant &srvcModelVariant) const
{
debugFuncCall();
......@@ -140,15 +142,15 @@ void Gov::loadServicesToModel(const QVariant &srvcModelVariant) const
}
}
void Gov::loadFormToModel(const QString &userName,
void GovWrapper::loadFormToModel(const QString &userName,
const QString &serviceInternalId, const QVariant &formModelVariant) const
{
debugFuncCall();
Q_UNUSED(userName); /* Currently unused. */
GovService *govService = m_govServices.value(serviceInternalId, Q_NULLPTR);
if (Q_UNLIKELY(govService == Q_NULLPTR)) {
Gov::Service *govSrvc = m_govServices.value(serviceInternalId, Q_NULLPTR);
if (Q_UNLIKELY(govSrvc == Q_NULLPTR)) {
logErrorNL("Cannot access gov service '%s'.",
serviceInternalId.toUtf8().constData());
Q_ASSERT(0);
......@@ -163,16 +165,16 @@ void Gov::loadFormToModel(const QString &userName,
return;
}
formModel->setEntries(govService->requiredFields());
formModel->setEntries(govSrvc->requiredFields());
}
bool Gov::sendGovRequest(const QString &userName,
bool GovWrapper::sendGovRequest(const QString &userName,
const QString &serviceInternalId, const QVariant &formModelVariant) const
{
debugFuncCall();
GovService *govService = m_govServices.value(serviceInternalId, Q_NULLPTR);
if (govService == Q_NULLPTR) {
Gov::Service *govSrvc = m_govServices.value(serviceInternalId, Q_NULLPTR);
if (govSrvc == Q_NULLPTR) {
logErrorNL("Cannot access gov service '%s'.",
serviceInternalId.toUtf8().constData());
Q_ASSERT(0);
......@@ -188,14 +190,14 @@ bool Gov::sendGovRequest(const QString &userName,
}
{
QString service = tr("Request: %1").arg(govService->fullName());
QString service = tr("Request: %1").arg(govSrvc->fullName());
service.append("\n");
service.append(tr("Recipient: %1").arg(govService->instituteName()));
service.append(tr("Recipient: %1").arg(govSrvc->instituteName()));
int msgResponse = Dialogues::message(Dialogues::QUESTION,
tr("Send GOV request"),
tr("Do you want to send the GOV request to data box '%1'?").
arg(govService->boxId()), service,
arg(govSrvc->boxId()), service,
Dialogues::NO | Dialogues::YES, Dialogues::NO);
if (msgResponse == Dialogues::NO) {
return false;
......@@ -207,23 +209,23 @@ bool Gov::sendGovRequest(const QString &userName,
}
/* Set message content according to model data. */