text: /**
  	* \file PnlWzemUsgRec_blks.cpp
  	* job handler for job PnlWzemUsgRec (implementation of blocks)
  	* \copyright (C) 2016-2020 MPSI Technologies GmbH
  	* \author Alexander Wirthmueller (auto-generation)
  	* \date created: 1 Dec 2020
  	*/
  // IP header --- ABOVE
  
  using namespace std;
  using namespace Sbecore;
  using namespace Xmlio;
  
  /******************************************************************************
   class PnlWzemUsgRec::VecVDo
   ******************************************************************************/
  
  uint PnlWzemUsgRec::VecVDo::getIx(
  			const string& sref
  		) {
  	string s = StrMod::lc(sref);
  
  	if (s == "butminimizeclick") return BUTMINIMIZECLICK;
  	if (s == "butregularizeclick") return BUTREGULARIZECLICK;
  
  	return(0);
  };
  
  string PnlWzemUsgRec::VecVDo::getSref(
  			const uint ix
  		) {
  	if (ix == BUTMINIMIZECLICK) return("ButMinimizeClick");
  	if (ix == BUTREGULARIZECLICK) return("ButRegularizeClick");
  
  	return("");
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::ContInf
   ******************************************************************************/
  
  PnlWzemUsgRec::ContInf::ContInf(
  			const string& TxtRef
  		) :
  			Block()
  		{
  	this->TxtRef = TxtRef;
  
  	mask = {TXTREF};
  };
  
  void PnlWzemUsgRec::ContInf::writeJSON(
  			Json::Value& sup
  			, string difftag
  		) {
  	if (difftag.length() == 0) difftag = "ContInfWzemUsgRec";
  
  	Json::Value& me = sup[difftag] = Json::Value(Json::objectValue);
  
  	me["TxtRef"] = TxtRef;
  };
  
  void PnlWzemUsgRec::ContInf::writeXML(
  			xmlTextWriter* wr
  			, string difftag
  			, bool shorttags
  		) {
  	if (difftag.length() == 0) difftag = "ContInfWzemUsgRec";
  
  	string itemtag;
  	if (shorttags) itemtag = "Ci";
  	else itemtag = "ContitemInfWzemUsgRec";
  
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  		writeStringAttr(wr, itemtag, "sref", "TxtRef", TxtRef);
  	xmlTextWriterEndElement(wr);
  };
  
  set<uint> PnlWzemUsgRec::ContInf::comm(
  			const ContInf* comp
  		) {
  	set<uint> items;
  
  	if (TxtRef == comp->TxtRef) insert(items, TXTREF);
  
  	return(items);
  };
  
  set<uint> PnlWzemUsgRec::ContInf::diff(
  			const ContInf* comp
  		) {
  	set<uint> commitems;
  	set<uint> diffitems;
  
  	commitems = comm(comp);
  
  	diffitems = {TXTREF};
  	for (auto it = commitems.begin(); it != commitems.end(); it++) diffitems.erase(*it);
  
  	return(diffitems);
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::StatApp
   ******************************************************************************/
  
  void PnlWzemUsgRec::StatApp::writeJSON(
  			Json::Value& sup
  			, string difftag
  			, const bool initdoneDetail
  			, const bool initdoneAAccess
  			, const bool initdoneMNUser
  		) {
  	if (difftag.length() == 0) difftag = "StatAppWzemUsgRec";
  
  	Json::Value& me = sup[difftag] = Json::Value(Json::objectValue);
  
  	me["initdoneDetail"] = initdoneDetail;
  	me["initdoneAAccess"] = initdoneAAccess;
  	me["initdoneMNUser"] = initdoneMNUser;
  };
  
  void PnlWzemUsgRec::StatApp::writeXML(
  			xmlTextWriter* wr
  			, string difftag
  			, bool shorttags
  			, const bool initdoneDetail
  			, const bool initdoneAAccess
  			, const bool initdoneMNUser
  		) {
  	if (difftag.length() == 0) difftag = "StatAppWzemUsgRec";
  
  	string itemtag;
  	if (shorttags) itemtag = "Si";
  	else itemtag = "StatitemAppWzemUsgRec";
  
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  		writeBoolAttr(wr, itemtag, "sref", "initdoneDetail", initdoneDetail);
  		writeBoolAttr(wr, itemtag, "sref", "initdoneAAccess", initdoneAAccess);
  		writeBoolAttr(wr, itemtag, "sref", "initdoneMNUser", initdoneMNUser);
  	xmlTextWriterEndElement(wr);
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::StatShr
   ******************************************************************************/
  
  PnlWzemUsgRec::StatShr::StatShr(
  			const uint ixWzemVExpstate
  			, const ubigint jrefDetail
  			, const ubigint jrefAAccess
  			, const ubigint jrefMNUser
  			, const bool ButRegularizeActive
  		) :
  			Block()
  		{
  	this->ixWzemVExpstate = ixWzemVExpstate;
  	this->jrefDetail = jrefDetail;
  	this->jrefAAccess = jrefAAccess;
  	this->jrefMNUser = jrefMNUser;
  	this->ButRegularizeActive = ButRegularizeActive;
  
  	mask = {IXWZEMVEXPSTATE, JREFDETAIL, JREFAACCESS, JREFMNUSER, BUTREGULARIZEACTIVE};
  };
  
  void PnlWzemUsgRec::StatShr::writeJSON(
  			Json::Value& sup
  			, string difftag
  		) {
  	if (difftag.length() == 0) difftag = "StatShrWzemUsgRec";
  
  	Json::Value& me = sup[difftag] = Json::Value(Json::objectValue);
  
  	me["srefIxWzemVExpstate"] = VecWzemVExpstate::getSref(ixWzemVExpstate);
  	me["scrJrefDetail"] = Scr::scramble(jrefDetail);
  	me["scrJrefAAccess"] = Scr::scramble(jrefAAccess);
  	me["scrJrefMNUser"] = Scr::scramble(jrefMNUser);
  	me["ButRegularizeActive"] = ButRegularizeActive;
  };
  
  void PnlWzemUsgRec::StatShr::writeXML(
  			xmlTextWriter* wr
  			, string difftag
  			, bool shorttags
  		) {
  	if (difftag.length() == 0) difftag = "StatShrWzemUsgRec";
  
  	string itemtag;
  	if (shorttags) itemtag = "Si";
  	else itemtag = "StatitemShrWzemUsgRec";
  
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  		writeStringAttr(wr, itemtag, "sref", "srefIxWzemVExpstate", VecWzemVExpstate::getSref(ixWzemVExpstate));
  		writeStringAttr(wr, itemtag, "sref", "scrJrefDetail", Scr::scramble(jrefDetail));
  		writeStringAttr(wr, itemtag, "sref", "scrJrefAAccess", Scr::scramble(jrefAAccess));
  		writeStringAttr(wr, itemtag, "sref", "scrJrefMNUser", Scr::scramble(jrefMNUser));
  		writeBoolAttr(wr, itemtag, "sref", "ButRegularizeActive", ButRegularizeActive);
  	xmlTextWriterEndElement(wr);
  };
  
  set<uint> PnlWzemUsgRec::StatShr::comm(
  			const StatShr* comp
  		) {
  	set<uint> items;
  
  	if (ixWzemVExpstate == comp->ixWzemVExpstate) insert(items, IXWZEMVEXPSTATE);
  	if (jrefDetail == comp->jrefDetail) insert(items, JREFDETAIL);
  	if (jrefAAccess == comp->jrefAAccess) insert(items, JREFAACCESS);
  	if (jrefMNUser == comp->jrefMNUser) insert(items, JREFMNUSER);
  	if (ButRegularizeActive == comp->ButRegularizeActive) insert(items, BUTREGULARIZEACTIVE);
  
  	return(items);
  };
  
  set<uint> PnlWzemUsgRec::StatShr::diff(
  			const StatShr* comp
  		) {
  	set<uint> commitems;
  	set<uint> diffitems;
  
  	commitems = comm(comp);
  
  	diffitems = {IXWZEMVEXPSTATE, JREFDETAIL, JREFAACCESS, JREFMNUSER, BUTREGULARIZEACTIVE};
  	for (auto it = commitems.begin(); it != commitems.end(); it++) diffitems.erase(*it);
  
  	return(diffitems);
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::Tag
   ******************************************************************************/
  
  void PnlWzemUsgRec::Tag::writeJSON(
  			const uint ixWzemVLocale
  			, Json::Value& sup
  			, string difftag
  		) {
  	if (difftag.length() == 0) difftag = "TagWzemUsgRec";
  
  	Json::Value& me = sup[difftag] = Json::Value(Json::objectValue);
  
  	if (ixWzemVLocale == VecWzemVLocale::ENUS) {
  		me["Cpt"] = "User group";
  	};
  };
  
  void PnlWzemUsgRec::Tag::writeXML(
  			const uint ixWzemVLocale
  			, xmlTextWriter* wr
  			, string difftag
  			, bool shorttags
  		) {
  	if (difftag.length() == 0) difftag = "TagWzemUsgRec";
  
  	string itemtag;
  	if (shorttags) itemtag = "Ti";
  	else itemtag = "TagitemWzemUsgRec";
  
  	xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str());
  		if (ixWzemVLocale == VecWzemVLocale::ENUS) {
  			writeStringAttr(wr, itemtag, "sref", "Cpt", "User group");
  		};
  	xmlTextWriterEndElement(wr);
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::DpchAppDo
   ******************************************************************************/
  
  PnlWzemUsgRec::DpchAppDo::DpchAppDo() :
  			DpchAppWzem(VecWzemVDpch::DPCHAPPWZEMUSGRECDO)
  		{
  	ixVDo = 0;
  };
  
  string PnlWzemUsgRec::DpchAppDo::getSrefsMask() {
  	vector<string> ss;
  	string srefs;
  
  	if (has(JREF)) ss.push_back("jref");
  	if (has(IXVDO)) ss.push_back("ixVDo");
  
  	StrMod::vectorToString(ss, srefs);
  
  	return(srefs);
  };
  
  void PnlWzemUsgRec::DpchAppDo::readJSON(
  			Json::Value& sup
  			, bool addbasetag
  		) {
  	clear();
  
  	bool basefound;
  
  	Json::Value& me = sup;
  	if (addbasetag) me = sup["DpchAppWzemUsgRecDo"];
  
  	basefound = (me != Json::nullValue);
  
  	if (basefound) {
  		if (me.isMember("scrJref")) {jref = Scr::descramble(me["scrJref"].asString()); add(JREF);};
  		if (me.isMember("srefIxVDo")) {ixVDo = VecVDo::getIx(me["srefIxVDo"].asString()); add(IXVDO);};
  	} else {
  	};
  };
  
  void PnlWzemUsgRec::DpchAppDo::readXML(
  			xmlXPathContext* docctx
  			, string basexpath
  			, bool addbasetag
  		) {
  	clear();
  
  	string scrJref;
  	string srefIxVDo;
  
  	bool basefound;
  
  	if (addbasetag)
  		basefound = checkUclcXPaths(docctx, basexpath, basexpath, "DpchAppWzemUsgRecDo");
  	else
  		basefound = checkXPath(docctx, basexpath);
  
  	if (basefound) {
  		if (extractStringUclc(docctx, basexpath, "scrJref", "", scrJref)) {
  			jref = Scr::descramble(scrJref);
  			add(JREF);
  		};
  		if (extractStringUclc(docctx, basexpath, "srefIxVDo", "", srefIxVDo)) {
  			ixVDo = VecVDo::getIx(srefIxVDo);
  			add(IXVDO);
  		};
  	} else {
  	};
  };
  
  /******************************************************************************
   class PnlWzemUsgRec::DpchEngData
   ******************************************************************************/
  
  PnlWzemUsgRec::DpchEngData::DpchEngData(
  			const ubigint jref
  			, ContInf* continf
  			, StatShr* statshr
  			, const set<uint>& mask
  		) :
  			DpchEngWzem(VecWzemVDpch::DPCHENGWZEMUSGRECDATA, jref)
  		{
  	if (find(mask, ALL)) this->mask = {JREF, CONTINF, STATAPP, STATSHR, TAG};
  	else this->mask = mask;
  
  	if (find(this->mask, CONTINF) && continf) this->continf = *continf;
  	if (find(this->mask, STATSHR) && statshr) this->statshr = *statshr;
  };
  
  string PnlWzemUsgRec::DpchEngData::getSrefsMask() {
  	vector<string> ss;
  	string srefs;
  
  	if (has(JREF)) ss.push_back("jref");
  	if (has(CONTINF)) ss.push_back("continf");
  	if (has(STATAPP)) ss.push_back("statapp");
  	if (has(STATSHR)) ss.push_back("statshr");
  	if (has(TAG)) ss.push_back("tag");
  
  	StrMod::vectorToString(ss, srefs);
  
  	return(srefs);
  };
  
  void PnlWzemUsgRec::DpchEngData::merge(
  			DpchEngWzem* dpcheng
  		) {
  	DpchEngData* src = (DpchEngData*) dpcheng;
  
  	if (src->has(JREF)) {jref = src->jref; add(JREF);};
  	if (src->has(CONTINF)) {continf = src->continf; add(CONTINF);};
  	if (src->has(STATAPP)) add(STATAPP);
  	if (src->has(STATSHR)) {statshr = src->statshr; add(STATSHR);};
  	if (src->has(TAG)) add(TAG);
  };
  
  void PnlWzemUsgRec::DpchEngData::writeJSON(
  			const uint ixWzemVLocale
  			, Json::Value& sup
  		) {
  	Json::Value& me = sup["DpchEngWzemUsgRecData"] = Json::Value(Json::objectValue);
  
  	if (has(JREF)) me["scrJref"] = Scr::scramble(jref);
  	if (has(CONTINF)) continf.writeJSON(me);
  	if (has(STATAPP)) StatApp::writeJSON(me);
  	if (has(STATSHR)) statshr.writeJSON(me);
  	if (has(TAG)) Tag::writeJSON(ixWzemVLocale, me);
  };
  
  void PnlWzemUsgRec::DpchEngData::writeXML(
  			const uint ixWzemVLocale
  			, xmlTextWriter* wr
  		) {
  	xmlTextWriterStartElement(wr, BAD_CAST "DpchEngWzemUsgRecData");
  	xmlTextWriterWriteAttribute(wr, BAD_CAST "xmlns", BAD_CAST "http://www.mpsitech.com/wzem");
  		if (has(JREF)) writeString(wr, "scrJref", Scr::scramble(jref));
  		if (has(CONTINF)) continf.writeXML(wr);
  		if (has(STATAPP)) StatApp::writeXML(wr);
  		if (has(STATSHR)) statshr.writeXML(wr);
  		if (has(TAG)) Tag::writeXML(ixWzemVLocale, wr);
  	xmlTextWriterEndElement(wr);
  };
  