-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive Refactoring, implemented Login Use case according to the MVP …
…pattern
- Loading branch information
Showing
19 changed files
with
242 additions
and
74 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/interface_adapters/login_interface_adapters/UserChatsPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package interface_adapters.login_interface_adapters; | ||
|
||
import use_cases.user_login_use_cases.UserLoginOutputBoundary; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class UserChatsPresenter implements UserLoginOutputBoundary { | ||
private List<String> chats; | ||
private boolean notExists; | ||
private boolean notMatched; | ||
private String username; | ||
|
||
public UserChatsPresenter(){ | ||
this.chats = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
@Override | ||
public void setChats(List<String> chats) { | ||
this.chats = chats; | ||
} | ||
public List<String> getChats(){ | ||
return this.chats; | ||
} | ||
|
||
@Override | ||
public void setUserNotExists(boolean notExists) { | ||
this.notExists = notExists; | ||
} | ||
|
||
public boolean isNotExists() { | ||
return notExists; | ||
} | ||
|
||
@Override | ||
public void setPasswordNotMatched(boolean notMatched) { | ||
this.notMatched = notMatched; | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return this.username; | ||
} | ||
|
||
public boolean isNotMatched() { | ||
return notMatched; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/interface_adapters/login_interface_adapters/UserLoginPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package interface_adapters.login_interface_adapters; | ||
|
||
import data_access.Database; | ||
import use_cases.user_login_use_cases.UserLoginInputBoundary; | ||
|
||
public class UserLoginPresenter { | ||
private final UserLoginInputBoundary loginGuard; | ||
private String username; | ||
private String password; | ||
Database database; | ||
private UserLoginViewI loginView; | ||
|
||
public UserLoginPresenter(Database database, UserLoginInputBoundary loginGuard){ | ||
this.database = database; | ||
this.loginGuard = loginGuard; | ||
} | ||
|
||
public void tryLogin() { | ||
loginGuard.login(this.username, this.password); | ||
loginView.setChatsPresenter(loginGuard.getChatsPresenter()); | ||
loginView.display(); | ||
} | ||
|
||
public void setLoginCredentials(String username, String password) { | ||
this.username = username; | ||
this.password = password; | ||
} | ||
public void setLoginView(UserLoginViewI loginView){ | ||
this.loginView = loginView; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/interface_adapters/login_interface_adapters/UserLoginViewI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package interface_adapters.login_interface_adapters; | ||
|
||
import use_cases.user_login_use_cases.UserLoginOutputBoundary; | ||
|
||
public interface UserLoginViewI { | ||
void display(); | ||
void setChatsPresenter(UserLoginOutputBoundary outputBoundary); | ||
} |
4 changes: 2 additions & 2 deletions
4
...n_use_cases/UserExistsOutputBoundary.java → ...erface_adapters/UserExistsOutputView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...a/interface_adapters/user_registration_interface_adapters/UserVerificationOutputView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package interface_adapters.user_registration_interface_adapters; | ||
|
||
public interface UserVerificationOutputView { | ||
void getLoginCredentials(); | ||
void cannotVerify(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...se_cases/userRegCredentialsRetriever.java → ...adapters/userRegCredentialsRetriever.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package screens.login_screen; | ||
import interface_adapters.login_interface_adapters.UserLoginViewI; | ||
import screens.appscreen.AppScreen; | ||
import use_cases.user_login_use_cases.UserLoginOutputBoundary; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class AppScreenCreator implements UserLoginViewI { | ||
private String username ; | ||
private ArrayList<String> chats; | ||
private boolean userNotExists; | ||
private boolean passNotMatched; | ||
AppScreen appScreen; | ||
public AppScreenCreator(){ | ||
} | ||
@Override | ||
public void display() { | ||
if(userNotExists|| passNotMatched){ | ||
showUnableToLogin(); | ||
}else{ | ||
/*this.appScreen = new AppScreen(username, chats);*/ | ||
System.out.println(username); | ||
} | ||
} | ||
|
||
private void showUnableToLogin() { | ||
System.out.println("unable to login"); | ||
} | ||
@Override | ||
public void setChatsPresenter(UserLoginOutputBoundary chatsPresenter){ | ||
this.username = chatsPresenter.getUsername(); | ||
this.chats = (ArrayList<String>) chatsPresenter.getChats(); | ||
this.userNotExists = chatsPresenter.isNotExists(); | ||
this.passNotMatched = chatsPresenter.isNotMatched(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/main/java/use_cases/user_login_use_cases/UserLoginInputBoundary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package use_cases.user_login_use_cases; | ||
|
||
public interface UserLoginInputBoundary { | ||
void tryLogin(); | ||
void login(String username, String password); | ||
|
||
UserLoginOutputBoundary getChatsPresenter(); | ||
|
||
void setLoginCredentials(String username, String password); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/use_cases/user_login_use_cases/UserLoginInteractor2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package use_cases.user_login_use_cases; | ||
|
||
import data_access.Database; | ||
import entities.user_entities.User; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class UserLoginInteractor2 implements UserLoginInputBoundary { | ||
private final UserLoginOutputBoundary chatPresenter; | ||
private final Database database; | ||
|
||
private User user; | ||
|
||
public UserLoginInteractor2(Database database, UserLoginOutputBoundary chatPresenter){ | ||
this.database = database; | ||
this.chatPresenter = chatPresenter; | ||
} | ||
|
||
@Override | ||
public void login(String username, String password) { | ||
//will update this.chatPresenter | ||
//TODO: change below, as its just temporary | ||
chatPresenter.setChats(new ArrayList<>()); | ||
chatPresenter.setUsername(username); | ||
chatPresenter.setUserNotExists(false); | ||
chatPresenter.setPasswordNotMatched(false); | ||
|
||
} | ||
|
||
@Override | ||
public UserLoginOutputBoundary getChatsPresenter() { | ||
return this.chatPresenter; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/use_cases/user_login_use_cases/UserLoginOutputBoundary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package use_cases.user_login_use_cases; | ||
|
||
import java.util.List; | ||
|
||
public interface UserLoginOutputBoundary { | ||
void setUsername(String username); | ||
void setChats(List<String> chats); | ||
void setUserNotExists(boolean notExists); | ||
void setPasswordNotMatched(boolean notMatched); | ||
|
||
String getUsername(); | ||
List<String> getChats(); | ||
boolean isNotExists(); | ||
boolean isNotMatched(); | ||
} |
36 changes: 0 additions & 36 deletions
36
src/main/java/use_cases/user_login_use_cases/UserLoginPresenter.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.