Package beans.directory.doctoraction

Source Code of beans.directory.doctoraction.DirectoryDoctorActionBean

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

package beans.directory.doctoraction;

import framework.beans.directory.DirectoryBean;
import beans.directory.doctoraction.entity.DoctorAction;
import beans.directory.doctoraction.entity.DoctorActionDetails;
import beans.directory.service.entity.ServiceAction;
import framework.generic.ClipsServerException;
import framework.generic.EMoveToTrash;
import javax.ejb.Stateful;
import beans.UserRightsSet;
import framework.security.UserRight;

/**
*
* @author lacoste
*/

@Stateful(mappedName="clips-beans/DirectoryDoctorActionBean")
public class DirectoryDoctorActionBean extends DirectoryBean<DoctorAction, DoctorActionDetails>
        implements DirectoryDoctorActionBeanRemote {

    public DirectoryDoctorActionBean() {
        super(DoctorAction.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(DoctorAction doctorAction, DoctorActionDetails item) throws ClipsServerException {
        DoctorAction doctorActionParent = item.parentItem == 0 ?
            null : findEntity(DoctorAction.class, item.parentItem);
        doctorAction.setTitle(item.title);
        //doctorAction.setDirty(details.dirty);
        doctorAction.setCode(item.code);
        //doctorAction.setTrash(item.hidden);
        if(doctorActionParent != null) {
            doctorAction.setParent(doctorActionParent);
        }
    }

    @Override
    protected void onRemove(DoctorAction entity) throws ClipsServerException {
        Field f1[] = { new Field("parent", entity) };
        if(getEntityCount(DoctorAction.class, f1) > 0) {
            throw new EMoveToTrash("Действие врача содержит вложенные действия");
        }
         Field f2[] = { new Field("action", entity) };
        if(getEntityCount(ServiceAction.class, f2, "") > 0) {
            throw new EMoveToTrash("Действие врача связан с услугой");
        }
    }
}
TOP

Related Classes of beans.directory.doctoraction.DirectoryDoctorActionBean

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.