Skip to content

Commit

Permalink
pull from microplanning-v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishi-egov committed Jan 9, 2025
2 parents 8796581 + 7e89808 commit d654fef
Show file tree
Hide file tree
Showing 20 changed files with 844 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ public class ServiceConstants {

public static final String FACILITY_NAME_SEARCH_PARAMETER_KEY = "facilityName";

public static final String FACILITY_ID_SEARCH_PARAMETER_KEY = "facilityId";

public static final String FACILITY_STATUS_SEARCH_PARAMETER_KEY = "facilityStatus";

public static final String FACILITY_TYPE_SEARCH_PARAMETER_KEY = "facilityType";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.*;

import static digit.config.ServiceConstants.FACILITY_NAME_SEARCH_PARAMETER_KEY;
import static digit.config.ServiceConstants.FACILITY_ID_SEARCH_PARAMETER_KEY;

@Component
public class PlanEnricher {
Expand Down Expand Up @@ -252,9 +252,9 @@ public void enrichSearchRequest(PlanSearchRequest planSearchRequest) {
// Filter map for filtering plan metadata present in additional details
Map<String, String> filtersMap = new LinkedHashMap<>();

// Add facility name as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getFacilityName())) {
filtersMap.put(FACILITY_NAME_SEARCH_PARAMETER_KEY, planSearchCriteria.getFacilityName());
// Add facility id as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getFacilityId())) {
filtersMap.put(FACILITY_ID_SEARCH_PARAMETER_KEY, planSearchCriteria.getFacilityId());
}

if(!CollectionUtils.isEmpty(filtersMap))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import digit.repository.PlanRepository;
import digit.service.workflow.WorkflowService;
import digit.web.models.*;
import org.egov.common.contract.response.ResponseInfo;
import org.egov.common.utils.ResponseInfoUtil;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ public void validateUpdate(PlanEmployeeAssignmentRequest request) {
// Validate if Plan employee assignment exists
validatePlanEmployeeAssignmentExistance(planEmployeeAssignment);

// Validate campaign id and employee jurisdiction
validateCampaignDetails(planConfigurations.get(0).getCampaignId(), rootTenantId, request);
// Validate campaign id and employee jurisdiction for active records
if(planEmployeeAssignment.getActive())
validateCampaignDetails(planConfigurations.get(0).getCampaignId(), rootTenantId, request);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,43 @@ private void validateCampaignDetails(String campaignId, String rootTenantId, Pla
String lowestHierarchy = hierarchyMap.get(LOWEST_HIERARCHY_FIELD_FOR_MICROPLAN);

// Collect all boundary code for the campaign
Set<String> boundaryCodes = fetchBoundaryCodes(campaignResponse.getCampaignDetails().get(0), lowestHierarchy);
Set<String> lowestHierarchyBCodes = fetchBoundaryCodes(campaignResponse.getCampaignDetails().get(0), lowestHierarchy);
Set<String> allBoundaryCodes = fetchAllBoundaryCodes(campaignResponse.getCampaignDetails().get(0));

// Validate residing boundaries
validateResidingBoundaries(boundaryCodes, planFacility);
// Validate residing boundaries with all the boundary codes.
validateResidingBoundaries(allBoundaryCodes, planFacility);

// Validate service boundaries
validateServiceBoundaries(boundaryCodes, planFacility);
// Validate service boundaries with the lowest hierarchy boundary codes.
validateServiceBoundaries(lowestHierarchyBCodes, planFacility);

//Enrich jurisdiction mapping and boundary ancestral path
enrichment.enrichJurisdictionMapping(planFacilityRequest, campaignResponse.getCampaignDetails().get(0).getHierarchyType());
}

/**
* This method returns boundary code for the campaign
* This method returns a set of all boundary codes for the given campaign.
*
* @param campaignDetail
* @param lowestHierarchy
* @param campaignDetail the campaign details whose BCodes are required.
* @return returns a set of boundaries for the given campaign.
*/
private Set<String> fetchBoundaryCodes(CampaignDetail campaignDetail, String lowestHierarchy) {
private Set<String> fetchAllBoundaryCodes(CampaignDetail campaignDetail) {
Set<String> boundaryCodes = campaignDetail.getBoundaries().stream()
.filter(boundary -> lowestHierarchy.equals(boundary.getType().toLowerCase()))
.map(Boundary::getCode)
.collect(Collectors.toSet());

return boundaryCodes;
}

/**
* This method filters the boundaries based on given hierarchy type for the campaign and returns a set of those boundaries.
*
* @param campaignDetail the campaign details whose BCodes are required.
* @param hierarchyType hierarchy type of the required boundaries.
* @return returns a set of boundaries of the given hierarchy type.
*/
private Set<String> fetchBoundaryCodes(CampaignDetail campaignDetail, String hierarchyType) {
Set<String> boundaryCodes = campaignDetail.getBoundaries().stream()
.filter(boundary -> hierarchyType.equals(boundary.getType().toLowerCase()))
.map(Boundary::getCode)
.collect(Collectors.toSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class PlanSearchCriteria {
@JsonProperty("planConfigurationId")
private String planConfigurationId = null;

@JsonProperty("facilityName")
private String facilityName = null;
@JsonProperty("facilityId")
private String facilityId = null;

@JsonProperty("status")
private String status = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class Configuration {
@Value("${egov.plan.search.endpoint}")
private String planSearchEndPoint;

@Value("${egov.plan.facility.search.endpoint}")
private String planFacilitySearchEndPoint;

// Filestore

@Value("${egov.filestore.service.host}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public class ServiceConstants {
public static final String FILE_NOT_FOUND_CODE = "FILE_NOT_FOUND";
public static final String FILE_NOT_FOUND_MESSAGE = "No file with the specified templateIdentifier found - ";

public static final String PROVIDED_KEY_IS_NOT_PRESENT_IN_JSON_OBJECT_CODE = "PROVIDED_KEY_IS_NOT_PRESENT_IN_JSON_OBJECT";
public static final String PROVIDED_KEY_IS_NOT_PRESENT_IN_JSON_OBJECT_MESSAGE = "Key is not present in json object - ";

public static final String EMPTY_HEADER_ROW_CODE = "EMPTY_HEADER_ROW";
public static final String EMPTY_HEADER_ROW_MESSAGE = "The header row is empty for the given sheet";

public static final String UNABLE_TO_CREATE_ADDITIONAL_DETAILS_CODE = "UNABLE_TO_CREATE_ADDITIONAL_DETAILS";
public static final String UNABLE_TO_CREATE_ADDITIONAL_DETAILS_MESSAGE = "Unable to create additional details for facility creation.";

Expand All @@ -51,6 +57,9 @@ public class ServiceConstants {
public static final String NO_PLAN_FOUND_FOR_GIVEN_DETAILS_CODE = "NO_PLAN_FOUND_FOR_GIVEN_DETAILS";
public static final String NO_PLAN_FOUND_FOR_GIVEN_DETAILS_MESSAGE = "Plan records do not exists for the given details: ";

public static final String NO_PLAN_FACILITY_FOUND_FOR_GIVEN_DETAILS_CODE = "NO_PLAN_FACILITY_FOUND_FOR_GIVEN_DETAILS";
public static final String NO_PLAN_FACILITY_FOUND_FOR_GIVEN_DETAILS_MESSAGE = "Plan facilities do not exists for the given details: ";

public static final String BOUNDARY_CODE = "HCM_ADMIN_CONSOLE_BOUNDARY_CODE";
public static final String TOTAL_POPULATION = "HCM_ADMIN_CONSOLE_TOTAL_POPULATION";

Expand All @@ -60,6 +69,7 @@ public class ServiceConstants {
public static final String ERROR_WHILE_DATA_CREATE_CALL = "Exception occurred while creating data for campaign - ";
public static final String ERROR_WHILE_CALLING_MICROPLAN_API =
"Unexpected error while calling fetch from Microplan API for plan config Id: ";
public static final String INVALID_HEX = "Invalid hex color specified: ";

public static final String FILE_NAME = "output.xls";
public static final String FILE_TYPE = "boundaryWithTarget";
Expand All @@ -77,6 +87,7 @@ public class ServiceConstants {
public static final String BOUNDARY = "boundary";
public static final String DOT_SEPARATOR = ".";
public static final String MICROPLAN_PREFIX = "MP-";
public static final Double BRIGHTEN_FACTOR = 1.1;
public static final String ACCESSIBILITY_DETAILS = "accessibilityDetails";
public static final String SECURITY_DETAILS = "securityDetails";

Expand All @@ -88,7 +99,8 @@ public class ServiceConstants {
public static final String NAME = "name";

public static final String ERROR_WHILE_UPDATING_PLAN_CONFIG = "Exception occurred while updating plan configuration.";
public static final String ERROR_WHILE_SEARCHING_PLAN = "Exception occurred while search plans.";
public static final String ERROR_WHILE_SEARCHING_PLAN = "Exception occurred while searching plans.";
public static final String ERROR_WHILE_SEARCHING_PLAN_FACILITY = "Exception occurred while searching plan facility.";

public static final String VALIDATE_STRING_REGX = "^(?!\\d+$).+$";
public static final String VALIDATE_NUMBER_REGX = "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$";
Expand Down Expand Up @@ -122,8 +134,16 @@ public class ServiceConstants {
public static final String MICROPLAN_SOURCE_KEY = "microplan";
public static final String MICROPLAN_ID_KEY = "microplanId";
public static final String FACILITY_NAME = "facilityName";
public static final String HCM_MICROPLAN_SERVING_FACILITY = "HCM_MICROPLAN_SERVING_FACILITY";
public static final String FIXED_POST = "fixedPost";

//Census additional field constants
public static final String UPLOADED_KEY = "UPLOADED_";
public static final String CONFIRMED_KEY = "CONFIRMED_";

//Excel header row styling constants
public static final String HEX_BACKGROUND_COLOR = "93C47D"; // Constant background color
public static final boolean FREEZE_CELL = true; // Constant to lock cell
public static final int COLUMN_WIDTH = 40; // Column width in characters

}
Loading

0 comments on commit d654fef

Please sign in to comment.