From 15252da5199361d2e1b127ec9f0ff38281b0baaa Mon Sep 17 00:00:00 2001 From: Mahidhar Mullapudi Date: Thu, 6 Sep 2018 11:51:40 -0400 Subject: [PATCH] Major Commit: Fixed some minor issues for adding the Role dscription while saving the Registration information for the Staff. - Updated the js files to use the CreatedAt date instead of dateCreated which is being used to display the submitted date for the Timesheet information. --- .../ApplicationSessionConfiguration.java | 2 +- .../com/tutorialq/config/MailingConfig.java | 1 - .../constants/ApplicationConstants.java | 5 ++-- .../tutorialq/models/TimesheetActivity.java | 30 ------------------- .../controllers/RegistrationController.java | 21 +++++++++---- src/main/resources/messages.properties | 4 +-- src/main/resources/static/js/addTimesheet.js | 2 +- .../resources/static/js/dashboard-staff.js | 4 +-- src/main/resources/static/js/dashboard.js | 2 +- 9 files changed, 25 insertions(+), 46 deletions(-) delete mode 100644 src/main/java/com/tutorialq/models/TimesheetActivity.java diff --git a/src/main/java/com/tutorialq/config/ApplicationSessionConfiguration.java b/src/main/java/com/tutorialq/config/ApplicationSessionConfiguration.java index cca3b57..4ddc315 100644 --- a/src/main/java/com/tutorialq/config/ApplicationSessionConfiguration.java +++ b/src/main/java/com/tutorialq/config/ApplicationSessionConfiguration.java @@ -10,6 +10,6 @@ public class ApplicationSessionConfiguration { @Bean public ServletListenerRegistrationBean sessionListener() { - return new ServletListenerRegistrationBean(new SessionListener()); + return new ServletListenerRegistrationBean<>(new SessionListener()); } } \ No newline at end of file diff --git a/src/main/java/com/tutorialq/config/MailingConfig.java b/src/main/java/com/tutorialq/config/MailingConfig.java index 0305fe8..8fbcf12 100644 --- a/src/main/java/com/tutorialq/config/MailingConfig.java +++ b/src/main/java/com/tutorialq/config/MailingConfig.java @@ -6,7 +6,6 @@ import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; -import java.io.IOException; import java.util.Properties; @Configuration diff --git a/src/main/java/com/tutorialq/constants/ApplicationConstants.java b/src/main/java/com/tutorialq/constants/ApplicationConstants.java index 6d701fa..9f957bc 100644 --- a/src/main/java/com/tutorialq/constants/ApplicationConstants.java +++ b/src/main/java/com/tutorialq/constants/ApplicationConstants.java @@ -64,9 +64,9 @@ public class ApplicationConstants implements Serializable { public static final String INIT_VECTOR_RANDOM_KEY = "RandomInitVector"; // 16 bytes IV any random String with 16 characters can be used. - public static final String MAX_UPLOAD_FILE_SIZE = "1000000"; // 5MB file limit. + public static final String MAX_UPLOAD_FILE_SIZE = "1000000"; // 10MB file limit. - public static final String fromAddress = "admin@tutorialq.com"; + public static final String fromAddress = "admin@geeksoft.com"; public static final Map skillMap = ImmutableMap.builder() .put("java", "Java") @@ -76,6 +76,7 @@ public class ApplicationConstants implements Serializable { .put("qa", "Quality Assurance") .put("ba", "Business Analyst") .build(); + public static final Map companyNamesMap = ImmutableMap.builder() .put("geeksoft", "Geeksoft LLC.,") .put("datasols", "DataSols LLC.,") diff --git a/src/main/java/com/tutorialq/models/TimesheetActivity.java b/src/main/java/com/tutorialq/models/TimesheetActivity.java deleted file mode 100644 index 4e6a4b4..0000000 --- a/src/main/java/com/tutorialq/models/TimesheetActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.tutorialq.models; - -import lombok.Data; -import org.springframework.context.annotation.Scope; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.stereotype.Component; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * This class maintains the Activity of time sheet for audit purposes. - */ -@Component -@Scope(value = "prototype") -@Data -public class TimesheetActivity implements Serializable { - - private long timesheetActivityId; - private long timesheetId; - @DateTimeFormat(pattern = "MM/dd/yyyy HH:mm:ss") - private LocalDateTime dateLastModified; - private long nmeLastModified; - private String prevStatus; //This refers to the status of the time sheet before modification. - private String modifiedStatus; //This refers to the status of the time sheet before modification. - - public TimesheetActivity() { - } - -} diff --git a/src/main/java/com/tutorialq/web/controllers/RegistrationController.java b/src/main/java/com/tutorialq/web/controllers/RegistrationController.java index a35902c..e5cba54 100644 --- a/src/main/java/com/tutorialq/web/controllers/RegistrationController.java +++ b/src/main/java/com/tutorialq/web/controllers/RegistrationController.java @@ -52,8 +52,8 @@ public class RegistrationController { public ModelAndView getRegistration() { log.info("Inside getRegistration method of Registration Controller."); Employee employeeRegistration = new Employee(); - employeeRegistration.setEmployeeRoleId(100); - employeeRegistration.setEmployeeRoleDesc("EMPLOYEE"); + employeeRegistration.setEmployeeRoleId(ApplicationConstants.USER_ROLE_EMPLOYEE_ID); + employeeRegistration.setEmployeeRoleDesc(ApplicationConstants.USER_ROLE_EMPLOYEE); log.info("Completed setting required parameter values."); //Initiating ModelAndView object with the Employee object return new ModelAndView("registration", "employee", employeeRegistration); @@ -62,11 +62,7 @@ public ModelAndView getRegistration() { @GetMapping("/staffRegistration") public ModelAndView getStaffRegistration(ModelMap modelMap) { log.info("Inside getStaffRegistration method of Registration Controller."); - Map roleIdDescMap = new TreeMap<>(); - roleIdDescMap.put(ApplicationConstants.USER_ROLE_SUPERVISOR_ID, ApplicationConstants.USER_ROLE_SUPERVISOR); - roleIdDescMap.put(ApplicationConstants.USER_ROLE_ADMIN_ID, ApplicationConstants.USER_ROLE_ADMIN); - modelMap.addAttribute("roleIdDescMap", roleIdDescMap); modelMap.addAttribute("employee", new Employee()); //Initiating ModelAndView object with the Employee object return new ModelAndView("registration-staff", modelMap); @@ -87,6 +83,10 @@ public ModelAndView submitRegistration(@ModelAttribute("employee") Employee empl try { employeeRegistration.setAccountStatusFlag(ApplicationConstants.REGISTRATION_STATUS_ACTIVE); employeeRegistration.setNameCreated(employeeRegistration.getEmployeeFullName()); + if (employeeRegistration.getEmployeeRoleId() != ApplicationConstants.USER_ROLE_EMPLOYEE_ID) { + Map roleDescMap = getRoleDescMap(); + employeeRegistration.setEmployeeRoleDesc(roleDescMap.get(employeeRegistration.getEmployeeRoleId())); + } log.info("Saving the registration details of the Employee."); registrationService.saveRegistrationDetails(employeeRegistration); emailService.sendPlainTextMailWithoutAttachment(ApplicationConstants.fromAddress, employeeRegistration.getEmployeeEmailId(), @@ -292,6 +292,15 @@ public ModelAndView updatePassword(@ModelAttribute("employee") Employee employee } + @ModelAttribute("roleIdDescMap") + public Map getRoleDescMap() { + Map roleIdDescMap = new TreeMap<>(); + roleIdDescMap.put(ApplicationConstants.USER_ROLE_SUPERVISOR_ID, ApplicationConstants.USER_ROLE_SUPERVISOR); + roleIdDescMap.put(ApplicationConstants.USER_ROLE_ADMIN_ID, ApplicationConstants.USER_ROLE_ADMIN); + + return roleIdDescMap; + } + } diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index fbd7b2c..cc3ef05 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -17,8 +17,8 @@ NotValid.registration.phoneNum=Please enter a 10 digit valid Phone Number. Duplicate.registration.email=An account exists for this EmailId. Please login using this Email Id or use a different Email for Registration. Error.checking.registration.email=An unexpected error occurred while checking for EmailId. Please contact Admin to resolve the issue. ###ClientDetails page Validation Messages ### -NotEmpty.clientDetails.clientName=Please enter Client Name. -NotEmpty.clientDetails.clientAddress=Please enter Client Address. +NotEmpty.clientDetails.clientName=Please enter Client Name. +NotEmpty.clientDetails.clientAddress=Please enter Client Address. NotEmpty.clientDetails.clientCity=Please enter Client City. NotEmpty.clientDetails.clientState=Please enter Client State. NotEmpty.clientDetails.confirm.clientZip=Please enter Client Zip. diff --git a/src/main/resources/static/js/addTimesheet.js b/src/main/resources/static/js/addTimesheet.js index 24a98e4..7c58621 100644 --- a/src/main/resources/static/js/addTimesheet.js +++ b/src/main/resources/static/js/addTimesheet.js @@ -38,7 +38,7 @@ function populateTimesheetInfo(timesheetObj) { //Populate the HTML information. $('#timesheetStatus').html(timesheetObj.timesheetStatus != null ? timesheetObj.timesheetStatus : ''); $('#submitterName').html(timesheetObj.nameCreated !== null ? timesheetObj.nameCreated : ''); - $('#submittedDate').html(timesheetObj.dateCreated !== null ? moment(timesheetObj.dateCreated).format("MM/DD/YYYY hh:mm a") : ''); + $('#submittedDate').html(timesheetObj.createdAt !== null ? moment(timesheetObj.createdAt).format("MM/DD/YYYY hh:mm a") : ''); $('#approverName').html(timesheetObj.nameApproved !== null ? timesheetObj.nameApproved : ''); $('#approvalDate').html(timesheetObj.dateApproved !== null ? moment(timesheetObj.dateApproved).format("MM/DD/YYYY hh:mm a") : ''); //Populate the input values. diff --git a/src/main/resources/static/js/dashboard-staff.js b/src/main/resources/static/js/dashboard-staff.js index 774f02d..d460087 100644 --- a/src/main/resources/static/js/dashboard-staff.js +++ b/src/main/resources/static/js/dashboard-staff.js @@ -120,8 +120,8 @@ function populateViewTimesheet(timesheetObj, confirmMessageFlag) { $('#extraHours').html(timesheetObj.extraHours != null ? timesheetObj.extraHours : 0.0); $('#totalHours').html(timesheetObj.regularHours + timesheetObj.extraHours); $('#submitterName').html(timesheetObj.nameCreated); - $('#submittedDate').html(timesheetObj.dateCreated != null ? - moment(timesheetObj.dateCreated).format("MM/DD/YYYY hh:mm a") : ''); + $('#submittedDate').html(timesheetObj.createdAt != null ? + moment(timesheetObj.createdAt).format("MM/DD/YYYY hh:mm a") : ''); $('#approvalDate').html(timesheetObj.dateApproved != null ? moment(timesheetObj.dateApproved).format("MM/DD/YYYY hh:mm a") : ''); $('#timesheetComments').html(timesheetObj.dscComments); diff --git a/src/main/resources/static/js/dashboard.js b/src/main/resources/static/js/dashboard.js index 234c74e..a4e76af 100644 --- a/src/main/resources/static/js/dashboard.js +++ b/src/main/resources/static/js/dashboard.js @@ -101,7 +101,7 @@ function populateViewTimesheet(timesheetObj) { $('#extraHours').html(timesheetObj.extraHours); $('#totalHours').html(timesheetObj.regularHours + timesheetObj.extraHours); $('#submitterName').html(timesheetObj.nameCreated); - $('#submittedDate').html(timesheetObj.dateCreated != null ? moment(timesheetObj.dateCreated).format("MM/DD/YYYY hh:mm a") : ''); + $('#submittedDate').html(timesheetObj.createdAt != null ? moment(timesheetObj.createdAt).format("MM/DD/YYYY hh:mm a") : ''); $('#approvalDate').html(timesheetObj.dateApproved != null ? moment(timesheetObj.dateApproved).format("MM/DD/YYYY hh:mm a") : ''); $('#timesheetComments').html(timesheetObj.dscComments); $('#uploadedTimesheetName').html(timesheetObj.dscFileName);