Skip to content

Commit

Permalink
Dev (#1235)
Browse files Browse the repository at this point in the history
* Hlm 6385 irs changes (#841)

* HLM-6385: added changes for IRS activity track and closed household concepts

* HLM-6385: added changes for IRS activity track and closed household concepts, added db migration script, validations for closed household

* HLM-6385: added changes for location tracking

* HLM-6385: added changes for location points

* HLM-6385: added clientReferenceId and tenantId in LocationPoint, updated Location_capture model

* HLM-6385, HCMPRE-46: Updated changes as per design review

* HLM-6385, HCMPRE-46: Added Location capture changes

* HLM-6385, HCMPRE-46: Added UserAction changes

* HLM-6385, HCMPRE-46: updated common models, replaced digit models with service-common

* Revert "HLM-6385, HCMPRE-46: updated common models, replaced digit models with service-common"

This reverts commit 6abdea4.

* HLM-6385, HCMPRE-46: updated table informations and columns for migration scripts

* reverting BoundaryUtil change

* reverting BoundaryUtil changes

* HLM-6385, HCMPRE-46: updated validators and IRSConsumer

* HLM-6385, HCMPRE-46: updated validators

* HLM-6385, HCMPRE-46: updated project configuration

* HLM-6385, HCMPRE-49: updated models to have isDeleted as it is required in common utils enrichment code

* HLM-6385, HCMPRE-46: updated the projectid field, added notnull annotation

* HLM-6385, HCMPRE-46: updated all the changes related to enrichment

* HLM-6385, HCMPRE-46: made action field notnull

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields, HCMPRE-116, HCMPRE-117

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields, HCMPRE-116, HCMPRE-117, added in services

* HLM-6385, HCMPRE-46: removed outdated changes from Task.java

* removed all user location models

* Refactored from LocationCapture model to UserAction and packges from irs to useraction

* HLM-6385 - lat/long irs name changes

* HLM Downsync Incremental product changes pull from impel (#831)

* HLM Downsync Incremental product changes pull from impel

* HLM removed impel specific changes

* renamed Project type filter code constant

* HLM updated beneficiary based search

* HLM updated downsync search, cycles is required only when it is smc based campaign

* HCM - removed project task resource quantity validator

* HLM updated downsync logic as per review comments

* HCMPRE-216 : Added Administration failed status for validation when task resource is empty or when status is ADMINISTRATION_FAILED

* HCMPRE-216: updated task status

* HCMPRE-216: changed to ADMINISTRATION_FAILED

* HLM-6385: updated with code review comments

* HLM-6385: added changes as per review comments, and added correct logs wherever required.

* HLM-6385: code review comments addressed.

* HLM-6385: review comment added for error handling on LocationCaptureRepository

* HLM-6385: another batch of coderabbitai code review comments addressed.

* HLM-6385: added more logs in repository for useraction and location capture

* HLM-6385: updated the code as per code review comments from @kavi-egov

---------

Co-authored-by: kavi_elrey <[email protected]>
Co-authored-by: Holash Chand <[email protected]>

* Hcmpre 240 (#846)

* HLM closed household status

* HCMPRE-240: validate no resource task status scenario with configurable statuses

* HCMPRE-240: fixed issues related to string trimming

* HLM fixed rowversion referral bug, mis placement of rowversion validator

* HCMPRE-240: code review changes

* HCMPRE-242: updated for null resources and address check

* HCMPRE-242: added for proper null check

* HCMPRE-242: added checks for task resource where ever applicable

* HCMPRE-242: updated taskstatus to enum from string

* HCMPRE-242, HCMPRE-240: renamed task's status field to taskStatus field, as there is contradiction with EgovModel status field

* HCMPRE-242: fixed dupcalite entity cache issue for existing entity validation during bulk create

* HCMPRE-242: updated project test case for taskStatus field contraints changes : not null

* HCMPRE-242: fix generic repository code

* HCMPRE-242: added taskstatus migration script

* HCMPRE-240: updated PtIsResourceEmptyValidator, for task status

* HLM-242: added changes as per code review

* Revert "HCMPRE-242: added taskstatus migration script", and removed status field from EgovModel, and rename TaskStatus to status

This reverts commit 7caf0c4.

* HCMPRE-240: FIXED all task status reference

---------

Co-authored-by: sivajiganesh-dev <[email protected]>

* HLM rowmapper issue in household, referral fixed (#848)

* HLM rowmapper issue in household, referral fixed

* HCMPRE-255: updated the changes for household

* reverted local changes commit by mistake

* added logic for cascading project date updates (#834)

* added logic for cascading project date updates

* updated application.properties

* refactored logic for using ProjectRequest pojo to send message to kafka instead of Ancestor and Descendant Projects pojo

* added comments and enhanced search project logic

* made public back to private

* made  more concise the method in project service separated create project map logic

* separated concerns of update based on action whether null or updateProjectDates

* updated action logic for just test purpose

* updated version of health-service-models library

* update logic

* updated final logic for cascading update project dates based on flag in project request

* reverted config

* reverted config 2

* added multiple line comments

* udpated error messages

* HLM fixed issues in useraction existent entity validator (#850)

* HLM fixed issues in useraction existent entity validator

* updated after code review comments

* updated version for hcm v1.5 release (#852)

* updated version for hcm v1.5 release

* HLM updated the code as per code review from code rabbit

* HCMPRE-209: updated code review comments and code documentation

* Hcmpre 309 rebase (#857)

* removed digit-models from health-services-models library

* removed digit-models from health-services-models library

* added SMSRequest model

* Updated individual models

* Updating health services models version in health services common library

* version bump

* hcmpre-309: merged removed-digit-models and rebase to dev

* HLM-309: updated common models version

---------

Co-authored-by: shubhang-egov <[email protected]>

* HCMPRE-169 code review comments (#835)

* HCMPRE-169 code review comments

* HCMPRE-169 adding code comments

* HCMPRE-169 adding code comments

* HCMPRE-169 changing mdms v2 field name for uom

* HCMPRE-169 code review comments

* HCMPRE-169 code review comments

* HCMPRE-218 adding validation for plan config name  (#844)

* HCMPRE-218 adding validation for name validation

* HCMPRE-218 adding validation for name validation

* HCMPRE-218 moving "$." into constants

* HCMPRE-218 code review comments

---------

Co-authored-by: kavi_elrey@1993 <[email protected]>

* HCMPRE-646: added changes (#897)

* Update CODEOWNERS (#924)

* Hcmpre 639 shashwat changes (#919)

* Removed the project facility mapping validation check as it is not required

* Removed the project facilty valaidation check in ValidatorUtil.java

* Removed the local receiverId in ValidatorUtil.java

---------

Co-authored-by: Shashwat12-egov <[email protected]>

* Fixed multiple role search in individual service (#992)

* Hcmpre 639 shashwat changes (#973)

* Removed the project facility mapping validation check as it is not required

* Removed the project facilty valaidation check in ValidatorUtil.java

* Removed the local receiverId in ValidatorUtil.java

* Validating the sender and receiver based on transactiontype

* Validating the sender and receiver based on transactiontype

* Corrected the validation for the failed case

* Added the comments

---------

Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: kavi_elrey@1993 <[email protected]>

* HCMPRE-371: Added service definition update api (#996)

* update service definition api added

* fix values persister config

* fix "values" persister config

* active added in service definition persister config

* resolved code review comments

* added includeDeleted parameter in search

* fix some issues

* fix create api

* Update ValidatorUtil.java (#1112)

* added-search-criterias-project-service (#1169)

* Service additional field (#1146)

* changed additionalDetails to additionalFields

* boolean data type added in attribute definition

* Added the filter for isActive

* changed the serviceDefinition.code size from character varying(64) to character varying(256)

* Revert "changed the serviceDefinition.code size from character varying(64) to character varying(256)"

This reverts commit 24c971f.

* Revert "Added the filter for isActive"

This reverts commit 09d65c4.

* changed the code character size from 64 to 256 (#1147)

Co-authored-by: shubhang-eGov <[email protected]>

* added validation for boolean data type in service-request

---------

Co-authored-by: yashita-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: shubhang-eGov <[email protected]>

* Hcmpre 469 pagination all (#891)

* HCMPRE-469: added changes for facility count

* HCMPRE-469: added changes for models, added totalCount fields in required model classes

* HCMPRE-469: added changes for project facility, project staff, project resource, hf-referral, stock and stock reconciliation, also added helper function in common utils for findWithCount

* HCMPRE-469: added changes for removing digit-models deprecated dependency, replaced with tracer library references and mdms client references

* HCMPRE-469: added changes for project service, removed reference for digits model

* Removed the dev from version

* Removed the dev from version of common libraries

* Removed the dev from version of common libraries

* Removed the order by id statement while searching the facility

* Removed setting of total count line from the FacilityService file

* Removed setting of total count line from the FacilityService file

---------

Co-authored-by: Shashwat12-egov <[email protected]>
Co-authored-by: shubhang-eGov <[email protected]>

* PR to develop branch for Microplanning v0.1 (changes in plan-service, resource-generator service) (#1176)

* HCMPRE-599 updating Plan service models

* HCMPRE-599 updating Plan service models

* HCMPRE-599 changes

* HCMPRE-599 adding census POJOs

* HCMPRE-599changes for triggering pland census records on workflow status

* HCMPRE-599 app.prop changes for resource generator service

* Renaming resource-estimation-service to resource-generator

* HCMPRE-1078  enrichment of resource mapping

* HCMPRE-1122 changing processing logic

* HCMPRE-1122 changing processing logic

* HCMPRE-1122 updating operation related validations

* HCMPRE-1122 adding method comments

* enhancement in facilityCatchmentConsumer

* enhancement in facilityCatchmentConsumer

* removing catchement topic that was added before

* added wf validation for approving estimations

* adding additionalDetails as string while preparing rows for batchUpdate

* adding additionalDetails as string while preparing rows for batchUpdate

* HCMPRE-1094 changes for facility mapping create trigger on workflow

* reverting the change in census-bulk-api

* parsing additional details in bulk update api

* Added plan config name in plan employee's and plan facility's search criteria

* Bypassing validations for operations when source is CUSTOM

* added workflow validations

* removing unused service constants

* Changes for triggering plan-facility mapping

* adding project factory data create host

* handling case for empty areaCodes in search criteria

* handling case for empty areaCodes in search criteria

* adding project factory data create host

* Adding facility create trigger status

* Adding additionalField table in census

* adding plan config name in plan employee and plan facility pojo

* Adding additionalField table in census

* implemented partial search in plan config name

* Changing datatype of value

* HCMPRE-1162 enrich additionalfieldForCensus

* HCMPRE-1162 enrich additionalfieldForCensus

* updated query builder for census

* handling null pointer exception on updating additional details

* Changes to allow assumption values in input

* Removing older method for getting input value

* Making editable false for uploaded additional field during census create

* HCMPRE-853 removing lat long fields from additional field overridekeys

* Changes for adding execution order for operations

* Changes for adding execution order for operations

* Adding facilityName column and enriching servingPop

* HCMPRE-853 added chnages for census search and fetching boundarycodes from one sheet

* HCMPRE-853 changes for updating file with approved census data

* HCMPRE-853 adding logs

* pull from microplanning-dev

* HCMPRE-853 integrating with project factory with updated resources

* modification in wf-service

* workflow auto-assignee issue

* HCMPRE-853 commenting project factory integration

* adding pagination for plan-employee api

* changed the data type of BigDecimal

* HCMPRE-1282 changes for updating estimates into plan

* HCMPRE-1282 app.prop changes

* Adding case for when celltype is formula.

* enriching additional details with additional field key-value

* modified orderBy clause

* made changes in order by clause

* added facilityType

* pull from microplanning-dev

* making fuzzy search cAse-insenSItive

* making fuzzy search cAse-insenSItive

* making fuzzy search cAse-insenSItive

* pull from microplanning-dev

* pull from microplanning-dev

* modified pagination

* HCMPRE-1282 changes for updating approved plans into file for campaign integration

* added planConfigStatus in search criteria

* HCMPRE-1282 changes for updating approved plans into file for campaign integration

* HCMPRE-771 merging multiple alter table migration scripts into create table scripts.

* Adding workflow restricted roles in census

* Adding workflow restricted roles in census

* Fixing limit and adding check for empty row

* Fixing limit and adding check for empty row

* added ranked query for plan employee assignment

* added ranked query for plan employee assignment

* HCMPRE-1300 DB migration script cleanup

* adding plan bulk update topic

* Adding facility name in census additional details

* Wf auto assignment to multiple people

* Wf auto assignment to multiple people

* Adding boundaryTypeHierarchy Pojos and search endpoint

* enriching jurisdiction mapping in census

* changing jurisdictionMapping from jsonIgnore to jsonProperty

* optimizing the enrichment functions and adding comments

* handling null pointer exception

* Wf auto assignment to multiple people

* Set last modified time on update call

* enriching serving population with sum of confirmed target population of serving boundaries

* Reverting campaign update at the end.

* modifying Wf for send back actions

* enriching jurisdiction mapping in plan

* setting assignees separetly for send back actions

* Changing assignee column to Text in db

* Changing assignee column to Text in db

* enriching jurisdiction mapping

* Changing validation logic for operations

* enriching jurisdiction mapping

* Changes for only validating when operation is active

* Sort operations in planconfig search by execution order

* Sort operations in planconfig search by execution order

* Sort operations in planconfig search by execution order

* Sort operations in planconfig search by execution order

* type casting jurisdiction into list

* Adding census changelog

* Adding census changelog

* Adding census changelog

* Adding census changelog

* Adding census changelog

* Show on UI false for lat long fields

* Updated plan service CHANGELOG

* update plan config validation

* Adding jurisdiction mapping in plan facility

* Changing all collection dataType from list to set in API search criteria

* Changing all collection dataType from list to set in API search criteria

* removing validation for operation source

* adding overloaded method for query builder in plan

* adding overloaded method for query builder in plan

* Adding validation to check for duplicates

* pull from census-bulk-api

* pull from census-bulk-api

* Removing comments from WF in resource generator

* Decreasing min size of assumptionvalue in Operation POJO to 1.

* Changing mdms master in plan service for hierarchyConfig

* changing min size of resource type in resource pojo

* increasing request size for producer

* changed version from 1.1.0 to 1.0.0

* changed version from 1.1.0 to 1.0.0

* changing the order

* changing the order

* changing the order

* Increasing request size in application.properties

* Updating resource generator changelog

* Updating resource generator changelog

* Adding boundaryAncestralPath for Plan Facility API

* Adding boundaryAncestralPath for Plan Facility API

* Adding ProjectFactory consumer in Plan Facility Service

* Adding ProjectFactory consumer in Plan Facility Service

* Adding plan changelog

* Adding empty list as service boundary when null in consumer for project-factory

* Increasing the max-request-size in census producer configuration

* Increasing the max-request-size in plan producer configuration

* Adding orderBy clause for plan search query

* Removing unused census consumer

* Replacing map from set for duplicate check in census row mapper

* Replacing map from set for duplicate check in plan config row mapper

* Replacing map from set for duplicate check in census row mapper

* Replacing map from set for duplicate check in census row mapper

* Replacing map from set for duplicate check in plan config row mapper

* Replacing map from set for duplicate check in plan row mapper

* Clearing set on new census entry

* Clearing set on new plan entry

* Clearing set on new plan config entry

---------

Co-authored-by: Shashwat Mishra <[email protected]>
Co-authored-by: Tanishi Goyal <[email protected]>

---------

Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: kavi_elrey <[email protected]>
Co-authored-by: Holash Chand <[email protected]>
Co-authored-by: sivajiganesh-dev <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: shubhang-egov <[email protected]>
Co-authored-by: Priyanka-eGov <[email protected]>
Co-authored-by: Shashwat12-egov <[email protected]>
Co-authored-by: Shashwat Mishra <[email protected]>
Co-authored-by: yashita-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: shubhang-eGov <[email protected]>
Co-authored-by: Tanishi Goyal <[email protected]>
  • Loading branch information
14 people authored Dec 13, 2024
1 parent 8072220 commit 3f860f8
Show file tree
Hide file tree
Showing 222 changed files with 1,312 additions and 879 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @kavi-egov @sathishp-eGov

health-services/project-factory/ @jagankumar-egov
health-services/project-factory/ @jagankumar-egov
2 changes: 1 addition & 1 deletion core-services/service-request/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.22.3</version>
<!-- <version>9.22.3</version>-->
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public MappingJackson2HttpMessageConverter jacksonConverter(ObjectMapper objectM
@Value("${egov.service.definition.create.topic}")
private String serviceDefinitionCreateTopic;

@Value("${egov.service.definition.update.topic}")
private String serviceDefinitionUpdateTopic;

@Value("${egov.service.create.topic}")
private String serviceCreateTopic;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.egov.servicerequest.error;

import org.springframework.stereotype.Component;
import org.apache.kafka.common.protocol.types.Field;

@Component
public class ErrorCode {
Expand Down Expand Up @@ -30,6 +31,8 @@ public class ErrorCode {

public static final String SERVICE_REQUEST_ATTRIBUTE_INVALID_MULTI_VALUE_LIST_VALUE_MSG = "Attribute Value provided against the attribute definition of type multi value list must be an instance of list";

public static final String SERVICE_REQUEST_ATTRIBUTE_INVALID_BOOLEAN_VALUE_MSG = "Attribute Value provided against the attribute definition of type boolean must be an instance of boolean";

public static final String INVALID_SIZE_OF_INPUT_CODE = "INVALID_SIZE_OF_INPUT_CODE";

public static final String INVALID_SIZE_OF_TEXT_MSG = "Text value cannot be of length greater than configured length ";
Expand Down Expand Up @@ -61,4 +64,17 @@ public class ErrorCode {
public static final String INVALID_REGEX_ERR_CODE = "INVALID_REGEX_ERR_CODE";

public static final String INVALID_REGEX_ERR_MSG = "The provided regex failed to compile for attribute definition with code - ";

public static final String SERVICE_DEFINITION_NOT_EXIST_ERR_CODE = "SERVICE_DEFINITION_NOT_EXIST_ERR_CODE";

public static final String SERVICE_DEFINITION_NOT_EXIST_ERR_MSG = "Provided tenantId and code unique combination does not exist";

public static final String VALID_SERVICE_EXIST_ERR_CODE = "VALID_SERVICE_EXIST_ERR_CODE";

public static final String VALID_SERVICE_EXIST_ERR_MSG = "Valid Service exists corresponding to Service Definition";

public static final String INACTIVE_SERVICE_DEFINITION_ERR_CODE = "INACTIVE_SERVICE_DEFINITION_ERR_CODE";

public static final String INACTIVE_SERVICE_DEFINITION_ERR_MSG = "Inactive Service Definition cannot be updated";

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public String getServiceDefinitionsIdsQuery(ServiceDefinitionSearchRequest servi
}

// Fetch service definitions which have NOT been soft deleted
addClauseIfRequired(query, preparedStmtList);
query.append(" sd.isActive = ? ");
preparedStmtList.add(Boolean.TRUE);
if(!serviceDefinitionSearchRequest.isIncludeDeleted()){
addClauseIfRequired(query, preparedStmtList);
query.append(" sd.isActive = ? ");
preparedStmtList.add(Boolean.TRUE);
}

// order service definitions based on their createdtime in latest first manner
query.append(ORDERBY_CREATEDTIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@ public List<ServiceDefinition> searchServiceDefinition(ServiceDefinitionSearchRe

public ServiceDefinition updateServiceDefinition(ServiceDefinitionRequest serviceDefinitionRequest) {

// TO DO
ServiceDefinition serviceDefinition = serviceDefinitionRequest.getServiceDefinition();

//Validate incoming service definition request
ServiceDefinition definitionFromDb = serviceDefinitionRequestValidator.validateUpdateRequest(serviceDefinitionRequest);

//Enrich incoming service definition request
enrichmentService.enrichServiceDefinitionUpdateRequest(serviceDefinitionRequest, definitionFromDb);

// Producer statement to emit service definition to kafka for persisting
producer.push(config.getServiceDefinitionUpdateTopic(), serviceDefinitionRequest);

// Restore attribute values to the type in which it was sent in service definition request
enrichmentService.setAttributeDefinitionValuesBackToNativeState(serviceDefinition);

return serviceDefinitionRequest.getServiceDefinition();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;

@Component
public class ServiceRequestEnrichmentService {
Expand Down Expand Up @@ -110,4 +111,68 @@ public void setAttributeValuesBackToNativeState(ServiceRequest serviceRequest, M
attributeValue.setValue(attributeCodeVsValueMap.get(attributeValue.getAttributeCode()));
});
}

private void updateAttributeDefinition(AttributeDefinition attributeDefinition, AttributeDefinition existingAttributeDefinition, RequestInfo requestInfo){

attributeDefinition.setId(existingAttributeDefinition.getId());

attributeDefinition.setAuditDetails(existingAttributeDefinition.getAuditDetails());

attributeDefinition.setReferenceId(existingAttributeDefinition.getReferenceId());

attributeDefinition.getAuditDetails().setLastModifiedTime(System.currentTimeMillis());

attributeDefinition.getAuditDetails().setLastModifiedBy(requestInfo.getUserInfo().getUuid());

}
private void upsertAttributeDefinition(AttributeDefinition attributeDefinition, ServiceDefinitionRequest serviceDefinitionRequest){
RequestInfo requestInfo = serviceDefinitionRequest.getRequestInfo();

attributeDefinition.setId(UUID.randomUUID().toString());

attributeDefinition.setAuditDetails(
AuditDetails.builder()
.createdBy(requestInfo.getUserInfo().getUuid())
.createdTime(System.currentTimeMillis())
.lastModifiedBy(requestInfo.getUserInfo().getUuid())
.lastModifiedTime(System.currentTimeMillis())
.build()
);

attributeDefinition.setReferenceId(serviceDefinitionRequest.getServiceDefinition().getId());
}
public void enrichServiceDefinitionUpdateRequest(ServiceDefinitionRequest serviceDefinitionRequest, ServiceDefinition definitionFromDb) {
List<AttributeDefinition> attributeDefinitions = serviceDefinitionRequest.getServiceDefinition().getAttributes();

//For quick lookup of Attribute Definition with Code
Map<String,AttributeDefinition> existingAttributeCode = definitionFromDb
.getAttributes()
.stream()
.collect(Collectors.toMap(AttributeDefinition::getCode, a->a));

RequestInfo requestInfo = serviceDefinitionRequest.getRequestInfo();

ServiceDefinition serviceDefinition = serviceDefinitionRequest.getServiceDefinition();

serviceDefinition.setId(definitionFromDb.getId());
serviceDefinition.setAuditDetails(definitionFromDb.getAuditDetails());
serviceDefinition.getAuditDetails().setLastModifiedBy(requestInfo.getUserInfo().getUuid());
serviceDefinition.getAuditDetails().setLastModifiedTime(System.currentTimeMillis());

attributeDefinitions.forEach(attributeDefinition -> {
if(existingAttributeCode.containsKey(attributeDefinition.getCode())){
updateAttributeDefinition(attributeDefinition, existingAttributeCode.get(attributeDefinition.getCode()), requestInfo);
}
else{
upsertAttributeDefinition(attributeDefinition, serviceDefinitionRequest);
}

if(!(attributeDefinition.getDataType().equals(AttributeDefinition.DataTypeEnum.SINGLEVALUELIST) || attributeDefinition.getDataType().equals(AttributeDefinition.DataTypeEnum.MULTIVALUELIST))){
List<String> emptyStringList = new ArrayList<>();
emptyStringList.add("");
attributeDefinition.setValues(emptyStringList);
}
});

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package org.egov.servicerequest.validators;

import org.egov.servicerequest.repository.ServiceDefinitionRequestRepository;
import org.egov.servicerequest.web.models.AttributeDefinition;
import org.egov.servicerequest.web.models.ServiceDefinition;
import org.egov.servicerequest.web.models.ServiceDefinitionCriteria;
import org.egov.servicerequest.web.models.ServiceDefinitionRequest;
import org.egov.servicerequest.web.models.ServiceDefinitionSearchRequest;
import org.egov.servicerequest.repository.ServiceRequestRepository;
import org.egov.servicerequest.web.models.*;
import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand All @@ -18,21 +15,18 @@
import java.util.Set;
import java.util.regex.Pattern;

import static org.egov.servicerequest.error.ErrorCode.ATTRIBUTE_CODE_UNIQUENESS_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.ATTRIBUTE_CODE_UNIQUENESS_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.INVALID_ATTRIBUTE_DEFINITION_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.INVALID_ATTRIBUTE_DEFINITION_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.INVALID_REGEX_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.INVALID_REGEX_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_DEFINITION_ALREADY_EXISTS_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_DEFINITION_ALREADY_EXISTS_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.*;

@Component
public class ServiceDefinitionRequestValidator {

@Autowired
private ServiceDefinitionRequestRepository serviceDefinitionRequestRepository;

@Autowired
private ServiceRequestRepository serviceRequestRepository;


public void validateServiceDefinitionRequest(ServiceDefinitionRequest serviceDefinitionRequest){
ServiceDefinition serviceDefinition = serviceDefinitionRequest.getServiceDefinition();

Expand Down Expand Up @@ -87,16 +81,57 @@ private void validateAttributeDefinitionUniqueness(ServiceDefinition serviceDefi
}

private void validateServiceDefinitionExistence(ServiceDefinition serviceDefinition) {
List<ServiceDefinition> serviceDefinitionList = serviceDefinitionRequestRepository.getServiceDefinitions(ServiceDefinitionSearchRequest.builder().serviceDefinitionCriteria(ServiceDefinitionCriteria.builder().tenantId(serviceDefinition.getTenantId()).code(Collections.singletonList(serviceDefinition.getCode())).build()).build());
List<ServiceDefinition> serviceDefinitionList = serviceDefinitionRequestRepository.getServiceDefinitions(ServiceDefinitionSearchRequest.builder().includeDeleted(true).serviceDefinitionCriteria(ServiceDefinitionCriteria.builder().tenantId(serviceDefinition.getTenantId()).code(Collections.singletonList(serviceDefinition.getCode())).build()).build());
if(!CollectionUtils.isEmpty(serviceDefinitionList)){
throw new CustomException(SERVICE_DEFINITION_ALREADY_EXISTS_ERR_CODE, SERVICE_DEFINITION_ALREADY_EXISTS_ERR_MSG);
}
}

public void validateUpdateRequest(ServiceDefinitionRequest serviceDefinitionRequest) {
private List<ServiceDefinition> validateExistence(ServiceDefinition serviceDefinition) {
List<ServiceDefinition> serviceDefinitionList = serviceDefinitionRequestRepository.
getServiceDefinitions(ServiceDefinitionSearchRequest.builder()
.includeDeleted(true)
.serviceDefinitionCriteria(ServiceDefinitionCriteria.builder().tenantId(serviceDefinition.getTenantId()).code(Collections.singletonList(serviceDefinition.getCode())).build()).build());

//Check if valid service definition exists
if (CollectionUtils.isEmpty(serviceDefinitionList)) {
throw new CustomException(SERVICE_DEFINITION_NOT_EXIST_ERR_CODE, SERVICE_DEFINITION_NOT_EXIST_ERR_MSG);
}

return serviceDefinitionList;
}

private void validateService(List<ServiceDefinition> serviceDefinition){
List<Service> service = serviceRequestRepository.getService(
ServiceSearchRequest.builder().serviceCriteria(
ServiceCriteria.builder().serviceDefIds(Collections.singletonList(serviceDefinition.get(0).getId())).build()
).build()
);
//already a service exists corresponding to service definition
if(!CollectionUtils.isEmpty(service)){
throw new CustomException(VALID_SERVICE_EXIST_ERR_CODE, VALID_SERVICE_EXIST_ERR_MSG);
}
}

public ServiceDefinition validateUpdateRequest(ServiceDefinitionRequest serviceDefinitionRequest) {
ServiceDefinition serviceDefinition = serviceDefinitionRequest.getServiceDefinition();

//Validate if a Service Definition exists
List<ServiceDefinition> serviceDefinitionList = validateExistence(serviceDefinition);

//Validate if a Service exists corresponding to this Service Definition
validateService(serviceDefinitionList);

// Validate if all attribute definitions provided as part of service definitions have unique code
validateAttributeDefinitionUniqueness(serviceDefinition);

// TO DO
// Validate values provided in attribute definitions as per data type
validateAttributeValuesAsPerDataType(serviceDefinition);

// Validate regex values provided in attribute definitions
validateRegex(serviceDefinition);

return serviceDefinitionList.get(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,7 @@
import java.util.Map;
import java.util.Set;

import static org.egov.servicerequest.error.ErrorCode.INVALID_SIZE_OF_INPUT_CODE;
import static org.egov.servicerequest.error.ErrorCode.INVALID_SIZE_OF_TEXT_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_DATETIME_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_MULTI_VALUE_LIST_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_NUMBER_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_SINGLE_VALUE_LIST_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_STRING_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_TEXT_VALUE_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_VALUE_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_VALUE_MULTIVALUELIST_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_INVALID_VALUE_SINGLEVALUELIST_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_VALUES_UNIQUENESS_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_ATTRIBUTE_VALUES_UNIQUENESS_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_INVALID_SERVICE_DEF_ID_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_INVALID_SERVICE_DEF_ID_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_REQUIRED_ATTRIBUTE_NOT_PROVIDED_ERR_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_REQUIRED_ATTRIBUTE_NOT_PROVIDED_ERR_MSG;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_UNRECOGNIZED_ATTRIBUTE_CODE;
import static org.egov.servicerequest.error.ErrorCode.SERVICE_REQUEST_UNRECOGNIZED_ATTRIBUTE_MSG;
import static org.egov.servicerequest.error.ErrorCode.*;

@Slf4j
@Component
Expand Down Expand Up @@ -133,6 +115,10 @@ private void validateAttributeValuesAgainstServiceDefinition(ServiceDefinition s
if(!(attributeValue.getValue() instanceof List)){
throw new CustomException(SERVICE_REQUEST_ATTRIBUTE_INVALID_VALUE_CODE, SERVICE_REQUEST_ATTRIBUTE_INVALID_MULTI_VALUE_LIST_VALUE_MSG);
}
}else if(attributeCodeVsDataType.get(attributeValue.getAttributeCode()).equals(AttributeDefinition.DataTypeEnum.BOOLEAN)){
if(!(attributeValue.getValue() instanceof Boolean)){
throw new CustomException(SERVICE_REQUEST_ATTRIBUTE_INVALID_VALUE_CODE, SERVICE_REQUEST_ATTRIBUTE_INVALID_BOOLEAN_VALUE_MSG);
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AttributeDefinition {

@JsonProperty("code")
@NotNull
@Size(min = 2, max = 64)
@Size(min = 2, max = 256)
private String code = null;

/**
Expand All @@ -50,6 +50,8 @@ public class AttributeDefinition {
public enum DataTypeEnum {
STRING("String"),

BOOLEAN("Boolean"),

NUMBER("Number"),

TEXT("Text"),
Expand Down Expand Up @@ -112,7 +114,7 @@ public static DataTypeEnum fromValue(String text) {
@Valid
private AuditDetails auditDetails = null;

@JsonProperty("additionalDetails")
@JsonProperty("additionalFields")
private Object additionalDetails = null;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AttributeValue {
@Valid
private AuditDetails auditDetails = null;

@JsonProperty("additionalDetails")
@JsonProperty("additionalFields")
private Object additionalDetails = null;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Service {
@Valid
private AuditDetails auditDetails = null;

@JsonProperty("additionalDetails")
@JsonProperty("additionalFields")
private Object additionalDetails = null;

@JsonProperty("accountId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ServiceDefinition {

@JsonProperty("code")
@NotNull
@Size(min = 2, max = 64)
@Size(min = 2, max = 256)
private String code = null;

@JsonProperty("isActive")
Expand All @@ -50,7 +50,7 @@ public class ServiceDefinition {
@Valid
private AuditDetails auditDetails = null;

@JsonProperty("additionalDetails")
@JsonProperty("additionalFields")
private Object additionalDetails = null;

@JsonProperty("clientId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public class ServiceDefinitionSearchRequest {
@Valid
private Pagination pagination = null;


@JsonProperty("includeDeleted")
private boolean includeDeleted = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ egov.service.request.max.limit=100
# Kafka topics
egov.service.definition.create.topic=save-service-definition
egov.service.create.topic=save-service
egov.service.definition.update.topic=update-service-definition

# String input size configuration
egov.max.string.input.size=8192
Loading

0 comments on commit 3f860f8

Please sign in to comment.