Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCMPRE-1922 - Microplanning v0.2 master merge #1340

Open
wants to merge 126 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
dba50ac
Removed readme sheet, localised estimation sheet and added facility name
tanishi-egov Jan 3, 2025
f3893e3
Adding additional field in plan
tanishi-egov Jan 3, 2025
ffa7974
Resolved code rabbit review comments
tanishi-egov Jan 3, 2025
47cc3b2
Updating validation for residing boundaries in plan facility
tanishi-egov Jan 3, 2025
4dd4d23
Change the mdms master to adminSchemas in resource generator
tanishi-egov Jan 6, 2025
27fad49
Add Facility Name in additional details and enable search on facility…
tanishi-egov Jan 6, 2025
a8a18a6
Merge pull request #1315 from egovernments/HCMPRE-1661-new
Priyanka-eGov Jan 6, 2025
fee41c7
Resource generator - add Village accessibility details from census in…
tanishi-egov Jan 6, 2025
067d1d3
Enable search on Village Accessibility Details in Plan Service
tanishi-egov Jan 6, 2025
51ac2ed
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 6, 2025
f6ffa03
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 6, 2025
62cf501
Plan-facility integration to fetch fixedPost details
tanishi-egov Jan 6, 2025
f6f02d1
HCMPRE-1801 setting dynamic column width for column headers
Priyanka-eGov Jan 6, 2025
a6e93b1
Enriching additionalField ID after empty check
tanishi-egov Jan 6, 2025
eae77b9
Merge pull request #1327 from egovernments/microplan-feature-new
Priyanka-eGov Jan 6, 2025
5cc0d9e
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 6, 2025
d7719c2
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
b35e3a3
Adding comments
tanishi-egov Jan 7, 2025
8d60a42
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
1c2ab26
enabling search on security questions
tanishi-egov Jan 7, 2025
8825386
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
e5d73f8
Adding security details in plan additional details
tanishi-egov Jan 7, 2025
c18cc2c
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
8796581
Merge branch 'HCMPRE-1768-new' of https://github.com/egovernments/hea…
tanishi-egov Jan 7, 2025
eb7282c
Merge branch 'HCMPRE-1768-new' of https://github.com/egovernments/hea…
tanishi-egov Jan 7, 2025
4fbf404
Merge pull request #1316 from egovernments/HCMPRE-1678-new
Priyanka-eGov Jan 7, 2025
56e44cc
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
698e8ae
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
e4a9894
Merge branch 'HCMPRE-1768-new' of https://github.com/egovernments/hea…
tanishi-egov Jan 7, 2025
518c1cf
Validating only active employee assignments
tanishi-egov Jan 7, 2025
23fe8e8
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
ee76c4d
Creating map of boundary code to facility fixed post details
tanishi-egov Jan 7, 2025
e3849c2
Updating preparePartialJsonStringFromFilterMap function
tanishi-egov Jan 7, 2025
60bea5e
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 7, 2025
308cd0b
HCMPRE-1577 Updating comments
Priyanka-eGov Jan 8, 2025
37dbd5c
Merge remote-tracking branch 'origin/download-estimation-1578' into d…
Priyanka-eGov Jan 8, 2025
2988c15
Adding comments
tanishi-egov Jan 8, 2025
4af6dde
Merge remote-tracking branch 'origin/download-estimation-1578' into d…
tanishi-egov Jan 8, 2025
2670e26
HCMPRE-1577 Updating comments
Priyanka-eGov Jan 8, 2025
b3a68e8
Merge remote-tracking branch 'origin/download-estimation-1578' into d…
Priyanka-eGov Jan 8, 2025
89f4046
HCMPRE-1577 Removing todo
Priyanka-eGov Jan 8, 2025
656f733
Merge pull request #1314 from egovernments/download-estimation-1578
Priyanka-eGov Jan 8, 2025
0b28c94
Pull from microplanning-v0.2
tanishi-egov Jan 8, 2025
8ff81e2
Resolved review comments
tanishi-egov Jan 8, 2025
bcd3ade
Merge pull request #1325 from egovernments/HCMPRE-1782
Priyanka-eGov Jan 8, 2025
c4ba102
HCMPRE-1808 adding changes for Mixed Strategy
Priyanka-eGov Jan 8, 2025
d2d7f2b
HCMPRE-1846 making output columns and facility name cell editable.
Priyanka-eGov Jan 8, 2025
1a926cf
removing not null constraint from Resource.java
tanishi-egov Jan 8, 2025
1ba656a
Merge pull request #1329 from egovernments/HCMPRE-1817
Priyanka-eGov Jan 9, 2025
be041ea
Modifying filter logic
tanishi-egov Jan 9, 2025
1235cac
changing filter from facilityName to facilityId
tanishi-egov Jan 9, 2025
7e89808
changing filter from facilityName to facilityId
tanishi-egov Jan 9, 2025
ec0e93c
removed not null constraint from plan
tanishi-egov Jan 9, 2025
0de2e9a
removed not null constraint from plan
tanishi-egov Jan 9, 2025
6979433
Merge remote-tracking branch 'origin/HCMPRE-1808' into HCMPRE-1808
tanishi-egov Jan 9, 2025
dad46a2
resolved comments and pulled from microplanning-v0.2
tanishi-egov Jan 9, 2025
d654fef
pull from microplanning-v0.2
tanishi-egov Jan 9, 2025
6f9da7b
filter on facilityId
tanishi-egov Jan 9, 2025
804ae7d
pull from microplanning-v0.2
tanishi-egov Jan 9, 2025
c270aed
adding facilityId in plan additional details
tanishi-egov Jan 9, 2025
99eed5c
Merge pull request #1320 from egovernments/HCMPRE-1729-new
Priyanka-eGov Jan 9, 2025
8b22819
removing calculationUtil from parsingUtil since unused
tanishi-egov Jan 9, 2025
3b1c47b
Merge pull request #1334 from egovernments/HCMPRE-1846
Priyanka-eGov Jan 9, 2025
8ef6398
resolved review comments
tanishi-egov Jan 9, 2025
eeaf9c2
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 9, 2025
2d388cc
Mark formula as null
tanishi-egov Jan 9, 2025
035542f
modified census pojo
tanishi-egov Jan 10, 2025
68a0415
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 10, 2025
89c9a90
added comment
tanishi-egov Jan 10, 2025
44201d8
resolved comment
tanishi-egov Jan 10, 2025
6468f4d
Merge pull request #1322 from egovernments/HCMPRE-1767-new
Priyanka-eGov Jan 10, 2025
9007d2c
pull from microplanning-v0.2
tanishi-egov Jan 10, 2025
3db1245
moving isSheetAllowedToProcess function
tanishi-egov Jan 10, 2025
30c99f0
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 10, 2025
b52e262
Merge pull request #1321 from egovernments/HCMPRE-1768-new
Priyanka-eGov Jan 10, 2025
ef0352f
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 10, 2025
b70f07a
pull from microplanning-v0.2
tanishi-egov Jan 13, 2025
48ff551
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 13, 2025
ed5e90d
Merge branch 'HCMPRE-1708-new' of https://github.com/egovernments/hea…
tanishi-egov Jan 13, 2025
8c69a08
handling NullPointerException
tanishi-egov Jan 13, 2025
40d989d
Adding accessibility details in plan additional details
tanishi-egov Jan 16, 2025
1c8f26a
Adding accessibility details in plan additional details
tanishi-egov Jan 16, 2025
5eb30a6
Merge remote-tracking branch 'origin/HCMPRE-1708-new' into HCMPRE-170…
tanishi-egov Jan 16, 2025
2ff8b2c
Adding accessibility details in plan additional details
tanishi-egov Jan 16, 2025
eb52289
Merge remote-tracking branch 'origin/HCMPRE-1708-new' into HCMPRE-170…
tanishi-egov Jan 16, 2025
cf7d2a4
Resolving code rabbit comments
tanishi-egov Jan 17, 2025
ceeee9e
Merge remote-tracking branch 'origin/HCMPRE-1708-new' into HCMPRE-170…
tanishi-egov Jan 17, 2025
5f52303
Adding accessibility details in plan additional details
tanishi-egov Jan 20, 2025
87dac50
Adding pipe regex
tanishi-egov Jan 20, 2025
8b04d1b
changes in planUtil
tanishi-egov Jan 20, 2025
86ffaf4
resolving review comments
tanishi-egov Jan 20, 2025
1db1da2
Merge pull request #1323 from egovernments/HCMPRE-1708-new
shashwat-egov Jan 20, 2025
12bc8ef
Merge branch 'microplanning-v0.2' of https://github.com/egovernments/…
tanishi-egov Jan 20, 2025
8cc8055
Pull from microplanning-v0.2
tanishi-egov Jan 20, 2025
cdb1e5a
Code review changes
Priyanka-eGov Jan 21, 2025
f2686bc
Merge branch 'microplanning-v0.2' into v0.2-code-review
Priyanka-eGov Jan 21, 2025
a7c69ba
Resolving code rabbit comments
tanishi-egov Jan 20, 2025
4c5f3b3
Handling null pointer exception
tanishi-egov Jan 21, 2025
4b2e60f
renaming pagination variables
tanishi-egov Jan 21, 2025
9faf6e3
resolving code rabbit review comments
tanishi-egov Jan 21, 2025
54660ef
Adding function comments
tanishi-egov Jan 22, 2025
46cc2f3
Resolving review comments
tanishi-egov Jan 22, 2025
4149d63
Removing unused functions
tanishi-egov Jan 22, 2025
002e42d
Merge pull request #1331 from egovernments/HCMPRE-1808
shashwat-egov Jan 22, 2025
073ea3e
added better comments
Priyanka-eGov Jan 22, 2025
3d213fc
Merge remote-tracking branch 'origin/v0.2-code-review' into v0.2-code…
Priyanka-eGov Jan 22, 2025
743f38b
Merge branch 'microplanning-v0.2' into v0.2-code-review
Priyanka-eGov Jan 22, 2025
f468715
Fixing typo in mixedStrategyUtil.class
Priyanka-eGov Jan 22, 2025
f7ee03f
Adding error while fetching mdms data
Priyanka-eGov Jan 22, 2025
66be9e6
Making getCategoriesNotAllowed function readable
tanishi-egov Jan 22, 2025
ae91e07
Merge remote-tracking branch 'origin/v0.2-code-review' into v0.2-code…
tanishi-egov Jan 22, 2025
bba68fd
Error handling for null pointer exceptions and replacing string liter…
tanishi-egov Jan 22, 2025
d67bd4d
moving mdms data search call outside the isSheetAllowedToProcess func…
tanishi-egov Jan 23, 2025
33e4b54
Removing unused parameters
tanishi-egov Jan 23, 2025
4a842e1
Setting cellValue as N/A for restricted categories
tanishi-egov Jan 23, 2025
249d174
Merge pull request #1347 from egovernments/v0.2-code-review
shashwat-egov Jan 23, 2025
464b487
Changing facility_name constraint from VARCHAR(64) to VARCHAR(2000)
tanishi-egov Jan 24, 2025
7ade1ec
Merge pull request #1353 from egovernments/HCMPRE-2203
Priyanka-eGov Jan 24, 2025
1e2505b
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 27, 2025
b561a96
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 27, 2025
fcce569
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 27, 2025
06f635d
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 28, 2025
3ff5add
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 28, 2025
42cc286
HCMPRE-2212 making facilityId in plan search a set for multiple drop …
Priyanka-eGov Jan 28, 2025
6f2066c
HCMPRE-2212 Adding comments
Priyanka-eGov Jan 28, 2025
33c8666
Merge pull request #1360 from egovernments/HCMPRE-2212
Priyanka-eGov Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,20 @@ public class ServiceConstants {

public static final String FACILITY_NAME_SEARCH_PARAMETER_KEY = "facilityName";

public static final String FACILITY_ID_SEARCH_PARAMETER_KEY = "facilityId";

Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved
public static final String FACILITY_STATUS_SEARCH_PARAMETER_KEY = "facilityStatus";

public static final String FACILITY_TYPE_SEARCH_PARAMETER_KEY = "facilityType";

public static final String TERRAIN_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails|terrain|code";

public static final String ROAD_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails|roadCondition|code";

public static final String SECURITY_Q1_SEARCH_PARAMETER_KEY = "securityDetails|1|code";

public static final String SECURITY_Q2_SEARCH_PARAMETER_KEY = "securityDetails|2|code";

public static final String COMMA_DELIMITER = ",";

public static final String SERVING_POPULATION_CODE = "servingPopulation";
Expand All @@ -374,4 +384,11 @@ public class ServiceConstants {

public static final String CONFIRMED_TARGET_POPULATION = "CONFIRMED_HCM_ADMIN_CONSOLE_TARGET_POPULATION";

public static final String ADDITIONAL_DETAILS_QUERY = " additional_details @> CAST( ? AS jsonb )";

public static final String JSONB_QUERY_FORMAT = "additional_details @> ?::jsonb";

public static final String AND_CONDITION = " AND ";

public static final String OR_CONDITION = " OR ";
Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private PlanRequestDTO convertToPlanReqDTO(PlanRequest planRequest) {
.assignee(assignee)
.additionalDetails(plan.getAdditionalDetails())
.jurisdictionMapping(plan.getJurisdictionMapping())
.additionalFields(plan.getAdditionalFields())
.activities(plan.getActivities())
.resources(plan.getResources())
.targets(plan.getTargets())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.*;

Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved
import static digit.config.ServiceConstants.ADDITIONAL_DETAILS_QUERY;
import static digit.config.ServiceConstants.FACILITY_ID_SEARCH_PARAMETER_KEY;
Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved

@Component
public class PlanQueryBuilder {
Expand All @@ -30,12 +30,14 @@ public PlanQueryBuilder(Configuration config, QueryUtil queryUtil) {
"\t plan_activity.id as plan_activity_id, plan_activity.code as plan_activity_code, plan_activity.description as plan_activity_description, plan_activity.planned_start_date as plan_activity_planned_start_date, plan_activity.planned_end_date as plan_activity_planned_end_date, plan_activity.dependencies as plan_activity_dependencies, plan_activity.plan_id as plan_activity_plan_id, plan_activity.created_by as plan_activity_created_by, plan_activity.created_time as plan_activity_created_time, plan_activity.last_modified_by as plan_activity_last_modified_by, plan_activity.last_modified_time as plan_activity_last_modified_time,\n" +
"\t plan_activity_condition.id as plan_activity_condition_id, plan_activity_condition.entity as plan_activity_condition_entity, plan_activity_condition.entity_property as plan_activity_condition_entity_property, plan_activity_condition.expression as plan_activity_condition_expression, plan_activity_condition.activity_id as plan_activity_condition_activity_id, plan_activity_condition.is_active as plan_activity_condition_is_active, plan_activity_condition.created_by as plan_activity_condition_created_by, plan_activity_condition.created_time as plan_activity_condition_created_time, plan_activity_condition.last_modified_by as plan_activity_condition_last_modified_by, plan_activity_condition.last_modified_time as plan_activity_condition_last_modified_time,\n" +
"\t plan_resource.id as plan_resource_id, plan_resource.resource_type as plan_resource_resource_type, plan_resource.estimated_number as plan_resource_estimated_number, plan_resource.plan_id as plan_resource_plan_id, plan_resource.activity_code as plan_resource_activity_code, plan_resource.created_by as plan_resource_created_by, plan_resource.created_time as plan_resource_created_time, plan_resource.last_modified_by as plan_resource_last_modified_by, plan_resource.last_modified_time as plan_resource_last_modified_time,\n" +
"\t plan_target.id as plan_target_id, plan_target.metric as plan_target_metric, plan_target.metric_value as plan_target_metric_value, plan_target.metric_comparator as plan_target_metric_comparator, plan_target.metric_unit as plan_target_metric_unit, plan_target.plan_id as plan_target_plan_id, plan_target.activity_code as plan_target_activity_code, plan_target.created_by as plan_target_created_by, plan_target.created_time as plan_target_created_time, plan_target.last_modified_by as plan_target_last_modified_by, plan_target.last_modified_time as plan_target_last_modified_time\n" +
"\t plan_target.id as plan_target_id, plan_target.metric as plan_target_metric, plan_target.metric_value as plan_target_metric_value, plan_target.metric_comparator as plan_target_metric_comparator, plan_target.metric_unit as plan_target_metric_unit, plan_target.plan_id as plan_target_plan_id, plan_target.activity_code as plan_target_activity_code, plan_target.created_by as plan_target_created_by, plan_target.created_time as plan_target_created_time, plan_target.last_modified_by as plan_target_last_modified_by, plan_target.last_modified_time as plan_target_last_modified_time, \n" +
"\t paf.id as plan_additional_field_id, paf.plan_id as plan_additional_field_plan_id, paf.key as plan_additional_field_key, paf.value as plan_additional_field_value, paf.show_on_ui as plan_additional_field_show_on_ui, paf.editable as plan_additional_field_editable, paf.order as plan_additional_field_order \n" +
"\t FROM plan \n" +
"\t LEFT JOIN plan_activity ON plan.id = plan_activity.plan_id\n" +
"\t LEFT JOIN plan_activity_condition ON plan_activity.id = plan_activity_condition.activity_id\n" +
"\t LEFT JOIN plan_resource ON plan.id = plan_resource.plan_id\n" +
"\t LEFT JOIN plan_target ON plan.id = plan_target.plan_id";
"\t LEFT JOIN plan_target ON plan.id = plan_target.plan_id\n" +
"\t LEFT JOIN plan_additional_field paf ON plan.id = paf.plan_id";
Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved

private static final String BULK_PLAN_UPDATE_QUERY = "UPDATE plan SET status = ?, assignee = ?, last_modified_by = ?, last_modified_time = ? WHERE id = ?";

Expand Down Expand Up @@ -170,6 +172,22 @@ private String buildPlanSearchQuery(PlanSearchCriteria planSearchCriteria, List<
queryUtil.addToPreparedStatement(preparedStmtList, planSearchCriteria.getJurisdiction());
}

if (!CollectionUtils.isEmpty(planSearchCriteria.getFiltersMap())) {
Map<String, Set<String>> filtersMap = planSearchCriteria.getFiltersMap();
for (String key : filtersMap.keySet()) {
if (FACILITY_ID_SEARCH_PARAMETER_KEY.equals(key)) {
// its for facility multi select then no need to add to preparedStmtList
String partialQueryJsonString = queryUtil.preparePartialJsonStringFromFilterMap(planSearchCriteria.getFiltersMap(), preparedStmtList, key);
builder.append(partialQueryJsonString);
} else {
// handle all other keys normally.
queryUtil.addClauseIfRequired(builder, preparedStmtList);
builder.append(ADDITIONAL_DETAILS_QUERY);
String partialQueryJsonString = queryUtil.preparePartialJsonStringFromFilterMap(planSearchCriteria.getFiltersMap(), preparedStmtList, key);
preparedStmtList.add(partialQueryJsonString);
}
}
}

StringBuilder countQuery = new StringBuilder();
if (isCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public List<Plan> extractData(ResultSet rs) throws SQLException, DataAccessExcep
Set<String> conditionSet = new HashSet<>();
Set<String> resourceSet = new HashSet<>();
Set<String> targetSet = new HashSet<>();
Set<String> additionalFieldSet = new HashSet<>();

// Traverse through result set and create plan objects
while (rs.next()) {
Expand All @@ -43,6 +44,7 @@ public List<Plan> extractData(ResultSet rs) throws SQLException, DataAccessExcep
conditionSet.clear();
resourceSet.clear();
targetSet.clear();
additionalFieldSet.clear();

// Prepare audit details
AuditDetails auditDetails = AuditDetails.builder()
Expand Down Expand Up @@ -72,6 +74,7 @@ public List<Plan> extractData(ResultSet rs) throws SQLException, DataAccessExcep
addActivities(rs, planEntry, activityMap, conditionSet);
addResources(rs, planEntry, resourceSet);
addTargets(rs, planEntry, targetSet);
addAdditionalField(rs, planEntry, additionalFieldSet);
planMap.put(planId, planEntry);
}

Expand Down Expand Up @@ -234,4 +237,39 @@ private void addTargets(ResultSet rs, Plan planEntry, Set<String> targetSet) thr
targetSet.add(target.getId());

}

/**
* Adds a AdditionalField object to the plan entry based on the result set.
*
* @param rs The ResultSet containing the data.
* @param additionalFieldSet A set to keep track of added AdditionalField objects.
* @param planEntry The Plan entry to which the AdditionalField object will be added.
* @throws SQLException If an SQL error occurs.
*/
private void addAdditionalField(ResultSet rs, Plan planEntry, Set<String> additionalFieldSet) throws SQLException {
String additionalFieldId = rs.getString("plan_additional_field_id");

if (ObjectUtils.isEmpty(additionalFieldId) || additionalFieldSet.contains(additionalFieldId)) {
return;
}

AdditionalField additionalField = new AdditionalField();
additionalField.setId(rs.getString("plan_additional_field_id"));
additionalField.setKey(rs.getString("plan_additional_field_key"));
additionalField.setValue(rs.getBigDecimal("plan_additional_field_value"));
additionalField.setShowOnUi(rs.getBoolean("plan_additional_field_show_on_ui"));
additionalField.setEditable(rs.getBoolean("plan_additional_field_editable"));
additionalField.setOrder(rs.getInt("plan_additional_field_order"));

if (CollectionUtils.isEmpty(planEntry.getAdditionalFields())) {
List<AdditionalField> additionalFields = new ArrayList<>();
additionalFields.add(additionalField);
planEntry.setAdditionalFields(additionalFields);
} else {
planEntry.getAdditionalFields().add(additionalField);
}

additionalFieldSet.add(additionalFieldId);
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package digit.service.enrichment;
package digit.service;

import digit.web.models.Plan;
import digit.web.models.PlanRequest;
import digit.web.models.*;
import digit.web.models.boundary.BoundaryTypeHierarchy;
import digit.web.models.boundary.BoundaryTypeHierarchyDefinition;
import digit.web.models.boundary.EnrichedBoundary;
Expand All @@ -14,6 +13,8 @@

import java.util.*;

import static digit.config.ServiceConstants.*;

@Component
Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved
public class PlanEnricher {

Expand Down Expand Up @@ -53,6 +54,10 @@ public void enrichPlanCreate(PlanRequest body) {
// Generate id for targets
body.getPlan().getTargets().forEach(target -> UUIDEnrichmentUtil.enrichRandomUuid(target, "id"));

// Generate id for additional fields
if(!CollectionUtils.isEmpty(body.getPlan().getAdditionalFields()))
body.getPlan().getAdditionalFields().forEach(additionalField -> UUIDEnrichmentUtil.enrichRandomUuid(additionalField, "id"));

// Enrich audit details
Priyanka-eGov marked this conversation as resolved.
Show resolved Hide resolved
body.getPlan().setAuditDetails(AuditDetailsEnrichmentUtil
.prepareAuditDetails(body.getPlan().getAuditDetails(), body.getRequestInfo(), Boolean.TRUE));
Expand Down Expand Up @@ -107,6 +112,15 @@ public void enrichPlanUpdate(PlanRequest body) {
}
});

// Generate uuid for new additionalFields
if(!CollectionUtils.isEmpty(body.getPlan().getAdditionalFields())) {
body.getPlan().getAdditionalFields().forEach(additionalFields -> {
if(ObjectUtils.isEmpty(additionalFields.getId())) {
UUIDEnrichmentUtil.enrichRandomUuid(additionalFields, "id");
}
});
}

// Enriching last modified time for update
body.getPlan().getAuditDetails().setLastModifiedTime(System.currentTimeMillis());
}
Expand Down Expand Up @@ -228,4 +242,45 @@ private List<String> getBoundaryCodeFromAncestralPath(String boundaryAncestralPa
}
return Arrays.asList(boundaryAncestralPath.split("\\|"));
}

/**
* Enriches the PlanSearchRequest by populating the filters map from the fields in search criteria.
* This filterMap is populated to search the fields in plan additional detail object.
*
* @param planSearchRequest the planSearchRequest object whose search criteria need enrichment.
*/
public void enrichSearchRequest(PlanSearchRequest planSearchRequest) {
PlanSearchCriteria planSearchCriteria = planSearchRequest.getPlanSearchCriteria();

// Filter map for filtering plan metadata present in additional details
Map<String, Set<String>> filtersMap = new LinkedHashMap<>();

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

// Add terrain as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getTerrain())) {
filtersMap.put(TERRAIN_CONDITION_SEARCH_PARAMETER_KEY, Collections.singleton(planSearchCriteria.getTerrain()));
}

// Add onRoadCondition as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getOnRoadCondition())) {
filtersMap.put(ROAD_CONDITION_SEARCH_PARAMETER_KEY, Collections.singleton(planSearchCriteria.getOnRoadCondition()));
}

// Add securityQ1 as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getSecurityQ1())) {
filtersMap.put(SECURITY_Q1_SEARCH_PARAMETER_KEY, Collections.singleton(planSearchCriteria.getSecurityQ1()));
}

// Add securityQ2 as a filter if present in search criteria
if (!ObjectUtils.isEmpty(planSearchCriteria.getSecurityQ2())) {
filtersMap.put(SECURITY_Q2_SEARCH_PARAMETER_KEY, Collections.singleton(planSearchCriteria.getSecurityQ2()));
}

if(!CollectionUtils.isEmpty(filtersMap))
planSearchCriteria.setFiltersMap(filtersMap);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package digit.service;

import digit.repository.PlanRepository;
import digit.service.enrichment.PlanEnricher;
import digit.service.validator.PlanValidator;
import digit.service.workflow.WorkflowService;
import digit.web.models.*;
import org.egov.common.utils.ResponseInfoUtil;
Expand Down Expand Up @@ -61,6 +59,9 @@ public PlanResponse createPlan(PlanRequest body) {
* @return
*/
public PlanResponse searchPlan(PlanSearchRequest body) {
// Enrich search request
planEnricher.enrichSearchRequest(body);

// Delegate search request to repository
List<Plan> planList = planRepository.search(body.getPlanSearchCriteria());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package digit.service.validator;
package digit.service;

import com.jayway.jsonpath.JsonPath;
import digit.config.Configuration;
import digit.repository.PlanConfigurationRepository;
import digit.repository.PlanRepository;
import digit.service.PlanEmployeeService;
import digit.service.enrichment.PlanEnricher;
import digit.util.BoundaryUtil;
import digit.util.CampaignUtil;
import digit.util.CommonUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import digit.util.BoundaryUtil;
import digit.util.CensusUtil;
import digit.util.CommonUtil;
import digit.web.models.PlanFacility;
import digit.web.models.PlanFacilityRequest;
import digit.web.models.PlanFacilitySearchCriteria;
import digit.web.models.PlanFacilitySearchRequest;
import digit.web.models.*;
tanishi-egov marked this conversation as resolved.
Show resolved Hide resolved
import digit.web.models.boundary.BoundarySearchResponse;
import digit.web.models.boundary.EnrichedBoundary;
import digit.web.models.census.*;
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
Loading
Loading