Skip to content

Commit

Permalink
Major Commit: Added required maps for the dropdown list on the Client…
Browse files Browse the repository at this point in the history
… Details and other Employee management pages. Moved the files to appropriate folders.
  • Loading branch information
mahi-mullapudi committed May 16, 2018
1 parent 3f3c132 commit 0bac00f
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 372 deletions.
12 changes: 12 additions & 0 deletions src/main/java/com/tutorialq/constants/ApplicationConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,16 @@ public class ApplicationConstants implements Serializable {
.put("training", "Training")
.build();

public static final Map<String, String> paymentTermsMap = ImmutableMap.<String, String>builder()
.put("net30", "Net 30")
.put("net45", "Net 45")
.put("net60", "Net 60")
.build();

public static final Map<String, String> invoiceFrequencyMap = ImmutableMap.<String, String>builder()
.put("weekly", "Weekly")
.put("biweekly", "Bi-weekly")
.put("monthly", "Monthly")
.build();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@


import com.tutorialq.entities.ClientDetails;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly = true)
public interface ClientDetailsRepository extends CrudRepository<ClientDetails, Long> {
public interface ClientDetailsRepository extends JpaRepository<ClientDetails, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import org.springframework.transaction.annotation.Transactional;

@Transactional(readOnly = true)
public interface ImmigrationDetailsRepository
extends JpaRepository<ImmigrationDetails, Long> {
public interface ImmigrationDetailsRepository extends JpaRepository<ImmigrationDetails, Long> {

}
12 changes: 9 additions & 3 deletions src/main/java/com/tutorialq/services/EmployeeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.tutorialq.entities.Employee;
import com.tutorialq.entities.ImmigrationDetails;

import java.util.Optional;

public interface EmployeeService {

/**
Expand All @@ -30,7 +28,15 @@ public interface EmployeeService {
/**
* Returns ClientDetails object for a given clientDetailsId object.
*/
Optional<ClientDetails> getClientDetails(long clientDetailsId) throws Exception;
ClientDetails getClientDetails(long clientDetailsId) throws Exception;

/**
* Returns ImmigrationDetails object for a given Immigration Details Id.
*
* @return
* @throws Exception
*/
ImmigrationDetails getImmigrationDetails(long immigrationDetailsId) throws Exception;

/**
* Save Client Details.
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/com/tutorialq/services/EmployeeServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
@Slf4j
public class EmployeeServiceImpl implements EmployeeService {
Expand All @@ -35,9 +33,9 @@ public boolean checkIfEmployeeIdExists(String emailAddress) throws Exception {
}

@Override
public Optional<ClientDetails> getClientDetails(long clientDetailsId) throws Exception {
public ClientDetails getClientDetails(long clientDetailsId) throws Exception {
log.info("Inside getClientDetails method of EmployeeServiceImpl:: clientDetailsId: " + clientDetailsId);
return clientRepository.findById(clientDetailsId);
return clientRepository.findById(clientDetailsId).orElse(new ClientDetails());
}

@Override
Expand All @@ -46,12 +44,17 @@ public void saveClientDetails(ClientDetails clientDetails) throws Exception {
clientRepository.save(clientDetails);
}

@Override
public ImmigrationDetails getImmigrationDetails(long immigrationDetailsId) throws Exception {
log.info("Inside the getImmigrationDetails method of EmployeeServiceImpl");
return immigrationRepository.findById(immigrationDetailsId).orElse(new ImmigrationDetails());
}

@Override
public void saveImmigrationDetails(ImmigrationDetails immigrationDetails) throws Exception {
log.info("Inside the saveImmigrationDetails method of EmployeeServiceImpl");
immigrationRepository.save(immigrationDetails);
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public String getClientDetails(@RequestParam("empId") long empId,
log.info("Inside getClientDetails method of EmployeeDetails Controller:: empId: " + empId);
Employee employee = employeeService.getEmployeeByEmployeeId(empId);
model.addAttribute("employeeDetails", employee);
model.addAttribute("clientDetails", employee.getClientDetails());
model.addAttribute("clientDetails", employeeService.getClientDetails(empId));
return "clientDetails";
}

Expand All @@ -112,7 +112,6 @@ public String submitClientDetails(
model.addAttribute("msg", "Invalid / Missing Information. Please correct the information entered below!!");
return "clientDetails";
}
log.info("The form has no errors, so persisting the data.");
try {
log.info("Saving the registration details of the Employee.");
employeeService.saveClientDetails(clientDetails);
Expand Down Expand Up @@ -184,4 +183,14 @@ public Map<String, String> empTypeMap() {
return ApplicationConstants.empTypeMap;
}

@ModelAttribute("paymentTermsMap")
public Map<String, String> paymentTermsMap() {
return ApplicationConstants.paymentTermsMap;
}

@ModelAttribute("invoiceFrequencyMap")
public Map<String, String> invoiceFrequencyMap() {
return ApplicationConstants.invoiceFrequencyMap;
}

}
Loading

0 comments on commit 0bac00f

Please sign in to comment.