Changeset 562 for trunk/grails-app
- Timestamp:
- Jun 2, 2010, 4:31:17 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AppCoreController.groovy
r548 r562 11 11 def appConfigService 12 12 def createDataService 13 def searchableService 13 14 def createBulkDataService 14 15 … … 251 252 } 252 253 254 /** 255 * Rebuild the lucene text search index. 256 */ 257 @Secured(['ROLE_AppAdmin', 'ROLE_Manager']) 258 def rebuildTextSearchIndex = { 259 log.info "Rebuilding lucene text search index." 260 searchableService.reindex() 261 log.info "Rebuilding lucene text search index, complete." 262 263 flash.message = g.message(code:"default.update.success", args:["Index ", '']) 264 redirect(action: manager) 265 } 266 253 267 } // end of class. -
trunk/grails-app/controllers/InventoryItemDetailedController.groovy
r554 r562 134 134 def isFilterApplied = FilterUtils.isFilterApplied(params) 135 135 136 // Restore default sort if a new text search is requested 137 if(params.newTextSearch) { 138 params.sort = 'id' 139 params.order = 'desc' 140 } 141 136 142 // Restore search unless a new search is being requested. 137 if(!params.quickSearch && !filterParams) { 138 if(session.inventoryItemQuickSearch) { 143 if(!params.searchText && !params.quickSearch && !filterParams) { 144 if(session.inventoryItemSearchText) { 145 params.searchText = session.inventoryItemSearchText 146 params.searchName = session.inventoryItemSearchName 147 params.searchDescription = session.inventoryItemSearchDescription 148 params.searchComment = session.inventoryItemSearchComment 149 params.searchLocation = session.inventoryItemSearchLocation 150 params.searchSpareFor = session.inventoryItemSearchSpareFor 151 } 152 else if(session.inventoryItemQuickSearch) { 139 153 params.quickSearch = session.inventoryItemQuickSearch 140 154 if(session.inventoryItemQuickSearchDaysBack) … … 166 180 session.inventoryItemSearchFilterParams = new LinkedHashMap(filterParams) 167 181 session.inventoryItemSearchFilter = new LinkedHashMap(params.filter) 182 // Clear any previous search. 183 session.removeAttribute("inventoryItemSearchText") 184 session.removeAttribute("inventoryItemSearchName") 185 session.removeAttribute("inventoryItemSearchDescription") 186 session.removeAttribute("inventoryItemSearchComment") 187 session.removeAttribute("inventoryItemSearchLocation") 188 session.removeAttribute("inventoryItemSearchSpareFor") 168 189 session.removeAttribute("inventoryItemQuickSearch") 169 190 session.removeAttribute("inventoryItemQuickSearchDaysBack") 170 191 } 192 else if(params.searchText) { 193 // Quick Search Text: 194 def result = inventoryItemSearchService.getTextSearch(params, RCU.getLocale(request)) 195 inventoryItemInstanceList = result.inventoryItemList 196 inventoryItemInstanceTotal = result.inventoryItemList.totalCount 197 params.message = result.message 198 filterParams.searchText = result.searchText 199 // Remember search. 200 session.inventoryItemSearchText = params.searchText 201 session.inventoryItemSearchName = params.searchName 202 session.inventoryItemSearchDescription = params.searchDescription 203 session.inventoryItemSearchComment = params.searchComment 204 session.inventoryItemSearchLocation = params.searchLocation 205 session.inventoryItemSearchSpareFor = params.searchSpareFor 206 // Clear any previous search. 207 session.removeAttribute("inventoryItemQuickSearch") 208 session.removeAttribute("inventoryItemQuickSearchDaysBack") 209 session.removeAttribute("inventoryItemSearchFilterParams") 210 session.removeAttribute("inventoryItemSearchFilter") 211 } 171 212 else { 172 // Quick Search :213 // Quick Search Links: 173 214 if(!params.quickSearch) params.quickSearch = "all" 174 215 def result = inventoryItemSearchService.getQuickSearch(params, RCU.getLocale(request)) … … 178 219 filterParams.quickSearch = result.quickSearch 179 220 // Remember search. 180 session.removeAttribute("inventoryItemSearchFilterParams")181 session.removeAttribute("inventoryItemSearchFilter")182 221 session.inventoryItemQuickSearch = result.quickSearch 183 222 if(result.daysBack) 184 223 session.inventoryItemQuickSearchDaysBack = result.daysBack 224 // Clear any previous search. 225 session.removeAttribute("inventoryItemSearchText") 226 session.removeAttribute("inventoryItemSearchName") 227 session.removeAttribute("inventoryItemSearchDescription") 228 session.removeAttribute("inventoryItemSearchComment") 229 session.removeAttribute("inventoryItemSearchLocation") 230 session.removeAttribute("inventoryItemSearchSpareFor") 231 session.removeAttribute("inventoryItemSearchFilterParams") 232 session.removeAttribute("inventoryItemSearchFilter") 185 233 } 186 234 -
trunk/grails-app/domain/Asset.groovy
r456 r562 30 30 } 31 31 32 static searchable = { 33 root false // only index as a component of InventoryItem. 34 only = ['name', 'description', 'comment'] 35 } 36 32 37 // This additional setter is used to convert the checkBoxList string or string array 33 38 // of ids selected to the corresponding domain objects. -
trunk/grails-app/domain/InventoryItem.groovy
r484 r562 61 61 String toString() {"${this.name}"} 62 62 63 static searchable = { 64 only = ['name', 'description', 'comment', 'inventoryLocation', 'spareFor'] 65 //name boost: 1.5 66 inventoryLocation component: true 67 spareFor component: true 68 } 69 63 70 def afterInsert = { 64 71 addReverseAlternateItems() -
trunk/grails-app/domain/InventoryLocation.groovy
r389 r562 16 16 "${this.name}" 17 17 } 18 19 static searchable = { 20 root false // only index as a component of InventoryItem. 21 only = ['name'] 22 } 23 18 24 } -
trunk/grails-app/i18n/messages.properties
r549 r562 308 308 309 309 # InventoryItemSearch 310 inventoryItem.search.text.found=Results for: {0} 311 inventoryItem.search.text.none.found=No results for: {0} 310 312 inventoryItem.search.text.below.reorder=Below Reorder 311 313 inventoryItem.search.text.below.reorder.description=Inventory items at or below reorder point, with reorder enabled. -
trunk/grails-app/services/InventoryItemSearchService.groovy
r489 r562 1 1 import grails.orm.PagedResultList 2 import org.compass.core.engine.SearchEngineQueryParseException 2 3 3 4 /** … … 138 139 } // getRecentlyUsed 139 140 141 /** 142 * Get a list of inventory items by search text. 143 * @param params The request params. 144 * @param locale The locale to use when generating result.message. 145 */ 146 def getTextSearch(params, locale) { 147 def result = [:] 148 result.searchText = params.searchText.trim() ?: "" 149 150 def getMessage = { Map m -> 151 messageSource.getMessage(m.code, m.args == null ? null : m.args.toArray(), locale) 152 } 153 154 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 155 params.offset = params?.offset?.toInteger() ?: 0 156 params.sort = params?.sort ?: "id" 157 params.order = params?.order ?: "asc" 158 159 // Build searchableParams. 160 // Do not include params.sort, since not all properites are indexed. 161 def searchableParams = [max: params.max, offset: params.offset, 162 reload: true, defaultOperator: 'or'] 163 164 // Perform the searchable query. 165 try { 166 result.inventoryItemList = InventoryItem.search(result.searchText, searchableParams) 167 } catch (e) { 168 log.error e 169 result.inventoryItemList = [:] 170 result.inventoryItemList.results = [] 171 result.inventoryItemList.total = 0 172 } 173 174 // Sort the returned instances. 175 if(params.sort != 'id') { 176 if(params.order == 'asc') { 177 if(params.sort == 'name' || params.sort == 'description') 178 result.inventoryItemList.results.sort { p1, p2 -> p1[params.sort].compareToIgnoreCase(p2[params.sort]) } 179 else if(params.sort == 'inventoryGroup') { 180 result.inventoryItemList.results.sort { p1, p2 -> 181 p1.inventoryGroup.name.compareToIgnoreCase(p2.inventoryGroup.name) 182 } 183 } 184 else if(params.sort == 'unitsInStock') 185 result.inventoryItemList.results.sort {p1, p2 -> p1[params.sort] <=> p2[params.sort] } 186 } // asc. 187 else { 188 if(params.sort == 'name' || params.sort == 'description') 189 result.inventoryItemList.results.sort { p1, p2 -> p2[params.sort].compareToIgnoreCase(p1[params.sort]) } 190 else if(params.sort == 'inventoryGroup') { 191 result.inventoryItemList.results.sort { p1, p2 -> 192 p2.inventoryGroup.name.compareToIgnoreCase(p1.inventoryGroup.name) 193 } 194 } 195 else if(params.sort == 'unitsInStock') 196 result.inventoryItemList.results.sort {p1, p2 -> p2[params.sort] <=> p1[params.sort]} 197 } // desc. 198 } // sort. 199 200 // Create a PagedResultList. 201 result.inventoryItemList = new PagedResultList(result.inventoryItemList.results, result.inventoryItemList.total) 202 203 // Get the result message. 204 if(result.inventoryItemList.totalCount > 0) 205 result.message = getMessage(code:"inventoryItem.search.text.found", args: [result.searchText]) 206 else 207 result.message = getMessage(code:"inventoryItem.search.text.none.found", args: [result.searchText]) 208 209 // Success. 210 return result 211 212 } // getTextSearch() 213 140 214 } // end class -
trunk/grails-app/views/appCore/manager.gsp
r560 r562 75 75 <tr class="prop"> 76 76 <td valign="top" class="name"> 77 <label>Search Index:</label> 78 </td> 79 <td valign="top" class="value"> 80 <g:link action="rebuildTextSearchIndex"> 81 Rebuild 82 </g:link> - Reindex the entire text search index. 83 <br /> 84 </td> 85 </tr> 86 87 <tr class="prop"> 88 <td valign="top" class="name"> 77 89 <label>Entity Relationship Diagram:</label> 78 90 </td> -
trunk/grails-app/views/inventoryItemDetailed/search.gsp
r554 r562 22 22 removeImgDir="images" 23 23 removeImgFile="bullet_delete.png" 24 title=" Search"/>24 title="Advanced Search"/> 25 25 26 26 <div class="paginateButtons"> … … 30 30 Results: ${inventoryItemInstanceList.size()} / ${inventoryItemInstanceTotal} 31 31 <span class="searchButtons"> 32 <filterpane:filterButton text=" Search" appliedText="Change Search" />32 <filterpane:filterButton text="Advanced" appliedText="Advanced" /> 33 33 </span> 34 34 </div> … … 178 178 179 179 <filterpane:filterPane domainBean="InventoryItem" 180 title=" Search"180 title="Advanced Search" 181 181 action="search" 182 182 class="overlayPane" … … 197 197 <div class="overlayPane" id="searchPane" style="display:none;"> 198 198 <h2>Quick Search</h2> 199 199 200 <g:form method="post" id="searchForm" name="searchForm" > 201 <g:hiddenField name="newTextSearch" value="true" /> 202 200 203 <table> 201 204 <tbody> … … 252 255 </tbody> 253 256 </table> 257 258 <table> 259 <tbody> 260 261 <tr class="prop"> 262 <td valign="top" class="name"> 263 <label for="searchText">Search:</label> 264 </td> 265 <td valign="top" class="value"> 266 <input type="text" style="width:450px" maxlength="75" id="searchText" name="searchText" value="${filterParams.searchText}"/> 267 </td> 268 </tr> 269 270 <tr class="prop"> 271 <td valign="top" class="name"> 272 </td> 273 <td valign="top" class="value"> 274 <!-- <g:checkBox name="searchName" value="${true}" ></g:checkBox> --> 275 <label for="searchName">Name,</label> 276 <!-- <g:checkBox name="searchDescription" value="${true}" ></g:checkBox> --> 277 <label for="searchDescription">Description,</label> 278 <!-- <g:checkBox name="searchComment" value="${true}" ></g:checkBox> --> 279 <label for="searchComment">Comment,</label> 280 <!-- <g:checkBox name="searchLocation" value="${true}" ></g:checkBox> --> 281 <label for="searchLocation">Location and</label> 282 <!-- <g:checkBox name="searchSpareFor" value="${true}" ></g:checkBox> --> 283 <label for="searchSpareFor">Spare For.</label> 284 </td> 285 </tr> 286 287 </tbody> 288 </table> 289 254 290 <div class="buttons"> 255 291 <span class="button"> 256 <input type="button" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" /> 292 <g:actionSubmit class="save" value="Update" action="search" /> 293 <g:actionSubmit class="cancel" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" /> 257 294 </span> 258 295 </div> -
trunk/grails-app/views/taskDetailed/_quickSearchPane.gsp
r503 r562 110 110 <div class="buttons"> 111 111 <span class="button"> 112 < input type="button" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" />112 <g:actionSubmit class="cancel" value="${g.message(code:'fp.tag.filterPane.button.cancel.text', default:'Cancel')}" onclick="return hideElement('searchPane');" /> 113 113 </span> 114 114 </div>
Note: See TracChangeset
for help on using the changeset viewer.