Package beans.directory.dlodrugsection

Source Code of beans.directory.dlodrugsection.DirectoryDloDrugSectionBean

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

package beans.directory.dlodrugsection;

import beans.UserRightsSet;
import framework.beans.directory.DirectoryBean;
import framework.generic.ClipsServerException;
import framework.generic.EDataIntegrity;
import framework.security.UserRight;
import java.util.List;
import javax.ejb.Stateful;

/**
*
* @author lacoste
*/
@Stateful(mappedName="clips-beans/DirectoryDloDrugSectionBean")
public class DirectoryDloDrugSectionBean extends DirectoryBean<DloDrugSection, DloDrugSectionDetails>
        implements DirectoryDloDrugSectionBeanRemote {

    public DirectoryDloDrugSectionBean() {
        super(DloDrugSection.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(DloDrugSection drugSection, DloDrugSectionDetails item) throws ClipsServerException {
        drugSection.setTitle(item.title);
        drugSection.setCode(item.code);
        drugSection.setNumber(item.number);
        drugSection.setSubNumber(item.subNumber);
        drugSection.setSubTitle(item.subTitle);
    }

    @Override
    protected void onRemove(DloDrugSection entity) throws ClipsServerException {
        //чтоб не удалялся. а кидался в трэш
        throw new EDataIntegrity();
    }

    @Override
    public DloDrugSectionDetails getItemByCode(int code) throws ClipsServerException {
        Field[] f = new Field[]{new Field("code", this)};
        List<DloDrugSection> sections = findEntityList(DloDrugSection.class, f);
        if (sections.size() > 1) {
            throw new ClipsServerException("Найдено несколько разделов перечня по коду");
        }
        else if (sections.isEmpty()) {
            throw new ClipsServerException("Не найден раздел перечня по коду");
        }
        return sections.get(0).getDetails(this);
    }
}
TOP

Related Classes of beans.directory.dlodrugsection.DirectoryDloDrugSectionBean

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.