-
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.
Merge pull request #21 from zireline/get-all-user
Get all user
- Loading branch information
Showing
6 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/splitscale/shield/credential/read/ReadAllCredentialInteractor.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,19 @@ | ||
package com.splitscale.shield.credential.read; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import com.splitscale.shield.credential.Credential; | ||
import com.splitscale.shield.repositories.CredentialRepository; | ||
|
||
public class ReadAllCredentialInteractor { | ||
private CredentialRepository repository; | ||
|
||
public ReadAllCredentialInteractor(CredentialRepository repository) { | ||
this.repository = repository; | ||
} | ||
|
||
public List<Credential> getAllCredentials() throws IOException { | ||
return repository.getAll(); | ||
} | ||
} |
33 changes: 31 additions & 2 deletions
33
src/main/java/com/splitscale/shield/workflows/updateuserinfo/GetAllUserInfoWorkflow.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,22 +1,51 @@ | ||
package com.splitscale.shield.workflows.updateuserinfo; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.splitscale.shield.credential.Credential; | ||
import com.splitscale.shield.credential.read.ReadAllCredentialInteractor; | ||
import com.splitscale.shield.userinfo.UserInfo; | ||
import com.splitscale.shield.userinfo.getall.GetAllUserInfoInteractor; | ||
|
||
public class GetAllUserInfoWorkflow { | ||
GetAllUserInfoInteractor getAllUserInfoInteractor; | ||
ReadAllCredentialInteractor readAllCredentialInteractor; | ||
|
||
public GetAllUserInfoWorkflow() { | ||
} | ||
|
||
public GetAllUserInfoWorkflow(GetAllUserInfoInteractor getAllUserInfoInteractor) { | ||
public GetAllUserInfoWorkflow(GetAllUserInfoInteractor getAllUserInfoInteractor, | ||
ReadAllCredentialInteractor readAllCredentialInteractor) { | ||
this.getAllUserInfoInteractor = getAllUserInfoInteractor; | ||
this.readAllCredentialInteractor = readAllCredentialInteractor; | ||
} | ||
|
||
public List<UserInfo> getAll() throws IOException { | ||
return getAllUserInfoInteractor.getAll(); | ||
List<UserInfo> userInfos = getAllUserInfoInteractor.getAll(); | ||
List<Credential> credentials = readAllCredentialInteractor.getAllCredentials(); | ||
|
||
for (UserInfo userInfo : userInfos) { | ||
// Find the corresponding Credential for the current UserInfo | ||
Credential credential = findCredentialById(credentials, userInfo.getId()); | ||
|
||
// Update UserInfo with values from Credential | ||
if (credential != null) { | ||
userInfo.setFirstName(credential.getUsername()); | ||
// Update other fields as needed | ||
} | ||
} | ||
|
||
return userInfos; | ||
} | ||
|
||
private Credential findCredentialById(List<Credential> credentials, String userId) { | ||
for (Credential credential : credentials) { | ||
if (userId.matches(credential.getUserId())) { | ||
return credential; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.