<?xml version='1.0' encoding='UTF-8'?>

<Properties version="4.1">
	<Property name="ErrorSuppression" type="Boolean">false</Property>
	<Property name="xslt.base64Zipped">true</Property>
	<Property name="xslt.ignoreInput">true</Property>
	<Property name="xslt.params" type="List">
		<Property name="var.session">var.session</Property>
	</Property>
	<Property name="xslt.saveAtServer">true</Property>
	<Property name="xslt.setAllVariablesAsTransformerParams">true</Property>
	<Property name="xslt.source">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;miss/></Property>
	<Property name="xslt.sourceVariables" type="Map">
		<Property name="ISCurrentTime">1524474314263</Property>
		<Property name="ISWorkflowName">VAM_am_059_queryQueries</Property>
		<Property name="ISModuleName">VAM_am_joiner</Property>
		<Property name="ISModuleId">29</Property>
		<Property name="ISProcessId">5846578</Property>
		<Property name="ISUserName">VAM</Property>
		<Property name="ISServerName">dev04.virtimo.net</Property>
		<Property name="ISGlobalProcessId">5846578</Property>
		<Property name="ISInvokingWorkflow">VAM_am_060_query</Property>
		<Property name="ISInvokingModule">VAM_am_wfc_059_queryQueries</Property>
		<Property name="log" type="XmlDocument">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;log>&lt;entries/>&lt;/log></Property>
		<Property name="var.canCache">true</Property>
		<Property name="var.storage">VAM_queries</Property>
		<Property name="var.key">showcase@all@de_DE</Property>
		<Property name="var.session" type="XmlDocument">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;session>&lt;request>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>query&lt;/method>&lt;parameters>&lt;filters>&lt;filter>&lt;key>createdByUserDisplayName&lt;/key>&lt;operator>contains&lt;/operator>&lt;value>dkfjds&lt;/value>&lt;/filter>&lt;/filters>&lt;start>10&lt;/start>&lt;limit>15&lt;/limit>&lt;/parameters>&lt;withUser>false&lt;/withUser>&lt;startTimestamp>1524474314250&lt;/startTimestamp>&lt;/request>&lt;configuration>&lt;api xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">&lt;database>&lt;type>mssql&lt;/type>&lt;default>&lt;alertTimeout>20&lt;/alertTimeout>&lt;queryTimeout>60&lt;/queryTimeout>&lt;/default>&lt;/database>&lt;entity>&lt;validate>false&lt;/validate>&lt;/entity>&lt;response>&lt;debuggingInformation>false&lt;/debuggingInformation>&lt;format>false&lt;/format>&lt;validate>true&lt;/validate>&lt;/response>&lt;user>&lt;maxAge>P0DT2H0M5S&lt;/maxAge>&lt;/user>&lt;technicalUser>&lt;loginName>sys&lt;/loginName>&lt;/technicalUser>&lt;alerting>&lt;recipient>&lt;eMailAddress>kaufhold@virtimo.de &lt;/eMailAddress>&lt;/recipient>&lt;mail>&lt;host>smtp.googlemail.com&lt;/host>&lt;sender>&lt;eMailAddress>jochen@virtimo.net &lt;/eMailAddress>&lt;/sender>&lt;debuggingInformation>true&lt;/debuggingInformation>&lt;/mail>&lt;/alerting>&lt;backend>&lt;imnot>&lt;url>https://localhost:7080/im/1/rest/&lt;/url>&lt;/imnot>&lt;bpc>&lt;url>http://localhost:8181/cxf/bpc-core/authentication&lt;/url>&lt;/bpc>&lt;/backend>&lt;/api>&lt;am xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">&lt;entity>&lt;validate>false&lt;/validate>&lt;/entity>&lt;technicalUser>&lt;loginName>sys&lt;/loginName>&lt;/technicalUser>&lt;/am>&lt;userGroupName>VAM&lt;/userGroupName>&lt;/configuration>&lt;user>&lt;id>bpcadmin&lt;/id>&lt;displayName>bpcadmin&lt;/displayName>&lt;loginName>bpcadmin&lt;/loginName>&lt;name>bpcadmin&lt;/name>&lt;eMailAddress/>&lt;active>true&lt;/active>&lt;locale>de_DE&lt;/locale>&lt;language>de&lt;/language>&lt;country>DE&lt;/country>&lt;roles>&lt;role>10XCH-SWISSGRID2&lt;/role>&lt;role>bpcadmin&lt;/role>&lt;role>VAM-administrator&lt;/role>&lt;role>VAM_organization_16103&lt;/role>&lt;role>VAM_organization_ebix&lt;/role>&lt;role>VAM_organization_showcase&lt;/role>&lt;role>EAI Developer&lt;/role>&lt;role>bpcAdmin&lt;/role>&lt;role>bpcUser&lt;/role>&lt;/roles>&lt;permissions>&lt;permission>&lt;module>api&lt;/module>&lt;context>organization&lt;/context>&lt;method>getConfiguration&lt;/method>&lt;/permission>&lt;permission>&lt;module>api&lt;/module>&lt;context>organization&lt;/context>&lt;method>setConfiguration&lt;/method>&lt;/permission>&lt;permission>&lt;module>api&lt;/module>&lt;context>organization&lt;/context>&lt;method>setName&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>create&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>update&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>delete&lt;/method>&lt;/permission>&lt;permission>&lt;module&gt;am&lt;/module>&lt;context>asset&lt;/context>&lt;method>getActionAttributes&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>executeAction&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>get&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>asset&lt;/context>&lt;method>query&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>person&lt;/context>&lt;method>create&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>person&lt;/context>&lt;method>update&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>person&lt;/context>&lt;method>delete&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>person&lt;/context>&lt;method>get&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>person&lt;/context>&lt;method>query&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>create&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>update&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>delete&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>get&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>query&lt;/context>&lt;method>query&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>create&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>update&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>delete&lt;/method&gt;&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>setImage&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>getImage&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>get&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>query&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>getActionAttributes&lt;/method>&lt;/permission>&lt;permission>&lt;module>am&lt;/module>&lt;context>template&lt;/context>&lt;method>executeAction&lt;/method>&lt;/permission>&lt;/permissions>&lt;organizations>&lt;organization>&lt;id>showcase&lt;/id>&lt;displayName>showcase&lt;/displayName>&lt;name/>&lt;configuration/>&lt;active>true&lt;/active>&lt;/organization>&lt;/organizations>&lt;/user>&lt;/session></Property>
	</Property>
	<Property name="xslt.stylesheet" type="XmlDocument">&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:am="http://www.bosch-si.com/2013/AM" xmlns:local="local:local" exclude-result-prefixes="#all" version="2.0">
  &lt;xsl:import href="inubitmodule://VAM_api_XSLT_Tools"/>
  &lt;xsl:output method="xml" encoding="UTF-8"/>
  &lt;xsl:param name="var.session" as="element()"/>
  &lt;xsl:variable name="var.body" select="$var.session/request/parameters" as="element()?">
    
  &lt;/xsl:variable>
  &lt;xsl:variable name="var.filters" select="$var.body/filters" as="element()?">
    
  &lt;/xsl:variable>
  &lt;xsl:function name="local:orderQueriesBy">&lt;xsl:param name="var.sorters" as="element()*"/>&lt;xsl:text>     order by  &lt;/xsl:text>&lt;xsl:for-each select="$var.sorters">
  &lt;xsl:choose>&lt;xsl:when test="key = 'description'">&lt;xsl:value-of select="am:orderByWithNull(., concat('q.', key))"/>

    &lt;/xsl:when>&lt;xsl:when test="key = ('id', 'displayName', 'visibility', 'createdOn', 'createdByUserId', 'lastUpdatedOn', 'lastUpdatedByUserId') ">&lt;xsl:value-of select="am:orderBy(., concat('q.', key))"/>

    &lt;/xsl:when>&lt;xsl:when test="key = 'createdByUserDisplayName'">&lt;xsl:value-of select="am:orderBy(., 'cu.displayName')"/>

    &lt;/xsl:when>&lt;xsl:when test="key = 'lastUpdatedByUserDisplayName'">&lt;xsl:value-of select="am:orderBy(., 'luu.displayName')"/>

    &lt;/xsl:when>&lt;/xsl:choose>
&lt;/xsl:for-each>&lt;xsl:text>   q.ID asc   &lt;/xsl:text>









  &lt;/xsl:function>

  &lt;xsl:function name="local:queries">&lt;xsl:text> select &lt;/xsl:text>&lt;xsl:choose>&lt;xsl:when test="am:orderAtTop()">&lt;xsl:text> ROW_NUMBER() over( &lt;/xsl:text>&lt;xsl:value-of select="local:orderQueriesBy($var.body/sorters/*)"/>&lt;xsl:text>) AS rownumber, &lt;/xsl:text>&lt;/xsl:when>&lt;xsl:otherwise>&lt;xsl:text> rownum rowNumber, &lt;/xsl:text>&lt;/xsl:otherwise>&lt;/xsl:choose>&lt;xsl:text>q.id,
q.displayName,
q.visibility,
q.description,
q.filters,
q.createdOn,
q.createdByUserId,
cu.displayName createdByUserDisplayName,
q.lastUpdatedOn,
q.lastUpdatedByUserId,
luu.displayName lastUpdatedByUserDisplayName

from queries q

join users cu
on cu.id = q.createdByUserId



join users luu
on luu.id = q.lastUpdatedByUserId



&lt;/xsl:text>&lt;xsl:value-of select="am:whereOrganizationFilter($var.session, 'q')"/>&lt;xsl:text>
and (
  q.visibility = 'o' or
  q.lastUpdatedByUserId = &lt;/xsl:text>&lt;xsl:value-of select="am:stringToDB($var.session/user/id)"/>&lt;xsl:text>
)

&lt;/xsl:text>&lt;xsl:value-of select="am:userNameFilters($var.filters)"/>&lt;xsl:value-of select="am:metaFilters($var.filters, 'q')"/>&lt;xsl:for-each select="$var.filters/filter[not(starts-with(operator, 'contains'))]">
  &lt;xsl:choose>
    
    &lt;xsl:when test="key = 'displayName'">&lt;xsl:value-of select="am:plainFilter(., 'q.displayName', 'string')"/>
      
    &lt;/xsl:when>
    &lt;xsl:when test="key = 'visibility'">&lt;xsl:value-of select="am:plainFilter(., 'q.visibility', 'string')"/>
      
    &lt;/xsl:when>
    &lt;xsl:when test="key = 'description'">&lt;xsl:value-of select="am:plainFilter(., 'q.description', 'string')"/>
      
    &lt;/xsl:when>
    
    
    
    
  &lt;/xsl:choose>
&lt;/xsl:for-each>&lt;xsl:for-each select="$var.filters/filter[starts-with(operator, 'contains')]">
  &lt;xsl:choose>
    
    &lt;xsl:when test="key = 'displayName' or key = 'description'">&lt;xsl:value-of select="am:containsFilter(., 'q')"/>
      
    &lt;/xsl:when>
    
    
    
    
    
    
  &lt;/xsl:choose>
&lt;/xsl:for-each>&lt;xsl:if test="not(am:orderAtTop())">&lt;xsl:value-of select="local:orderQueriesBy($var.body/sorters/*)"/>&lt;/xsl:if>
&lt;/xsl:function>

  &lt;xsl:template match="/">
    &lt;queries>&lt;xsl:if test="$var.body/start != '' and  $var.body/limit != ''">&lt;query properties="force" queryID="total">
        &lt;value>&lt;xsl:text>
select count(*) TOTAL

from (&lt;/xsl:text>&lt;xsl:value-of select="local:queries()"/>&lt;xsl:text>) q
        &lt;/xsl:text>&lt;/value>
      &lt;/query>&lt;/xsl:if>
      
      &lt;query properties="force" queryID="queries">
        
        
        &lt;value>&lt;xsl:text>
select 
q.ROWNUMBER,
q.ID,
q.DISPLAYNAME,
q.VISIBILITY,
q.DESCRIPTION,
q.CREATEDBYUSERID,
q.CREATEDBYUSERDISPLAYNAME,
q.LASTUPDATEDBYUSERID,
q.LASTUPDATEDBYUSERDISPLAYNAME,

&lt;/xsl:text>&lt;xsl:value-of select="am:nodeFromDB('q.FILTERS'), am:comma()"/>&lt;xsl:value-of select="am:timestampFromDB('q.CREATEDON'), am:comma()"/>&lt;xsl:value-of select="am:timestampFromDB('q.LASTUPDATEDON')"/>&lt;xsl:text>
from (&lt;/xsl:text>&lt;xsl:value-of select="local:queries()"/>&lt;xsl:text>) q &lt;/xsl:text>&lt;xsl:copy-of select="am:paging($var.body/start, $var.body/limit, 'q')"/>&lt;/value>
      &lt;/query>
    &lt;/queries>
  &lt;/xsl:template>
&lt;/xsl:stylesheet></Property>
	<Property name="xslt.target"></Property>
	<Property name="xslt.transformer">net.sf.saxon.TransformerFactoryImpl</Property>
</Properties>