Package org.salamanca.commands.periodo

Source Code of org.salamanca.commands.periodo.EliminarPeriodo

package org.salamanca.commands.periodo;

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

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

    /**
     * InsertarPersona
     *
     * @param persona Persona
     */
    public EliminarPeriodo( Periodo periodo) {
        this.periodo = periodo;

    }

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


     if(periodo.getAlumno().getVectorPeriodos().lastElement()!=periodo){
         throw new MessageException(
                    "Solo se puede eliminar el ultimo periodo");
     }


        PersistenceManager pm = BrokerServer.instance().getPMF().
                                getPersistenceManager();
        Periodo periodoPM = (Periodo) pm.getObjectById(javax.jdo.JDOHelper.
                getObjectId(periodo),true);

        pm.currentTransaction().begin();
        periodoPM.getAlumno().removePeriodo(periodoPM);
        pm.deletePersistent(periodoPM);
        pm.currentTransaction().commit();

    }

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

    /**
     * getBarDelimitedParameters
     *
     * @return String
     */
    public String getBarDelimitedParameters() {
        return  periodo.getAlumno().getPersona().getNombre() + "|" +
                periodo.getAlumno().getPersona().getApellido() + "|" +
                periodo.getEscribir() + "|" + periodo.getEscuchar() + "|" +
                periodo.getGramatica() + "|" + periodo.getHablar() +
                "|" + periodo.getLeer() + "|" +
                periodo.getInasistenciasInjustificadas() + "|" +
                periodo.getInasistenciasjustificadas();
    }

}
TOP

Related Classes of org.salamanca.commands.periodo.EliminarPeriodo

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.