From d644fa9123a9082874ed6c42c1d7c989eeece99f Mon Sep 17 00:00:00 2001 From: MithunKashyap Date: Tue, 2 Dec 2014 16:18:29 +0530 Subject: [PATCH] MIFOSX-1674:The description field added to m_code_value can be edited/entered --- api-docs/apiLive.htm | 12 +++- .../integrationtests/SystemCodeTest.java | 69 +++++++++---------- .../common/system/CodeHelper.java | 24 ++++++- .../infrastructure/codes/CodeConstants.java | 2 +- .../codes/data/CodeValueData.java | 34 +++++---- .../codes/domain/CodeValue.java | 20 ++++-- ...deValueCommandFromApiJsonDeserializer.java | 13 ++++ .../CodeValueReadPlatformServiceImpl.java | 25 +++---- 8 files changed, 123 insertions(+), 76 deletions(-) diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm index 16e6ab529..9a4cadd90 100644 --- a/api-docs/apiLive.htm +++ b/api-docs/apiLive.htm @@ -13880,6 +13880,7 @@ Content-Type: application/json Request Body: { "name":"Ration Card", + "description: "Ration card information", "position":"1" } @@ -13909,26 +13910,31 @@ GET https://DomainName/api/v1/codes/{codeId}/codevalues { "id": 1, "name": "Passport", + "description: "Passport information", "position": 0 }, { "id": 2, "name": "Id", + "description: "ID information", "position": 0 }, { "id": 3, "name": "Drivers License", + "description: "Drivers License information", "position": 0 }, { "id": 4, "name": "Any Other Id Type", + "description: "Any Other Id Type information", "position": 0 }, { "id": 5, "name": "Ration Card", + "description: "Ration Card information", "position": 1 } ] @@ -13953,6 +13959,7 @@ GET https://DomainName/api/v1/codes/{codeId}/codevalues/{codevalueId} { "id": 1, "name": "Passport", + "description: "Passport information", "position": 0 } @@ -13976,14 +13983,17 @@ Content-Type: application/json Request Body: { "name": "Indian Passport", + "description": "Indian Passport information", "position":2 } { "resourceId": 1, - "changes": { + "changes": + { "name": "Indian Passport", + "description": "Indian Passport information", "position": 2 } } diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SystemCodeTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SystemCodeTest.java index 0dae7c777..89eec793f 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SystemCodeTest.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/SystemCodeTest.java @@ -8,6 +8,7 @@ package org.mifosplatform.integrationtests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -159,13 +160,16 @@ public class SystemCodeTest { @Test public void testCodeValuesNotAssignedToTable() { - final String codeName = "Client Marital Status"; + final String codeName = "Marital Status1"; - final String codeValue1 = "Married"; - final String codeValue2 = "Unmarried"; + final String codeValue1 = "Married1"; + final String codeValue2 = "Unmarried1"; final int codeValue1Position = 1; - final int codeValue2Position = 2; + final int codeValue2Position = 1; + + final String codeDescription1 = "Description11"; + final String codeDescription2 = "Description22"; // create code final Integer createCodeResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName, @@ -173,11 +177,11 @@ public class SystemCodeTest { // create first code value final Integer createCodeValueResponseId1 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec, - createCodeResponseId, codeValue1, codeValue1Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); + createCodeResponseId, codeValue1, codeDescription1, codeValue1Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); // create second code value final Integer createCodeValueResponseId2 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec, - createCodeResponseId, codeValue2, codeValue2Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); + createCodeResponseId, codeValue2, codeDescription2, codeValue1Position, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); // verify two code values created @@ -196,6 +200,9 @@ public class SystemCodeTest { assertEquals("Verify value of code name", codeValue1, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME)); + assertEquals("Verify value of code description", codeDescription1, + codeValuesAttributes1.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME)); + assertEquals("Verify position of code value", codeValue1Position, codeValuesAttributes1.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME)); @@ -209,62 +216,48 @@ public class SystemCodeTest { assertEquals("Verify value of code name", codeValue2, codeValuesAttributes2.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME)); + assertEquals("Verify value of code description", codeDescription2, + codeValuesAttributes2.get(CodeHelper.CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME)); + assertEquals("Verify position of code value", codeValue2Position, codeValuesAttributes2.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME)); // update code value 1 - final HashMap codeValueChanges = (HashMap) CodeHelper.updateCodeValue(this.requestSpec, this.responseSpec, createCodeResponseId, - createCodeValueResponseId1, codeValue1 + "CHANGE", 4, "changes"); + createCodeValueResponseId1, codeValue1 + "CHANGE", codeDescription1 + "CHANGE", 4, "changes"); assertEquals("Verify changed code value name", codeValueChanges.get("name"), codeValue1 + "CHANGE"); + assertEquals("Verify changed code value description", codeValueChanges.get("description"), codeDescription1 + "CHANGE"); + // delete code value - final Integer deletedCodeValueResponseId1 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec, + Integer deletedCodeValueResponseId1 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec, createCodeResponseId, createCodeValueResponseId1, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); // Verify code value deleted - final HashMap deletedCodeValueAttributes1 = (HashMap) CodeHelper.getCodeValueById(this.requestSpec, this.generalResponseSpec, - createCodeResponseId, deletedCodeValueResponseId1, ""); + final ArrayList deletedCodeValueAttributes1 = (ArrayList) CodeHelper.getCodeValueById(this.requestSpec, + this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId1, CommonConstants.RESPONSE_ERROR); - // Assert.assertNotNull(deletedCodeValueAttributes1); - assertNull("Verify value of codeValueId", deletedCodeValueAttributes1.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME)); - - assertNull("Verify value of code name", deletedCodeValueAttributes1.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME)); - - assertNull("Verify position of code value", deletedCodeValueAttributes1.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME)); + assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); final List deletedCodeValuesList = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec, createCodeResponseId, ""); assertEquals("Number of code values is 1", 1, deletedCodeValuesList.size()); - // delete code, remaining code values automatically deleted + final Integer deletedCodeValueResponseId2 = (Integer) CodeHelper.deleteCodeValueById(this.requestSpec, this.generalResponseSpec, + createCodeResponseId, createCodeValueResponseId2, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME); - final Integer deleteCodeResponseId = (Integer) CodeHelper.deleteCodeById(this.requestSpec, this.generalResponseSpec, - createCodeResponseId, CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME); - assertEquals("Verify code deleted", createCodeResponseId, deleteCodeResponseId); + final ArrayList deletedCodeValueAttributes2 = (ArrayList) CodeHelper.getCodeValueById(this.requestSpec, + this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId2, CommonConstants.RESPONSE_ERROR); - // verify code deleted - final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec, + assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes2.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE)); + + final List deletedCodeValuesList1 = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec, createCodeResponseId, ""); - Assert.assertNotNull(deletedCodeAttributes); - assertNull("Verify value of codeId is null", deletedCodeAttributes.get(CodeHelper.CODE_ID_ATTRIBUTE_NAME)); - - assertNull("Verify code name is null", deletedCodeAttributes.get(CodeHelper.CODE_NAME_ATTRIBUTE_NAME)); - assertNull("Verify system defined is null", deletedCodeAttributes.get(CodeHelper.CODE_SYSTEM_DEFINED_ATTRIBUTE_NAME)); - - // Verify remaining code value deleted - final HashMap deletedCodeValues2 = (HashMap) CodeHelper.getCodeValueById(this.requestSpec, this.generalResponseSpec, - createCodeResponseId, createCodeValueResponseId2, ""); - - assertNull("Verify value of codeValueId is null", deletedCodeValues2.get(CodeHelper.CODE_VALUE_ID_ATTRIBUTE_NAME)); - - assertNull("Verify value of code name is null", deletedCodeValues2.get(CodeHelper.CODE_VALUE_NAME_ATTRIBUTE_NAME)); - - assertNull("Verify position of code value null", deletedCodeValues2.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME)); + assertEquals("Number of code values is 0", 0, deletedCodeValuesList1.size()); } diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/system/CodeHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/system/CodeHelper.java index 8e78e491b..85a931e1a 100644 --- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/system/CodeHelper.java +++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/system/CodeHelper.java @@ -27,6 +27,7 @@ public class CodeHelper { public static final String CODE_VALUE_ID_ATTRIBUTE_NAME = "id"; public static final String CODE_VALUE_NAME_ATTRIBUTE_NAME = "name"; + public static final String CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME = "description"; public static final String CODE_VALUE_POSITION_ATTRIBUTE_NAME = "position"; public static final String CODE_VALUE_URL = "/mifosng-provider/api/v1/codes/[codeId]/codevalues"; @@ -76,9 +77,12 @@ public class CodeHelper { return new Gson().toJson(map); } - public static String getTestCodeValueAsJSON(final String codeValueName, final Integer position) { + public static String getTestCodeValueAsJSON(final String codeValueName, final String description, final Integer position) { final HashMap map = new HashMap<>(); map.put(CODE_VALUE_NAME_ATTRIBUTE_NAME, codeValueName); + if (description != null) { + map.put(CODE_VALUE_DESCRIPTION_ATTRIBUTE_NAME, description); + } map.put(CODE_VALUE_POSITION_ATTRIBUTE_NAME, position); return new Gson().toJson(map); } @@ -93,9 +97,16 @@ public class CodeHelper { public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer codeId, final String codeValueName, final Integer position, final String jsonAttributeToGetback) { + String description = null; + return createCodeValue(requestSpec, responseSpec, codeId, codeValueName, description, position, jsonAttributeToGetback); + } + + public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer codeId, final String codeValueName, final String description, final Integer position, + final String jsonAttributeToGetback) { return Utils.performServerPost(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "?" - + Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, position), jsonAttributeToGetback); + + Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, description, position), jsonAttributeToGetback); } public static Object getCodeValuesForCode(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, @@ -123,9 +134,16 @@ public class CodeHelper { public static Object updateCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer codeId, final Integer codeValueId, final String codeValueName, final Integer position, final String jsonAttributeToGetback) { + String description = null; + return updateCodeValue(requestSpec, responseSpec, codeId, codeValueId, codeValueName, description, position, jsonAttributeToGetback); + } + + public static Object updateCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, + final Integer codeId, final Integer codeValueId, final String codeValueName, final String description, final Integer position, + final String jsonAttributeToGetback) { return Utils.performServerPut(requestSpec, responseSpec, CODE_VALUE_URL.replace("[codeId]", codeId.toString()) + "/" + codeValueId - + "?" + Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, position), jsonAttributeToGetback); + + "?" + Utils.TENANT_IDENTIFIER, getTestCodeValueAsJSON(codeValueName, description, position), jsonAttributeToGetback); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/CodeConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/CodeConstants.java index b9b3d13ff..d11c24dda 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/CodeConstants.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/CodeConstants.java @@ -15,7 +15,7 @@ public class CodeConstants { * value ***/ public static enum CODEVALUE_JSON_INPUT_PARAMS { - CODEVALUE_ID("id"), NAME("name"), POSITION("position"); + CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"); private final String value; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java index f0d757eab..9c0a1f1e9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/data/CodeValueData.java @@ -19,32 +19,36 @@ public class CodeValueData implements Serializable { @SuppressWarnings("unused") private final Integer position; - + @SuppressWarnings("unused") private final String description; public static CodeValueData instance(final Long id, final String name, final Integer position) { String description = null; - return new CodeValueData(id, name, position, description); - } + return new CodeValueData(id, name, position, description); + } public static CodeValueData instance(final Long id, final String name, final String description) { - Integer position = null; - return new CodeValueData(id, name, position, description); - } - + Integer position = null; + return new CodeValueData(id, name, position, description); + } + public static CodeValueData instance(final Long id, final String name) { String description = null; - Integer position=null; + Integer position = null; return new CodeValueData(id, name, position, description); - } + } - private CodeValueData(final Long id, final String name, final Integer position, final String description) { - this.id = id; - this.name = name; - this.position = position; - this.description = description; - } + public static CodeValueData instance(final Long id, final String name, final Integer position, final String description) { + return new CodeValueData(id, name, position, description); + } + + private CodeValueData(final Long id, final String name, final Integer position, final String description) { + this.id = id; + this.name = name; + this.position = position; + this.description = description; + } public Long getId() { return this.id; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/domain/CodeValue.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/domain/CodeValue.java index f128bbc8a..67046fd84 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/domain/CodeValue.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/domain/CodeValue.java @@ -31,22 +31,26 @@ public class CodeValue extends AbstractPersistable { @Column(name = "order_position") private int position; + @Column(name = "code_description") + private String description; + @ManyToOne @JoinColumn(name = "code_id", nullable = false) private Code code; - public static CodeValue createNew(final Code code, final String label, final int position) { - return new CodeValue(code, label, position); + public static CodeValue createNew(final Code code, final String label, final int position, final String description) { + return new CodeValue(code, label, position, description); } protected CodeValue() { // } - private CodeValue(final Code code, final String label, final int position) { + private CodeValue(final Code code, final String label, final int position, final String description) { this.code = code; this.label = StringUtils.defaultIfEmpty(label, null); this.position = position; + this.description = description; } public String label() { @@ -61,10 +65,11 @@ public class CodeValue extends AbstractPersistable { final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()); Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue()); + String description = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()); if (position == null) { position = new Integer(0); } - return new CodeValue(code, label, position.intValue()); + return new CodeValue(code, label, position.intValue(),description); } public Map update(final JsonCommand command) { @@ -77,6 +82,13 @@ public class CodeValue extends AbstractPersistable { actualChanges.put(labelParamName, newValue); this.label = StringUtils.defaultIfEmpty(newValue, null); } + + final String decriptionParamName = CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(); + if (command.isChangeInStringParameterNamed(decriptionParamName, this.description)) { + final String newValue = command.stringValueOfParameterNamed(decriptionParamName); + actualChanges.put(decriptionParamName, newValue); + this.description = StringUtils.defaultIfEmpty(newValue, null); + } final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(); if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/serialization/CodeValueCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/serialization/CodeValueCommandFromApiJsonDeserializer.java index d134dda4d..748ee28d7 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/serialization/CodeValueCommandFromApiJsonDeserializer.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/serialization/CodeValueCommandFromApiJsonDeserializer.java @@ -55,6 +55,13 @@ public final class CodeValueCommandFromApiJsonDeserializer { final String name = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element); baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank().notExceedingLengthOf(100); + if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), element)) { + final String description = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), + element); + baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(description) + .notExceedingLengthOf(500); + } + if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) { // Validate input value is a valid Integer this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element); @@ -79,6 +86,12 @@ public final class CodeValueCommandFromApiJsonDeserializer { baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank() .notExceedingLengthOf(100); } + if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), element)) { + final String description = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue(), + element); + baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()).value(description) + .notExceedingLengthOf(500); + } if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) { // Validate input value is a valid Integer diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java index e73ccbee2..979306e4a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java @@ -35,7 +35,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe private static final class CodeValueDataMapper implements RowMapper { public String schema() { - return " cv.id as id, cv.code_value as value, cv.code_id as codeId, cv.order_position as position" + return " cv.id as id, cv.code_value as value, cv.code_id as codeId, cv.code_description as description, cv.order_position as position" + " from m_code_value as cv join m_code c on cv.code_id = c.id "; } @@ -45,8 +45,8 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe final Long id = rs.getLong("id"); final String value = rs.getString("value"); final Integer position = rs.getInt("position"); - - return CodeValueData.instance(id, value, position); + final String description = rs.getString("description"); + return CodeValueData.instance(id, value, position, description); } } @@ -76,19 +76,16 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe @Override public CodeValueData retrieveCodeValue(final Long codeValueId) { - try { - this.context.authenticatedUser(); + try { + this.context.authenticatedUser(); - final CodeValueDataMapper rm = new CodeValueDataMapper(); - final String sql = "select " + rm.schema() - + "where cv.id = ? order by position"; - - return this.jdbcTemplate.queryForObject(sql, rm, - new Object[] { codeValueId }); - } catch (final EmptyResultDataAccessException e) { - throw new CodeValueNotFoundException(codeValueId); - } + final CodeValueDataMapper rm = new CodeValueDataMapper(); + final String sql = "select " + rm.schema() + "where cv.id = ? order by position"; + return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeValueId }); + } catch (final EmptyResultDataAccessException e) { + throw new CodeValueNotFoundException(codeValueId); + } } } \ No newline at end of file