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

Updated Gov::SrvcSzrRobVvu.

parent a5ce3b08
......@@ -88,7 +88,8 @@ const QString &Gov::SrvcSzrRobVu::boxId(void) const
const QString &Gov::SrvcSzrRobVu::dmAnnotation(void) const
{
return fullName();
static const QString dmAnnotation("Výpis z Registru obyvatel");
return dmAnnotation;
}
const QString &Gov::SrvcSzrRobVu::dmSenderIdent(void) const
......
......@@ -23,43 +23,164 @@
#include "src/datovka_shared/gov_services/service/gov_szr_rob_vvu.h"
#define SRVC_SHORT_NAME "GovSzrRobVvu"
#define SRVC_FULL_NAME "Výpis o využití údajů z registru obyvatel"
#define SRVC_XML_TEMPLATE "<?xml version='1.0' encoding='utf-8'?>" \
"<d:FormularData xmlns:d=\"http://software602.cz/formulare\" " \
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \
"xmlns:date=\"http://exslt.org/dates-and-times\" " \
"xsi:schemaLocation=\"http://software602.cz/formulare FormularData_ZRDS11.xsd\" " \
"version=\"1.3o\">" \
"<d:Identifikace><d:Formular>ZRDS5</d:Formular><d:Zadatel><d:Aifo/>" \
"<d:Idds/><d:DatumNarozeni/><d:Jmeno/><d:MistoNarozeniNazev/>" \
"<d:Prijmeni/><d:Doklady><d:Cislo/><d:Druh/></d:Doklady><d:AdresaPobytu>" \
"<d:OkresNazev/><d:ObecNazev/><d:CastObceNazev/><d:UliceNazev/>" \
"<d:PostaKod/><d:TypCislaDomovnihoKod/><d:CisloDomovni/>" \
"<d:CisloOrientacni/><d:CisloOrientacniPismeno/></d:AdresaPobytu>" \
"</d:Zadatel></d:Identifikace><d:Parametry>" \
"<d:CasOd>xFROM-DATE</d:CasOd><d:CasDo>xTO-DATE</d:CasDo>" \
"</d:Parametry></d:FormularData>"
GovSzrRobVvu::GovSzrRobVvu(void)
: GovService(QStringLiteral(SRVC_SHORT_NAME),
QStringLiteral(SRVC_FULL_NAME), QStringLiteral(GOV_SZR_FULL_NAME),
QStringLiteral(GOV_SZR_DB_ID), QStringLiteral(SRVC_FULL_NAME), QString(),
QStringLiteral(GOV_SZR_XML_FILE_NAME), QStringLiteral(GOV_SRV_XML_DATE))
static const char xml_template[] =
"<?xml version='1.0' encoding='utf-8'?>""\n"
"<d:FormularData xmlns:d=\"http://software602.cz/formulare\" "
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
"xmlns:date=\"http://exslt.org/dates-and-times\" "
"xsi:schemaLocation=\"http://software602.cz/formulare "
"FormularData_ZRDS11.xsd\" version=\"1.3o\">""\n"
" <d:Identifikace>""\n"
" <d:Formular>ZRDS5</d:Formular>""\n"
" <d:Zadatel>""\n"
" <d:Aifo/>""\n"
" <d:Idds/>""\n"
" <d:DatumNarozeni/>""\n"
" <d:Jmeno/>""\n"
" <d:MistoNarozeniNazev/>""\n"
" <d:Prijmeni/>""\n"
" <d:Doklady>""\n"
" <d:Cislo/>""\n"
" <d:Druh/>""\n"
" </d:Doklady>""\n"
" <d:AdresaPobytu>""\n"
" <d:OkresNazev/>""\n"
" <d:ObecNazev/>""\n"
" <d:CastObceNazev/>""\n"
" <d:UliceNazev/>""\n"
" <d:PostaKod/>""\n"
" <d:TypCislaDomovnihoKod/>""\n"
" <d:CisloDomovni/>""\n"
" <d:CisloOrientacni/>""\n"
" <d:CisloOrientacniPismeno/>""\n"
" </d:AdresaPobytu>""\n"
" </d:Zadatel>""\n"
" </d:Identifikace>""\n"
" <d:Parametry>""\n"
" <d:CasOd>__repl_FROM_DATE__</d:CasOd>""\n"
" <d:CasDo>__repl_TO_DATE__</d:CasDo>""\n"
" </d:Parametry>""\n"
"</d:FormularData>";
Gov::SrvcSzrRobVvu::SrvcSzrRobVvu(void)
: m_fromDate(),
m_toDate()
{
}
const QString &Gov::SrvcSzrRobVvu::internalId(void) const
{
static const QString shortName("SrvcSzrRobVvu");
return shortName;
}
const QString &Gov::SrvcSzrRobVvu::fullName(void) const
{
static const QString fullName(tr("Printout about the usage of entries from the resident register"));
// Výpis o využití údajů z registru obyvatel
return fullName;
}
const QString &Gov::SrvcSzrRobVvu::instituteName(void) const
{
static const QString instituteName(GOV_SZR_FULL_NAME);
return instituteName;
}
const QString &Gov::SrvcSzrRobVvu::boxId(void) const
{
static const QString boxId(GOV_SZR_DB_ID);
return boxId;
}
const QString &Gov::SrvcSzrRobVvu::dmAnnotation(void) const
{
static const QString dmAnnotation("Výpis o využití údajů z registru obyvatel");
return dmAnnotation;
}
const QString &Gov::SrvcSzrRobVvu::dmSenderIdent(void) const
{
static const QString dmSenderIdent; /* Null string. */
return dmSenderIdent;
}
const QString &Gov::SrvcSzrRobVvu::dmFileDescr(void) const
{
static const QString dmFileDescr(GOV_SZR_XML_FILE_NAME);
return dmFileDescr;
}
bool Gov::SrvcSzrRobVvu::canSend(enum Isds::Type::DbType dbType) const
{
/* TODO -- Check all required types. */
return (dbType == Isds::Type::BT_FO);
}
#define FROM_KEY "fromDate"
#define TO_KEY "toDate"
#define DATE_FORMAT "yyyy-MM-dd"
QList<Gov::RequiredInput> Gov::SrvcSzrRobVvu::requiredFields(void) const
{
QList<RequiredInput> formList;
{
RequiredInput ri;
ri.key = FROM_KEY;
ri.val = m_fromDate.isNull() ? QString() : m_fromDate.toString(DATE_FORMAT);
ri.descr = tr("From");
ri.placeholder = tr("Enter date (YYYY-MM-DD)");
ri.mandatory = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = TO_KEY;
ri.val = m_toDate.isNull() ? QString() : m_toDate.toString(DATE_FORMAT);
ri.descr = tr("To");
ri.placeholder = tr("Enter date (YYYY-MM-DD)");
ri.mandatory = true;
formList.append(ri);
}
return formList;
}
bool Gov::SrvcSzrRobVvu::setRequiredField(const QString &key, const QString &val)
{
if (key == FROM_KEY) {
QDate date(QDate::fromString(val, DATE_FORMAT));
if (date.isNull()) {
return false;
}
m_fromDate = date;
return true;
} else if (key == TO_KEY) {
QDate date(QDate::fromString(val, DATE_FORMAT));
if (date.isNull()) {
return false;
}
m_toDate = date;
return true;
} else {
return false;
}
}
GovSzrRobVvu::~GovSzrRobVvu(void)
bool Gov::SrvcSzrRobVvu::haveAllMandatoryFields(void) const
{
return (!m_fromDate.isNull()) && (!m_toDate.isNull());
}
const QByteArray GovSzrRobVvu::createXmlAttachment(
const Isds::DbOwnerInfo &dbOwnerInfo, XmlRequiredFileds reqFields)
QByteArray Gov::SrvcSzrRobVvu::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
{
Q_UNUSED(dbOwnerInfo);
QString xml(QStringLiteral(SRVC_XML_TEMPLATE));
xml.replace("xFROM-DATE", reqFields.from);
xml.replace("xTO-DATE", reqFields.to);
QString xml(xml_template);
xml.replace("__repl_FROM_DATE__", m_fromDate.toString(DATE_FORMAT));
xml.replace("__repl_TO_DATE__", m_toDate.toString(DATE_FORMAT));
return xml.toUtf8();
}
......@@ -23,38 +23,68 @@
#pragma once
#include "src/datovka_shared/gov_services/service/gov_service.h"
#include <QCoreApplication> /* Q_DECLARE_TR_FUNCTIONS */
#include <QDate>
/*!
* GOV SZR service
* Name: Žádost o výpis o využití údajů z registru obyvatel
* DS: 4h8cxph - Automat ZR (Správa základních registrů)
* XML: zrds.xml - do xml je třeba doplnit časové rozmezí od-do.
* Source DS type: FO
*/
class GovSzrRobVvu : public GovService {
#include "src/datovka_shared/gov_services/service/gov_service.h"
public:
namespace Gov {
/*!
* @brief Constructor.
* GOV SZR service
* Name: Žádost o výpis o využití údajů z registru obyvatel
* DS: 4h8cxph - Automat ZR (Správa základních registrů)
* XML: zrds.xml - do xml je třeba doplnit časové rozmezí od-do.
* Source DS type: FO
*/
GovSzrRobVvu(void);
class SrvcSzrRobVvu : public Service {
Q_DECLARE_TR_FUNCTIONS(SrvcSzrRobVvu)
/*!
* @brief Destructor.
*/
virtual
~GovSzrRobVvu(void) Q_DECL_OVERRIDE;
public:
/*!
* @brief Constructor.
*/
SrvcSzrRobVvu(void);
/*!
* @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;
};
virtual
const QString &internalId(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 &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
bool canSend(enum Isds::Type::DbType dbType) 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 haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
private:
QDate m_fromDate; /*!< Start date. */
QDate m_toDate; /*!< Stop date. */
};
}
......@@ -32,7 +32,7 @@
//#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_rob_vvu.h"
//#include "src/datovka_shared/gov_services/service/gov_szr_ros_vv.h"
#include "src/datovka_shared/isds/message_interface.h"
#include "src/datovka_shared/log/log.h"
......@@ -71,7 +71,7 @@ void GovWrapper::initGovServices(void)
Gov::Service *gs;
/* Výpis z Registru obyvatel */
gs = new Gov::SrvcSzrRobVu();
gs = new (std::nothrow) Gov::SrvcSzrRobVu;
if (gs != Q_NULLPTR) {
const QString &key(gs->internalId());
if (!m_govServices.contains(key)) {
......@@ -80,12 +80,23 @@ void GovWrapper::initGovServices(void)
logError(
"Key '%s' already exists in gov services container.",
key.toUtf8().constData());
delete gs;
}
}
// /* Výpis o využití údajů z registru obyvatel */
// GovSzrRobVvu *gs2 = new GovSzrRobVvu();
// m_govServices.insert(gs2->serviceId(), gs2);
/* Výpis o využití údajů z registru obyvatel */
gs = new (std::nothrow) Gov::SrvcSzrRobVvu;
if (gs != Q_NULLPTR) {
const QString &key(gs->internalId());
if (!m_govServices.contains(key)) {
m_govServices.insert(key, gs);
} else {
logError(
"Key '%s' already exists in gov services container.",
key.toUtf8().constData());
delete gs;
}
}
// /* Veřejný výpis z registru osob */
// GovSzrRosVv *gs3 = new GovSzrRosVv();
......@@ -101,6 +112,7 @@ void GovWrapper::initGovServices(void)
logError(
"Key '%s' already exists in gov services container.",
key.toUtf8().constData());
delete gs;
}
}
......@@ -118,6 +130,7 @@ void GovWrapper::initGovServices(void)
logError(
"Key '%s' already exists in gov services container.",
key.toUtf8().constData());
delete gs;
}
}
......
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