Package clips.delegate.kek

Source Code of clips.delegate.kek.CommitteeLocal$InabilityList

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

package clips.delegate.kek;

import beans.cec.CommitteeBean;
import beans.cec.CommitteeBeanRemote;
import beans.cec.entity.CommitteeDetails;
import beans.cec.entity.CommitteeDirectionDetails;
import beans.cec.entity.CommitteeMemberDetails;
import beans.cec.entity.CommitteeResolutionDetails;
import beans.cec.entity.InabilityDetails;
import cli_fmw.delegate.AuditListener;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.cache.ExtraDataManager;
import cli_fmw.main.ClipsException;
import cli_fmw.delegate.lists.DataChunkList;
import cli_fmw.delegate.lists.DataChunkMapList;
import cli_fmw.delegate.utils.TimeLocal;
import cli_fmw.utils.SelectorEditable;
import framework.beans.ModificationInfo;
import java.util.Date;


/**
*Делегат, предоставляющий доступ к одной строке таблицы Committee,
* есть возможность подгрузить список членов комиссии, и список направлений, рассмотренных
* этой комиссией.
* @author lacoste
*/
public class CommitteeLocal
    extends DelegateLine2<CommitteeBeanRemote, CommitteeDetails> {

    CommitteeMember memberList = new CommitteeMember(getEDM());
    DirectionList directionList = new DirectionList(getEDM());
    ResolutionList resolutionList = new ResolutionList(getEDM());
    InabilityList inabilityList = new InabilityList(getEDM());
       
    public CommitteeLocal(AuditListener al) throws ClipsException {
        super(al);
        getDetails().date = TimeLocal.getCurrentTime().getTime();
    }
   
    public CommitteeLocal(int id, AuditListener al) {
        super(id, al);
    }

    public CommitteeLocal(CommitteeDetails details, AuditListener al) {
        super(details, al);
    }

    @Override
    protected CommitteeDetails getNewDetails() {
        return new CommitteeDetails();
    }

   
    public Date getDate() throws ClipsException {
        return getDetails().date;
    }

    public void setDate(Date date) throws ClipsException {
        getDetails().date = date;
        fireContentStateEvent();
   

  
    @Override
    protected String getBeanName() {
        return CommitteeBean.class.getSimpleName();
    }
   
    /*******************************************************************************
     *
     *   Memebers
     *
     * /******************************************************************************
     * @return
     * @throws ClipsException
     */
    public SelectorEditable<CommitteeMemberData> getMemberList() throws ClipsException {
        return memberList.selector();
    }
   
    class CommitteeMember extends DataChunkList<CommitteeMemberData> {

        public CommitteeMember(ExtraDataManager contaner) {
            super(contaner);
        }
       
        @Override
        protected void deleteDB(CommitteeMemberData data) throws Exception {
            ModificationInfo mi = getBean().removeCommitteeMember(data.getDetails().getId());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
        }

        @Override
        protected int saveDB(CommitteeMemberData data) throws Exception {
            ModificationInfo mi = getBean().setCommitteeMember(data.getDetails());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
            return mi.getId();
        }

        @Override
        protected void loadDB() throws Exception {
            if (!isNewlyCreated()) {
                for(CommitteeMemberDetails d : getBean().getCommitteeMemberList()) {
                    initByDetails(new CommitteeMemberData(CommitteeLocal.this, d));
                }
            }
        }
    }   
   
    /*******************************************************************************
     *
     *   Directions
     *
     * /******************************************************************************
     * @return
     * @throws ClipsException
     */
    public SelectorEditable<CommitteeDirectionData> getDirectionList() throws ClipsException {
        return directionList.selector();       
    }
   
    class DirectionList extends DataChunkList<CommitteeDirectionData> {

        public DirectionList(ExtraDataManager contaner) {
            super(contaner);
        }
       
        @Override
        protected void deleteDB(CommitteeDirectionData data) throws Exception {
            ModificationInfo mi = getBean().removeCommitteeDirection(data.getDetails().getId());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
        }

        @Override
        protected int saveDB(CommitteeDirectionData data) throws Exception {
            ModificationInfo mi = getBean().setCommitteeDirection(data.getDetails());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
            return mi.getId();
        }

        @Override
        protected void loadDB() throws Exception {
            if (!isNewlyCreated()) {
                for(CommitteeDirectionDetails d : getBean().getCommitteeDirectionList()) {
                    initByDetails(new CommitteeDirectionData(CommitteeLocal.this, d));
                }
            }
        }
    }
   
    /*******************************************************************************
     *
     *   RESOLUTIONS
     *
     * /******************************************************************************
     * @return
     * @throws ClipsException
     */
    public SelectorEditable<CommitteeResolutionData> getResolutionList(boolean force) throws ClipsException {
        if (force) {
            return resolutionList.selectorForced();
        }
        return resolutionList.selector();
    }
   
    /**
     *
     * @param direction
     * @return Решение КЭК по данному направлению, если решения нет, тогда NULL
     * @throws ClipsException
     */
    public CommitteeResolutionData getResolutionByDirection(CommitteeDirectionData direction) throws ClipsException {
        return resolutionList.get(direction.getId());
    }
   
    class ResolutionList extends DataChunkMapList<CommitteeResolutionData, Integer> {

        public ResolutionList(ExtraDataManager contaner) {
            super(contaner);
        }
       
        @Override
        protected void deleteDB(CommitteeResolutionData data) throws Exception {
            ModificationInfo mi = getBean().removeCommitteeResolution(data.getDetails().getId());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
        }

        @Override
        protected int saveDB(CommitteeResolutionData data) throws Exception {
            ModificationInfo mi = getBean().setCommitteeResolution(data.getDetails());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
            return mi.getId();
        }

        @Override
        protected void loadDB() throws Exception {
            if (!isNewlyCreated()) {
                for(CommitteeResolutionDetails d : getBean().getCommitteeResolutionList()) {
                    CommitteeDirectionData direction = directionList.getByID(d.directionID);
                    initByDetails(new CommitteeResolutionData(direction, d));
                }
            }
        }
       
    }
   
    /*******************************************************************************
     *
     * INABILITY    
     *
     * /******************************************************************************
     * @return
     * @throws ClipsException
     */
    public SelectorEditable<InabilityData> getInabilityList(boolean force) throws ClipsException {
        if (force) {
            return inabilityList.selectorForced();
        }
        return inabilityList.selector();
    }
   
    /**
     *
     * @param resolution
     * @return Направление на МСЭК по конкретному решению комиссии, если нет такого, то NULL
     * @throws ClipsException
     */
    public InabilityData getInabilityByResolution(CommitteeResolutionData resolution) throws ClipsException {
        return inabilityList.get(resolution.getId());
    }
   
    class InabilityList extends DataChunkMapList<InabilityData, Integer> {

        public InabilityList(ExtraDataManager contaner) {
            super(contaner);
        }
       
        @Override
        protected void deleteDB(InabilityData data) throws Exception {
            ModificationInfo mi = getBean().removeCommitteeInability(data.getDetails().getId());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
        }

        @Override
        protected int saveDB(InabilityData data) throws Exception {
            ModificationInfo mi = getBean().setCommitteeInability(data.getDetails());
            auditDetailsList.addAll(mi.getAudit());
            fireAuditEvent();
            return mi.getId();
        }

        @Override
        protected void loadDB() throws Exception {
            if (!isNewlyCreated()) {
                for(InabilityDetails d : getBean().getCommitteeInabilityList()) {
                    CommitteeResolutionData direction = resolutionList.getByID(d.committeeResolutionID);
                    initByDetails(new InabilityData(direction, d));
                }
            }
        }
    }

}
TOP

Related Classes of clips.delegate.kek.CommitteeLocal$InabilityList

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.