package com.etherios.gae.connector.tank.datastore;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.digi.connector.client.CloudConnection;

@PersistenceCapable
public class UserData {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private String userID;
	
	@Persistent
	private String user;
	
	@Persistent
	private String password;
	
	@Persistent
	private String server;
	
	@Persistent
	private String latitude;
	
	@Persistent
	private String longitude;
	
	@Persistent
	private String selectedDevice;
	
	@Persistent
	private String selectedXBee;
	
	public UserData(String user, String password, String server) {
		this.userID = user + server;
		this.user = user;
		this.password = password;
		this.server = server;
	}
	
	/**
	 * Returns the user ID.
	 * 
	 * @return The user ID.
	 */
	public String getUserID() {
		return userID;
	}
	
	/**
	 * Returns the user name.
	 * 
	 * @return The user name.
	 */
	public String getUser() {
		return user;
	}
	
	/**
	 * Returns the password.
	 * 
	 * @return The password.
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * Sets a new password.
	 * 
	 * @param password The new password.
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	/**
	 * Returns the server.
	 * 
	 * @return The server.
	 */
	public String getServer() {
		return server;
	}
	
	/**
	 * Sets a new server.
	 * 
	 * @param server The new server.
	 */
	public void setServer(String server) {
		this.server = server;
	}
	
	/**
	 * Returns the CloudConnection corresponding to this user.
	 * 
	 * @return the CloudConnection corresponding to this user.
	 */
	public CloudConnection getCloudConnection() {
		return new CloudConnection(user, password, password);
	}
	
	/**
	 * Returns the selected device of the user.
	 * 
	 * @return The ID of the selected device.
	 */
	public String getSelectedDevice() {
		return selectedDevice;
	}
	
	/**
	 * Sets the selected device of the user.
	 * 
	 * @param deviceID The selected device ID.
	 */
	public void setSelectedDevice(String deviceID) {
		selectedDevice = deviceID;
	}
	
	/**
	 * Returns the selected XBee of the user.
	 * 
	 * @return The ID of the selected XBee.
	 */
	public String getSelectedXBee() {
		return selectedXBee;
	}
	
	/**
	 * Sets the selected XBee of the user.
	 * 
	 * @param XBeeID The selected XBee ID.
	 */
	public void setSelectedXBee(String XBeeID) {
		selectedXBee = XBeeID;
	}
	
	/**
	 * Returns the latitude of the selected device.
	 * 
	 * @return The latitude.
	 */
	public String getLatitude() {
		return latitude;
	}
	
	/**
	 * Sets the latitude of the selected device.
	 * 
	 * @param latitude The latitude.
	 */
	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	
	/**
	 * Returns the longitude of the selected device.
	 * 
	 * @return The longitude.
	 */
	public String getLongitude() {
		return longitude;
	}
	
	/**
	 * Sets the longitude of the selected device.
	 * 
	 * @param longitude The longitude.
	 */
	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
}
