Package clips.delegate.shedule.prorumble

Source Code of clips.delegate.shedule.prorumble.SheduleProrumbleData

/*
* SheduleHolidayDayLocal.java
*
*/

package clips.delegate.shedule.prorumble;

import TimeTable.Day;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.delegate.cache.Cache;
import cli_fmw.main.ClipsException;
import cli_fmw.delegate.lists.DataChunk;
import cli_fmw.delegate.lists.Mappable;
import beans.shedule.prorumble.ProrumbleDetails;
import clips.delegate.directory.ro.DirectoryCollaborator;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import clips.delegate.directory.simple.prorumble.DirectoryProrumble;
import clips.delegate.directory.simple.prorumble.DirectoryProrumbleItem;

/**
* @author Axe Ilshat
*/
public class SheduleProrumbleData extends DataChunk<ProrumbleDetails> implements Mappable<Integer> {
   
    private Cache<Day> day = new Cache<Day>();
   
    public SheduleProrumbleData(DirectoryCollaboratorItem collaborator) throws ClipsException {
        this(new ProrumbleDetails());
        getDetails().collID = collaborator.getID();
        setDay(new Day());
    }
   
    public SheduleProrumbleData(ProrumbleDetails details) throws ClipsException {
        super(details);
        day.set(new Day(details.year, details.month-1, details.day));
    }
   
    @Override
    public Integer getKey() {
        return getDetails().day;
    }
   
    @Override
    public String toString() {
        try {
            return getDay().toString() + " " + getType().toString();
        } catch (ClipsException ex) {
            return getDay().toString() + " ERROR OCCURED";
        }
    }
   
   
    public DirectoryProrumbleItem getType() throws ClipsException {
        DirectoryProrumble types = DirectoryLocator.getDirectory(DirectoryProrumble.class);
        return types.getItemFromID(getDetails().type);
    }
   
    public void setType(DirectoryProrumbleItem item) {
        if(getDetails().type != item.getID()) {
            getDetails().type = item.getID();
            fireContentStateEvent();
        }
    }
   
    public DirectoryCollaboratorItem getCollaborator() throws ClipsException {
        DirectoryCollaborator dir = DirectoryLocator.getDirectory(DirectoryCollaborator.class, false);
        return dir.getItemFromID(getDetails().collID);
    }   
   
    /**
     * Возвращает день месяца
     * @return день месяца (1-31)
     */
    public Day getDay()  {
        return day.get().clone();
    }

    /**
     * Назаначает день месяца
     * @param day день месяца (1-31)
     */
    public void setDay(Day day){
        this.day.set(day.clone());
        boolean changed = false;
        if(getDetails().day != day.getDay())
        {
            getDetails().day = day.getDay();
            changed = true;
        }
        if(getDetails().month != day.getMonth()+1)
        {
            getDetails().month = day.getMonth()+1;
            changed = true;
        }
        if(getDetails().year != day.getYear())
        {
            getDetails().year = day.getYear();
            changed = true;
        }
        if(changed) {
            fireContentStateEvent();
        }
    }
}
TOP

Related Classes of clips.delegate.shedule.prorumble.SheduleProrumbleData

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.