Package org.salamanca.commands.persona

Source Code of org.salamanca.commands.persona.DesAgregarDescuento

package org.salamanca.commands.persona;

import org.salamanca.domain.Descuento;
import javax.jdo.PersistenceManager;
import org.salamanca.broker.BrokerServer;
import org.salamanca.commands.MessageException;
import org.salamanca.domain.Persona;
import org.salamanca.commands.ICommand;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class DesAgregarDescuento implements ICommand{

    Persona persona;
    Descuento descuento;


    /**
     * InsertarUsuario
     *
     * @param user User
     */
    public DesAgregarDescuento(Persona persona, Descuento descuento) {
        this.persona = persona;
        this.descuento = descuento;
    }

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

    /**
     * getBarDelimitedParameters
     *
     * @return String
     */
    public String getBarDelimitedParameters() {
        return persona.getNombre() + "|" + persona.getApellido() + "|" +
                descuento.getNombre();

    }

    /**
     * execute
     */
    public void execute() throws MessageException {
        PersistenceManager pm = BrokerServer.instance().getPMF().
                                getPersistenceManager();

        pm.currentTransaction().begin();
        Persona personaPM = (Persona) pm.getObjectById(javax.jdo.JDOHelper.
                getObjectId(persona), true);
        Descuento descuentoPM = (Descuento) pm.getObjectById(javax.jdo.JDOHelper.
                getObjectId(descuento), true);
        personaPM.removeDescuento(descuentoPM);
        pm.currentTransaction().commit();

    }



}
TOP

Related Classes of org.salamanca.commands.persona.DesAgregarDescuento

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.