package org.salamanca.commands.cuota;
import org.salamanca.commands.ICommand;
import org.salamanca.domain.Curso;
import org.salamanca.broker.BrokerServer;
import javax.jdo.PersistenceManager;
import org.salamanca.commands.MessageException;
import org.salamanca.domain.CuotaBasica;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class EliminarCuota implements ICommand {
CuotaBasica cuota = null;
/**
* InsertarPersona
*
* @param persona Persona
*/
public EliminarCuota(CuotaBasica cuota) {
this.cuota = cuota;
}
/**
* execute
*/
public void execute() throws MessageException {
PersistenceManager pm = BrokerServer.instance().getPMF().
getPersistenceManager();
pm.currentTransaction().begin();
CuotaBasica cuotaBasicaPM = (CuotaBasica) pm.getObjectById(javax.jdo.
JDOHelper.getObjectId(cuota),true);
if (cuotaBasicaPM.getSetPago().size() > 0) {
throw new MessageException(
"Esta cuota ya tiene pagos realizados por alumnos "+
", por lo tanto no se puede eliminar");
}
cuotaBasicaPM.getCurso().removeCuotaBasica(cuotaBasicaPM);
pm.deletePersistent(cuotaBasicaPM);
pm.currentTransaction().commit();
}
/**
* getCommandName
*
* @return String
*/
public String getCommandName() {
return this.getClass().getName();
}
/**
* getBarDelimitedParameters
*
* @return String
*/
public String getBarDelimitedParameters() {
return cuota.getFechaVencimiento() + "|" +
cuota.getConcepto() + "|" + cuota.getImporte() + "|" +
cuota.isPagoExtra();
}
}