package org.salamanca.commands.descuento;
import org.salamanca.commands.ICommand;
import org.salamanca.domain.CuotaBasica;
import org.salamanca.broker.BrokerServer;
import javax.jdo.PersistenceManager;
import org.salamanca.commands.MessageException;
import org.salamanca.domain.DescuentoSumaFija;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class EliminarDescuentoSumaFija implements ICommand{
DescuentoSumaFija descuentoSumaFija;
/**
* InsertarPersona
*
* @param persona Persona
*/
public EliminarDescuentoSumaFija( DescuentoSumaFija descuentoSumaFija) {
this.descuentoSumaFija = descuentoSumaFija;
}
/**
* execute
*/
public void execute() throws MessageException {
if (descuentoSumaFija.getSetPersona().size() > 0) {
throw new MessageException(
"Imposible eliminar, el descuento tiene personas asociadas");
}
PersistenceManager pm = BrokerServer.instance().getPMF().
getPersistenceManager();
pm.currentTransaction().begin();
DescuentoSumaFija descuentoSumaFijaPM = (DescuentoSumaFija) pm.getObjectById(javax.jdo.
JDOHelper.getObjectId(descuentoSumaFija),true);
pm.deletePersistent(descuentoSumaFijaPM);
pm.currentTransaction().commit();
}
/**
* getCommandName
*
* @return String
*/
public String getCommandName() {
return this.getClass().getName();
}
/**
* getBarDelimitedParameters
*
* @return String
*/
public String getBarDelimitedParameters() {
return descuentoSumaFija.getNombre() + "|" +
descuentoSumaFija.getSumaFija();
}
}