Skip to content

Commit 42ecdba

Browse files
authored
Merge pull request #31 from CSC207-2022F-UofT/14-feature-2-user-login
14 feature 2 user login
2 parents 1e1f4d9 + e6ed6ba commit 42ecdba

34 files changed

+237
-184
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
22
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
33

4-
# entities.userEntities.User-specific stuff
4+
# entities.user_entities.User-specific stuff
55
.idea/**/workspace.xml
66
.idea/**/tasks.xml
77
.idea/**/usage.statistics.xml
88
.idea/**/dictionaries
99
.idea/**/shelf
1010

11-
# AWS entities.userEntities.User-specific
11+
# AWS entities.user_entities.User-specific
1212
.idea/**/aws.xml
1313

1414
# Generated files

src/main/java/data_access/UserDatabase.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package data_access;
22

3-
import entities.userEntities.User;
4-
import entities.userEntities.UserFactory;
5-
import interface_adapters.Chat.ConvHistGateway;
6-
import interface_adapters.Chat.MsgSenderGateway;
7-
import interface_adapters.Chat.UserChatGateway;
8-
import interface_adapters.User.*;
3+
import interface_adapters.User_search_IA.IRetrieveList;
4+
import interface_adapters.user_registration_interface_adapters.UserExists;
5+
import entities.user_entities.User;
6+
import interface_adapters.profile_modification_IA.UserModificationGateway;
7+
import use_cases.user_registration_use_cases.UserCreator;
8+
import entities.user_entities.UserFactory;
9+
import interface_adapters.User_search_IA.UserRetriever;
910

1011
import java.io.*;
1112
import java.util.ArrayList;
1213
import java.util.List;
13-
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway,
14-
ConvHistGateway, MsgSenderGateway, UserChatGateway {
14+
public class UserDatabase implements UserExists, UserRetriever, UserCreator, IRetrieveList, UserModificationGateway {
1515
File accounts;
1616
List<User> accountList;
1717
public UserDatabase(){
@@ -92,7 +92,7 @@ public List<User> getList() {
9292
/*
9393
while(true){
9494
try{
95-
entities.userEntities.User user = (entities.userEntities.User) in.readObject();
95+
Entities.User_Entities.User user = (Entities.User_Entities.User) in.readObject();
9696
users.add(user);}
9797
catch(EOFException e){
9898
break;
@@ -125,7 +125,6 @@ public void modifyUser(String oldUsername, User modified){
125125
}
126126
}
127127

128-
129128
// Below two methods are used by conversation history-related interactors
130129
// (Commented as objects are not found)
131130
// /**
@@ -137,7 +136,7 @@ public void modifyUser(String oldUsername, User modified){
137136
// String chatID = dsRequestModel.getChatID();
138137
// Message message = dsRequestModel.getMessage();
139138
//
140-
// // Find chat under specified entities.userEntities.User
139+
// // Find chat under specified Entities.User_Entities.User
141140
// Chat chat = this.getUser(userID).getChat(chatID);
142141
//
143142
// chat.addMessage(message);
@@ -152,25 +151,9 @@ public void modifyUser(String oldUsername, User modified){
152151
// String userID = dsRequestModel.getUserID();
153152
// String chatID = dsRequestModel.getChatID();
154153
//
155-
// // Find chat under specified entities.userEntities.User
154+
// // Find chat under specified Entities.User_Entities.User
156155
// Chat chat = this.getUser(userID).getChat(chatID);
157156
//
158157
// return Chat.getConversationHistory();
159158
// }
160-
161-
162-
163-
164-
// This method will get a user's chats; this will be used by AppScreenLoader to display chats and could
165-
// also be used by ChatInteractor (Chat entity is undefined here and at the moment user doesn't have chats)
166-
// @Override
167-
// public ArrayList<Chat> getUserChats(String username) {
168-
// for (entities.userEntities.User user: accountList){
169-
// if (user.getUsername().equals(username)){
170-
// return user.getChats();
171-
// }
172-
// }
173-
// throw new RuntimeException("Invalid username: user does not exist");
174-
// }
175-
176159
}

src/main/java/entities/userEntities/BasicUser.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/java/entities/userEntities/User.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/main/java/entities/userEntities/UserFactory.java

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package entities.user_entities;
22

3-
import entities.user_entities.User;
3+
import java.util.ArrayList;
4+
import entities.chat;
5+
46
public class BasicUser extends User{
5-
public BasicUser(String Username, String Password, String Email){
6-
super(Username, Password, Email);
7+
public BasicUser(String Username, String Password, String Email, ArrayList<Chat> userChats){
8+
super(Username, Password, Email, userChats);
79
}
810
}

src/main/java/entities/user_entities/User.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
package entities.user_entities;
22

3+
import interface_adapters.login_interface_adapters.Login;
34
import use_cases.user_attribute_modification_use_case.Changeable;
5+
import interface_adapters.app_screen_interface_adapters.UserAppScreenGateway;
6+
import entities.chat;
47

58
import java.io.Serializable;
6-
public abstract class User implements Serializable, Changeable {
9+
import java.util.ArrayList;
10+
11+
public abstract class User implements Serializable, Changeable, Login {
712
protected String username;
813
protected String password;
914
protected String email;
15+
16+
protected ArrayList<Chat> userChats;
1017
boolean verified = false;
1118
boolean online = false;
12-
public User(String username, String password, String email){
19+
public User(String username, String password, String email, ArrayList<Chat> userChats){
1320
this.username = username;
1421
this.password = password;
1522
this.email = email;
23+
this.userChats = userChats;
1624
}
1725
public String getEmail(){
1826
return this.email;
@@ -23,6 +31,9 @@ public String getUsername(){
2331
private String getPassword(){
2432
return this.password;
2533
}
34+
public ArrayList<Chat> getUserChats(){
35+
return this.userChats;
36+
}
2637

2738
@Override
2839
// from Changeable
@@ -36,4 +47,8 @@ public void changeFeature(String feature, String newFeature){
3647
}
3748
}
3849

50+
public void login(){
51+
UserAppScreenGateway appScreenGateway = new UserAppScreenGateway(this.getUsername());
52+
}
53+
3954
}

src/main/java/interface_adapters/Chat/ConvHistGateway.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/interface_adapters/Chat/MsgSenderGateway.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main/java/interface_adapters/IRetrieveList.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)