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

HLM-5117 Plan Service changes #737

Open
wants to merge 82 commits into
base: dev
Choose a base branch
from
Open

HLM-5117 Plan Service changes #737

wants to merge 82 commits into from

Conversation

Priyanka-eGov
Copy link
Collaborator

@Priyanka-eGov Priyanka-eGov commented May 14, 2024

Summary by CodeRabbit

  • New Features

    • Added comprehensive plan management capabilities, including defining, creating, and searching for plans and configurations.
    • Introduced new models for operations, resources, and metrics to enhance plan detail specifications.
  • Bug Fixes

    • Implemented validation constraints to ensure data integrity and consistency across plan-related entities.
  • Chores

    • Added database migration scripts to set up and modify tables required for plan management.
    • Introduced Dockerfile and shell script for automated database migrations.
  • Refactor

    • Utilized Lombok annotations to reduce boilerplate code in model classes.

Priyanka-eGov and others added 30 commits March 5, 2024 12:31
Copy link
Collaborator Author

@Priyanka-eGov Priyanka-eGov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai review

@Priyanka-eGov
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 14, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 40

Out of diff range and nitpick comments (1)
health-services/plan-service/README.md (1)

16-16: Avoid using bare URLs.

Consider using markdown syntax for the URL: [http://localhost:8080/](http://localhost:8080/).

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between fee2c58 and b314b18.
Files selected for processing (56)
  • build/17/maven/Dockerfile (1 hunks)
  • build/build-config.yml (1 hunks)
  • health-services/plan-service/README.md (1 hunks)
  • health-services/plan-service/pom.xml (1 hunks)
  • health-services/plan-service/src/main/java/digit/Main.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/config/Configuration.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/config/MainConfiguration.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/config/ServiceConstants.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/kafka/Consumer.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/kafka/Producer.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/PlanConfigurationRepository.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/PlanRepository.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/ServiceRequestRepository.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/impl/PlanConfigurationRepositoryImpl.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/impl/PlanRepositoryImpl.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanConfigQueryBuilder.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanQueryBuilder.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanConfigRowMapper.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanRowMapper.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanConfigurationService.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanEnricher.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanService.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanValidator.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/enrichment/EnrichmentService.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/validator/PlanConfigurationValidator.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/util/MdmsUtil.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/util/QueryUtil.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/util/ResponseInfoFactory.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/util/WorkflowUtil.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/controllers/PlanConfigController.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/controllers/PlanController.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Activity.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Assumption.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Condition.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/File.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/MetricDetail.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Operation.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Plan.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanConfiguration.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationRequest.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationResponse.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationSearchCriteria.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationSearchRequest.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanRequest.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanResponse.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanSearchCriteria.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanSearchRequest.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Resource.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/ResourceMapping.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/Target.java (1 hunks)
  • health-services/plan-service/src/main/resources/application.properties (1 hunks)
  • health-services/plan-service/src/main/resources/db/Dockerfile (1 hunks)
  • health-services/plan-service/src/main/resources/db/migrate.sh (1 hunks)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240305113045__plan_configuration_create_ddl.sql (1 hunks)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240305113047__plan_create_ddl.sql (1 hunks)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240404113045__plan_configuration_add_filestoreid_ddl.sql (1 hunks)
Files not processed due to max files limit (5)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240404150000__plan_configuration_add_template_identifier_ddl.sql
  • health-services/plan-service/src/main/resources/db/migration/main/V20241604150000__plan_configuration_add_status_ddl.sql
  • health-services/plan-service/src/test/java/digit/TestConfiguration.java
  • health-services/plan-service/src/test/java/digit/web/controllers/CreateApiControllerTest.java
  • health-services/plan-service/src/test/java/digit/web/controllers/PlanConfigControllerTest.java
Files not reviewed due to errors (3)
  • health-services/plan-service/src/main/java/digit/config/MainConfiguration.java (no review received)
  • health-services/plan-service/src/main/java/digit/config/Configuration.java (no review received)
  • health-services/plan-service/src/main/java/digit/service/PlanService.java (no review received)
Files skipped from review due to trivial changes (5)
  • health-services/plan-service/src/main/java/digit/Main.java
  • health-services/plan-service/src/main/java/digit/repository/PlanConfigurationRepository.java
  • health-services/plan-service/src/main/java/digit/web/models/Activity.java
  • health-services/plan-service/src/main/resources/db/Dockerfile
  • health-services/plan-service/src/main/resources/db/migration/main/V20240404113045__plan_configuration_add_filestoreid_ddl.sql
Additional Context Used
LanguageTool (3)
health-services/plan-service/README.md (3)

Near line 11: Unpaired symbol: ‘]’ seems to be missing
Context: ...ry integrating swagger to SpringBoot is [springfox](https://github.com/springfox/...


Near line 13: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...gfox/springfox) Start your server as an simple java application You can view...


Near line 18: You might be missing the article “the” here.
Context: ...g to http://localhost:8080/ Change default port value in application.properties

ShellCheck (5)
health-services/plan-service/src/main/resources/db/migrate.sh (5)

[info] 3-3: Double quote to prevent globbing and word splitting.


[info] 3-3: Double quote to prevent globbing and word splitting.


[info] 3-3: Double quote to prevent globbing and word splitting.


[info] 3-3: Double quote to prevent globbing and word splitting.


[info] 3-3: Double quote to prevent globbing and word splitting.

Additional comments not posted (128)
health-services/plan-service/src/main/java/digit/repository/PlanRepository.java (1)

1-16: Interface methods are correctly defined.

health-services/plan-service/src/main/java/digit/kafka/Producer.java (1)

1-20: Class correctly uses Lombok annotations and the custom Kafka template.

health-services/plan-service/src/main/java/digit/web/models/PlanRequest.java (1)

1-30: Class is well-defined with proper annotations for validation and serialization.

health-services/plan-service/src/main/java/digit/web/models/PlanResponse.java (1)

1-31: Class is well-defined with proper annotations for validation and serialization.

health-services/plan-service/src/main/java/digit/web/models/PlanSearchRequest.java (1)

1-30: Class is well-defined with proper annotations for validation and serialization.

health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationRequest.java (1)

1-31: The PlanConfigurationRequest class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationSearchRequest.java (1)

1-30: The PlanConfigurationSearchRequest class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

health-services/plan-service/src/main/java/digit/web/models/Target.java (1)

1-37: The Target class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

build/17/maven/Dockerfile (1)

1-34: The Dockerfile is well-structured and follows best practices. The use of Amazon Corretto and Maven is appropriate for the project.

health-services/plan-service/src/main/java/digit/web/models/Condition.java (1)

1-40: The Condition class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

health-services/plan-service/src/main/java/digit/web/models/Resource.java (1)

1-39: The Resource class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

health-services/plan-service/src/main/java/digit/web/models/PlanSearchCriteria.java (1)

1-46: The PlanSearchCriteria class is well-structured and follows best practices. The use of Lombok and validation annotations is appropriate.

health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationSearchCriteria.java (1)

21-23: The tenantId field with size constraint looks good.

health-services/plan-service/src/main/java/digit/web/models/ResourceMapping.java (3)

28-32: The filestoreId field with validation constraints looks good.


34-37: The mappedFrom field with validation constraints looks good.


39-42: The mappedTo field with validation constraints looks good.

health-services/plan-service/src/main/java/digit/web/models/PlanConfigurationResponse.java (4)

23-25: The responseInfo field with @Valid annotation looks good.


27-29: The planConfiguration field with @Valid annotation looks good.


31-33: The totalCount field with @Valid annotation looks good.


35-41: The addPlanConfigurationResponseItem method looks good.

health-services/plan-service/src/main/java/digit/web/models/Assumption.java (3)

27-30: The id field with validation constraints looks good.


32-35: The key field with validation constraints looks good.


37-43: The value field with validation constraints looks good.

health-services/plan-service/src/main/java/digit/repository/ServiceRequestRepository.java (2)

25-28: The constructor initializing mapper and restTemplate looks good.


31-44: The fetchResult method looks good with appropriate error handling.

health-services/plan-service/src/main/java/digit/web/models/Plan.java (6)

29-32: The tenantId field with validation constraints looks good.


34-36: The locality field with validation constraints looks good.


38-40: The executionPlanId field with validation constraints looks good.


42-44: The planConfigurationId field with validation constraints looks good.


49-51: The activities field with @Valid annotation looks good.


53-55: The resources field with @Valid annotation looks good.

health-services/plan-service/src/main/java/digit/web/models/Operation.java (2)

25-47: Class fields are well-defined with necessary validation constraints.


52-85: Enum OperatorEnum is well-implemented with appropriate methods for JSON handling.

health-services/plan-service/src/main/java/digit/web/controllers/PlanController.java (3)

32-36: The createPost method is well-implemented and correctly uses @Valid for request body validation.


43-47: The searchPost method is well-implemented and correctly uses @Valid for request body validation.


54-58: The updatePost method is well-implemented and correctly uses @Valid for request body validation.

health-services/plan-service/src/main/resources/db/migration/main/V20240305113047__plan_create_ddl.sql (5)

1-13: The plan table definition is well-structured with appropriate data types and constraints.


15-29: The plan_activity table definition is well-structured with appropriate data types, constraints, and foreign key reference to plan table.


31-44: The plan_activity_condition table definition is well-structured with appropriate data types, constraints, and foreign key reference to plan_activity table.


46-58: The plan_resource table definition is well-structured with appropriate data types, constraints, and foreign key reference to plan table.


60-74: The plan_target table definition is well-structured with appropriate data types, constraints, and foreign key reference to plan table.

health-services/plan-service/src/main/java/digit/web/models/File.java (2)

25-44: Class fields are well-defined with necessary validation constraints.


49-76: Enum InputFileTypeEnum is well-implemented with appropriate methods for JSON handling.

health-services/plan-service/src/main/java/digit/web/models/MetricDetail.java (2)

26-40: Class fields are well-defined with necessary validation constraints.


42-74: Enum MetricComparatorEnum is well-implemented with appropriate methods for JSON handling.

health-services/plan-service/src/main/java/digit/web/models/PlanConfiguration.java (2)

29-80: Class fields are well-defined with necessary validation constraints.


85-88: Enum StatusEnum is well-implemented.

health-services/plan-service/src/main/resources/application.properties (13)

1-2: Server configuration is well-defined.


4-6: Management endpoint configuration is well-defined.


8-12: Database configuration is well-defined.


14-22: Flyway configuration is well-defined.


24-33: Kafka server configuration is well-defined.


35-38: Kafka consumer configuration is well-defined.


40-43: Kafka producer configuration is well-defined.


45-47: Persister Kafka topics configuration is well-defined.


49-54: Localization configuration is well-defined.


57-58: MDMS configuration is well-defined.


61-67: Workflow configuration is well-defined.


70-70: Kafka topics consumer configuration is well-defined.


73-74: Pagination configuration is well-defined.

health-services/plan-service/src/main/resources/db/migration/main/V20240305113045__plan_configuration_create_ddl.sql (5)

2-12: The plan_configuration table creation statement looks correct.


16-27: The plan_configuration_files table creation statement looks correct.


31-42: The plan_configuration_assumptions table creation statement looks correct.


46-59: The plan_configuration_operations table creation statement looks correct.


63-73: The plan_configuration_mapping table creation statement looks correct.

health-services/plan-service/src/main/java/digit/repository/impl/PlanRepositoryImpl.java (5)

31-37: The constructor looks correct.


43-46: The create method looks correct.


53-67: The search method looks correct.


73-76: The update method looks correct.


83-100: The helper methods look correct.

health-services/plan-service/src/main/java/digit/web/controllers/PlanConfigController.java (4)

33-38: The constructor looks correct.


45-57: The configCreatePost method looks correct.


64-68: The configSearchPost method looks correct.


75-79: The configUpdatePost method looks correct.

health-services/plan-service/src/main/java/digit/service/PlanConfigurationService.java (4)

36-44: The constructor looks correct.


51-56: The create method looks correct.


63-72: The search method looks correct.


79-89: The update method looks correct.

health-services/plan-service/src/main/java/digit/util/MdmsUtil.java (3)

37-56: The fetchMdmsData method looks correct.


58-68: The getMdmsRequest method looks correct.


70-88: The getPlanModuleDetail method looks correct.

health-services/plan-service/src/main/java/digit/repository/impl/PlanConfigurationRepositoryImpl.java (5)

32-39: The constructor looks correct.


45-48: The create method looks correct.


56-62: The search method looks correct.


70-81: The count method looks correct.


88-90: The update method looks correct.

health-services/plan-service/src/main/java/digit/service/PlanEnricher.java (2)

22-55: The enrichPlanCreate method looks correct.


61-105: The enrichPlanUpdate method looks correct.

health-services/plan-service/src/main/java/digit/util/QueryUtil.java (2)

28-34: The addClauseIfRequired method looks correct.


42-52: The createQuery method looks correct.

health-services/plan-service/pom.xml (7)

37-39: Flyway dependency addition looks good.


42-44: PostgreSQL dependency addition looks good.


56-59: Swagger dependencies addition looks good.

Also applies to: 61-64


78-81: Lombok dependency addition looks good.


84-86: Jackson datatype JSR310 dependency addition looks good.


88-91: JUnit dependency addition looks good.


67-70: eGov services dependencies addition looks good.

Also applies to: 72-75

health-services/plan-service/src/main/java/digit/service/enrichment/EnrichmentService.java (5)

31-37: enrichCreate method implementation looks good.


43-59: enrichPlanConfiguration method implementation looks good.


67-71: enrichAuditDetails method implementation looks good.


79-85: enrichUpdate method implementation looks good.


91-121: enrichPlanConfigurationForUpdate method implementation looks good.

health-services/plan-service/src/main/java/digit/config/ServiceConstants.java (5)

46-47: Constants for user info missing look good.


49-50: Constants for assumption value not found look good.


52-53: Constants for filestore ID invalid look good.


55-56: Constants for assumption key not found in MDMS look good.


58-59: Constants for template identifier not found in MDMS look good.

health-services/plan-service/src/main/java/digit/util/WorkflowUtil.java (5)

49-65: getBusinessService method implementation looks good.


79-87: updateWorkflowStatus method implementation looks good.


96-104: getSearchURLWithParams method implementation looks good.


117-141: getProcessInstanceForWorkflow method implementation looks good.


180-186: callWorkFlow method implementation looks good.

build/build-config.yml (1)

171-177: Build configuration for plan-service looks good.

health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanQueryBuilder.java (4)

36-50: getPlanQuery method implementation looks good.


52-57: getPlanSearchQuery method implementation looks good.


65-99: buildPlanSearchQuery method implementation looks good.


101-113: getPaginatedQuery method implementation looks good.

health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanConfigQueryBuilder.java (6)

1-18: No issues found in the constructor and field declarations.


42-48: No issues found in the getPlanConfigSearchQuery method.


50-54: No issues found in the getPlanConfigCountQuery method.


63-103: No issues found in the buildPlanConfigSearchQuery method.


105-111: No issues found in the addClauseIfRequired method.


119-131: No issues found in the getPaginatedQuery method.

health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanConfigRowMapper.java (5)

24-61: No issues found in the extractData method.


71-92: No issues found in the addFiles method.


103-124: No issues found in the addAssumptions method.


134-157: No issues found in the addOperations method.


167-189: No issues found in the addResourceMappings method.

@@ -0,0 +1,3 @@
#!/bin/sh

flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote variables to prevent globbing and word splitting.

- flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
+ flyway -url="$DB_URL" -table="$SCHEMA_TABLE" -user="$FLYWAY_USER" -password="$FLYWAY_PASSWORD" -locations="$FLYWAY_LOCATIONS" -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
flyway -url="$DB_URL" -table="$SCHEMA_TABLE" -user="$FLYWAY_USER" -password="$FLYWAY_PASSWORD" -locations="$FLYWAY_LOCATIONS" -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate

health-services/plan-service/README.md Outdated Show resolved Hide resolved
health-services/plan-service/README.md Outdated Show resolved Hide resolved
health-services/plan-service/README.md Outdated Show resolved Hide resolved
Comment on lines 179 to 186
private void validatePlanConfigurationExistence(PlanRequest request) {
// If plan id provided is invalid, throw an exception
if(CollectionUtils.isEmpty(planConfigurationRepository.search(PlanConfigurationSearchCriteria.builder()
.id(request.getPlan().getPlanConfigurationId())
.build()))) {
throw new CustomException(INVALID_PLAN_CONFIG_ID_CODE, INVALID_PLAN_CONFIG_ID_MESSAGE);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle potential null values in the request.

Ensure that all fields in the PlanRequest are checked for null values before being used. This will prevent potential NullPointerException issues.

Comment on lines +192 to +211
private void validateResources(PlanRequest request) {
// If plan configuration id is not provided, providing resources is mandatory
if(ObjectUtils.isEmpty(request.getPlan().getPlanConfigurationId())
&& CollectionUtils.isEmpty(request.getPlan().getResources())) {
throw new CustomException("PLAN_RESOURCES_MANDATORY", "Resources are mandatory if plan configuration id is not provided");
}

// If plan configuration id is provided, providing resources is not allowed
if(!ObjectUtils.isEmpty(request.getPlan().getPlanConfigurationId())
&& !CollectionUtils.isEmpty(request.getPlan().getResources())) {
throw new CustomException("PLAN_RESOURCES_NOT_ALLOWED", "Resources are not allowed if plan configuration id is provided");
}

// Validate resource type existence
if(!CollectionUtils.isEmpty(request.getPlan().getResources())) {
request.getPlan().getResources().forEach(resource -> {
// Validate resource type existence
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle potential null values in the request.

Ensure that all fields in the PlanRequest are checked for null values before being used. This will prevent potential NullPointerException issues.

Comment on lines +217 to +231
private void validateResourceActivityLinkage(PlanRequest request) {
if(ObjectUtils.isEmpty(request.getPlan().getPlanConfigurationId())
&& !CollectionUtils.isEmpty(request.getPlan().getActivities())) {
// Collect all activity codes
Set<String> activityCodes = request.getPlan().getActivities().stream()
.map(Activity::getCode)
.collect(Collectors.toSet());

// Validate resource-activity linkage
request.getPlan().getResources().forEach(resource -> {
if(!activityCodes.contains(resource.getActivityCode()))
throw new CustomException("INVALID_RESOURCE_ACTIVITY_LINKAGE", "Resource-Activity linkage is invalid");
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle potential null values in the request.

Ensure that all fields in the PlanRequest are checked for null values before being used. This will prevent potential NullPointerException issues.

Comment on lines +237 to +250
private void validateTargetActivityLinkage(PlanRequest request) {
if(!CollectionUtils.isEmpty(request.getPlan().getActivities())) {
// Collect all activity codes
Set<String> activityCodes = request.getPlan().getActivities().stream()
.map(Activity::getCode)
.collect(Collectors.toSet());

// Validate target-activity linkage
request.getPlan().getTargets().forEach(target -> {
if(!activityCodes.contains(target.getActivityCode()))
throw new CustomException("INVALID_TARGET_ACTIVITY_LINKAGE", "Target-Activity linkage is invalid");
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle potential null values in the request.

Ensure that all fields in the PlanRequest are checked for null values before being used. This will prevent potential NullPointerException issues.

@egovernments egovernments deleted a comment from coderabbitai bot May 22, 2024
@egovernments egovernments deleted a comment from coderabbitai bot May 22, 2024
kavi-egov pushed a commit that referenced this pull request Jun 20, 2024
…ng, delivery type integarted (#790)

* Update campaignValidators.ts (#655)

* fixes-> cyclenumber issue, hover issue, dropdown height issue,

* css

* fixes-> cyclenumber issue, hover issue, dropdown height issue, (#656)

* fixes-> cyclenumber issue, hover issue, dropdown height issue,

* css

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update campaignUtils.ts

* fixed HLM-5970

* Feat : added boundary validation at data level

* fixes

* local add

* Added boundary validation

* Refactor

* fixed HLM-5935 and HLM-5749

* Refactor

* Feat : updated table

* change campaignid in payload

* Feat : added campaignId

* Update campaignApis.ts

* Update campaignValidators.ts

* refactored

* Refactor

* assigned campaignId

* Refactor

* updated createRequest Schema

* Feat : invalid Status Persist

* status fix

* version-fix

* Update CODEOWNERS

* core version updated and css fix for language dropdown

* refactor (#676)

* Uat signoff (#678)

* change in filter recursive

* lowest level

* added validation related to target sheet headers

* HLM-5916

* download button fixes in summary (#682)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Hlm 5927 (#687)

* change in filter recursive

* lowest level

* added validation for boundary codes to be invalid other than that selected from UI in target upload

* Added Delivery and cycle config for LLIN and SMC both (#688)

* no of cycle and deivery drafted changes

* fixes

* add localisation code for boundaries

* fixes

* fixes

* Value localise in summary screen, api error change

* fixes

* genarate api call fix

* font size change for summary

* login css change

* HLM-5718: SMC delivery config enhancement

* config update

* added config for in between

* fix config for llin

* added mdms integration

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Fixed HLM-5988_warning message (#689)

Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com>

* download filename fixes (#693)

* download button fixes in summary

* download filename with custom name changes added

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* download filename fixes (#694)

* download button fixes in summary

* download filename with custom name changes added

* config fix for llin

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* successful toast message is fixed (#695)

* successful toast message is fixed

* Update UploadData.js

* HLM-5991: Alert Pop UP CR (#696)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-5718 changes (#703)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Localization cache (#706)

* change in filter recursive

* lowest level

* refactored  localization cache logic

* Update README.md (#707)

* Update README.md

* Update README.md

* Update utilities/project-factory/README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update README.md

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* HLM-5985_made lowest level changes (#708)

* HLM-5985_made lowest level changes

* resolved codeRabbit comments

* Create LOCALSETUP.md (#709)

* Create LOCALSETUP.md

* Refactored config

* Update LOCALSETUP.md

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/LOCALSETUP.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update LOCALSETUP.md

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* updated the localisation module config

* Refactor config (#713)

* Refactor config

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update postman_collection.json (#714)

* Update postman_collection.json

* Update postman_collection.json

* Delete utilities/project-factory/project_factory_swagger.yml (#715)

* Feat : removed campaignId validation for boundary upload (#718)

* updated the delay for boundary relationship

* added logger for request TODO TEST

will be reverted

* Revert "added logger for request TODO TEST"

This reverts commit d5c2bf5.

* Schema validation (#719)

* Feat : removed campaignId validation for boundary upload

* Feat : added schema validation

* Fixed mdms host

* updated the logger messages

* updated the loggers

* delivery new changes, toast fix, error fix (#716)

* delivery new changes, toast fix, error fix

* new fixes

* fixes

* change text component to field component

* added hierarchy

* fix

* fix

* fix

* fix

* passing hierarchy from props

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Schema validation2 (#721)

* Feat : removed campaignId validation for boundary upload

* Feat : added schema validation

* Fixed mdms host

* Feat : added boundary validation

* Feat : optimized product search

* Fix : project mapping fixed (#722)

* Fixed project search (#723)

* smc fixes (#724)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Feat : added boundary confirmation (#727)

* Fix: fixed processing boundary

* Refactor

* fixed HLM-6109 (#729)

* gate fixes validation, ui ux (#731)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* integrated panelcard component (#732)

* integrated panelcard component

* Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/Response.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update genericUtils.ts (#733)

* updated the folder structure

* Create CHANGELOG.md (#717)

* updated the versions

* Update .gitignore

* Update request.ts (#735)

* fixed generate api issue (#734)

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>

* Create CHANGELOG.md

* gate fixes (#736)

* gate fixes validation, ui ux

* gate fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* added loader in the selecting boundaries (#737)

* Update createAndSearch.ts (#738)

* fix (#739)

* fix

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Patch 3 (#740)

* change in filter recursive

* lowest level

* trimmed underscore and empty spaces

* boundary fix (#742)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update genericUtils.ts (#746)

* fixed the delivery products issue

* Fixed delivery conditions issue

* Update campaignApis.ts (#747)

* fixed warning toast (#748)

* fixed warning toast

* Update UploadData.js

* fix (#749)

* fix

* fx

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* core -update (#751)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* fixed stepper issue (#752)

* fixed stepper issue

* Update index.html

* Feat : added user validation via individual (#753)

* fixes (#754)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* code fix nabeel (#756)

* fixes

* fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Updated few loggers (#759)

* updated few loggers flow

* Update utilities/project-factory/src/server/api/campaignApis.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/api/campaignApis.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/campaignMappingUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update utilities/project-factory/src/server/utils/genericUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Updated the user Password generation logic #761

* Update Listener.ts (#730)

* Update Listener.ts

* added try catch logic in producer

* Feat : added parallel batch execution (#767)

* Feat : added parallel batch execution

* Refactor

* Update utilities/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixed the stepper (#765)

* changes config (#769)

* Project type config and added loggers for process of campaign (#772)

* Feat : added themes in generate template (#773)

* fixed the ajv package version for build issue

* Feat : removed xlsx (#776)

* HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT (#778)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* css update (#780)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-6179 and HLM-6180 (#777)

* HLM-6179 and HLM-6180

* campaign name changes

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>

* Feat : fixed target generation (#781)

* fixed tenantId issue (#784)

* fix: resolved AJV-related Jenkins build issue reference #783 #786 (#787)

* module ui fix

* updated all the package version for build fixes

* fixed kafka-error at target generation (#789)

* updated core version (#791)

* updated core version

* updated css also

* Update campaignValidators.ts (#794)

* Updated the excel generation logic and files

* added changes for configurable column in target sheet (#779)

* change in filter recursive

* lowest level

* made target headers  genearte through mdms schema

* changed config index.ts

* changed config index.ts

* changes for now

* added configurable column logic from schema HLM-6169

* updated validate of target columns through schema

* added masterForColumnSchema in index.ts

* formatted dataManageService

* refactored lock TargetFields func

* removed console.log

* User creation performance improved (#800)

* Feat : Improved user creation performance

* Change status color

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update genericUtils.ts (#801)

* Hlm 6170 (#802)

* change in filter recursive

* lowest level

* HLM -6170 added logic for only village level data in target sheet and some refactoring

* updated css (#804)

* fixed button issue (#805)

* HLM 6177: Error card implementation in summary screen (#806)

* HLM-6177: PARALLEL SEARCH IMPLEMENT, DELIVERY TYPE IMPLEMENT

* Added Error Cards in summary screen and redirection

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* added error button styles (#807)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* updated popUp css (#808)

* HLM 6178: Implementing New Pop up screen in boundaries (#809)

* added error button styles

* Implementing New Pop up screen in boundaries

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Facility changes (#812)

* Feat : changed facility Template

* Feat : locked target templates

* fixed colour issue (#813)

* Updated the project type conversion logic for the             "deliveryType" dont1 and n config

* Unique field added (#814)

* Feat : changed facility Template

* Feat : locked target templates

* Feat : added unique check logic

* Target schema update (#815)

* change in filter recursive

* lowest level

* updated shcema of target columns to be configurable

* removed empty spaces from config index.ts

* Active mapping (#817)

* Feat : changed facility Template

* Feat : locked target templates

* Feat : added unique check logic

* Feat : added mapping via active field

* changes in the schema validation (#816)

* Updated the workbench and css module version

* Feat : added active inactive boundary check (#818)

* Update campaignValidators.ts (#819)

* added active inactive validation (#820)

* changed api call time (#826)

* Feat : added target sum mapping (#825)

* added campaign type as filter (#827)

* Update genericApis.ts (#828)

* Update excelUtils.ts (#829)

* UI issue fixes, icon fix in summary error (#831)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Target columns (#830)

* change in filter recursive

* lowest level

* commit

* Feat : target flow fixed for LLIN-mz

* uat to dev

---------

Co-authored-by: admin1 <nitish@egovernments.org>

* Feat : freezed target columns (#833)

* Target mr dn (#834)

* change in filter recursive

* lowest level

* Feat : skipped validation temporarily

* changes in the target validation (#835)

* fixed error info (#837)

* Added roboto font (#840)

* Feat : added roboto font

* Fixed config

* target validation based on diff campaign types (#843)

* change in filter recursive

* lowest level

* updated validation of target based on campaign type

* fixed validation issue (#844)

* Updated the workbench package version

* fixed validation logic (#846)

* fixed validation logic

* Update micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Error messages improved (#848)

* Feat : imporved error messages and initilised utils for tracking process

* Fix ; unused variables fixed

* Feat : improved error messages

* Fix : download error fix (#850)

* Update campaignUtils.ts (#851)

* Update campaignUtils.ts

* Update utilities/project-factory/src/server/utils/campaignUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update campaignValidators.ts (#853)

* HLM 6210: Toast, error focus fix and project type reset delivery data fix  (#854)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* HLM-6225_added time out according to data (#855)

* Update campaignValidators.ts (#859)

* HLM 6210 (#858)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

* parallel search fixes

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Remove validation (#852)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* spacing refactor

* Update campaignValidators.ts (#863)

* Header validation (#861)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* changed the logic of header validation

* space refactor

* Update campaignUtils.ts (#864)

* fixed ui error (#865)

* Read me (#867)

* change in filter recursive

* lowest level

* removed unnecessary validation for target

* changed the logic of header validation

* fixed portugese language error

* space refactoring

* Update Dockerfile

* Update Dockerfile

* Update migrate.sh

* Update Dockerfile

* Update campaignValidators.ts (#868)

* HLM 6210:campaign type change reset fix (#869)

* HLM-6210: campaign type change reset delivery data fix, summary error focus fix

* summary error focus fix

* parallel search fixes

* campaign type change reset fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update excelUtils.ts for sheetHeaders wraping (#870)

* Update package.json

* updated error messages (#871)

* feat : added jaeger-client tracing (#872)

* updated the table config

* Update campaignApis.ts (#875)

* removed the schema and updated the db name

* fixing generate API call, file auto delete, date error (#877)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Trim resource (#878)

* Feat : trimmed resource persist message

* Refactor

* Removed reject error in produce message

* fixed min time, draft logic (#879)

* Update index.ts (#880)

* added min ui error and facility usage (#883)

* added min ui error and facility usage

* changes

* Update campaignUtils.ts (#884)

* HLM 6007 (#885)

* fixing generate API call, file auto delete, date error

* generate api fix

---------

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* Update Dockerfile

* Feat : docker config update (#886)

* Update Dockerfile (#887)

* Create buildWorkbenchUI.yml

* Update README.md (#917)

* Update buildWorkbenchUI.yml

* Update README.md

* Updated the DB Schema issue of Project-factory

* fixed hierarchy order (#919)

* User flag hcm (#920)

* Feat : docker config update

* Feat : added user create flag

* Refactored

* Update campaignUtils.ts

* Update campaignMappingUtils.ts (#922)

* Ashish egov patch 2 (#921)

* Update index.ts

* Update campaignApis.ts

* Fixed the project type conversion and product duplicate issue

* Update campaignApis.ts (#924)

* Update campaignMappingUtils.ts (#925)

* Update campaignMappingUtils.ts

* Refactored

* Update publishProjectFactory.yml

* Update buildWorkbenchUI.yml

* Update campaignMappingUtils.ts (#926)

* Update request.ts (#928)

* Update request.ts

* Feat : updated httprequest

* Feat : warning response added

* Refactor

* added start and enddate in cycles

* Update campaignApis.ts (#930)

* Update request.ts (#932)

* fixed generate issue (#933)

* Fixed project-type resources duplication

* updated target error messages (#936)

* fixed stepper from draft (#937)

* Update Listener.ts

* delivery type disable fix, product sku name change (#939)

Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>

* fixed error message issue (#941)

* Redis integration (#940)

* Feat : added redis

* Feat : added redis retry

* updated migration

* fixed

* updated migration

* Delete .vscode/launch.json

* Delete .vscode/settings.json

---------

Co-authored-by: ashish-egov <137176738+ashish-egov@users.noreply.github.com>
Co-authored-by: nabeelmd-eGov <nabeel.md@egovernments.com>
Co-authored-by: nabeelmd-eGov <94039229+nabeelmd-eGov@users.noreply.github.com>
Co-authored-by: Bhavya-egov <bhavya.mangal@egovernments.org>
Co-authored-by: ashish-egov <ashish.tiwari@egovernments.org>
Co-authored-by: nitish-egov <137176807+nitish-egov@users.noreply.github.com>
Co-authored-by: Bhavya-egov <137176879+Bhavya-egov@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Swathi-eGov <137176788+Swathi-eGov@users.noreply.github.com>
Co-authored-by: admin1 <nitish@egovernments.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants