- Timestamp:
- Mar 5, 2010, 9:20:33 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetDetailedController.groovy
r421 r429 371 371 } 372 372 373 if(result.error.code != "default.create.failure") { 374 flash.errorMessage = g.message(code: result.error.code, args: ["Asset"]) 375 } 373 flash.errorMessage = g.message(code: result.error.code, args: ["Asset"]) 376 374 377 375 render(view:'copy', model:[assetInstance: result.assetInstance, assetToCopy: result.assetToCopy]) -
trunk/grails-app/i18n/messages.properties
r425 r429 8 8 inventory.import.failure=Could not create inventory from supplied file, failed on line {0}, see {1}. 9 9 10 asset.copy.subItem.create.failure=Could not complete operation, as sub item failed to save. 11 asset.copy.subItem.too.many.failure=Could not complete operation, as there appears to be too many sub items. 10 12 asset.copy.method.required=Please select a copy method for sub items. 11 13 asset.copy.method=Copy Method 12 14 asset.copy.method.help=Link creates a new asset and links it to EXISTING sub items. \ 13 While copy creates a new asset and new sub items .15 While copy creates a new asset and new sub items by appending '(id:#)' to create unique sub item names. 14 16 asset.copy.asset.required=Please select an asset to copy. 15 17 -
trunk/grails-app/services/AssetService.groovy
r387 r429 159 159 // Copy subItems from level 2 and bellow. 160 160 def copyAssetSubItem = { assetSubItemToCopy, parentItem -> 161 def assetSubItemInstance = new AssetSubItem(name: assetSubItemToCopy.name, 161 def nextCount = AssetSubItem.count() + 1 162 def baseName = assetSubItemToCopy.name.split('\\(id:')[0] 163 def name = baseName +'(id:'+nextCount+')' 164 def assetSubItemInstance = new AssetSubItem(name: name, 162 165 description: assetSubItemToCopy.description, 163 166 parentItem: parentItem) 164 167 165 168 if(assetSubItemInstance.hasErrors() || !assetSubItemInstance.save()) 166 return fail( field:"subItems", code:"default.create.failure")169 return fail(code:"asset.copy.subItem.create.failure") 167 170 168 171 def i = 0 … … 172 175 i++ 173 176 if(i > 100) 174 fail(code:" default.create.failure")177 fail(code:"asset.copy.subItem.too.many.failure") 175 178 // Stop if an error is flagged. 176 179 if(result.error) … … 181 184 // Copy the 1st level of subItems. 182 185 def copyAssetSubItem1 = { assetSubItemToCopy -> 183 assetSubItemInstance1 = new AssetSubItem(name: assetSubItemToCopy.name, 186 def nextCount = AssetSubItem.count() + 1 187 def baseName = assetSubItemToCopy.name.split('\\(id:')[0] 188 def name = baseName +'(id:'+nextCount+')' 189 assetSubItemInstance1 = new AssetSubItem(name: name, 184 190 description: assetSubItemToCopy.description, 185 191 asset: result.assetInstance) 186 192 187 193 if(assetSubItemInstance1.hasErrors() || !assetSubItemInstance1.save()) 188 return fail( field:"assetSubItems", code:"default.create.failure")194 return fail(code:"asset.copy.subItem.create.failure") 189 195 190 196 result.assetInstance.addToAssetSubItems(assetSubItemInstance1) … … 196 202 i++ 197 203 if(i > 100) 198 fail(code:" default.create.failure")204 fail(code:"asset.copy.subItem.too.many.failure") 199 205 // Stop if an error is flagged. 200 206 if(result.error) … … 217 223 i++ 218 224 if(i > 100) 219 fail(code:" default.create.failure")225 fail(code:"asset.copy.subItem.too.many.failure") 220 226 // Stop if an error is flagged. 221 227 if(result.error)
Note: See TracChangeset
for help on using the changeset viewer.