Grails Model,Validation and Mapping

By | June 5th 2019 01:09:04 PM | viewed 439 times

Grails Model,Validation and Mapping as follows:

package com.ir

import com.enums.*
import com.auth.AuthUsers
import com.setting.SetnAlkp

class IrAplc {

    Long id
    String fName
    String lName
    String fatherName          // model attributes
    String motherName
    Date dateOfBirth
    SetnAlkp genderAlkp   // object 
    SetnAlkp religionAlkp
    SetnAlkp meritalStsAlkp
    String nationality
    String nid
    String permanentAdrs
    String presentAdrs
    String currentLoc
    String mobileOne
    String mobileTwo
    String mobileThree
    String email
    String altEmail
    Date isWrtnSeltDate
    Date isVivaSeltDate

    Date createDate
    Date updateDate
    Integer isActive = 1
    Integer countCV
	KeywordType keyword    // enum class

    static hasMany = [irJobAppliedList:IrJobAppliedList]    // mapping
	
    static belongsTo = [authUsers:AuthUsers]   // mapping


    static constraints = {

        fName nullable: true            // validation
        lName nullable: true
        fatherName nullable: true
        motherName nullable: true
        dateOfBirth nullable: true
        genderAlkp nullable: true
        religionAlkp nullable: true
        meritalStsAlkp nullable: true
        nationality nullable: true
        nid nullable: true
        permanentAdrs nullable: true
        presentAdrs nullable: true
        currentLoc nullable: true
        mobileOne nullable: true
        mobileTwo nullable: true
        mobileThree nullable: true
        email nullable: true
        altEmail nullable: true
        authUsers nullable: true
        createDate nullable: true
        updateDate nullable: true
        isActive nullable: true
        countCV nullable: true
        isWrtnSeltDate nullable: true
        isVivaSeltDate nullable: true
    }

    static mapping={
        version false
        isWrtnSeltDate sqlType: 'date'
        isVivaSeltDate sqlType: 'date'
    }
	String toString() {
        return "${fName +' '+lName}"
    }
}

IrJobAppliedList model mapping


package com.ir

import com.hrms.HrJobRqsn

class IrJobAppliedList {

    Long id
    HrJobRqsn hrJobRqsn
    IrAplc irAplc
    Integer isSeltWrtn
    Integer isSeltViva
    Date appliedDate

    static constraints = {
        hrJobRqsn nullable: true
        irAplc nullable: true
        isSeltWrtn nullable: true
        isSeltViva nullable: true
        appliedDate nullable: true
    }

    static mapping ={
        version false
    }
}

KeywordType Enum class

package com.enums

public enum KeywordType {
    BLOOD_GRP,
    JOB_FUNC,
    JOB_SKILL,
    LAVEL_OF_EDU,
    EXAM_DEGREE,
    RESULT,
    SPECIALIZE_SKILL,
    LANG_SKILL_LEVEL,
    REF_RElATION,
    DESIGNATION,
    POSITION,
    EMP_TYPE,
    MERITAL_STATUS,
    RELIGION,
    GENDER,
    ACCNT_TYPE,
    CALENDER_TYPE,
    ASSET_NAME,
    EMP_COTA
}

bONEandALL
Visitor

Total : 18979

Today :8

Today Visit Country :

  • Germany
  • Singapore
  • United States
  • Russia