Ignore:
Timestamp:
Oct 29, 2009, 8:30:58 PM (14 years ago)
Author:
gav
Message:

Substantial refactor of the Inventory domain.
InventoryItems can now be added to tasks, no quantity adjustments done yet.
Removed StoredItem and with it the ability to store an inventoryItem in multiple places, just too complex right now.
Svn move StoreLocation to InventoryLocation.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/InventoryLocationController.groovy

    r162 r175  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class StoreLocationController extends BaseAppAdminController {
     3class InventoryLocationController extends BaseAppAdminController {
    44   
    55    def index = { redirect(action:list,params:params) }
     
    1010    def list = {
    1111        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    12         [ storeLocationInstanceList: StoreLocation.list( params ), storeLocationInstanceTotal: StoreLocation.count() ]
     12        [ inventoryLocationInstanceList: InventoryLocation.list( params ), inventoryLocationInstanceTotal: InventoryLocation.count() ]
    1313    }
    1414
    1515    def show = {
    16         def storeLocationInstance = StoreLocation.get( params.id )
     16        def inventoryLocationInstance = InventoryLocation.get( params.id )
    1717
    18         if(!storeLocationInstance) {
    19             flash.message = "StoreLocation not found with id ${params.id}"
     18        if(!inventoryLocationInstance) {
     19            flash.message = "InventoryLocation not found with id ${params.id}"
    2020            redirect(action:list)
    2121        }
    22         else { return [ storeLocationInstance : storeLocationInstance ] }
     22        else { return [ inventoryLocationInstance : inventoryLocationInstance ] }
    2323    }
    2424
    2525    def delete = {
    26         def storeLocationInstance = StoreLocation.get( params.id )
    27         if(storeLocationInstance) {
     26        def inventoryLocationInstance = InventoryLocation.get( params.id )
     27        if(inventoryLocationInstance) {
    2828            try {
    29                 storeLocationInstance.delete()
    30                 flash.message = "StoreLocation ${params.id} deleted"
     29                inventoryLocationInstance.delete(flush:true)
     30                flash.message = "InventoryLocation ${params.id} deleted"
    3131                redirect(action:list)
    3232            }
    3333            catch(org.springframework.dao.DataIntegrityViolationException e) {
    34                 flash.message = "StoreLocation ${params.id} could not be deleted"
     34                flash.message = "InventoryLocation ${params.id} could not be deleted"
    3535                redirect(action:show,id:params.id)
    3636            }
    3737        }
    3838        else {
    39             flash.message = "StoreLocation not found with id ${params.id}"
     39            flash.message = "InventoryLocation not found with id ${params.id}"
    4040            redirect(action:list)
    4141        }
     
    4343
    4444    def edit = {
    45         def storeLocationInstance = StoreLocation.get( params.id )
     45        def inventoryLocationInstance = InventoryLocation.get( params.id )
    4646
    47         if(!storeLocationInstance) {
    48             flash.message = "StoreLocation not found with id ${params.id}"
     47        if(!inventoryLocationInstance) {
     48            flash.message = "InventoryLocation not found with id ${params.id}"
    4949            redirect(action:list)
    5050        }
    5151        else {
    52             return [ storeLocationInstance : storeLocationInstance ]
     52            return [ inventoryLocationInstance : inventoryLocationInstance ]
    5353        }
    5454    }
    5555
    5656    def update = {
    57         def storeLocationInstance = StoreLocation.get( params.id )
    58         if(storeLocationInstance) {
     57        def inventoryLocationInstance = InventoryLocation.get( params.id )
     58        if(inventoryLocationInstance) {
    5959            if(params.version) {
    6060                def version = params.version.toLong()
    61                 if(storeLocationInstance.version > version) {
     61                if(inventoryLocationInstance.version > version) {
    6262                   
    63                     storeLocationInstance.errors.rejectValue("version", "storeLocation.optimistic.locking.failure", "Another user has updated this StoreLocation while you were editing.")
    64                     render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     63                    inventoryLocationInstance.errors.rejectValue("version", "inventoryLocation.optimistic.locking.failure", "Another user has updated this InventoryLocation while you were editing.")
     64                    render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    6565                    return
    6666                }
    6767            }
    68             storeLocationInstance.properties = params
    69             if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    70                 flash.message = "StoreLocation ${params.id} updated"
    71                 redirect(action:show,id:storeLocationInstance.id)
     68            inventoryLocationInstance.properties = params
     69            if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     70                flash.message = "InventoryLocation ${params.id} updated"
     71                redirect(action:show,id:inventoryLocationInstance.id)
    7272            }
    7373            else {
    74                 render(view:'edit',model:[storeLocationInstance:storeLocationInstance])
     74                render(view:'edit',model:[inventoryLocationInstance:inventoryLocationInstance])
    7575            }
    7676        }
    7777        else {
    78             flash.message = "StoreLocation not found with id ${params.id}"
    79             redirect(action:edit,id:params.id)
     78            flash.message = "InventoryLocation not found with id ${params.id}"
     79            redirect(action:list)
    8080        }
    8181    }
    8282
    8383    def create = {
    84         def storeLocationInstance = new StoreLocation()
    85         storeLocationInstance.properties = params
    86         return ['storeLocationInstance':storeLocationInstance]
     84        def inventoryLocationInstance = new InventoryLocation()
     85        inventoryLocationInstance.properties = params
     86        return ['inventoryLocationInstance':inventoryLocationInstance]
    8787    }
    8888
    8989    def save = {
    90         def storeLocationInstance = new StoreLocation(params)
    91         if(!storeLocationInstance.hasErrors() && storeLocationInstance.save()) {
    92             flash.message = "StoreLocation ${storeLocationInstance.id} created"
    93             redirect(action:show,id:storeLocationInstance.id)
     90        def inventoryLocationInstance = new InventoryLocation(params)
     91        if(!inventoryLocationInstance.hasErrors() && inventoryLocationInstance.save()) {
     92            flash.message = "InventoryLocation ${inventoryLocationInstance.id} created"
     93            redirect(action:show,id:inventoryLocationInstance.id)
    9494        }
    9595        else {
    96             render(view:'create',model:[storeLocationInstance:storeLocationInstance])
     96            render(view:'create',model:[inventoryLocationInstance:inventoryLocationInstance])
    9797        }
    9898    }
Note: See TracChangeset for help on using the changeset viewer.