Changeset 830
- Timestamp:
- Aug 23, 2010, 3:40:32 PM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r816 r830 6 6 import org.codehaus.groovy.grails.commons.GrailsApplication 7 7 import grails.util.GrailsUtil 8 9 // Imports for Nimble 10 import grails.plugins.nimble.InstanceGenerator 11 import grails.plugins.nimble.core.LevelPermission 12 import grails.plugins.nimble.core.Role 13 import grails.plugins.nimble.core.Group 14 import grails.plugins.nimble.core.AdminsService 15 import grails.plugins.nimble.core.UserService 8 16 9 17 /** … … 18 26 */ 19 27 class BootStrap { 28 29 // Injections for Nimble 30 def grailsApplication 31 def nimbleService 32 def userService 33 def adminsService 34 20 35 def init = {servletContext -> 21 36 // define timezone 22 37 System.setProperty('user.timezone', 'CET') 38 39 // If there are no users yet in the database 40 println "Executing Nimble bootstrap..." 41 42 // The following must be executed 43 nimbleService.init() 44 45 // Add users 46 def user 47 48 if (dbnp.user.User.count() == 0) { 49 50 println "Adding example user..." 51 52 // Create example User account 53 user = InstanceGenerator.user() 54 user.username = "user" 55 user.pass = 'useR123!' 56 user.passConfirm = 'useR123!' 57 user.enabled = true 58 59 def userProfile = InstanceGenerator.profile() 60 userProfile.fullName = "Test User" 61 userProfile.owner = user 62 user.profile = userProfile 63 64 def savedUser = userService.createUser(user) 65 if (savedUser.hasErrors()) { 66 savedUser.errors.each { 67 log.error(it) 68 } 69 throw new RuntimeException("Error creating example user") 70 } 71 72 println "Adding example admin user..." 73 74 // Create example Administrative account 75 def admins = Role.findByName(AdminsService.ADMIN_ROLE) 76 def admin = InstanceGenerator.user() 77 admin.username = "admin" 78 admin.pass = "admiN123!" 79 admin.passConfirm = "admiN123!" 80 admin.enabled = true 81 82 def adminProfile = InstanceGenerator.profile() 83 adminProfile.fullName = "Administrator" 84 adminProfile.owner = admin 85 admin.profile = adminProfile 86 87 def savedAdmin = userService.createUser(admin) 88 if (savedAdmin.hasErrors()) { 89 savedAdmin.errors.each { 90 log.error(it) 91 } 92 throw new RuntimeException("Error creating administrator") 93 } 94 95 adminsService.add(admin) 96 } 97 else { 98 user = dbnp.user.User.findByUsername("user") 99 } 100 101 println "Done with Nimble bootstrap" 23 102 24 103 // If there are no templates yet in the database … … 60 139 } else { 61 140 // general study boostrapping 62 BootStrapStudies.addExampleStudies( )141 BootStrapStudies.addExampleStudies(user) 63 142 } 64 143 } -
trunk/grails-app/conf/BootStrapStudies.groovy
r821 r830 19 19 */ 20 20 21 public static void addExampleStudies( ) {21 public static void addExampleStudies(dbnp.user.User owner) { 22 22 23 23 // Look up the used ontologies which should be in the database by now … … 168 168 ecCode:"2007117.c", 169 169 startDate: Date.parse('yyyy-MM-dd','2008-01-02'), 170 owner: owner 170 171 ).with { if (!validate()) { errors.each { println it} } else save()} 171 172 … … 374 375 ecCode:"unknown", 375 376 startDate: Date.parse('yyyy-MM-dd','2008-01-14'), 377 owner: owner 376 378 ) 377 379 .setFieldValue( 'Description', "Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U." ) -
trunk/grails-app/conf/NimbleBootStrap.groovy
r829 r830 17 17 18 18 19 import grails.plugins.nimble.InstanceGenerator20 21 import grails.plugins.nimble.core.LevelPermission22 import grails.plugins.nimble.core.Role23 import grails.plugins.nimble.core.Group24 import grails.plugins.nimble.core.AdminsService25 import grails.plugins.nimble.core.UserService26 27 19 /* 28 20 * Allows applications using Nimble to undertake process at BootStrap that are related to Nimbe provided objects … … 34 26 class NimbleBootStrap { 35 27 36 def grailsApplication37 38 def nimbleService39 def userService40 def adminsService41 28 42 def init = {servletContext -> 43 44 println "Executing Nimble bootstrap..." 45 46 // The following must be executed 47 internalBootStap(servletContext) 48 49 // Execute any custom Nimble related BootStrap for your application below 50 51 println "Adding example user..." 52 53 if (0 && dbnp.user.User.count() == 0) { 54 55 // Create example User account 56 def user = InstanceGenerator.user() 57 user.username = "user" 58 user.pass = 'useR123!' 59 user.passConfirm = 'useR123!' 60 user.enabled = true 61 62 def userProfile = InstanceGenerator.profile() 63 userProfile.fullName = "Test User" 64 userProfile.owner = user 65 user.profile = userProfile 66 67 def savedUser = userService.createUser(user) 68 if (savedUser.hasErrors()) { 69 savedUser.errors.each { 70 log.error(it) 71 } 72 throw new RuntimeException("Error creating example user") 73 } 74 75 println "Adding example admin user..." 76 77 // Create example Administrative account 78 def admins = Role.findByName(AdminsService.ADMIN_ROLE) 79 def admin = InstanceGenerator.user() 80 admin.username = "admin" 81 admin.pass = "admiN123!" 82 admin.passConfirm = "admiN123!" 83 admin.enabled = true 84 85 def adminProfile = InstanceGenerator.profile() 86 adminProfile.fullName = "Administrator" 87 adminProfile.owner = admin 88 admin.profile = adminProfile 89 90 def savedAdmin = userService.createUser(admin) 91 if (savedAdmin.hasErrors()) { 92 savedAdmin.errors.each { 93 log.error(it) 94 } 95 throw new RuntimeException("Error creating administrator") 96 } 97 98 adminsService.add(admin) 99 } 100 101 println "Done with Nimble bootstrap" 102 29 def init = { servletContext -> 30 // Skipping the normal Nimble (plugin) bootstrap initialization because we already called it earlier 103 31 } 104 32 105 33 def destroy = { 106 107 34 } 108 35 109 private internalBootStap(def servletContext) {110 nimbleService.init()111 }112 36 } -
trunk/grails-app/domain/dbnp/user/Profile.groovy
r814 r830 2 2 package dbnp.user 3 3 4 class Profile extends grails.plugins.nimble.core.ProfileBase {4 class Profile extends grails.plugins.nimble.core.ProfileBase implements Serializable { 5 5 6 6 // Extend ProfileBase with your custom values here -
trunk/grails-app/domain/dbnp/user/User.groovy
r814 r830 2 2 package dbnp.user 3 3 4 class User extends grails.plugins.nimble.core.UserBase {4 class User extends grails.plugins.nimble.core.UserBase implements Serializable { 5 5 6 6 // Extend UserBase with your custom values here 7 7 8 def String toString() { 9 return username; 10 } 11 8 12 } -
trunk/grails-app/views/study/show.gsp
r824 r830 273 273 </g:each> 274 274 </tr> 275 <tr> 276 <td>Owner</td> 277 <g:each in="${studyList}" var="studyInstance"> 278 <td> 279 <g:if test="${studyInstance.owner}"> 280 <g:link controller="user" action="show" id="${studyInstance.owner.id}">${studyInstance.owner?.encodeAsHTML()}</g:link> 281 </g:if> 282 <g:else> 283 - 284 </g:else> 285 </td> 286 </g:each> 287 </tr> 275 288 <tr> 276 289 <td>Readers</td>
Note: See TracChangeset
for help on using the changeset viewer.