1 | package edu.ucsb.cs156.frontiers.startup; | |
2 | ||
3 | import edu.ucsb.cs156.frontiers.entities.Admin; | |
4 | import edu.ucsb.cs156.frontiers.repositories.AdminRepository; | |
5 | import lombok.extern.slf4j.Slf4j; | |
6 | import org.springframework.beans.factory.annotation.Value; | |
7 | import org.springframework.stereotype.Component; | |
8 | import org.springframework.beans.factory.annotation.Autowired; | |
9 | ||
10 | @Slf4j | |
11 | @Component | |
12 | public class FrontiersStartup { | |
13 | ||
14 | @Autowired | |
15 | private AdminRepository adminRepository; | |
16 | ||
17 | @Value("${admin.emails:}") | |
18 | private String adminEmails; | |
19 | ||
20 | public void alwaysRunOnStartup() { | |
21 | log.info("FrontiersStartup.alwaysRunOnStartup called"); | |
22 | ||
23 | String[] emails = adminEmails.split(","); | |
24 | for (String email : emails) { | |
25 | email = email.trim(); | |
26 |
1
1. alwaysRunOnStartup : negated conditional → KILLED |
if (!email.isEmpty()) { |
27 |
1
1. alwaysRunOnStartup : negated conditional → KILLED |
if (adminRepository.findById(email).isEmpty()) { |
28 | adminRepository.save(Admin.builder().email(email).build()); | |
29 | log.info("Added admin: " + email); | |
30 | } else { | |
31 | log.info("Admin already exists: " + email); | |
32 | } | |
33 | } | |
34 | } | |
35 | } | |
36 | } | |
Mutations | ||
26 |
1.1 |
|
27 |
1.1 |