Package clips.delegate.shedule.reception

Source Code of clips.delegate.shedule.reception.SheduleReceptionLocal

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

package clips.delegate.shedule.reception;

import TimeTable.Day;
import beans.shedule.reception.SheduleReceptionBean;
import beans.shedule.reception.SheduleReceptionBeanRemote;
import cli_fmw.delegate.DelegateStandart;
import cli_fmw.delegate.cache.ExtraDataManager;
import beans.shedule.reception.SheduleReceptionDetails;
import cli_fmw.main.ClipsException;
import cli_fmw.delegate.lists.DataChunkList;
import cli_fmw.utils.SelectorEditable;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import java.util.Calendar;
import java.util.Date;
import java.util.List;


/**
*
* @author axe
*/
public class SheduleReceptionLocal  extends DelegateStandart<SheduleReceptionBeanRemote> {

    private ReceptionList itemList;
    private ExtraDataManager ecm;
   
    /**
     * Creates new object.
     * @param day
     * @param collaborator
     * @throws ClipsException
     */
    public SheduleReceptionLocal(Day day, DirectoryCollaboratorItem collaborator)
            throws ClipsException {
        super(SheduleReceptionBean.class.getSimpleName());
        initBean();
        ecm = new ExtraDataManager(getBean(), this, false);
       
        Calendar cal = day.getCalendar();
        Date begin = cal.getTime();
        cal.add(Calendar.DAY_OF_MONTH, 1);
        Date end = cal.getTime();
       
        itemList = new ReceptionList(ecm, begin, end, collaborator);
        itemList.selector();
    }

    /**
     * Сохраняет изменения, произошедшие в делегате
     * @throws ClipsException
     */
    @Override
    public void save1() throws ClipsException {
        itemList.save();
    }

    /**
     * Сбрасывает изменения, произошедшие в делегатие
     */
    @Override
    public void restore() {
        itemList.restore();
        fireContentStateEvent();
    }

    /**
     * Проверяет, нуждается ли делегат в сохранении состояния
     * @return boolean
     */
    @Override
    public boolean isDirty() {
        return itemList.isDirty();
    }

    /**
     * Возвращает селектор для перебора работ заданного дня
     * @return
     * @throws ClipsException
     */
    public SelectorEditable<SheduleReceptionData> selector() throws ClipsException {
        return itemList.selector();
    }
   
   
    class ReceptionList extends DataChunkList<SheduleReceptionData> {
        private Date from;
        private Date till;
        private DirectoryCollaboratorItem collaborator;
       
        public ReceptionList(ExtraDataManager contaner, Date from, Date till, DirectoryCollaboratorItem collaborator ) {
            super(contaner);
            this.from = from;
            this.till = till;
            this.collaborator = collaborator;
        }
       
        @Override
        protected void deleteDB(SheduleReceptionData data) throws Exception {
            bean().removeReception(data.getDetails().getId());
        }

        @Override
        protected int saveDB(SheduleReceptionData data) throws Exception {
            return bean().setReception(data.getDetails());
        }

        @Override
        protected void loadDB() throws Exception {
            List<SheduleReceptionDetails> list =
                bean().getReceptionList(collaborator.getID(), from, till);
            for(SheduleReceptionDetails d: list) {
                initByDetails(new SheduleReceptionData(null, d));
            }
        }
    }

}
TOP

Related Classes of clips.delegate.shedule.reception.SheduleReceptionLocal

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.