From 293f1d84c0f6f8bdfee35109cae9114e4aa5164b Mon Sep 17 00:00:00 2001 From: Tanishi Goyal Date: Wed, 18 Sep 2024 15:58:38 +0530 Subject: [PATCH] Added controller, service layer, validator and enrichment layer for plan employee assignment --- .../main/java/digit/config/Configuration.java | 12 +++ .../java/digit/config/ServiceConstants.java | 5 + .../PlanEmployeeAssignmentRepository.java | 10 ++ .../impl/PlanEmployeeAssignmentImpl.java | 39 ++++++++ .../digit/service/PlanEmployeeService.java | 86 ++++++++++++++++ .../java/digit/service/PlanValidator.java | 13 ++- .../PlanEmployeeAssignmentEnricher.java | 43 ++++++++ .../src/main/java/digit/util/HrmsUtil.java | 58 +++++++++++ .../src/main/java/digit/util/ServiceUtil.java | 27 +++++ .../controllers/PlanEmployeeController.java | 62 ++++++++++++ .../digit/web/models/RequestInfoWrapper.java | 18 ++++ .../digit/web/models/hrms/Assignment.java | 53 ++++++++++ .../web/models/hrms/DeactivationDetails.java | 46 +++++++++ .../web/models/hrms/DepartmentalTest.java | 44 +++++++++ .../models/hrms/EducationalQualification.java | 49 +++++++++ .../java/digit/web/models/hrms/Employee.java | 99 +++++++++++++++++++ .../web/models/hrms/EmployeeDocument.java | 69 +++++++++++++ .../web/models/hrms/EmployeeRequest.java | 36 +++++++ .../web/models/hrms/EmployeeResponse.java | 32 ++++++ .../digit/web/models/hrms/Jurisdiction.java | 49 +++++++++ .../web/models/hrms/ReactivationDetails.java | 47 +++++++++ .../digit/web/models/hrms/ServiceHistory.java | 46 +++++++++ 22 files changed, 938 insertions(+), 5 deletions(-) create mode 100644 health-services/plan-service/src/main/java/digit/repository/PlanEmployeeAssignmentRepository.java create mode 100644 health-services/plan-service/src/main/java/digit/repository/impl/PlanEmployeeAssignmentImpl.java create mode 100644 health-services/plan-service/src/main/java/digit/service/PlanEmployeeService.java create mode 100644 health-services/plan-service/src/main/java/digit/service/enrichment/PlanEmployeeAssignmentEnricher.java create mode 100644 health-services/plan-service/src/main/java/digit/util/HrmsUtil.java create mode 100644 health-services/plan-service/src/main/java/digit/web/controllers/PlanEmployeeController.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/RequestInfoWrapper.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/Assignment.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/DeactivationDetails.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/DepartmentalTest.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/EducationalQualification.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/Employee.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeDocument.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeRequest.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeResponse.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/Jurisdiction.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/ReactivationDetails.java create mode 100644 health-services/plan-service/src/main/java/digit/web/models/hrms/ServiceHistory.java diff --git a/health-services/plan-service/src/main/java/digit/config/Configuration.java b/health-services/plan-service/src/main/java/digit/config/Configuration.java index 7cf4b3549f7..22bc1f4eb07 100644 --- a/health-services/plan-service/src/main/java/digit/config/Configuration.java +++ b/health-services/plan-service/src/main/java/digit/config/Configuration.java @@ -28,6 +28,12 @@ public class Configuration { @Value("${egov.mdms.search.endpoint}") private String mdmsEndPoint; + //HRMS + @Value("${egov.hrms.host}") + private String hrmsHost; + + @Value("${egov.hrms.search.endpoint}") + private String hrmsEndPoint; //Persister Topic @Value("${plan.configuration.create.topic}") @@ -36,6 +42,12 @@ public class Configuration { @Value("${plan.configuration.update.topic}") private String planConfigUpdateTopic; + @Value("${plan.employee.assignment.create.topic}") + private String planEmployeeAssignmentCreateTopic; + + @Value("${plan.employee.assignment.update.topic}") + private String planEmployeeAssignmentUpdateTopic; + @Value("${plan.create.topic}") private String planCreateTopic; diff --git a/health-services/plan-service/src/main/java/digit/config/ServiceConstants.java b/health-services/plan-service/src/main/java/digit/config/ServiceConstants.java index ab694a05961..59754cb8048 100644 --- a/health-services/plan-service/src/main/java/digit/config/ServiceConstants.java +++ b/health-services/plan-service/src/main/java/digit/config/ServiceConstants.java @@ -12,6 +12,8 @@ public class ServiceConstants { public static final String ERROR_WHILE_FETCHING_FROM_MDMS = "Exception occurred while fetching category lists from mdms: "; + public static final String ERROR_WHILE_FETCHING_DATA_FROM_HRMS = "Exception occurred while fetching employee from hrms: "; + public static final String RES_MSG_ID = "uief87324"; public static final String SUCCESSFUL = "successful"; public static final String FAILED = "failed"; @@ -55,6 +57,9 @@ public class ServiceConstants { public static final String NO_MDMS_DATA_FOUND_FOR_GIVEN_TENANT_CODE = "NO_MDMS_DATA_FOUND_FOR_GIVEN_TENANT"; public static final String NO_MDMS_DATA_FOUND_FOR_GIVEN_TENANT_MESSAGE = "Invalid or incorrect TenantId. No mdms data found for provided Tenant."; + public static final String NO_HRMS_DATA_FOUND_FOR_GIVEN_EMPLOYEE_ID_CODE = "NO_HRMS_DATA_FOUND_FOR_GIVEN_EMPLOYEE_ID"; + public static final String NO_HRMS_DATA_FOUND_FOR_GIVEN_EMPLOYEE_ID_MESSAGE = "Invalid or incorrect employee id. No hrms data found for provided employee id."; + public static final String SEARCH_CRITERIA_EMPTY_CODE = "SEARCH_CRITERIA_EMPTY"; public static final String SEARCH_CRITERIA_EMPTY_MESSAGE = "Search criteria cannot be empty"; diff --git a/health-services/plan-service/src/main/java/digit/repository/PlanEmployeeAssignmentRepository.java b/health-services/plan-service/src/main/java/digit/repository/PlanEmployeeAssignmentRepository.java new file mode 100644 index 00000000000..557d010697b --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/repository/PlanEmployeeAssignmentRepository.java @@ -0,0 +1,10 @@ +package digit.repository; + +import digit.web.models.PlanEmployeeAssignmentRequest; + +public interface PlanEmployeeAssignmentRepository { + + public void create(PlanEmployeeAssignmentRequest planEmployeeAssignmentRequest); + + public void update(PlanEmployeeAssignmentRequest planEmployeeAssignmentRequest); +} diff --git a/health-services/plan-service/src/main/java/digit/repository/impl/PlanEmployeeAssignmentImpl.java b/health-services/plan-service/src/main/java/digit/repository/impl/PlanEmployeeAssignmentImpl.java new file mode 100644 index 00000000000..a724c239ab8 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/repository/impl/PlanEmployeeAssignmentImpl.java @@ -0,0 +1,39 @@ +package digit.repository.impl; + +import digit.config.Configuration; +import digit.kafka.Producer; +import digit.repository.PlanEmployeeAssignmentRepository; +import digit.web.models.PlanEmployeeAssignmentRequest; +import org.springframework.stereotype.Repository; + +@Repository +public class PlanEmployeeAssignmentImpl implements PlanEmployeeAssignmentRepository { + + private Producer producer; + + private Configuration config; + + public PlanEmployeeAssignmentImpl(Producer producer, Configuration config) + { + this.producer = producer; + this.config = config; + } + + /** + * Pushes a new plan employee assignment to persister kafka topic. + * @param planEmployeeAssignmentRequest The request containing the plan employee assignment details. + */ + @Override + public void create(PlanEmployeeAssignmentRequest planEmployeeAssignmentRequest) { + producer.push(config.getPlanEmployeeAssignmentCreateTopic(), planEmployeeAssignmentRequest); + } + + /** + * Pushes an updated existing plan employee assignment to persister kafka topic. + * @param planEmployeeAssignmentRequest The request containing the updated plan employee assignment details. + */ + @Override + public void update(PlanEmployeeAssignmentRequest planEmployeeAssignmentRequest) { + producer.push(config.getPlanEmployeeAssignmentUpdateTopic(), planEmployeeAssignmentRequest); + } +} diff --git a/health-services/plan-service/src/main/java/digit/service/PlanEmployeeService.java b/health-services/plan-service/src/main/java/digit/service/PlanEmployeeService.java new file mode 100644 index 00000000000..d0fbb68f108 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/service/PlanEmployeeService.java @@ -0,0 +1,86 @@ +package digit.service; + +import digit.config.Configuration; +import digit.kafka.Producer; +import digit.repository.PlanEmployeeAssignmentRepository; +import digit.service.enrichment.PlanEmployeeAssignmentEnricher; +import digit.service.validator.PlanEmployeeAssignmentValidator; +import digit.util.ResponseInfoFactory; +import digit.web.models.*; +import org.egov.common.utils.ResponseInfoUtil; +import org.springframework.stereotype.Service; + +import java.util.Collections; + +@Service +public class PlanEmployeeService { + + Producer producer; + + Configuration config; + + ResponseInfoFactory responseInfoFactory; + + PlanEmployeeAssignmentRepository repository; + + PlanEmployeeAssignmentEnricher enricher; + + PlanEmployeeAssignmentValidator validator; + + public PlanEmployeeService(Producer producer, Configuration config, ResponseInfoFactory responseInfoFactory, PlanEmployeeAssignmentRepository repository, PlanEmployeeAssignmentEnricher enricher, PlanEmployeeAssignmentValidator validator) + { + this.producer = producer; + this.config = config; + this.responseInfoFactory = responseInfoFactory; + this.repository = repository; + this.enricher = enricher; + this.validator = validator; + } + + /** + * Creates a new plan employee assignment based on the provided request. + * @param request The request containing the plan employee assignment details. + * @return The response containing the created plan employee assignment. + */ + public PlanEmployeeAssignmentResponse create(PlanEmployeeAssignmentRequest request) { + + validator.validateCreate(request); + enricher.enrichCreate(request); + repository.create(request); + + return PlanEmployeeAssignmentResponse.builder() + .planEmployeeAssignment(Collections.singletonList(request.getPlanEmployeeAssignment())) + .responseInfo(responseInfoFactory.createResponseInfoFromRequestInfo(request.getRequestInfo(), Boolean.TRUE)) + .build(); + } + + /** + * Searches for plan employee assignment based on the provided search criteria. + * @param request The search request containing the criteria. + * @return A list of plan employee assignments that matches the search criteria. + */ + public PlanEmployeeAssignmentResponse search(PlanEmployeeAssignmentSearchRequest request) { + + return PlanEmployeeAssignmentResponse.builder(). + responseInfo(responseInfoFactory.createResponseInfoFromRequestInfo(request.getRequestInfo(), Boolean.TRUE)) + .build(); + } + + /** + * Updates an existing plan employee assignment based on the provided request. + * @param request The request containing the updated plan employee assignment details. + * @return The response containing the updated plan employee assignment. + */ + + public PlanEmployeeAssignmentResponse update(PlanEmployeeAssignmentRequest request) { + + validator.validateUpdate(request); + enricher.enrichUpdate(request); + repository.update(request); + + return PlanEmployeeAssignmentResponse.builder() + .responseInfo(ResponseInfoUtil.createResponseInfoFromRequestInfo(request.getRequestInfo(), Boolean.TRUE)) + .planEmployeeAssignment(Collections.singletonList(request.getPlanEmployeeAssignment())) + .build(); + } +} diff --git a/health-services/plan-service/src/main/java/digit/service/PlanValidator.java b/health-services/plan-service/src/main/java/digit/service/PlanValidator.java index 40958a9e0d3..cca38f58e19 100644 --- a/health-services/plan-service/src/main/java/digit/service/PlanValidator.java +++ b/health-services/plan-service/src/main/java/digit/service/PlanValidator.java @@ -4,6 +4,7 @@ import digit.repository.PlanConfigurationRepository; import digit.repository.PlanRepository; import digit.util.MdmsUtil; +import digit.util.ServiceUtil; import digit.web.models.*; import org.egov.common.utils.MultiStateInstanceUtil; import org.egov.tracer.model.CustomException; @@ -27,11 +28,14 @@ public class PlanValidator { private MultiStateInstanceUtil centralInstanceUtil; - public PlanValidator(PlanRepository planRepository, PlanConfigurationRepository planConfigurationRepository, MdmsUtil mdmsUtil, MultiStateInstanceUtil centralInstanceUtil) { + private ServiceUtil serviceUtil; + + public PlanValidator(PlanRepository planRepository, PlanConfigurationRepository planConfigurationRepository, MdmsUtil mdmsUtil, MultiStateInstanceUtil centralInstanceUtil, ServiceUtil serviceUtil) { this.planRepository = planRepository; this.planConfigurationRepository = planConfigurationRepository; this.mdmsUtil = mdmsUtil; this.centralInstanceUtil = centralInstanceUtil; + this.serviceUtil = serviceUtil; } /** @@ -163,10 +167,9 @@ private void validateActivities(PlanRequest request) { */ private void validatePlanConfigurationExistence(PlanRequest request) { // If plan id provided is invalid, throw an exception - if(!ObjectUtils.isEmpty(request.getPlan().getPlanConfigurationId()) && CollectionUtils.isEmpty(planConfigurationRepository.search(PlanConfigurationSearchCriteria.builder() - .id(request.getPlan().getPlanConfigurationId()) - .tenantId(request.getPlan().getTenantId()) - .build()))) { + if(!ObjectUtils.isEmpty(request.getPlan().getPlanConfigurationId()) && + CollectionUtils.isEmpty(serviceUtil.searchPlanConfigId(request.getPlan().getPlanConfigurationId(), request.getPlan().getTenantId()))) + { throw new CustomException(INVALID_PLAN_CONFIG_ID_CODE, INVALID_PLAN_CONFIG_ID_MESSAGE); } } diff --git a/health-services/plan-service/src/main/java/digit/service/enrichment/PlanEmployeeAssignmentEnricher.java b/health-services/plan-service/src/main/java/digit/service/enrichment/PlanEmployeeAssignmentEnricher.java new file mode 100644 index 00000000000..ff716387626 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/service/enrichment/PlanEmployeeAssignmentEnricher.java @@ -0,0 +1,43 @@ +package digit.service.enrichment; + +import digit.web.models.PlanEmployeeAssignment; +import digit.web.models.PlanEmployeeAssignmentRequest; +import org.egov.common.utils.UUIDEnrichmentUtil; +import org.springframework.stereotype.Component; + +import static org.egov.common.utils.AuditDetailsEnrichmentUtil.prepareAuditDetails; + +@Component +public class PlanEmployeeAssignmentEnricher { + + /** + * Enriches the PlanEmployeeAssignmentRequest with id and audit details. + * @param request The PlanEmployeeAssignmentRequest body to be enriched + */ + public void enrichCreate(PlanEmployeeAssignmentRequest request) + { + PlanEmployeeAssignment planEmployeeAssignment = request.getPlanEmployeeAssignment(); + + // Generate id for Plan employee assignment body + UUIDEnrichmentUtil.enrichRandomUuid(planEmployeeAssignment, "id"); + + // Set Audit Details for Plan employee assignment + planEmployeeAssignment.setAuditDetails(prepareAuditDetails(planEmployeeAssignment.getAuditDetails(), + request.getRequestInfo(), + Boolean.TRUE)); + } + + /** + * Enriches the PlanEmployeeAssignmentRequest for updating an existing plan employee assignment with audit details. + * @param request The PlanEmployeeAssignmentRequest body to be enriched + */ + public void enrichUpdate(PlanEmployeeAssignmentRequest request) + { + PlanEmployeeAssignment planEmployeeAssignment = request.getPlanEmployeeAssignment(); + + // Set Audit Details for Plan employee assignment update + planEmployeeAssignment.setAuditDetails(prepareAuditDetails(planEmployeeAssignment.getAuditDetails(), + request.getRequestInfo(), + Boolean.FALSE)); + } +} diff --git a/health-services/plan-service/src/main/java/digit/util/HrmsUtil.java b/health-services/plan-service/src/main/java/digit/util/HrmsUtil.java new file mode 100644 index 00000000000..fac5852a01c --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/util/HrmsUtil.java @@ -0,0 +1,58 @@ +package digit.util; + + +import digit.config.Configuration; +import digit.web.models.hrms.*; +import digit.web.models.RequestInfoWrapper; +import lombok.extern.slf4j.Slf4j; +import org.egov.common.contract.request.RequestInfo; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + + +import java.util.*; + +import static digit.config.ServiceConstants.*; + +@Slf4j +@Component +public class HrmsUtil { + + private RestTemplate restTemplate; + + private Configuration configs; + + private RequestInfoWrapper requestInfoWrapper; + + public HrmsUtil(RestTemplate restTemplate, Configuration configs, RequestInfoWrapper requestInfoWrapper) + { + this.restTemplate = restTemplate; + this.configs = configs; + this.requestInfoWrapper = requestInfoWrapper; + } + + public List fetchHrmsData(RequestInfo requestInfo, String employeeId, String tenantId) { + + StringBuilder uri = new StringBuilder(); + uri.append(configs.getHrmsHost()).append(configs.getHrmsEndPoint()).append("?limit={limit}&tenantId={tenantId}&offset={offset}&ids={employeeId}"); + + Map uriParameters = new HashMap<>(); + uriParameters.put("limit", configs.getDefaultLimit().toString()); + uriParameters.put("tenantId", tenantId); + uriParameters.put("offset", configs.getDefaultOffset().toString()); + uriParameters.put("employeeId", employeeId); + + RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(requestInfo).build(); + EmployeeResponse employeeResponse = new EmployeeResponse(); + + try { + employeeResponse = restTemplate.postForObject(uri.toString(), requestInfoWrapper, EmployeeResponse.class, uriParameters); + } catch (Exception e) { + log.error(ERROR_WHILE_FETCHING_DATA_FROM_HRMS, e); + } + + return employeeResponse.getEmployees(); + } + + +} diff --git a/health-services/plan-service/src/main/java/digit/util/ServiceUtil.java b/health-services/plan-service/src/main/java/digit/util/ServiceUtil.java index 51959990534..373127d63aa 100644 --- a/health-services/plan-service/src/main/java/digit/util/ServiceUtil.java +++ b/health-services/plan-service/src/main/java/digit/util/ServiceUtil.java @@ -1,13 +1,24 @@ package digit.util; +import digit.repository.PlanConfigurationRepository; +import digit.web.models.PlanConfiguration; +import digit.web.models.PlanConfigurationSearchCriteria; import org.springframework.stereotype.Component; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @Component public class ServiceUtil { + private PlanConfigurationRepository planConfigurationRepository; + + public ServiceUtil(PlanConfigurationRepository planConfigurationRepository) + { + this.planConfigurationRepository = planConfigurationRepository; + } + /** * Validates the given input string against the provided regex pattern. * @@ -20,4 +31,20 @@ public Boolean validateStringAgainstRegex(String patternString, String inputStri Matcher matcher = pattern.matcher(inputString); return matcher.matches(); } + + /** + * Searches the plan config based on the plan config id provided + * @param planConfigId the plan config id to validate + * @param tenantId the tenant id of the plan config + * @return list of planConfiguration for the provided plan config id + */ + public List searchPlanConfigId(String planConfigId, String tenantId) + { + List planConfigurations = planConfigurationRepository.search(PlanConfigurationSearchCriteria.builder() + .id(planConfigId) + .tenantId(tenantId) + .build()); + + return planConfigurations; + } } diff --git a/health-services/plan-service/src/main/java/digit/web/controllers/PlanEmployeeController.java b/health-services/plan-service/src/main/java/digit/web/controllers/PlanEmployeeController.java new file mode 100644 index 00000000000..db707f9e872 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/controllers/PlanEmployeeController.java @@ -0,0 +1,62 @@ +package digit.web.controllers; + +import digit.service.PlanEmployeeService; +import digit.web.models.*; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +public class PlanEmployeeController { + + PlanEmployeeService planEmployeeService; + + public PlanEmployeeController(PlanEmployeeService planEmployeeService) + { + this.planEmployeeService = planEmployeeService; + } + + /** + * Request handler for serving plan employee assignment create requests + * @param body + * @return + */ + @RequestMapping(value = "/employee/_create", method = RequestMethod.POST) + public ResponseEntity employeeCreatePost(@Parameter(in = ParameterIn.DEFAULT, description = "", schema = @Schema()) @Valid @RequestBody PlanEmployeeAssignmentRequest body) { + + PlanEmployeeAssignmentResponse response = planEmployeeService.create(body); + return ResponseEntity.status(HttpStatus.ACCEPTED).body(response); + + } + + /** + * Request handler for serving plan employee assignment search requests + * @param body + * @return + */ + @RequestMapping(value = "/employee/_search", method = RequestMethod.POST) + public ResponseEntity employeeSearchPost(@Parameter(in = ParameterIn.DEFAULT, description = "", schema = @Schema()) @Valid @RequestBody PlanEmployeeAssignmentSearchRequest body) { + + PlanEmployeeAssignmentResponse response = planEmployeeService.search(body); + return ResponseEntity.status(HttpStatus.OK).body(response); + } + + /** + * Request handler for serving plan employee assignment update requests + * @param body + * @return + */ + @RequestMapping(value = "/employee/_update", method = RequestMethod.POST) + public ResponseEntity employeeUpdatePost(@Parameter(in = ParameterIn.DEFAULT, description = "", schema = @Schema()) @Valid @RequestBody PlanEmployeeAssignmentRequest body) { + + PlanEmployeeAssignmentResponse response = planEmployeeService.update(body); + return ResponseEntity.status(HttpStatus.ACCEPTED).body(response); + } +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/RequestInfoWrapper.java b/health-services/plan-service/src/main/java/digit/web/models/RequestInfoWrapper.java new file mode 100644 index 00000000000..9613a753b82 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/RequestInfoWrapper.java @@ -0,0 +1,18 @@ +package digit.web.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.*; +import org.egov.common.contract.request.RequestInfo; +import org.springframework.stereotype.Component; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Component +public class RequestInfoWrapper { + + @JsonProperty("RequestInfo") + private RequestInfo requestInfo; +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/Assignment.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/Assignment.java new file mode 100644 index 00000000000..b14d6e616f6 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/Assignment.java @@ -0,0 +1,53 @@ +package digit.web.models.hrms; + + +import javax.validation.constraints.NotNull; + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.*; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@AllArgsConstructor +@Builder +@Getter +@NoArgsConstructor +@Setter +@ToString +public class Assignment { + + private String id; + + private Long position; + + @NotNull + private String designation; + + @NotNull + private String department; + + @NotNull + private Long fromDate; + + private Long toDate; + + private String govtOrderNumber; + + private String tenantid; + + private String reportingTo; + + @JsonProperty("isHOD") + private Boolean isHOD; + + @NotNull + @JsonProperty("isCurrentAssignment") + private Boolean isCurrentAssignment; + + private AuditDetails auditDetails; + +} \ No newline at end of file diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/DeactivationDetails.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/DeactivationDetails.java new file mode 100644 index 00000000000..73e08c0446d --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/DeactivationDetails.java @@ -0,0 +1,46 @@ +package digit.web.models.hrms; + + +import javax.validation.constraints.NotNull; + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +@Builder +public class DeactivationDetails { + + private String id; + + @NotNull + private String reasonForDeactivation; + + private String orderNo; + + private String remarks; + + @NotNull + private Long effectiveFrom; + + private String tenantId; + + private AuditDetails auditDetails; + + + + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/DepartmentalTest.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/DepartmentalTest.java new file mode 100644 index 00000000000..982ff7e6aad --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/DepartmentalTest.java @@ -0,0 +1,44 @@ +package digit.web.models.hrms; + + +import javax.validation.constraints.NotNull; + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +public class DepartmentalTest { + + private String id; + + @NotNull + private String test; + + @NotNull + private Long yearOfPassing; + + private String remarks; + + private String tenantId; + + private AuditDetails auditDetails; + + private Boolean isActive; + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/EducationalQualification.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/EducationalQualification.java new file mode 100644 index 00000000000..c1c82017647 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/EducationalQualification.java @@ -0,0 +1,49 @@ +package digit.web.models.hrms; + + +import javax.validation.constraints.NotNull; + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +public class EducationalQualification { + private String id; + + @NotNull + private String qualification; + + @NotNull + private String stream; + + @NotNull + private Long yearOfPassing; + + private String university; + + private String remarks; + + private String tenantId; + + private AuditDetails auditDetails; + + private Boolean isActive; + + +} \ No newline at end of file diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/Employee.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/Employee.java new file mode 100644 index 00000000000..a4de5473f27 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/Employee.java @@ -0,0 +1,99 @@ +package digit.web.models.hrms; + + + +import java.util.ArrayList; +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + + +import org.egov.common.contract.models.AuditDetails; +import org.egov.common.contract.request.User; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; + +@Validated +@AllArgsConstructor +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Setter +@ToString +@Builder +public class Employee { + + private Long id; + + private String uuid; + + @Size(min = 1, max = 256) + private String code; + + @NotNull + private String employeeStatus; + + @NotNull + private String employeeType; + + private Long dateOfAppointment; + + @Valid + @NonNull + @Size(min = 1,max = 50) + private List jurisdictions = new ArrayList<>(); + + + @Valid + @NonNull + @Size(min = 1) + private List assignments = new ArrayList<>(); + + @Valid + @Size(max=25) + private List serviceHistory = new ArrayList<>(); + + + private Boolean isActive; + + @Valid + @Size(max=25) + private List education = new ArrayList<>(); + + @Valid + @Size(max=25) + private List tests = new ArrayList<>(); + + @NotNull + @Size(max = 256) + private String tenantId; + + @Valid + @Size(max=50) + private List documents = new ArrayList<>(); + + @Valid + private List deactivationDetails = new ArrayList<>(); + + private List reactivationDetails = new ArrayList<>(); + + private AuditDetails auditDetails; + + private Boolean reActivateEmployee; + + @Valid + @NotNull + private User user; + + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeDocument.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeDocument.java new file mode 100644 index 00000000000..86a77013762 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeDocument.java @@ -0,0 +1,69 @@ +package digit.web.models.hrms; + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = { "auditDetails" }) +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +@Builder +public class EmployeeDocument { + + private String id; + + private String documentName; + + private String documentId; + + private EmployeeDocumentReferenceType referenceType; + + private String referenceId; + + private String tenantId; + + private AuditDetails auditDetails; + + public enum EmployeeDocumentReferenceType { + HEADER("HEADER"), ASSIGNMENT("ASSIGNMENT"), JURISDICTION("JURISDICTION"), SERVICE("SERVICE"), + EDUCATION("EDUCATION"), TEST("TEST"), DEACTIVATION("DEACTIVATION"); + + private String value; + + EmployeeDocumentReferenceType(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return name(); + } + + @JsonCreator + public static EmployeeDocumentReferenceType fromValue(String passedValue) { + for (EmployeeDocumentReferenceType obj : EmployeeDocumentReferenceType.values()) { + if (String.valueOf(obj.value).equalsIgnoreCase(passedValue)) { + return obj; + } + } + return null; + } + } + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeRequest.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeRequest.java new file mode 100644 index 00000000000..00c62c9b846 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeRequest.java @@ -0,0 +1,36 @@ +package digit.web.models.hrms; + + +import java.util.List; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +import org.egov.common.contract.request.RequestInfo; +import org.springframework.validation.annotation.Validated; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +@Validated +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EmployeeRequest { + + @NotNull + @JsonProperty("RequestInfo") + private RequestInfo requestInfo; + + @Valid + @NonNull + @JsonProperty("Employees") + private List employees; + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeResponse.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeResponse.java new file mode 100644 index 00000000000..890c19a476f --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/EmployeeResponse.java @@ -0,0 +1,32 @@ +package digit.web.models.hrms; + + +import java.util.List; + +import org.egov.common.contract.response.ResponseInfo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +@Builder +@AllArgsConstructor +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Setter +@ToString +public class EmployeeResponse { + + @JsonProperty("ResponseInfo") + private ResponseInfo responseInfo; + + @JsonProperty("Employees") + private List employees; + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/Jurisdiction.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/Jurisdiction.java new file mode 100644 index 00000000000..cc5a3fc62e9 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/Jurisdiction.java @@ -0,0 +1,49 @@ +package digit.web.models.hrms; + + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +public class Jurisdiction { + + private String id; + + @NotNull + @Size(min=2, max=100) + private String hierarchy; + + @NotNull + @Size(min=2, max=100) + private String boundary; + + @NotNull + @Size(max=256) + private String boundaryType; + + private String tenantId; + + private AuditDetails auditDetails; + + private Boolean isActive; + +} diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/ReactivationDetails.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/ReactivationDetails.java new file mode 100644 index 00000000000..b0c95cffdc3 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/ReactivationDetails.java @@ -0,0 +1,47 @@ +package digit.web.models.hrms; + +import javax.validation.constraints.NotNull; + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +@Builder +public class ReactivationDetails { + + private String id; + + @NotNull + private String reasonForReactivation; + + private String orderNo; + + private String remarks; + + @NotNull + private Long effectiveFrom; + + private String tenantId; + + private AuditDetails auditDetails; + + + + +} + diff --git a/health-services/plan-service/src/main/java/digit/web/models/hrms/ServiceHistory.java b/health-services/plan-service/src/main/java/digit/web/models/hrms/ServiceHistory.java new file mode 100644 index 00000000000..592aa078479 --- /dev/null +++ b/health-services/plan-service/src/main/java/digit/web/models/hrms/ServiceHistory.java @@ -0,0 +1,46 @@ +package digit.web.models.hrms; + + + +import org.egov.common.contract.models.AuditDetails; +import org.springframework.validation.annotation.Validated; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Validated +@EqualsAndHashCode(exclude = {"auditDetails"}) +@Builder +@AllArgsConstructor +@Getter +@NoArgsConstructor +@Setter +@ToString +public class ServiceHistory { + + private String id; + + private String serviceStatus; + + private Long serviceFrom; + + private Long serviceTo; + + private String orderNo; + + private String location; + + private String tenantId; + + private Boolean isCurrentPosition; + + private AuditDetails auditDetails; + + + +}