1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.persistence.hibernate.permission.voter;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
12
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
13
|
|
14
|
/**
|
15
|
* @author a.kohlbecker
|
16
|
* @date Feb 24, 2014
|
17
|
*
|
18
|
*/
|
19
|
public class TypeDesignationVoter extends CdmPermissionVoter {
|
20
|
|
21
|
/* (non-Javadoc)
|
22
|
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#getResponsibilityClass()
|
23
|
*/
|
24
|
@Override
|
25
|
public Class<? extends CdmBase> getResponsibilityClass() {
|
26
|
return TypeDesignationBase.class;
|
27
|
}
|
28
|
|
29
|
/* (non-Javadoc)
|
30
|
* @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#isOrpahn(eu.etaxonomy.cdm.model.common.CdmBase)
|
31
|
*/
|
32
|
@Override
|
33
|
public boolean isOrpahn(CdmBase object) {
|
34
|
if(object instanceof TypeDesignationBase){
|
35
|
TypeDesignationBase<?> typeDesignation = (TypeDesignationBase<?>)object;
|
36
|
return typeDesignation.getTypifiedNames().isEmpty() && typeDesignation.getRegistrations().isEmpty();
|
37
|
} else {
|
38
|
throw new RuntimeException("Invalid object type: " + object.getClass().getName());
|
39
|
}
|
40
|
}
|
41
|
|
42
|
}
|