/*
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at http://www.opensource.org/licenses/cddl1.php
 * or http://www.opensource.org/licenses/cddl1.txt.
 *
 * When distributing Covered Code, include this CDDL Header Notice in each file
 * and include the License file at http://www.opensource.org/licenses/cddl1.php.
 * If applicable, add the following below the CDDL Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 *
 * The Original Software is de.dev.eth0_obroker_war_0.1. The Initial Developer of the Original
 * Software is Alexander Muthmann <amuthmann at dev-eth0.de>.
 */
package de.dev.eth0.obroker.entities.account;

import de.dev.eth0.obroker.entities.game.Game;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

/**
 *
 * @author Alexander Muthmann <amuthmann at dev-eth0.de>
 * @version 03/2010
 */
@PersistenceCapable
public class User {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private String login;
    @Persistent
    @Unique
    private String mail;
    @Persistent
    private String hashed_password;
    @Persistent
    private String activationlink;
    @Persistent
    private Group group;
    @Persistent
    private boolean newsletter;
    @Persistent
    private boolean active;
    private List<Game> games = new ArrayList<Game>();

    public String getHashed_password() {
        return hashed_password;
    }

    public void setHashed_password(final String hashed_password) {
        this.hashed_password = hashed_password;
    }

    public void setCleartext_password(final String clear_password) {
        this.hashed_password = PasswordHelper.getCryptedPassword(login);
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(final String _login) {
        this.login = _login;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public Group getGroup() {
        return this.group;
    }

    public void setGroup(final Group _group) {
        this.group = _group;
    }

    public void setActivationlink(final String _activationlink) {
        this.activationlink = _activationlink;
    }

    public String getActivationlink() {
        return this.activationlink;
    }

    public boolean isNewsletter() {
        return newsletter;
    }

    public void setNewsletter(boolean newsletter) {
        this.newsletter = newsletter;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public void setGames(List<Game> _games) {
        this.games = _games;
    }

    public void addGame(Game _game) {
        this.games.add(_game);
    }

    public List<Game> getGames() {
        return Collections.unmodifiableList(games);
    }
}


