Thursday, August 3, 2017

Domain Class

package main

import grails.util.Holders

/** * This domain class holds details (individual courses) of a request for combining 2 or more courses. * This domain class is used with "Request" domain class. * * READ DESCRIPTION IN "REQUEST" DOMAIN CLASS. * * !! RUN THE FOLLOWING LINE IN ORACLE DATABASE TO CREATE A SEQUENCE FOR THIS TABLE !! * CREATE SEQUENCE  "NJIT_GNS"."LMIS_REQUESTINFO_SEQUENCE"  MINVALUE 1 NOMAXVALUE INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE ; * * Columns: ( ** indicates "important". * indicates "not important but being used". nothing indicates "not being used") *      "id"             is a primary key and created by default *      "version"        is created by default *   ** "req"            is "Request" object to indicate this course belong to which request *   ** "crn"            is CRN of this course. "crn" and "term" together form a composite unique key *   ** "term"           is "Term" object to indicate this course belong to which term. "crn" and "term" together form a composite unique key *      "schd_code"      is "SCHD_CODE" of this course (e.g. 'LEC','ADV','LLB',etc.) *   ** "active"         is general column to indicate whether this course is active or inactive (inactive indicates this course is no longer a part of a combined course) *    * "lastUpdated"    is general column for datetime this data is last updated *    * "updater"        is general column for UCID of the person who updated this data */class RequestInfo {

    def springSecurityService

    String updater, crn, schd_code, section    Boolean active    Date lastUpdated    Term term    Request req
    static  belongsTo = Request

    def beforeValidate = {
//    defaults        active     = (active == null) ? true : active        updater = updater ?: springSecurityService.principal.usr.ucid
    }

    static mapping = {
      def cls = className.split('main.')[-1].toLowerCase()
      def appName = Holders.grailsApplication.config.app.name

      table     "${appName}_${cls}"        id       column : "${cls}_reqinfoid",       generator  : 'sequence', params: [sequence: "${appName}_${cls}_sequence"]
//    version    false        version       column : "${cls}_version",          defaultValue: '0'        req         column  : "${cls}_reqid"        crn         column  : "${cls}_crn"        section     column  : "${cls}_section"        term        column  : "${cls}_term"        schd_code   column  : "${cls}_schd_code"        active        column : "${cls}_is_active",     defaultValue: '1'        lastUpdated column : "${cls}_activity_date",  defaultValue: 'sysdate'        updater       column : "${cls}_updated_by"    }

    static constraints = {
        crn          unique : 'term'        crn         size    : 0..20        schd_code   size    : 0..3        updater        maxSize    : 10,      matches: '[a-z0-9]+'        section     nullable: true    }
}

No comments:

Post a Comment