Вопрос

I have a domain three domain class like this :

Tasks.groovy

class Tasks {
    static belongsTo = [ user : User ]
        //other fields
    Date startDate
    Date endDate
}

User.groovy

class User {
    //relationships. . . .
    static belongsTo = [ company : Company, role : Role, resource : Resource]
    static hasMany = [ holidays : Holiday, tasks : Tasks]
    //other fields
    }

Holiday.groovy

class Holiday {
    static belongsTo = User
    Date startDate
    Date endDate
    //other fields
}

Now when I create a Tasks instance, I want to put a constraint such that the Tasks startDate and endDate doesn't fall within the User's Holidays startDate and endDate. And throw and error if it has.

I want a way to put this constraint on my domain class itself(i.e on Tasks).

Is it possible to do so?

Thanks in advance.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top