-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ remove isWritableInterface from user, since it's not needed anymore.
- Loading branch information
1 parent
a4cbd82
commit e687228
Showing
27 changed files
with
171 additions
and
232 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
...va/ch/puzzle/okr/OkrChampionListener.java → ...tener/OkrChampionApplicationListener.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,33 +1,33 @@ | ||
package ch.puzzle.okr; | ||
package ch.puzzle.okr.applicationlistener; | ||
|
||
import ch.puzzle.okr.repository.UserRepository; | ||
import ch.puzzle.okr.service.persistence.UserPersistenceService; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.ApplicationListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class OkrChampionListener implements ApplicationListener<ApplicationReadyEvent> { | ||
public class OkrChampionApplicationListener implements ApplicationListener<ApplicationReadyEvent> { | ||
|
||
private static final String DELIMITER = ","; | ||
|
||
@Value("${okr.user.champion.emails}") | ||
private String okrChampionEmails; | ||
|
||
private final UserRepository userRepository; | ||
private final UserPersistenceService userPersistenceService; | ||
|
||
public OkrChampionListener(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
public OkrChampionApplicationListener(UserPersistenceService userPersistenceService) { | ||
this.userPersistenceService = userPersistenceService; | ||
} | ||
|
||
@Override | ||
public void onApplicationEvent(ApplicationReadyEvent event) { | ||
String[] championMails = okrChampionEmails.split(DELIMITER); | ||
for (var mail : championMails) { | ||
var user = userRepository.findByEmail(mail) | ||
var user = userPersistenceService.findByEmail(mail.trim()) | ||
.orElseThrow(() -> new RuntimeException("User not found by champion e-mail: " + mail)); | ||
user.setOkrChampion(true); | ||
userRepository.save(user); | ||
userPersistenceService.save(user); | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.