Skip to content

Commit

Permalink
Service additional field (#1146)
Browse files Browse the repository at this point in the history
* 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 <70943369+shubhang-eGov@users.noreply.github.com>

* added validation for boolean data type in service-request

---------

Co-authored-by: yashita-egov <yashita.bansal@egovernments.org>
Co-authored-by: Jagankumar <53823168+jagankumar-egov@users.noreply.github.com>
Co-authored-by: shubhang-eGov <70943369+shubhang-eGov@users.noreply.github.com>
  • Loading branch information
4 people authored Dec 4, 2024
1 parent 9bba4d0 commit 26763cf
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,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
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 @@ -110,7 +112,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
@@ -0,0 +1,9 @@
-- Migration script to alter the length of 'code' column in both tables to 256

-- Update eg_service_definition table
ALTER TABLE eg_service_definition
ALTER COLUMN code TYPE character varying(256);

-- Update eg_service_attribute_definition table
ALTER TABLE eg_service_attribute_definition
ALTER COLUMN code TYPE character varying(256);

0 comments on commit 26763cf

Please sign in to comment.