<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="HibernateQueryReport" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
	<import value="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
	<style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="12"/>
	<style name="Sans_Bold" isDefault="false" fontName="DejaVu Sans" fontSize="12" isBold="true"/>
	<style name="Sans_Italic" isDefault="false" fontName="DejaVu Sans" fontSize="12" isItalic="true"/>
	<parameter name="ReportTitle" class="java.lang.String"/>
	<parameter name="CityFilter" class="java.util.List"/>
	<parameter name="OrderClause" class="java.lang.String"/>
	<queryString language="hql">
		<![CDATA[from Address address where city not in ($P{CityFilter}) order by $P!{OrderClause}]]>
	</queryString>
	<field name="id" class="java.lang.Long"/>
	<field name="firstName" class="java.lang.String"/>
	<field name="lastName" class="java.lang.String"/>
	<field name="street" class="java.lang.String"/>
	<field name="city" class="java.lang.String"/>
	<field name="documents" class="java.util.Set"/>
	<variable name="CityNumber" class="java.lang.Integer" resetType="Group" resetGroup="CityGroup" calculation="System">
		<initialValueExpression><![CDATA[($V{CityNumber} != null)?(Integer.valueOf($V{CityNumber}.intValue() + 1)):(Integer.valueOf(1))]]></initialValueExpression>
	</variable>
	<group name="CityGroup" minHeightToStartNewPage="100">
		<groupExpression><![CDATA[$F{city}]]></groupExpression>
		<groupHeader>
			<band height="20">
				<rectangle>
					<reportElement x="0" y="4" width="515" height="15" forecolor="#C0C0C0" backcolor="#C0C0C0"/>
				</rectangle>
				<textField>
					<reportElement style="Sans_Bold" mode="Opaque" x="0" y="4" width="515" height="15" backcolor="#C0C0C0"/>
					<textElement textAlignment="Left"/>
					<textFieldExpression class="java.lang.String"><![CDATA["  " + String.valueOf($V{CityNumber}) + ". " + String.valueOf($F{city})]]></textFieldExpression>
				</textField>
				<line>
					<reportElement x="0" y="19" width="515" height="1"/>
				</line>
			</band>
		</groupHeader>
	</group>
	<title>
		<band height="50">
			<line>
				<reportElement x="0" y="0" width="515" height="1" forecolor="#000000"/>
			</line>
			<textField isBlankWhenNull="true">
				<reportElement style="Sans_Normal" x="0" y="10" width="515" height="30"/>
				<textElement textAlignment="Center" lineSpacing="Single">
					<font size="22"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{ReportTitle}]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band height="20">
			<frame>
				<reportElement mode="Opaque" x="0" y="5" width="515" height="15" backcolor="#333333"/>
				<staticText>
					<reportElement style="Sans_Bold" x="0" y="0" width="50" height="15" forecolor="#FFFFFF"/>
					<textElement textAlignment="Right"/>
					<text><![CDATA[ID]]></text>
				</staticText>
				<staticText>
					<reportElement style="Sans_Bold" x="55" y="0" width="205" height="15" forecolor="#FFFFFF"/>
					<textElement/>
					<text><![CDATA[Name]]></text>
				</staticText>
				<staticText>
					<reportElement style="Sans_Bold" x="260" y="0" width="155" height="15" forecolor="#FFFFFF"/>
					<textElement/>
					<text><![CDATA[Street]]></text>
				</staticText>
			</frame>
		</band>
	</pageHeader>
	<detail>
		<band height="41">
			<textField>
				<reportElement x="0" y="4" width="50" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.Long"><![CDATA[$F{id}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="55" y="4" width="200" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{firstName} + " " + $F{lastName}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true">
				<reportElement positionType="Float" x="260" y="4" width="155" height="15"/>
				<textElement/>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{street}]]></textFieldExpression>
			</textField>
			<subreport>
				<reportElement x="65" y="21" width="50" height="20" isRemoveLineWhenBlank="true"/>
				<dataSourceExpression><![CDATA[new JRBeanCollectionDataSource($F{documents})]]></dataSourceExpression>
				<subreportExpression class="java.lang.String"><![CDATA["DocumentsReport.jasper"]]></subreportExpression>
			</subreport>
		</band>
	</detail>
	<pageFooter>
		<band height="40">
			<printWhenExpression><![CDATA[$P{IS_IGNORE_PAGINATION}.booleanValue()?Boolean.FALSE:Boolean.TRUE]]></printWhenExpression>
			<line>
				<reportElement x="0" y="10" width="515" height="1"/>
			</line>
			<textField>
				<reportElement x="200" y="20" width="80" height="15"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression class="java.lang.String"><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
			</textField>
			<textField evaluationTime="Report">
				<reportElement x="280" y="20" width="75" height="15"/>
				<textElement textAlignment="Left"/>
				<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<summary>
		<band height="60">
			<textField isStretchWithOverflow="true">
				<reportElement style="Sans_Italic" x="175" y="20" width="165" height="15"/>
				<textElement textAlignment="Center"/>
				<textFieldExpression class="java.lang.String"><![CDATA["There were " +
					String.valueOf($V{REPORT_COUNT}) +
					" address records on this report."]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
