-
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.
* adding qa env * activate debug logging for qa build * enable full debug for qa deploy * enable full debug - bugfix * pom change to qa * bugfix - qa pom * adding qa profile * bugfix- for qa * frontend build script * test google-code-formatter for Java * applying google Java code formatter Co-authored-by: RichardYang_2016 <[email protected]> * Casts list printing function (#91) * linted and printing functions * printer button icon * adding segment ts declaration * change print casts autosave * restore formatting in perf-editor template * delete local vscode setting file * relint ts changes * restore lint Co-authored-by: RichardYang_2016 <[email protected]> * Replace lodash with higher order funcs (#93) * linted and printing functions * printer button icon * adding segment ts declaration * change print casts autosave * restore formatting in perf-editor template * delete local vscode setting file * relint ts changes * restore lint * replace lodash with higherorder funcs * separate performace segments as a standalone type Co-authored-by: RichardYang_2016 <[email protected]> * Fix types (#94) * bugfix - printing casts (#96) Co-authored-by: RichardYang_2016 <[email protected]> * Remove cache service, it's not used. (#95) * Remove dead code, including unused parameters as part of enabling noUnusedParameters tsconfig safety check. (#92) * New full name pipe (#90) * added fullName pipe * hook up fullName pipe * fixed display problem * Update user-editor.component.ts * Review fixes * More review fixes * Update cloudbuild.unit_tests.yaml (#99) Codecov will not be able to access repos under google-intern. Thus we will not upload the coverage information to codecov. * make dashboard columns a little wider (#97) * make dashboard columns a little wider * changing quote type Co-authored-by: RichardYang_2016 <[email protected]> * add print footer (#100) * add print footer * adding banner Co-authored-by: RichardYang_2016 <[email protected]> * fix backend test errors (#101) * fix backend test errors * Update User.java * fix karma/npm script issue (#103) * fix karma/npm script issue * remove headless chromium from browser options * clear trailing space Co-authored-by: RichardYang_2016 <[email protected]> * Fix karma script (#104) * fix karma/npm script issue * remove headless chromium from browser options * clear trailing space * fix the same for code coverage step Co-authored-by: RichardYang_2016 <[email protected]> Co-authored-by: RichardYang_2016 <[email protected]> Co-authored-by: Mikhail Zaturenskiy <[email protected]> Co-authored-by: yhedholm <[email protected]> Co-authored-by: zephyr-l <[email protected]>
- Loading branch information
1 parent
f687164
commit f94811c
Showing
78 changed files
with
1,488 additions
and
930 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ backend/.settings/* | |
backend/.classpath | ||
backend/.factorypath | ||
.idea | ||
frontend/rolecall/.vscode/settings.json |
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 |
---|---|---|
|
@@ -3,15 +3,13 @@ | |
import com.google.rolecall.models.User; | ||
import com.google.rolecall.repos.UserRepository; | ||
import com.google.rolecall.restcontrollers.exceptionhandling.RequestExceptions.InvalidParameterException; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Locale; | ||
import java.util.Optional; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.ApplicationArguments; | ||
import org.springframework.boot.ApplicationRunner; | ||
|
@@ -24,123 +22,130 @@ | |
public class ApplicationLoader implements ApplicationRunner { | ||
|
||
private Logger logger = Logger.getLogger(ApplicationLoader.class.getName()); | ||
|
||
private final Environment environment; | ||
private final UserRepository userRepo; | ||
private String adminFirstName; | ||
private String adminLastName; | ||
private String adminEmail; | ||
|
||
@Profile({"dev","prod"}) | ||
@Profile({"dev", "prod", "qa"}) | ||
@Override | ||
public void run(ApplicationArguments args) throws Exception { | ||
// Initialize admin if exists, or create one with given information. | ||
adminFirstName = environment.getProperty("admin.first.name"); | ||
adminLastName = environment.getProperty("admin.last.name"); | ||
adminEmail = environment.getProperty("admin.email"); | ||
|
||
Optional<User> possibleAdmin = userRepo.findByEmailIgnoreCase(adminEmail); | ||
|
||
possibleAdmin.ifPresentOrElse(this::adminExists, this::createAdmin); | ||
} | ||
|
||
private void adminExists(User user) { | ||
logger.log(Level.INFO, String.format("Admin User already exists: %s %s %s", | ||
user.getFirstName(), user.getLastName(), user.getEmail())); | ||
logger.log( | ||
Level.INFO, | ||
String.format( | ||
"Admin User already exists: %s %s %s", | ||
user.getFirstName(), user.getLastName(), user.getEmail())); | ||
} | ||
|
||
private void createAdmin() { | ||
User admin; | ||
try { | ||
admin = User.newBuilder() | ||
.setFirstName(adminFirstName) | ||
.setMiddleName("") | ||
.setLastName(adminLastName) | ||
.setSuffix("") | ||
.setEmail(adminEmail) | ||
.setIsActive(true) | ||
.setCanLogin(true) | ||
.setIsAdmin(true) | ||
.build(); | ||
} catch(InvalidParameterException e) { | ||
admin = | ||
User.newBuilder() | ||
.setFirstName(adminFirstName) | ||
.setMiddleName("") | ||
.setLastName(adminLastName) | ||
.setSuffix("") | ||
.setEmail(adminEmail) | ||
.setIsActive(true) | ||
.setCanLogin(true) | ||
.setIsAdmin(true) | ||
.build(); | ||
} catch (InvalidParameterException e) { | ||
logger.log(Level.SEVERE, "Unable to Create admin. Insufficient Properties."); | ||
return; | ||
} | ||
userRepo.save(admin); | ||
logger.log(Level.WARNING, String.format("Admin User Created: %s %s %s", | ||
adminFirstName, adminLastName, adminEmail)); | ||
if(DataCreateError.OK != createTestData()) { | ||
logger.log( | ||
Level.WARNING, | ||
String.format("Admin User Created: %s %s %s", adminFirstName, adminLastName, adminEmail)); | ||
if (DataCreateError.OK != createTestData()) { | ||
logger.log(Level.SEVERE, "Unable to Create Sample Data"); | ||
} | ||
} | ||
|
||
// TODO: Remove the sameple data creation once the customer is up and running. | ||
|
||
// Create sample data | ||
|
||
private enum DataCreateError { | ||
OK, | ||
OtherError | ||
} | ||
|
||
private void createOneUser(String fName, String mName, String lName, String suffix, | ||
String email, String dateJoined) throws ParseException, InvalidParameterException { | ||
private void createOneUser( | ||
String fName, String mName, String lName, String suffix, String email, String dateJoined) | ||
throws ParseException, InvalidParameterException { | ||
Calendar cal = Calendar.getInstance(); | ||
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US); | ||
User user; | ||
|
||
cal.setTime(sdf.parse(dateJoined)); | ||
|
||
user = User.newBuilder() | ||
.setFirstName(fName) | ||
.setMiddleName(mName) | ||
.setLastName(lName) | ||
.setSuffix(suffix) | ||
.setEmail(email) | ||
.setDateJoined(cal) | ||
.setIsActive(true) | ||
.setCanLogin(true) | ||
.setIsDancer(true) | ||
.build(); | ||
userRepo.save(user); | ||
cal.setTime(sdf.parse(dateJoined)); | ||
|
||
user = | ||
User.newBuilder() | ||
.setFirstName(fName) | ||
.setMiddleName(mName) | ||
.setLastName(lName) | ||
.setSuffix(suffix) | ||
.setEmail(email) | ||
.setDateJoined(cal) | ||
.setIsActive(true) | ||
.setCanLogin(true) | ||
.setIsDancer(true) | ||
.build(); | ||
userRepo.save(user); | ||
} | ||
|
||
private DataCreateError createTestData() { | ||
logger.log(Level.WARNING, "Creating test data."); | ||
logger.log(Level.WARNING, "Creating test data."); | ||
try { | ||
createOneUser("Jeroboam", "", "Bozeman", "", "[email protected]","1/1/2020"); | ||
createOneUser("Khalia", "", "Campbell", "", "[email protected]","1/1/2020"); | ||
createOneUser("Patrick", "", "Coker", "", "[email protected]","1/1/2020"); | ||
createOneUser("Sarah", "", "Daley", "", "[email protected]","1/1/2020"); | ||
createOneUser("Ghrai", "", "Devore", "", "[email protected]","1/1/2020"); | ||
createOneUser("Solomon", "", "Dumas", "", "[email protected]","1/1/2020"); | ||
createOneUser("Samantha", "", "Figgins", "", "[email protected]","1/1/2020"); | ||
|
||
createOneUser("James", "", "Gilmer", "", "[email protected]","1/1/2020"); | ||
createOneUser("Vernard", "", "Gilmore", "", "[email protected]","1/1/2020"); | ||
createOneUser("Jacqueline", "", "Green", "", "[email protected]","1/1/2020"); | ||
createOneUser("Jacquelin", "", "Harris", "", "[email protected]","1/1/2020"); | ||
createOneUser("Michael", "", "Jackson", " Jr.", "[email protected]","1/1/2020"); | ||
createOneUser("Yazzmeen", "", "Laidler", "", "[email protected]","1/1/2020"); | ||
createOneUser("Yannick", "", "Lebrun", "", "[email protected]","1/1/2020"); | ||
createOneUser("Constance", "Stamatiou", "Lopez", "", "[email protected]","1/1/2020"); | ||
createOneUser("Renaldo", "", "Maurice", "", "[email protected]","1/1/2020"); | ||
createOneUser("Corrin", "Rachelle", "Mitchell", "", "[email protected]","1/1/2020"); | ||
|
||
createOneUser("Chalvar", "", "Monteiro", "", "[email protected]","1/1/2020"); | ||
createOneUser("Belen", "", "Pereyra", "", "[email protected]","1/1/2020"); | ||
createOneUser("Jessica", "Amber", "Pinkett", "", "[email protected]","1/1/2020"); | ||
createOneUser("Miranda", "", "Quinn", "", "[email protected]","1/1/2020"); | ||
createOneUser("Jamar", "", "Roberts", "", "[email protected]","1/1/2020"); | ||
createOneUser("Kanji", "", "Segawa", "", "[email protected]","1/1/2020"); | ||
createOneUser("Courtney", "Celeste", "Spears", "", "[email protected]","1/1/2020"); | ||
createOneUser("Jermaine", "", "Terry", "", "[email protected]","1/1/2020"); | ||
createOneUser("Christopher", "", "Wilson", "", "[email protected]","1/1/2020"); | ||
|
||
createOneUser("Brandon", "", "Woolridge", "", "[email protected]","1/1/2020"); | ||
} catch(InvalidParameterException e) { | ||
createOneUser("Jeroboam", "", "Bozeman", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Khalia", "", "Campbell", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Patrick", "", "Coker", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Sarah", "", "Daley", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Ghrai", "", "Devore", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Solomon", "", "Dumas", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Samantha", "", "Figgins", "", "[email protected]", "1/1/2020"); | ||
|
||
createOneUser("James", "", "Gilmer", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Vernard", "", "Gilmore", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Jacqueline", "", "Green", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Jacquelin", "", "Harris", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Michael", "", "Jackson", " Jr.", "[email protected]", "1/1/2020"); | ||
createOneUser("Yazzmeen", "", "Laidler", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Yannick", "", "Lebrun", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Constance", "Stamatiou", "Lopez", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Renaldo", "", "Maurice", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Corrin", "Rachelle", "Mitchell", "", "[email protected]", "1/1/2020"); | ||
|
||
createOneUser("Chalvar", "", "Monteiro", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Belen", "", "Pereyra", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Jessica", "Amber", "Pinkett", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Miranda", "", "Quinn", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Jamar", "", "Roberts", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Kanji", "", "Segawa", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Courtney", "Celeste", "Spears", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Jermaine", "", "Terry", "", "[email protected]", "1/1/2020"); | ||
createOneUser("Christopher", "", "Wilson", "", "[email protected]", "1/1/2020"); | ||
|
||
createOneUser("Brandon", "", "Woolridge", "", "[email protected]", "1/1/2020"); | ||
} catch (InvalidParameterException e) { | ||
return DataCreateError.OtherError; | ||
} catch(ParseException e) { | ||
} catch (ParseException e) { | ||
return DataCreateError.OtherError; | ||
} | ||
return DataCreateError.OK; | ||
|
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.