Package beans.directory.direction

Source Code of beans.directory.direction.DirectoryDirectionTypeBean

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package beans.directory.direction;

import beans.directory.direction.entity.DirectionTypeDetails;
import framework.beans.directory.DirectoryBean;
import beans.directory.direction.entity.DirectionType;
import beans.doctor.direction.Direction;
import framework.generic.ClipsServerException;
import framework.generic.EMoveToTrash;
import javax.ejb.Stateful;
import beans.UserRightsSet;
import framework.security.UserRight;

/**
* @security - Ok.
* @author axe
*/
@Stateful(mappedName="clips-beans/DirectoryDirectionTypeBean")
public class DirectoryDirectionTypeBean extends DirectoryBean<DirectionType, DirectionTypeDetails>
        implements DirectoryDirectionTypeBeanRemote {

    public final static int OBLIGATE_SERVICE = 1;
    public final static int OBLIGATE_COMMITTEE = 3;
   
    public DirectoryDirectionTypeBean() {
        super(DirectionType.class, "тип направления");
    }

    @Override
    protected UserRight getRightForCreateDirectoryItem() {
        return UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY;
    }

    @Override
    protected UserRight getRightForWriteToDirectory() {
        return UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY;
    }
   
    @Override
    protected void set(DirectionType directionType, DirectionTypeDetails d) {
        directionType.setTitle(d.title);
        //directionType.setDirty(details.dirty);
        directionType.setChoice(d.choice);
        directionType.setTrash(d.hidden);
    }

    @Override
    protected void onRemove(DirectionType entity) throws ClipsServerException {
        //проверяем, есть ли связанные направления
        Field f[] = { new Field("directionType", entity) };
        if(getEntityCount(Direction.class, f) > 0) {
            throw new EMoveToTrash("Существуют направления данного типа, удаление невозможно");
        }
    }
}
TOP

Related Classes of beans.directory.direction.DirectoryDirectionTypeBean

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.