Package clips.delegate.shedule.reception

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

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

package clips.delegate.shedule.reception;

import clips.delegate.client.ClientLocal;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.main.ClipsException;
import cli_fmw.delegate.lists.DataChunk;
import clips.delegate.directory.ro.DirectoryCollaborator;
import clips.delegate.directory.ro.DirectoryCollaboratorItem;
import beans.shedule.reception.SheduleReceptionDetails;
import cli_fmw.delegate.AuditListener;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;



/**
*
* @author axe
*/
public class SheduleReceptionData extends DataChunk<SheduleReceptionDetails>
    implements Cloneable {
   
    private ClientLocal client;
           
    public SheduleReceptionData(ClientLocal client,
            DirectoryCollaboratorItem collaborator) throws ClipsException {
        super(new SheduleReceptionDetails());
        this.client = client;
        getDetails().clientID = client.getID();
        getDetails().collaboratorID = collaborator.getID();
    }
   
    public SheduleReceptionData( ClientLocal client, SheduleReceptionDetails details)
            throws ClipsException {
        super(details);
        this.client = client;
        if(client != null &&
                getDetails().clientID != client.getID()) {
            throw new IllegalArgumentException("Inconsistent client data");
        }
    }
   
    public Date getBegin() {
        return getDetails().begin;
    }

    public void setBegin(Date begin) {
        if(getDetails().begin != begin)  {
            getDetails().begin = begin;
            fireContentStateEvent();
        }
    }

    public Date getEnd() {
        Calendar cal = GregorianCalendar.getInstance();
        cal.setTime(getBegin());
        cal.add(Calendar.MINUTE, getDuration());
        return cal.getTime();
    }
   
    public int getDuration() {
        return getDetails().duration;
    }

    /**
     *
     * @param duration Minutes
     */
    public void setDuration(int duration) {
        if(getDetails().duration != duration) {
            getDetails().duration = duration;
            fireContentStateEvent();
        }
    }

    public ClientLocal getClient(AuditListener al) throws ClipsException {
        if(client == null) {
            client = new ClientLocal(getDetails().clientID, al);
        }
        return client;
    }

    public void setClient(ClientLocal client) throws ClipsException {
        if(getDetails().clientID != client.getID()) {
            getDetails().clientID = client.getID();
            this.client = client;
            fireContentStateEvent();
        }
    }
   
    public DirectoryCollaboratorItem getCollaborator() throws ClipsException {
        DirectoryCollaborator colls = DirectoryLocator.getDirectory(DirectoryCollaborator.class, false);
        return colls.getItemFromID(getDetails().collaboratorID);
    }

    @Override
    public String toString() {
        try {
            return getCollaborator().toString() + " at " + getBegin().toString();
        } catch (ClipsException ex) {
            ex.printStackTrace();
        }
        return "error";
    }
   
    /**
     *
     * @return can be null
     */
    public String getDescription() {
        return getDetails().description;
    }
   
    public void setDescription(String desc) {
        if(!getDetails().description.equals(desc)) {
            getDetails().description = desc;
            fireContentStateEvent();
        }       
    }
   
    public List<Integer> getLinkedServicesList() {
        return getDetails().serviceRenders;
    }
   
    public void setLinkedServicesList(List<Integer> list) {
        getDetails().serviceRenders = list;
        fireContentStateEvent();
    }   
}
TOP

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

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.