Package org.salamanca.commands.curso

Source Code of org.salamanca.commands.curso.ModificarCurso

package org.salamanca.commands.curso;

import java.util.Date;
import javax.jdo.PersistenceManager;
import org.salamanca.broker.BrokerServer;
import org.salamanca.domain.*;
import org.salamanca.commands.ICommand;
import org.salamanca.commands.MessageException;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class ModificarCurso implements ICommand {
    Curso curso;
    String nombre;
    String observaciones;
    int cantPeriodos;
    Date fechaInicio;
    Date fechaFin;
    boolean permitirDescuento = true;

    /**
     * InsertarPersona
     *
     * @param persona Persona
     */
    public ModificarCurso(Curso curso, String nombre, String observaciones,
                          int cantPeriodos,
                          Date fechaInicio, Date fechaFin,
                          boolean permitirDescuento) {
        this.curso = curso;
        this.nombre = nombre;
        this.observaciones = observaciones;
        this.cantPeriodos = cantPeriodos;
        this.fechaInicio = fechaInicio;
        this.fechaFin = fechaFin;
        this.permitirDescuento = permitirDescuento;
    }

    /**
     * execute
     */
    public void execute() throws MessageException {

        if (this.nombre.trim().length() == 0) {
            throw new MessageException(
                    "EL nombre del curso no puede estar vacio");
        }

        PersistenceManager pm = BrokerServer.instance().getPMF().
                                getPersistenceManager();
        pm.currentTransaction().begin();
        Curso cursoPM = (Curso) pm.getObjectById(javax.jdo.JDOHelper.
                                                 getObjectId(curso), true);
        cursoPM.setNombre(this.nombre);
        cursoPM.setObservaciones(observaciones);
        cursoPM.setCantidadPeriodos(this.cantPeriodos);
        cursoPM.setFechaFinalizacion(this.fechaFin);
        cursoPM.setFechaInicio(this.fechaInicio);
        cursoPM.setPermiteDescuentos(this.permitirDescuento);
        pm.currentTransaction().commit();
    }

    /**
     * getCommandName
     *
     * @return String
     */
    public String getCommandName() {
        return this.getClass().getName();
    }

    /**
     * getBarDelimitedParameters
     *
     * @return String
     */
    public String getBarDelimitedParameters() {
        return curso.getNombre() + "|" + curso.getObservaciones() + "|" +
                curso.getCantidadPeriodos() + "|" +
                curso.getFechaFinalizacion() + "|" + curso.getFechaInicio() +
                "==>" +
                nombre + "|" + observaciones + "|" +
                cantPeriodos + "|" +
                fechaFin + "|" + fechaInicio;
    }

}
TOP

Related Classes of org.salamanca.commands.curso.ModificarCurso

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.