Project

General

Profile

Download (1.08 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.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
 * @since Feb 24, 2014
19
 */
20
public class TeamOrPersonBaseVoter extends CdmPermissionVoter {
21

    
22
    @Override
23
    public Class<? extends CdmBase> getResponsibilityClass() {
24
        return TeamOrPersonBase.class;
25
    }
26

    
27
    @Override
28
    public boolean isOrpahn(CdmBase object) {
29
        if(object instanceof Person){
30
            return ((Person)object).getInstitutionalMemberships().size() > 0;
31
        }
32
        if(object instanceof Team){
33
            return ((Team)object).getTeamMembers().size() >  0;
34
        }
35

    
36
        return true; // should never be reached
37
    }
38

    
39
}
(12-12/12)