Package org.salamanca.commands.user

Source Code of org.salamanca.commands.user.ModificarUsuario

package org.salamanca.commands.user;

import org.salamanca.commands.ICommand;
import org.salamanca.domain.User;
import org.salamanca.broker.BrokerServer;
import javax.jdo.PersistenceManager;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ModificarUsuario implements ICommand {
    User user;
    int role;

    /**
     * InsertarUsuario
     *
     * @param user User
     */
    public ModificarUsuario(User user, int role) {
        this.user = user;
        this.role = role;
    }

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

    /**
     * getBarDelimitedParameters
     *
     * @return String
     */
    public String getBarDelimitedParameters() {
        return user.getName();
    }

    /**
     * execute
     */
    public void execute() {
        PersistenceManager pm = BrokerServer.instance().getPMF().
                                getPersistenceManager();
        pm.currentTransaction().begin();
        User userPM=  (User)pm.getObjectById(javax.jdo.JDOHelper.getObjectId(user),true);
        userPM.setRole(role);
        pm.currentTransaction().commit();

    }
}
TOP

Related Classes of org.salamanca.commands.user.ModificarUsuario

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.