Changeset 679 for trunk/grails-app/services
- Timestamp:
- Oct 5, 2010, 12:50:57 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/AssetReportService.groovy
r678 r679 125 125 def result = [:] 126 126 127 result.section = Section.get(params.section.id.toLong()) 128 result.site = result.section.site 129 127 130 // Inner join used to return only attribTypes that are used by AssetSubItemExtendedAttributes. 128 131 // So the result is only assetSubItem extendedAttributeTypes. … … 135 138 result.attribTypes = Asset.executeQuery(attribTypesQ.query, attribTypesQ.namedParams) 136 139 137 // Since there will be nothing to show in the report table for assets without level 1 assetSubItems, 138 // a list needs to be given to the user. 140 // A useful list of assets without subItems to be given to the user. 139 141 def assetsWithoutEquipmentQ = new HqlBuilder().query { 140 142 select 'distinct asset' … … 142 144 'left join asset.assetSubItems as assetSubItem' 143 145 where 'assetSubItem = null' 146 namedParams.section = result.section 147 and 'asset.section = :section' 144 148 } 145 149 result.assetsWithoutEquipment = AssetSubItem.executeQuery(assetsWithoutEquipmentQ.query, assetsWithoutEquipmentQ.namedParams) … … 158 162 'left join attrib.extendedAttributeType as attribT' 159 163 where 'asset != null' // ensure that only level 1 assetSubItems are returned. 160 if(params.section instanceof Section) { 161 namedParams.section = params.section 164 namedParams.section = result.section 162 165 and 'asset.section = :section' 163 }164 166 order 'by asset.name asc, assetSubItem.name asc, attribT.name asc' 165 167 } 166 168 def equipmentResults = AssetSubItem.executeQuery(q.query, q.namedParams) 169 170 // A result is returned for every asset and for any extended attributes. 171 def assetResultsQ = new HqlBuilder().query { 172 select 'new map(asset.name as assetName', 173 "' Asset Details' as name", // Place holder 'equipment' name, 3 leading spaces for sorting. 174 'asset.description as description', 175 'asset.comment as comment', 176 'attribT.name as attribType', 177 'attrib.value as attribValue)' 178 from 'Asset asset', 179 'left join asset.assetExtendedAttributes as attrib', 180 'left join attrib.extendedAttributeType as attribT' 181 where 'asset.section = :section' 182 namedParams.section = result.section 183 order 'by asset.name asc, attribT.name asc' 184 } 185 def assetResults = Asset.executeQuery(assetResultsQ.query, assetResultsQ.namedParams) 186 187 // Add asset details to equipmentResults. 188 equipmentResults.addAll(assetResults) 189 equipmentResults.sort { p1, p2 -> p1.assetName.compareToIgnoreCase(p2.assetName) ?: p1.name.compareToIgnoreCase(p2.name) } 167 190 168 191 // Build the report table rows.
Note: See TracChangeset
for help on using the changeset viewer.