#
#			ITSV GmbH
#	CCDB - Command and COntrol Database
#
#	FILE:			dquerymfile_genmfilezip.txt
#	DESCRIPTION:	DQUERY definition for DQUERY genmfilezip
#					this query accepts a selection for managed files and generates a ZIP archive containing all the selected files into a new managed files
#
@querytitle			ZIP-Archiv ausgewählter Managed Files
@querydescription	Erzeugt eine ZIP-Datei mit allen durch die Auswahl selektierten Managed Files
@group				DATAFILE
@attributenames		select:string:{{selectoptions}},mfilename:string:{{mfilenameoptions}},mfilelpath:string:{{mfilelpathoptions}},mfileattribs:string:{{mfileattribsoptions}}
@selectoptions {
	labeltext:		"Auswahlkriterium",
	typedesc:		"SQL-Statement zur Auswahl der zu packenden Managed Files, muss zumindest mfileid,mfilename,mfileattribs liefern" }
@mfilenameoptions {
	labeltext:		"Dateiname",
	typedesc:		"Name, den die ZIP-Datei beim Download haben soll",
	is_optional:	true	}
@mfilelpathoptions {
	labeltext:		"logischer Pfad",
	typedesc:		"logischer Pfad, den die ZIP-Datei haben soll",
	is_optional:	true }
@mfileattribsoptions {
	labeltext:		"Managed File Attribute",
	typedesc:		"Attribute für die ZIP-Datei im JSON-Format",
	is_optional:	true }
@querytype			function
@function			seqtrans.seqtrans

~query.tsteps

#
# <<TSTEPNUM:0>>: prepare query parameters and query database for selection
#
pre_qexpression
	proc: {
		if (this.query.select) {
			this.select = this.query.select;
		} else {
			this.errcoll.collect(null,"no selection SQL given",this.query);
			break proc;
		}
		this.mfiletype = 'genzip';
		if (this.query.mfilename) {
			this.mfilename = this.query.mfilename;
		}
		if (this.query.mfilelpath) {
			this.mfilelpath = this.query.mfilelpath;
		}
		if (this.query.mfileattribs) {
			this.mfileattribs = JSON.parse(this.query.mfileattribs);
		}
	}
sql				@@select@@
result_varname	sres
post_qexpression
	this.result = this.sres;
	this.result.toptext = "genmfilezip not yet implemented";
