Changeset 40


Ignore:
Timestamp:
Oct 29, 2009, 5:46:11 PM (8 years ago)
Author:
keesvb
Message:

changed study and experiment schema, added mysql production database

Location:
trunk
Files:
2 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/DataSource.groovy

    r16 r40  
    1212// environment specific settings
    1313environments {
    14         development {
     14        development {
    1515                dataSource {
    1616                        dbCreate = "create-drop" // one of 'create', 'create-drop','update'
     
    1818                }
    1919        }
    20         test {
     20    test {
    2121                dataSource {
    2222                        dbCreate = "update"
     
    2626        production {
    2727                dataSource {
    28                         dbCreate = "update"
    29                         url = "jdbc:hsqldb:file:prodDb;shutdown=true"
     28                           //   create a database first called gscf, add a user nmc with password nmcdsp and grant him all rights to nmc_dsp_tno
     29                            //  $ mysql --user=root
     30                            //  mysql> create database nmc_dsp_tno;
     31                            //  mysql> use nmc_dsp_tno;
     32                            //  mysql> grant all on nmc_dsp_tno.* to nmc@localhost identified by 'nmcdsp';
     33                            //  mysql> flush privileges;
     34                            //  mysql> exit
     35                            //  $ mysql --user=nmc -p --database=nmc_dsp_tno
     36
     37                            driverClassName = "com.mysql.jdbc.Driver"
     38                            dbCreate =  "update"
     39                            username = "gscf"
     40                            password = "dbnp"
     41                            url = "jdbc:mysql://localhost/gscf"
     42
     43                        //dbCreate = "update"
     44                        //url = "jdbc:hsqldb:file:prodDb;shutdown=true"
    3045                }
    3146        }
  • trunk/grails-app/conf/NimbleBootStrap.groovy

    r37 r40  
    1616 */
    1717 
     18import org.codehaus.groovy.grails.commons.GrailsApplication
     19import grails.util.GrailsUtil
    1820
    1921import intient.nimble.InstanceGenerator
     
    4749    // Execute any custom Nimble related BootStrap for your application below
    4850
    49     // Create example User account
    50     def user = InstanceGenerator.user()
    51     user.username = "user"
    52     user.pass = 'useR123!'
    53     user.passConfirm = 'useR123!'
    54     user.enabled = true
     51    if ( GrailsUtil.getEnvironment().equals(GrailsApplication.ENV_DEVELOPMENT)) {
    5552
    56     def userProfile = InstanceGenerator.profile()
    57     userProfile.fullName = "Test User"
    58     userProfile.owner = user
    59     user.profile = userProfile
     53        // Create example User account
     54        def user = InstanceGenerator.user()
     55        user.username = "user"
     56        user.pass = 'useR123!'
     57        user.passConfirm = 'useR123!'
     58        user.enabled = true
    6059
    61     def savedUser = userService.createUser(user)
    62     if (savedUser.hasErrors()) {
    63       savedUser.errors.each {
    64         log.error(it)
    65       }
    66       throw new RuntimeException("Error creating example user")
     60        def userProfile = InstanceGenerator.profile()
     61        userProfile.fullName = "Test User"
     62        userProfile.owner = user
     63        user.profile = userProfile
     64
     65        def savedUser = userService.createUser(user)
     66        if (savedUser.hasErrors()) {
     67          savedUser.errors.each {
     68            log.error(it)
     69          }
     70          throw new RuntimeException("Error creating example user")
     71        }
     72
     73        // Create example Administrative account
     74        def admins = Role.findByName(AdminsService.ADMIN_ROLE)
     75        def admin = InstanceGenerator.user()
     76        admin.username = "admin"
     77        admin.pass = "admiN123!"
     78        admin.passConfirm = "admiN123!"
     79        admin.enabled = true
     80
     81        def adminProfile = InstanceGenerator.profile()
     82        adminProfile.fullName = "Administrator"
     83        adminProfile.owner = admin
     84        admin.profile = adminProfile
     85
     86        def savedAdmin = userService.createUser(admin)
     87        if (savedAdmin.hasErrors()) {
     88          savedAdmin.errors.each {
     89            log.error(it)
     90          }
     91          throw new RuntimeException("Error creating administrator")
     92        }
     93
     94        adminsService.add(admin)
     95
    6796    }
    6897
    69     // Create example Administrative account
    70     def admins = Role.findByName(AdminsService.ADMIN_ROLE)
    71     def admin = InstanceGenerator.user()
    72     admin.username = "admin"
    73     admin.pass = "admiN123!"
    74     admin.passConfirm = "admiN123!"
    75     admin.enabled = true
    76 
    77     def adminProfile = InstanceGenerator.profile()
    78     adminProfile.fullName = "Administrator"
    79     adminProfile.owner = admin
    80     admin.profile = adminProfile
    81 
    82     def savedAdmin = userService.createUser(admin)
    83     if (savedAdmin.hasErrors()) {
    84       savedAdmin.errors.each {
    85         log.error(it)
    86       }
    87       throw new RuntimeException("Error creating administrator")
    88     }
    89 
    90     adminsService.add(admin)
    9198  }
    9299
  • trunk/grails-app/controllers/StudyController.groovy

    r39 r40  
     1class StudyController extends BaseController {
    12
    2 
    3 class StudyController extends BaseController {
    4    
    5     def index = { redirect(action:list,params:params) }
    6 
    7     // the delete, save and update actions only accept POST requests
    8     static allowedMethods = [delete:'POST', save:'POST', update:'POST']
    9 
    10     def list = {
    11         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    12         [ studyInstanceList: Study.list( params ), studyInstanceTotal: Study.count() ]
    13     }
    14 
    15     def show = {
    16         def studyInstance = Study.get( params.id )
    17 
    18         if(!studyInstance) {
    19             flash.message = "Study not found with id ${params.id}"
    20             redirect(action:list)
    21         }
    22         else { return [ studyInstance : studyInstance ] }
    23     }
    24 
    25     def delete = {
    26         def studyInstance = Study.get( params.id )
    27         if(studyInstance) {
    28             try {
    29                 studyInstance.delete(flush:true)
    30                 flash.message = "Study ${params.id} deleted"
    31                 redirect(action:list)
    32             }
    33             catch(org.springframework.dao.DataIntegrityViolationException e) {
    34                 flash.message = "Study ${params.id} could not be deleted"
    35                 redirect(action:show,id:params.id)
    36             }
    37         }
    38         else {
    39             flash.message = "Study not found with id ${params.id}"
    40             redirect(action:list)
    41         }
    42     }
    43 
    44     def edit = {
    45         def studyInstance = Study.get( params.id )
    46 
    47         if(!studyInstance) {
    48             flash.message = "Study not found with id ${params.id}"
    49             redirect(action:list)
    50         }
    51         else {
    52             return [ studyInstance : studyInstance ]
    53         }
    54     }
    55 
    56     def update = {
    57         def studyInstance = Study.get( params.id )
    58         if(studyInstance) {
    59             if(params.version) {
    60                 def version = params.version.toLong()
    61                 if(studyInstance.version > version) {
    62                    
    63                     studyInstance.errors.rejectValue("version", "study.optimistic.locking.failure", "Another user has updated this Study while you were editing.")
    64                     render(view:'edit',model:[studyInstance:studyInstance])
    65                     return
    66                 }
    67             }
    68             studyInstance.properties = params
    69             if(!studyInstance.hasErrors() && studyInstance.save()) {
    70                 flash.message = "Study ${params.id} updated"
    71                 redirect(action:show,id:studyInstance.id)
    72             }
    73             else {
    74                 render(view:'edit',model:[studyInstance:studyInstance])
    75             }
    76         }
    77         else {
    78             flash.message = "Study not found with id ${params.id}"
    79             redirect(action:list)
    80         }
    81     }
    82 
    83     def create = {
    84         def studyInstance = new Study()
    85         studyInstance.properties = params
    86         return ['studyInstance':studyInstance]
    87     }
    88 
    89     def save = {
    90         def studyInstance = new Study(params)
    91         if(!studyInstance.hasErrors() && studyInstance.save()) {
    92             flash.message = "Study ${studyInstance.id} created"
    93             redirect(action:show,id:studyInstance.id)
    94         }
    95         else {
    96             render(view:'create',model:[studyInstance:studyInstance])
    97         }
    98     }
     3    def scaffold = true
    994}
  • trunk/grails-app/domain/Experiment.groovy

    r31 r40  
    1717    Date        created
    1818    Date        modified
    19     Integer     Study
     19    Study       study
    2020
    2121    static constraints = {
  • trunk/grails-app/domain/Study.groovy

    r35 r40  
    1818    String      researchQuestion
    1919    Date        startDate
    20     Integer     ecCode
     20    String      ecCode
    2121    Date        created
    2222    Date        modified
     23    gscf.User   owner
    2324
    2425    static constraints = {
  • trunk/grails-app/views/index.gsp

    r39 r40  
    44      <meta name="layout" content="main" />
    55      <g:javascript library="jquery"/>
    6       <link rel="stylesheet" href="${createLinkTo(dir:'css/jquery-ui', file: 'jquery-ui-1.7.2.custom.css')}">
     6      <link rel="stylesheet" href="${createLinkTo(dir:'css/jquery-ui', file: 'jquery-ui-1.7.2.custom.css')}"/>
    77      <script src="${createLinkTo(dir: 'js', file: 'jquery-ui-1.7.2.custom.min.js')}" type="text/javascript"></script>
    88      <script type="text/javascript">
    99        $(function() {
    10                 $("#accordion").accordion();
    1110                $("#tabs").tabs();
    1211        });
Note: See TracChangeset for help on using the changeset viewer.