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

Modified the GovService interface.

parent d6effb27
......@@ -23,44 +23,106 @@
#include "src/datovka_shared/gov_services/service/gov_mv_crr_vbh.h"
#define SRVC_SHORT_NAME "GovMvCrrVbh"
#define SRVC_FULL_NAME "Výpis bodového hodnocení z Centrálního registru řidičů"
#define SRVC_ANNOTATION "CzechPOINT@home - Výpis z Centrálního registru řidičů"
#define SRVC_IDENTIFICATION "CzechPOINT@home - 258"
#define SRVC_XML_TEMPLATE "<?xml version='1.0' encoding='UTF-8'?>" \
"<d:root xmlns:d=\"http://software602.cz/sample\" ancestor_id=\"\" " \
"folder_id=\"\" formdata_id=\"\" fsuser_id=\"\" institute_type=\"\" ldapPass=\"\" " \
"nazev=\"\" page=\"0\" page_id=\"\" query_seq=\"2\" register=\"258\" " \
"retry=\"0\" seq=\"\" templateVersion_id=\"\" url=\"\" url_release=\"\" " \
"user_name=\"\" version=\"9.7\" xml:lang=\"cs\">" \
"<d:crr><d:crrVypisBody><d:zadost>" \
"<d:uid/><d:autor/><d:duvod/><d:osobaRC/><d:cisloRP_prevod/>" \
"<d:prijmeni>xSURNAME</d:prijmeni><d:jmeno>xNAME</d:jmeno><d:rodnePrijmeni/>" \
"<d:datumNarozeni>xBIRTH_DATE</d:datumNarozeni><d:datumNarozeni_prevod/>" \
"<d:cisloRP>xDRIVE_LICENSE_ID</d:cisloRP><d:vystup>PDF</d:vystup></d:zadost>" \
"</d:crrVypisBody><d:x509Certificate KeyName=\"\"/>" \
"<d:vydanyDokument url=\"\"><d:pdf/></d:vydanyDokument></d:crr></d:root>"
"folder_id=\"\" formdata_id=\"\" fsuser_id=\"\" institute_type=\"\" " \
"ldapPass=\"\" nazev=\"\" page=\"0\" page_id=\"\" query_seq=\"2\" " \
"register=\"258\" retry=\"0\" seq=\"\" templateVersion_id=\"\" " \
"url=\"\" url_release=\"\" user_name=\"\" version=\"9.7\" " \
"xml:lang=\"cs\">" \
"<d:crr>" \
"<d:crrVypisBody>" \
"<d:zadost>" \
"<d:uid/>" \
"<d:autor/>" \
"<d:duvod/>" \
"<d:osobaRC/>" \
"<d:cisloRP_prevod/>" \
"<d:prijmeni>__repl__SURNAME__</d:prijmeni>" \
"<d:jmeno>__repl_NAME__</d:jmeno>" \
"<d:rodnePrijmeni/>" \
"<d:datumNarozeni>__repl__BIRTH_DATE__</d:datumNarozeni>" \
"<d:datumNarozeni_prevod/>" \
"<d:cisloRP>__repl__DRIVE_LICENSE_ID__</d:cisloRP>" \
"<d:vystup>PDF</d:vystup>" \
"</d:zadost>" \
"</d:crrVypisBody>" \
"<d:x509Certificate KeyName=\"\"/>" \
"<d:vydanyDokument url=\"\">" \
"<d:pdf/>" \
"</d:vydanyDokument>" \
"</d:crr>" \
"</d:root>"
GovMvCrrVbh::GovMvCrrVbh(void)
: GovService(QStringLiteral(SRVC_SHORT_NAME),
QStringLiteral(SRVC_FULL_NAME), QStringLiteral(GOV_MV_FULL_NAME),
QStringLiteral(GOV_MV_DB_ID), QStringLiteral(SRVC_ANNOTATION),
QStringLiteral(SRVC_IDENTIFICATION), QStringLiteral(GOV_MV_XML_FILE_NAME),
QStringLiteral(GOV_SRV_XML_RPID))
: m_drivingLicenceId()
{
}
GovMvCrrVbh::~GovMvCrrVbh(void)
const QString &GovMvCrrVbh::internalId(void) const
{
static const QString shortName("GovMvCrrVbh");
return shortName;
}
const QByteArray GovMvCrrVbh::createXmlAttachment(
const Isds::DbOwnerInfo &dbOwnerInfo, XmlRequiredFileds reqFields)
const QString &GovMvCrrVbh::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
{
static const QString instituteName(GOV_MV_FULL_NAME);
return instituteName;
}
const QString &GovMvCrrVbh::boxId(void) const
{
static const QString boxId(GOV_MV_DB_ID);
return boxId;
}
const QString &GovMvCrrVbh::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
{
static const QString dmSenderIdent("CzechPOINT@home - 258");
return dmSenderIdent;
}
const QString &GovMvCrrVbh::dmFileDescr(void) const
{
static const QString dmFileDescr(GOV_MV_XML_FILE_NAME);
return dmFileDescr;
}
QList<RequiredInput> &GovMvCrrVbh::requiredFields(void) const
{
}
bool GovMvCrrVbh::setRequiredField(const QString &key, const QString &val)
{
return false;
}
bool GovMvCrrVbh::haveAllRequiredFields(void)
{
return false;
}
QByteArray GovMvCrrVbh::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
{
QString xml(QStringLiteral(SRVC_XML_TEMPLATE));
xml.replace("xNAME", dbOwnerInfo.personName().firstName());
xml.replace("xSURNAME", dbOwnerInfo.personName().lastName());
xml.replace("xBIRTH_DATE", dbOwnerInfo.birthInfo().date().toString("yyyy-MM-dd"));
xml.replace("xDRIVE_LICENSE_ID", reqFields.rpId);
xml.replace("__repl_NAME__", dbOwnerInfo.personName().firstName());
xml.replace("__repl__SURNAME__", dbOwnerInfo.personName().lastName());
xml.replace("__repl__BIRTH_DATE__", dbOwnerInfo.birthInfo().date().toString("yyyy-MM-dd"));
xml.replace("__repl__DRIVE_LICENSE_ID__", m_drivingLicenceId);
return xml.toUtf8();
}
......@@ -23,6 +23,8 @@
#pragma once
#include <QCoreApplication> /* Q_DECLARE_TR_FUNCTIONS */
#include "src/datovka_shared/gov_services/service/gov_service.h"
/*!
......@@ -34,28 +36,48 @@
* Source DS type: FO
*/
class GovMvCrrVbh : public GovService {
Q_DECLARE_TR_FUNCTIONS(GovMvCrrVbh)
public:
/*!
* @brief Constructor.
*/
GovMvCrrVbh(void);
/*!
* @brief Destructor.
*/
virtual
~GovMvCrrVbh(void) Q_DECL_OVERRIDE;
const QString &internalId(void) const Q_DECL_OVERRIDE;
/*!
* @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
const QByteArray createXmlAttachment(const Isds::DbOwnerInfo &dbOwnerInfo,
XmlRequiredFileds reqFields) Q_DECL_OVERRIDE;
const QString &fullName(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 &dmAnnotation(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmSenderIdent(void) const Q_DECL_OVERRIDE;
virtual
const QString &dmFileDescr(void) const Q_DECL_OVERRIDE;
virtual
QList<RequiredInput> &requiredFields(void) const;
virtual
bool setRequiredField(const QString &key, const QString &val);
virtual
bool haveAllRequiredFields(void);
virtual
QByteArray binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
private:
QString m_drivingLicenceId; /*!< Driving licence identifier (number) without white spaces. */
};
......@@ -23,115 +23,39 @@
#include "src/datovka_shared/gov_services/service/gov_service.h"
GovService::GovService(void)
: m_serviceId(),
m_serviceFullName(),
m_serviceGovName(),
m_serviceDbId(),
m_serviceSubject(),
m_serviceIdent(),
m_serviceXmlFileName(),
m_serviceReqField()
{
}
GovService::GovService(const QString &serviceId,
const QString &serviceFullName, const QString &serviceGovName,
const QString &serviceDbId, const QString &serviceSubject,
const QString &serviceIdent, const QString &serviceXmlFileName,
const QString &serviceReqField)
: m_serviceId(serviceId),
m_serviceFullName(serviceFullName),
m_serviceGovName(serviceGovName),
m_serviceDbId(serviceDbId),
m_serviceSubject(serviceSubject),
m_serviceIdent(serviceIdent),
m_serviceXmlFileName(serviceXmlFileName),
m_serviceReqField(serviceReqField)
{
}
GovService::GovService(const GovService &gs)
: m_serviceId(gs.m_serviceId),
m_serviceFullName(gs.m_serviceFullName),
m_serviceGovName(gs.m_serviceGovName),
m_serviceDbId(gs.m_serviceDbId),
m_serviceSubject(gs.m_serviceSubject),
m_serviceIdent(gs.m_serviceIdent),
m_serviceXmlFileName(gs.m_serviceXmlFileName),
m_serviceReqField(gs.m_serviceReqField)
{
}
GovService::~GovService(void)
{
}
const QString &GovService::serviceId(void) const
{
return m_serviceId;
}
const QString &GovService::serviceFullName(void) const
{
return m_serviceFullName;
}
const QString &GovService::serviceGovName(void) const
{
return m_serviceGovName;
}
const QString &GovService::serviceDbId(void) const
{
return m_serviceDbId;
}
const QString &GovService::serviceSubject(void) const
{
return m_serviceSubject;
}
const QString &GovService::serviceIdent(void) const
{
return m_serviceIdent;
}
const QString &GovService::serviceXmlFileName(void) const
{
return m_serviceXmlFileName;
}
const QString &GovService::serviceReqField(void) const
{
return m_serviceReqField;
}
const Isds::Message GovService::createMessage(const Isds::DbOwnerInfo &dbOwnerInfo,
XmlRequiredFileds reqFields)
Isds::Message GovService::dataMessage(
const Isds::DbOwnerInfo &dbOwnerInfo) const
{
Isds::Message message;
Isds::Envelope envelope;
Isds::Document document;
QList<Isds::Document> documents;
/* Fill message envelope */
envelope.setDmAnnotation(this->serviceSubject());
envelope.setDbIDRecipient(this->serviceDbId());
envelope.setDmRecipient(this->serviceGovName());
envelope.setDmSenderIdent(this->serviceIdent());
envelope.setDmPublishOwnID(Isds::Type::BOOL_FALSE);
envelope.setDmAllowSubstDelivery(Isds::Type::BOOL_FALSE);
envelope.setDmPersonalDelivery(Isds::Type::BOOL_FALSE);
message.setEnvelope(envelope);
/* Load xml content as attachment file */
document.setFileDescr(this->serviceXmlFileName());
document.setFileMetaType(Isds::Type::FMT_MAIN);
document.setMimeType(QStringLiteral("application/xml"));
document.setBinaryContent(this->createXmlAttachment(dbOwnerInfo, reqFields));
documents.append(document);
message.setDocuments(documents);
{
Isds::Envelope envelope;
/* Fill message envelope */
envelope.setDmAnnotation(dmAnnotation());
envelope.setDbIDRecipient(boxId());
envelope.setDmRecipient(instituteName());
envelope.setDmSenderIdent(dmSenderIdent());
envelope.setDmPublishOwnID(Isds::Type::BOOL_FALSE);
envelope.setDmAllowSubstDelivery(Isds::Type::BOOL_FALSE);
envelope.setDmPersonalDelivery(Isds::Type::BOOL_FALSE);
message.setEnvelope(envelope);
}
{
Isds::Document document;
QList<Isds::Document> documents;
/* Load xml content as attachment file */
document.setFileDescr(dmFileDescr());
document.setFileMetaType(Isds::Type::FMT_MAIN);
document.setMimeType(QStringLiteral("application/xml")); /* FIXME -- Properly detect mime type. */
document.setBinaryContent(binaryXmlContent(dbOwnerInfo));
documents.append(document);
message.setDocuments(documents);
}
return message;
}
......@@ -24,6 +24,7 @@
#pragma once
#include <QByteArray>
#include <QList>
#include <QString>
#include "src/datovka_shared/isds/message_interface.h"
......@@ -45,7 +46,7 @@
/*!
* @brief Encapsulates some mandatory XML information.
*/
class XmlRequiredFileds {
class XmlRequiredFields {
public:
QString ic;
QString rpId;
......@@ -53,40 +54,24 @@ public:
QString to;
};
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 Constructor. Creates an invalid structure.
*/
GovService(void);
/*!
* @brief Constructor.
*
* @param[in] serviceId Gov service ID.
* @param[in] serviceFullName Full name of gov service.
* @param[in] serviceGovName Full name of gov institute.
* @param[in] serviceDbId Gov institute databox ID.
* @param[in] serviceSubject Service request subject.
* @param[in] serviceIdent Service request sender identification.
* @param[in] serviceXmlFileName Service request xml file name.
* @param[in] serviceReqField Service required additional information.
*/
GovService(const QString &serviceId, const QString &serviceFullName,
const QString &serviceGovName, const QString &serviceDbId,
const QString &serviceSubject, const QString &serviceIdent,
const QString &serviceXmlFileName, const QString &serviceReqField);
/*!
* @brief Copy constructor.
*
* @param[in] gs Gov service.
*/
GovService(const GovService &gs);
/*!
* @brief Destructor.
*/
......@@ -94,70 +79,84 @@ public:
~GovService(void);
/*!
* @brief Return gov service ID.
* @brief Return application-internal gov service identifier.
*
* @return Gov service ID.
* @return Internal service identifier.
*/
const QString &serviceId(void) const;
virtual
const QString &internalId(void) const = 0;
/*!
* @brief Return gov service full name.
*
* @return Full name of service.
*/
const QString &serviceFullName(void) const;
virtual
const QString &fullName(void) const = 0;
/*!
* @brief Return gov institute full name.
*
* @return Full name of gov institute.
*/
const QString &serviceGovName(void) const;
virtual
const QString &instituteName(void) const = 0;
/*!
* @brief Return gov institute databox ID.
* @brief Return data-box ID of the gov institute.
*
* @return Gov institute databox ID.
* @return Data-box ID.
*/
const QString &serviceDbId(void) const;
virtual
const QString &boxId(void) const = 0;
/*!
* @brief Return gov service message subject.
*
* @return Message subject.
* @return Message annotation.
*/
const QString &serviceSubject(void) const;
virtual
const QString &dmAnnotation(void) const = 0;
/*!
* @brief Return gov service sender identification.
*
* @return Message sender identification.
*/
const QString &serviceIdent(void) const;
virtual
const QString &dmSenderIdent(void) const = 0;
/*!
* @brief Return gov service attachment file name.
*
* @return Message attachment file name.
*/
const QString &serviceXmlFileName(void) const;
virtual
const QString &dmFileDescr(void) const = 0;
/*!
* @brief Return gov service additional information.
*
* @return Additional information.
*/
const QString &serviceReqField(void) const;
virtual
QList<RequiredInput> &requiredFields(void) const = 0;
virtual
bool setRequiredField(const QString &key, const QString &val) = 0;
virtual
bool haveAllRequiredFields(void) = 0;
/*!
* @brief Create GOV ISDS message.
*
* @param[in] dbOwnerInfo DS owner info.
* @param[in] reqFields Gov service required information.
* @return Message structure.
* @return Message structure, null structure on any error.
*/
const Isds::Message createMessage(const Isds::DbOwnerInfo &dbOwnerInfo,
XmlRequiredFileds reqFields);
virtual
Isds::Message dataMessage(const Isds::DbOwnerInfo &dbOwnerInfo) const;
/*!
* @brief Create and fill XML attachment content.
......@@ -167,16 +166,6 @@ public:
* @return XML string for attachment.
*/
virtual
const QByteArray createXmlAttachment(const Isds::DbOwnerInfo &dbOwnerInfo,
XmlRequiredFileds reqFields) = 0;
private:
QString m_serviceId; /*!< Gov service ID. */
QString m_serviceFullName; /*!< Full name of gov service. */
QString m_serviceGovName; /*!< Full name of gov institute. */
QString m_serviceDbId; /*!< Gov institute databox ID. */
QString m_serviceSubject; /*!< Service request subject. */
QString m_serviceIdent; /*!< Service request sender identification. */
QString m_serviceXmlFileName; /*!< Service request xml file name. */
QString m_serviceReqField; /*!< Service required additional information. */
QByteArray binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const = 0;
};
......@@ -48,10 +48,6 @@ Gov::Gov(IsdsWrapper *isds, QObject *parent)
{
}
Gov::~Gov(void)
{
}
void Gov::deleteGovServices(void)
{
debugFuncCall();
......@@ -81,8 +77,10 @@ void Gov::initGovServices(void)
m_govServices.insert(gs3->serviceId(), gs3);
/* Výpis bodového hodnocení z Centrálního registru řidičů */
GovMvCrrVbh *gs4 = new GovMvCrrVbh();
m_govServices.insert(gs4->serviceId(), gs4);
GovMvCrrVbh *gs4 = new (std::nothrow) GovMvCrrVbh;
if (gs4 != Q_NULLPTR) {
m_govServices.insert(gs4->internalId(), gs4);
}
/* Výpis z Rejstříku trestů právnických osob */
GovMvRtpoVt *gs5 = new GovMvRtpoVt();
......
......@@ -46,11 +46,6 @@ public:
*/
explicit Gov(IsdsWrapper *isds, QObject *parent = Q_NULLPTR);
/*!
* @brief Destructor.
*/
~Gov(void);
/*!
* @brief Remove all Gov services from map and delete their objects.
*/
......@@ -86,7 +81,6 @@ public:
const QString &dTo);
private:
QMap<QString, GovService*> m_govServices; /*!< Holds pointers to Gov services. */
QMap<QString, GovService *> m_govServices; /*!< Holds pointers to Gov services. */
IsdsWrapper *m_isds; /*!< Pointer to isds wrapper. */
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment