Package net.sf.basedb.core.data
Class UserDeviceData
- java.lang.Object
-
- net.sf.basedb.core.data.BasicData
-
- net.sf.basedb.core.data.UserDeviceData
-
- All Implemented Interfaces:
IdentifiableData
,NameableData
,RegisteredData
public class UserDeviceData extends BasicData implements RegisteredData, NameableData
This class holds information about a verified user device. ThegetToken()
is randomly generated token that each device is supposed to keep track of and submit together with the login info.- Since:
- 3.12
- Author:
- Nicklas
- Hibernate: class
- table="`UserDevices`" lazy="false"
-
-
Field Summary
Fields Modifier and Type Field Description private ClientData
client
private String
description
private Date
entryDate
private boolean
isVerified
private Date
lastUsed
private String
location
private Float
locationLat
private Float
locationLong
static int
MAX_LOCATION_LENGTH
The maximum length of the location that can be stored in the database.static int
MAX_REMOTE_ID_LENGTH
The maximum length of the remote ID that can be stored in the database.static int
MAX_TOKEN_LENGTH
The maximum length of the device token that can be stored in the database.static int
MAX_USER_AGENT_LENGTH
The maximum length of the user agent that can be stored in the database.private String
name
private String
remoteId
private Set<SessionData>
sessions
private String
token
private UserData
user
private String
userAgent
-
Fields inherited from interface net.sf.basedb.core.data.NameableData
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
-
Constructor Summary
Constructors Constructor Description UserDeviceData()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientData
getClient()
Get the client application this device is associated with.String
getDescription()
Get the description for the item.Date
getEntryDate()
Get the date this item was added to the database.String
getLastRemoteId()
Get the remote id (=ip address) of the last login from this device.Date
getLastUsed()
Get the date and time the user last logged in from this device.String
getLocation()
Get the location of the user (if known).Float
getLocationLatitude()
Get the location latitude of the user (if known).Float
getLocationLongitude()
Get the location longitude of the user (if known).String
getName()
Get the name of the item.(package private) Set<SessionData>
getSessions()
This is the inverse end but we do not map with inverse="true" cascade="delete" since we want Hibernate to set SessionData.device_id = null instead of deleting sessions.String
getToken()
Get the device token.UserData
getUser()
The user that this device is associated with.String
getUserAgent()
Get a string with more information about the device (eg.boolean
isVerified()
This flag is TRUE if the device has been verified (by sending a code via email).void
setClient(ClientData client)
void
setDescription(String description)
Set the description for the item.void
setEntryDate(Date entryDate)
void
setLastRemoteId(String remoteId)
void
setLastUsed(Date lastUsed)
void
setLocation(String location)
void
setLocationLatitude(Float locationLat)
void
setLocationLongitude(Float locationLong)
void
setName(String name)
Set the name of the item.(package private) void
setSessions(Set<SessionData> sessions)
void
setToken(String token)
void
setUser(UserData user)
void
setUserAgent(String userAgent)
void
setVerified(boolean isVerified)
-
Methods inherited from class net.sf.basedb.core.data.BasicData
equals, getId, getVersion, hashCode, setId, setVersion, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.basedb.core.data.IdentifiableData
getId, getVersion
-
-
-
-
Field Detail
-
user
private UserData user
-
client
private ClientData client
-
entryDate
private Date entryDate
-
name
private String name
-
description
private String description
-
MAX_TOKEN_LENGTH
public static final int MAX_TOKEN_LENGTH
The maximum length of the device token that can be stored in the database.- See Also:
setToken(String)
, Constant Field Values
-
token
private String token
-
MAX_USER_AGENT_LENGTH
public static final int MAX_USER_AGENT_LENGTH
The maximum length of the user agent that can be stored in the database.- See Also:
setUserAgent(String)
, Constant Field Values
-
userAgent
private String userAgent
-
lastUsed
private Date lastUsed
-
MAX_REMOTE_ID_LENGTH
public static final int MAX_REMOTE_ID_LENGTH
The maximum length of the remote ID that can be stored in the database.- See Also:
setLastRemoteId(String)
, Constant Field Values
-
remoteId
private String remoteId
-
MAX_LOCATION_LENGTH
public static final int MAX_LOCATION_LENGTH
The maximum length of the location that can be stored in the database.- See Also:
setLocation(String)
, Constant Field Values
-
location
private String location
-
locationLat
private Float locationLat
-
locationLong
private Float locationLong
-
isVerified
private boolean isVerified
-
sessions
private Set<SessionData> sessions
-
-
Method Detail
-
getUser
public UserData getUser()
The user that this device is associated with.- Hibernate: many-to-one
- column="`user_id`" not-null="true" update="false" outer-join="false"
-
setUser
public void setUser(UserData user)
-
getClient
public ClientData getClient()
Get the client application this device is associated with.- Hibernate: many-to-one
- column="`client_id`" not-null="true" update="false" outer-join="false"
-
setClient
public void setClient(ClientData client)
-
getEntryDate
public Date getEntryDate()
Description copied from interface:RegisteredData
Get the date this item was added to the database. The value is generated at creation time and can't be modified later.- Specified by:
getEntryDate
in interfaceRegisteredData
-
setEntryDate
public void setEntryDate(Date entryDate)
-
getName
public String getName()
Description copied from interface:NameableData
Get the name of the item.- Specified by:
getName
in interfaceNameableData
- Returns:
- A
String
with the name of the item
-
setName
public void setName(String name)
Description copied from interface:NameableData
Set the name of the item. The name cannot be null and mustn't be longer than the value specified by theMAX_NAME_LENGTH
constant.- Specified by:
setName
in interfaceNameableData
- Parameters:
name
- The new name for the item
-
getDescription
public String getDescription()
Description copied from interface:NameableData
Get the description for the item.- Specified by:
getDescription
in interfaceNameableData
- Returns:
- A
String
with a description of the item
-
setDescription
public void setDescription(String description)
Description copied from interface:NameableData
Set the description for the item. The description can be null but mustn't be longer than the value specified by theMAX_DESCRIPTION_LENGTH
constant.- Specified by:
setDescription
in interfaceNameableData
- Parameters:
description
- The new description for the item
-
getToken
public String getToken()
Get the device token.- Hibernate: property
- column="`token`" type="string" length="255" not-null="true" update="false"
-
setToken
public void setToken(String token)
-
getUserAgent
public String getUserAgent()
Get a string with more information about the device (eg. User-Agent from a web browser).- Hibernate: property
- column="`user_agent`" type="text" not-null="false"
-
setUserAgent
public void setUserAgent(String userAgent)
-
getLastUsed
public Date getLastUsed()
Get the date and time the user last logged in from this device.- Hibernate: property
- column="`last_used`" type="timestamp" not-null="true"
-
setLastUsed
public void setLastUsed(Date lastUsed)
-
getLastRemoteId
public String getLastRemoteId()
Get the remote id (=ip address) of the last login from this device.- Hibernate: property
- column="`lastremote_id`" type="string" length="255" not-null="false"
-
setLastRemoteId
public void setLastRemoteId(String remoteId)
-
getLocation
public String getLocation()
Get the location of the user (if known).- Hibernate: property
- column="`location`" type="string" length="255" not-null="false"
-
setLocation
public void setLocation(String location)
-
getLocationLatitude
public Float getLocationLatitude()
Get the location latitude of the user (if known).- Hibernate: property
- column="`location_lat`" type="float" not-null="false"
-
setLocationLatitude
public void setLocationLatitude(Float locationLat)
-
getLocationLongitude
public Float getLocationLongitude()
Get the location longitude of the user (if known).- Hibernate: property
- column="`location_long`" type="float" not-null="false"
-
setLocationLongitude
public void setLocationLongitude(Float locationLong)
-
isVerified
public boolean isVerified()
This flag is TRUE if the device has been verified (by sending a code via email).- Since:
- 3.17 Mapped in hibernate-properties-UserDeviceData.xml since default is not supported in XDoclet //hibernate.property column="`is_verified`" type="boolean" not-null="true" default="false"
-
setVerified
public void setVerified(boolean isVerified)
-
getSessions
Set<SessionData> getSessions()
This is the inverse end but we do not map with inverse="true" cascade="delete" since we want Hibernate to set SessionData.device_id = null instead of deleting sessions.- See Also:
SessionData.getDevice()
- Hibernate: set
- lazy="true"
- Hibernate: collection-key
- column="`device_id`"
- Hibernate: collection-one-to-many
- class="net.sf.basedb.core.data.SessionData"
-
setSessions
void setSessions(Set<SessionData> sessions)
-
-