Package beans.directory.mes

Source Code of beans.directory.mes.DirectoryMESClassBean

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

package beans.directory.mes;

import beans.UserRightsSet;
import beans.directory.cabinet.entity.CabinetDetails;
import beans.directory.mes.entity.MesClass;
import beans.directory.mes.entity.MesClassDetail;
import beans.service.mes.entity.MedicEconomicStandart;
import framework.beans.FindEntity.Field;
import framework.beans.directory.DirectoryBean;
import framework.beans.directory.DirectoryItemDetails;
import framework.generic.ClipsServerException;
import framework.generic.EDataIntegrity;
import framework.generic.EMoveToTrash;
import framework.security.UserRight;
import javax.ejb.Stateful;

/**
*
* @author finder
*/
@Stateful(mappedName="clips-beans/DirectoryMESClassBean")
public class DirectoryMESClassBean extends DirectoryBean<MesClass, MesClassDetail> implements DirectoryMESClassBeanRemote {
    public DirectoryMESClassBean() {
        super(MesClass.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(MesClass entity, MesClassDetail details) {
        entity.setTitle(details.title);
     /*   entity.setDirty(details.dirty);
        entity.setDesc(d.description);*/
        entity.setTrash(details.hidden);
    }

    /**
     * Проверка данных при удалении типа мэса
   *
     * @param entity
     * @throws ClipsServerException если элемент используется медико-экономическими стандартами
     */
    @Override
    protected void onRemove(MesClass entity) throws ClipsServerException {
        Field f[] = { new Field("cabinet", entity) };
        if(getEntityCount(MedicEconomicStandart.class, f) > 0) {
            throw new EMoveToTrash("В базе есть мэдико-экономически стандаты, удаление невозможно");
        }
    }

    /**
     * Проверка данных при создании нового типа справки
     * Данные не должны быть пустыми
     * @param details детали новой сущности
     * @throws ClipsServerException
     */
    @Override
    protected void onAppend(MesClassDetail details) throws ClipsServerException {
        check(details);
    }

    /**
     * Проверка данных при редактировании справки
     * Данные не должны быть пустыми
     * @param entity сущность типа
     * @param details новые детали сущности
     * @throws ClipsServerException
     */
    @Override
    protected void onUpdate(MesClass entity, MesClassDetail details) throws ClipsServerException {
        check(details);
    }


    /**
     * проверка полей на валидность
     * @param details
     * @throws generic.ClipsServerException
     */
    private void check(DirectoryItemDetails details) throws ClipsServerException {
        CabinetDetails d = (CabinetDetails) details;
        if(d.description != null
                && d.description.length() > 250) {
                throw new EDataIntegrity("Задано слишком длинное описание");
        }
    }
}
TOP

Related Classes of beans.directory.mes.DirectoryMESClassBean

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.