Package com.ehealthsystem.user
Class User
java.lang.Object
com.ehealthsystem.user.User
- All Implemented Interfaces:
HasAddress
The class represents a user and his attributes
-
Field Summary
Modifier and TypeFieldDescriptionprivate LocalDate
private String
Attributes of the user.private String
Attributes of the user.private String
Attributes of the user.private String
Attributes of the user.private String
private String
Attributes of the user.private boolean
private String
Attributes of the user.private String
Attributes of the user.private String
-
Constructor Summary
ConstructorDescriptionUser
(String username, String email, String firstName, String lastName, String street, String houseNo, String zipCode, LocalDate birthDate, String gender, String password, String insuranceName, boolean privateInsurance, boolean insertIntoDb) Creates a new user object representing a row in the database -
Method Summary
Modifier and TypeMethodDescriptionboolean
changePassword
(String currentPassword, String newPassword) Change a user's password Used by the user to change their own passwordWrapper to get users appointments from the user object.get the birthday returnedget the first name returnedget the gender returnedget the house number returnedget the insurance name returnedget the last name returnedgetMail()
get the mail returnedget the street returnedget the username returnedget the zip returnedvoid
insertIntoDb
(String password) Inserts this user into the database.boolean
get the insurance type returnedvoid
setBirthDate
(LocalDate birthDate) set and update the birthday in the databasevoid
set and update email in the databasevoid
setFirstName
(String firstName) set and update the first name in the databasevoid
set and update the gender in the databasevoid
setHouseNo
(String houseNo) set and update house no. in the databasevoid
setInsuranceName
(String insuranceName) set and update the insurance name in the databasevoid
setLastName
(String lastName) set and update the last name in the databaseprivate void
setPassword
(String email, String password) Set a user's password Used as helper function but also by admin, which is why it's publicvoid
setPrivateInsurance
(boolean privateInsurance) set and update the insurance type in the databasevoid
set and update street in the databasevoid
setUsername
(String username) set and update the username in the databasevoid
setZipCode
(String zipCode) set and update zip code in the databaseprivate void
Updates this user's entry in the databaseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.ehealthsystem.tools.HasAddress
getFormattedAddress, getFormattedAddressWithPlaceName
-
Field Details
-
username
Attributes of the user. -
email
Attributes of the user. -
firstName
Attributes of the user. -
lastName
Attributes of the user. -
street
Attributes of the user. -
houseNo
Attributes of the user. -
gender
Attributes of the user. -
zipCode
-
birthDate
-
insuranceName
-
privateInsurance
private boolean privateInsurance
-
-
Constructor Details
-
User
public User(String username, String email, String firstName, String lastName, String street, String houseNo, String zipCode, LocalDate birthDate, String gender, String password, String insuranceName, boolean privateInsurance, boolean insertIntoDb) throws SQLException, javax.activation.UnsupportedDataTypeException Creates a new user object representing a row in the database- Parameters:
username
- Username of the user.password
- Password chosen by the user.firstName
- First name of the user.lastName
- Last name of the user.email
- E-mail address of the user.street
- Street where the user lives.houseNo
- House no. of the street.zipCode
- Zip code where the user lives.birthDate
- Birthdate of the user.privateInsurance
- Type of insurance.insertIntoDb
- Inserts the user in to the Database. * true if this is a new user that is inserted to the database, * false if the object shall solely represent a user that is already saved in the database (i.e. result of a SELECT query) * or also false if object is for bridging the step from registration to email validation- Throws:
SQLException
- Throws Exception during connection issues.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
-
Method Details
-
insertIntoDb
public void insertIntoDb(String password) throws SQLException, javax.activation.UnsupportedDataTypeException Inserts this user into the database. Only to be used if a new user is created.- Parameters:
password
- The password in plain-text that is to be stored for this user in a hashed form in the database- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format for the database.
-
changePassword
Change a user's password Used by the user to change their own password- Parameters:
currentPassword
- Verifying the current password of the user.newPassword
- Sets a new password if the current password is valid.- Returns:
- True if the new password is set, false if the process was aborted because current password is wrong.
- Throws:
SQLException
- Throws Exception during connection issues with the Database.
-
setPassword
Set a user's password Used as helper function but also by admin, which is why it's public- Parameters:
email
- The E-mail of the user which password is being set.password
- The password of the user set e.g. by the doctor.- Throws:
SQLException
- Throws Exception during connection issues with the Database.
-
update
private void update(Object[][] newValues) throws SQLException, javax.activation.UnsupportedDataTypeException Updates this user's entry in the database- Parameters:
newValues
- Attributes(values) of the user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setUsername
public void setUsername(String username) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the username in the database- Parameters:
username
- The username of the user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setEmail
public void setEmail(String email) throws SQLException, javax.activation.UnsupportedDataTypeException set and update email in the database- Parameters:
email
- The e-mail address of the user-- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setFirstName
public void setFirstName(String firstName) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the first name in the database- Parameters:
firstName
- the first name of the user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setLastName
public void setLastName(String lastName) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the last name in the database- Parameters:
lastName
- The last name of the user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setStreet
public void setStreet(String street) throws SQLException, javax.activation.UnsupportedDataTypeException set and update street in the database- Parameters:
street
- The street where the user lives.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setHouseNo
public void setHouseNo(String houseNo) throws SQLException, javax.activation.UnsupportedDataTypeException set and update house no. in the database- Parameters:
houseNo
- The house no. of the street.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setZipCode
public void setZipCode(String zipCode) throws SQLException, javax.activation.UnsupportedDataTypeException set and update zip code in the database- Parameters:
zipCode
- The zip code where the user lives.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setBirthDate
public void setBirthDate(LocalDate birthDate) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the birthday in the database- Parameters:
birthDate
- The birthday from user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setGender
public void setGender(String gender) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the gender in the database- Parameters:
gender
- The gender of the user.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setInsuranceName
public void setInsuranceName(String insuranceName) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the insurance name in the database- Parameters:
insuranceName
- The name of the insurance.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
setPrivateInsurance
public void setPrivateInsurance(boolean privateInsurance) throws SQLException, javax.activation.UnsupportedDataTypeException set and update the insurance type in the database- Parameters:
privateInsurance
- The type of the Insurance.- Throws:
SQLException
- Throws Exception during connection issues with the Database.javax.activation.UnsupportedDataTypeException
- Throws Exception if the input of data is invalid/in wrong format.
-
getUsername
get the username returned- Returns:
- The username of the user.
-
getFirstName
get the first name returned- Returns:
- The first name of the user.
-
getLastName
get the last name returned- Returns:
- The last name of the user.
-
getMail
get the mail returned- Returns:
- The E-mail of the user.
-
getStreet
get the street returned- Specified by:
getStreet
in interfaceHasAddress
- Returns:
- The street where the user lives.
-
getHouseNumber
get the house number returned- Specified by:
getHouseNumber
in interfaceHasAddress
- Returns:
- The house no. of the street.
-
getGender
get the gender returned- Returns:
- The gender of the user.
-
getInsuranceName
get the insurance name returned- Returns:
- The insurance name.
-
getZipCode
get the zip returned- Specified by:
getZipCode
in interfaceHasAddress
- Returns:
- The zip code of the users place of residence.
-
getBirthDate
get the birthday returned- Returns:
- The birthdate of the user as an object of the type LocalDate.
-
isPrivateInsurance
public boolean isPrivateInsurance()get the insurance type returned- Returns:
- The type of the insurance of the user.
-
getAppointments
public ArrayList<Appointment> getAppointments() throws SQLException, javax.activation.UnsupportedDataTypeExceptionWrapper to get users appointments from the user object.- Returns:
- The appointments of the user.
- Throws:
SQLException
- Throws Exception during connection issues.javax.activation.UnsupportedDataTypeException
-