Commit f30949f1 authored by NISUM's avatar NISUM

Provided error codes for resource allocation

parent 74aff0b5
......@@ -52,7 +52,7 @@ public class ResourceAllocationController {
if (!resourceAllocService.isResourceAssignedToAnyProject(resourceAllocationReq)) {
ResourceAllocation resourcePersisted = resourceAllocService.addResourceAllocation(resourceAllocationReq, loginEmpId);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 601, "Resource has been created",
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 800, "Resource has been created",
"Resource description", null, request.getContextPath(), "details", resourcePersisted);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
......@@ -61,12 +61,12 @@ public class ResourceAllocationController {
}
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, resourceAllocService.respMap.get("message").toString(),
ResponseDetails responseDetails = new ResponseDetails(new Date(), resourceAllocService.respMap.get("statusCode").toString(), resourceAllocService.respMap.get("message").toString(),
"Error message desc", null, request.getRequestURI(), "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Employee Id",
ResponseDetails responseDetails = new ResponseDetails(new Date(), 820, "Please provide the valid Employee Id",
"Employee Id is not valid", null, request.getRequestURI(), "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
......@@ -85,11 +85,11 @@ public class ResourceAllocationController {
resourceAllocService.updateResource(resourceAllocationReq, loginEmpId);
}
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 601, resourceAllocService.respMap.get("message").toString(),
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), resourceAllocService.respMap.get("statusCode").toString(), resourceAllocService.respMap.get("message").toString(),
"Resource description", null, request.getContextPath(), "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Employee Id",
ResponseDetails responseDetails = new ResponseDetails(new Date(), 820, "Please provide the valid Employee Id",
"Employee Id is not valid", null, request.getRequestURI(), "Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
......
......@@ -59,6 +59,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
isExists = true;
}
respMap.put("statusCode", 810);
respMap.put("message", "Resource Not Found");
return isExists;
}
......@@ -68,6 +69,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
if (resourceAlloc != null) {
ResourceAllocation resourcePers = resourceAllocationRepo.save(resourceAlloc);
respMap.put("statusCode", 801);
respMap.put("message", "resource has been updated");
respMap.put("resourceObj", resourcePers);
......@@ -104,12 +106,14 @@ public class ResourceAllocationService implements IResourceAllocationService {
if (!resourceAllocation.getBillingStartDate().after(project.getProjectStartDate())) {
log.info("Billing start date should be after Project start date");
respMap.put("statusCode", 811);
respMap.put("message", "Billing start date should be after Project start date");
isValid = false;
}
if (!resourceAllocation.getBillingStartDate().before(resourceAllocation.getBillingEndDate())) {
log.info("Billing start date should be before Billing End Date.");
respMap.put("statusCode", 812);
respMap.put("message", "Billing start date should be before Billing End Date.");
isValid = false;
}
......@@ -118,6 +122,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())) {
log.info("Billing end date should be before Project End Date.");
respMap.put("statusCode", 813);
respMap.put("message", "Billing end date should be before Project End Date.");
isValid = false;
}
......@@ -138,6 +143,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
+ projectService.getProjectByProjectId(resource.getProjectId()).getProjectName()
+ " project should not be before Date of Joining ( " + empDoj + ").";
isValid = false;
respMap.put("statusCode", 814);
respMap.put("message", message);
}
return isValid;
......@@ -160,6 +166,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
+ projectService.getProjectByProjectId(resourceAllocPrev.getProjectId()).getProjectName()
+ " Project" + " from " + resourceAllocPrev.getBillingStartDate() + "to " + resourceAllocPrev.getBillingEndDate();
isAssigned = true;
respMap.put("statusCode", 815);
respMap.put("message", message);
}
return isAssigned;
......@@ -168,6 +175,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
public void updateResource(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException {
ResourceAllocation resourceAllocationPers = resourceAllocationRepo.save(resourceAllocReq);
respMap.put("statusCode", 801;
respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourceAllocationPers);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment