package org.salamanca.commands.vale;
import org.salamanca.domain.Vale;
import org.salamanca.broker.BrokerServer;
import javax.jdo.PersistenceManager;
import org.salamanca.commands.MessageException;
import java.util.Date;
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 UtilizarVale implements ICommand{
Vale vale;
public UtilizarVale(Vale vale) {
this.vale = vale;
}
/**
* execute
*/
public void execute() throws MessageException {
PersistenceManager pm = BrokerServer.instance().getPMF().
getPersistenceManager();
pm.currentTransaction().begin();
Vale valePM = (Vale) pm.getObjectById(javax.jdo.JDOHelper.
getObjectId(
vale), true);
valePM.setFechaUtilizacion(new Date());
pm.currentTransaction().commit();
}
/**
* getCommandName
*
* @return String
*/
public String getCommandName() {
return this.getClass().getName();
}
/**
* getBarDelimitedParameters
*
* @return String
*/
public String getBarDelimitedParameters() {
return vale.getPersona().getNombre() + "|" + vale.getImporte() + "|" +
vale.getFechaEmision();
}
}