Project

General

Profile

Download (1.39 KB) Statistics
| Branch: | Tag: | Revision:
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.agent.Person;
12
import eu.etaxonomy.cdm.model.agent.Team;
13
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
14
import eu.etaxonomy.cdm.model.common.CdmBase;
15

    
16
/**
17
 * @author a.kohlbecker
18
 * @date Feb 24, 2014
19
 *
20
 */
21
public class TeamOrPersonBaseVoter extends CdmPermissionVoter {
22

    
23
    /* (non-Javadoc)
24
     * @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#getResponsibilityClass()
25
     */
26
    @Override
27
    public Class<? extends CdmBase> getResponsibilityClass() {
28
        return TeamOrPersonBase.class;
29
    }
30

    
31
    /* (non-Javadoc)
32
     * @see eu.etaxonomy.cdm.persistence.hibernate.permission.voter.CdmPermissionVoter#isOrpahn(eu.etaxonomy.cdm.model.common.CdmBase)
33
     */
34
    @Override
35
    public boolean isOrpahn(CdmBase object) {
36
        if(object instanceof Person){
37
            return ((Person)object).getInstitutionalMemberships().size() > 0;
38
        }
39
        if(object instanceof Team){
40
            return ((Team)object).getTeamMembers().size() >  0;
41
        }
42

    
43
        return true; // should never be reached
44
    }
45

    
46
}
(9-9/9)