MIFOSX-1674:The description field added to m_code_value can be edited/entered
This commit is contained in:
+11
-1
@@ -13880,6 +13880,7 @@ Content-Type: application/json
|
|||||||
Request Body:
|
Request Body:
|
||||||
{
|
{
|
||||||
"name":"Ration Card",
|
"name":"Ration Card",
|
||||||
|
"description: "Ration card information",
|
||||||
"position":"1"
|
"position":"1"
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
@@ -13909,26 +13910,31 @@ GET https://DomainName/api/v1/codes/{codeId}/codevalues
|
|||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Passport",
|
"name": "Passport",
|
||||||
|
"description: "Passport information",
|
||||||
"position": 0
|
"position": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "Id",
|
"name": "Id",
|
||||||
|
"description: "ID information",
|
||||||
"position": 0
|
"position": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "Drivers License",
|
"name": "Drivers License",
|
||||||
|
"description: "Drivers License information",
|
||||||
"position": 0
|
"position": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"name": "Any Other Id Type",
|
"name": "Any Other Id Type",
|
||||||
|
"description: "Any Other Id Type information",
|
||||||
"position": 0
|
"position": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"name": "Ration Card",
|
"name": "Ration Card",
|
||||||
|
"description: "Ration Card information",
|
||||||
"position": 1
|
"position": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -13953,6 +13959,7 @@ GET https://DomainName/api/v1/codes/{codeId}/codevalues/{codevalueId}
|
|||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Passport",
|
"name": "Passport",
|
||||||
|
"description: "Passport information",
|
||||||
"position": 0
|
"position": 0
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
@@ -13976,14 +13983,17 @@ Content-Type: application/json
|
|||||||
Request Body:
|
Request Body:
|
||||||
{
|
{
|
||||||
"name": "Indian Passport",
|
"name": "Indian Passport",
|
||||||
|
"description": "Indian Passport information",
|
||||||
"position":2
|
"position":2
|
||||||
}
|
}
|
||||||
</code>
|
</code>
|
||||||
<code class="method-response">
|
<code class="method-response">
|
||||||
{
|
{
|
||||||
"resourceId": 1,
|
"resourceId": 1,
|
||||||
"changes": {
|
"changes":
|
||||||
|
{
|
||||||
"name": "Indian Passport",
|
"name": "Indian Passport",
|
||||||
|
"description": "Indian Passport information",
|
||||||
"position": 2
|
"position": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-38
@@ -8,6 +8,7 @@ package org.mifosplatform.integrationtests;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -159,13 +160,16 @@ public class SystemCodeTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCodeValuesNotAssignedToTable() {
|
public void testCodeValuesNotAssignedToTable() {
|
||||||
|
|
||||||
final String codeName = "Client Marital Status";
|
final String codeName = "Marital Status1";
|
||||||
|
|
||||||
final String codeValue1 = "Married";
|
final String codeValue1 = "Married1";
|
||||||
final String codeValue2 = "Unmarried";
|
final String codeValue2 = "Unmarried1";
|
||||||
|
|
||||||
final int codeValue1Position = 1;
|
final int codeValue1Position = 1;
|
||||||
final int codeValue2Position = 2;
|
final int codeValue2Position = 1;
|
||||||
|
|
||||||
|
final String codeDescription1 = "Description11";
|
||||||
|
final String codeDescription2 = "Description22";
|
||||||
|
|
||||||
// create code
|
// create code
|
||||||
final Integer createCodeResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName,
|
final Integer createCodeResponseId = (Integer) CodeHelper.createCode(this.requestSpec, this.responseSpec, codeName,
|
||||||
@@ -173,11 +177,11 @@ public class SystemCodeTest {
|
|||||||
|
|
||||||
// create first code value
|
// create first code value
|
||||||
final Integer createCodeValueResponseId1 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec,
|
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
|
// create second code value
|
||||||
final Integer createCodeValueResponseId2 = (Integer) CodeHelper.createCodeValue(this.requestSpec, this.responseSpec,
|
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
|
// 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 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,
|
assertEquals("Verify position of code value", codeValue1Position,
|
||||||
codeValuesAttributes1.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
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 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,
|
assertEquals("Verify position of code value", codeValue2Position,
|
||||||
codeValuesAttributes2.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
codeValuesAttributes2.get(CodeHelper.CODE_VALUE_POSITION_ATTRIBUTE_NAME));
|
||||||
|
|
||||||
// update code value 1
|
// update code value 1
|
||||||
|
|
||||||
final HashMap codeValueChanges = (HashMap) CodeHelper.updateCodeValue(this.requestSpec, this.responseSpec, createCodeResponseId,
|
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 name", codeValueChanges.get("name"), codeValue1 + "CHANGE");
|
||||||
|
|
||||||
|
assertEquals("Verify changed code value description", codeValueChanges.get("description"), codeDescription1 + "CHANGE");
|
||||||
|
|
||||||
// delete code value
|
// 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);
|
createCodeResponseId, createCodeValueResponseId1, CodeHelper.SUBRESPONSE_ID_ATTRIBUTE_NAME);
|
||||||
|
|
||||||
// Verify code value deleted
|
// Verify code value deleted
|
||||||
|
|
||||||
final HashMap deletedCodeValueAttributes1 = (HashMap) CodeHelper.getCodeValueById(this.requestSpec, this.generalResponseSpec,
|
final ArrayList<HashMap> deletedCodeValueAttributes1 = (ArrayList<HashMap>) CodeHelper.getCodeValueById(this.requestSpec,
|
||||||
createCodeResponseId, deletedCodeValueResponseId1, "");
|
this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId1, CommonConstants.RESPONSE_ERROR);
|
||||||
|
|
||||||
// Assert.assertNotNull(deletedCodeValueAttributes1);
|
assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||||
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));
|
|
||||||
|
|
||||||
final List<HashMap> deletedCodeValuesList = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
final List<HashMap> deletedCodeValuesList = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||||
createCodeResponseId, "");
|
createCodeResponseId, "");
|
||||||
|
|
||||||
assertEquals("Number of code values is 1", 1, deletedCodeValuesList.size());
|
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,
|
final ArrayList<HashMap> deletedCodeValueAttributes2 = (ArrayList<HashMap>) CodeHelper.getCodeValueById(this.requestSpec,
|
||||||
createCodeResponseId, CodeHelper.RESPONSE_ID_ATTRIBUTE_NAME);
|
this.generalResponseSpec, createCodeResponseId, deletedCodeValueResponseId2, CommonConstants.RESPONSE_ERROR);
|
||||||
assertEquals("Verify code deleted", createCodeResponseId, deleteCodeResponseId);
|
|
||||||
|
|
||||||
// verify code deleted
|
assertEquals("error.msg.codevalue.id.invalid", deletedCodeValueAttributes2.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||||
final HashMap deletedCodeAttributes = (HashMap) CodeHelper.getCodeById(this.requestSpec, this.generalResponseSpec,
|
|
||||||
|
final List<HashMap> deletedCodeValuesList1 = (List) CodeHelper.getCodeValuesForCode(this.requestSpec, this.responseSpec,
|
||||||
createCodeResponseId, "");
|
createCodeResponseId, "");
|
||||||
|
|
||||||
Assert.assertNotNull(deletedCodeAttributes);
|
assertEquals("Number of code values is 0", 0, deletedCodeValuesList1.size());
|
||||||
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));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-3
@@ -27,6 +27,7 @@ public class CodeHelper {
|
|||||||
|
|
||||||
public static final String CODE_VALUE_ID_ATTRIBUTE_NAME = "id";
|
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_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_POSITION_ATTRIBUTE_NAME = "position";
|
||||||
public static final String CODE_VALUE_URL = "/mifosng-provider/api/v1/codes/[codeId]/codevalues";
|
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);
|
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<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put(CODE_VALUE_NAME_ATTRIBUTE_NAME, codeValueName);
|
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);
|
map.put(CODE_VALUE_POSITION_ATTRIBUTE_NAME, position);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
@@ -93,9 +97,16 @@ public class CodeHelper {
|
|||||||
|
|
||||||
public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static Object createCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer codeId, final String codeValueName, final Integer position, final String jsonAttributeToGetback) {
|
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()) + "?"
|
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,
|
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,
|
public static Object updateCodeValue(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final Integer codeId, final Integer codeValueId, final String codeValueName, final Integer position,
|
final Integer codeId, final Integer codeValueId, final String codeValueName, final Integer position,
|
||||||
final String jsonAttributeToGetback) {
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -15,7 +15,7 @@ public class CodeConstants {
|
|||||||
* value
|
* value
|
||||||
***/
|
***/
|
||||||
public static enum CODEVALUE_JSON_INPUT_PARAMS {
|
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;
|
private final String value;
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -25,26 +25,30 @@ public class CodeValueData implements Serializable {
|
|||||||
|
|
||||||
public static CodeValueData instance(final Long id, final String name, final Integer position) {
|
public static CodeValueData instance(final Long id, final String name, final Integer position) {
|
||||||
String description = null;
|
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) {
|
public static CodeValueData instance(final Long id, final String name, final String description) {
|
||||||
Integer position = null;
|
Integer position = 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) {
|
public static CodeValueData instance(final Long id, final String name) {
|
||||||
String description = null;
|
String description = null;
|
||||||
Integer position=null;
|
Integer position = null;
|
||||||
return new CodeValueData(id, name, position, description);
|
return new CodeValueData(id, name, position, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeValueData(final Long id, final String name, final Integer position, final String description) {
|
public static CodeValueData instance(final Long id, final String name, final Integer position, final String description) {
|
||||||
this.id = id;
|
return new CodeValueData(id, name, position, description);
|
||||||
this.name = name;
|
}
|
||||||
this.position = position;
|
|
||||||
this.description = 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() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
|
|||||||
+16
-4
@@ -31,22 +31,26 @@ public class CodeValue extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "order_position")
|
@Column(name = "order_position")
|
||||||
private int position;
|
private int position;
|
||||||
|
|
||||||
|
@Column(name = "code_description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "code_id", nullable = false)
|
@JoinColumn(name = "code_id", nullable = false)
|
||||||
private Code code;
|
private Code code;
|
||||||
|
|
||||||
public static CodeValue createNew(final Code code, final String label, final int position) {
|
public static CodeValue createNew(final Code code, final String label, final int position, final String description) {
|
||||||
return new CodeValue(code, label, position);
|
return new CodeValue(code, label, position, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CodeValue() {
|
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.code = code;
|
||||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String label() {
|
public String label() {
|
||||||
@@ -61,10 +65,11 @@ public class CodeValue extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
final String label = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue());
|
||||||
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
Integer position = command.integerValueSansLocaleOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue());
|
||||||
|
String description = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue());
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
position = new Integer(0);
|
position = new Integer(0);
|
||||||
}
|
}
|
||||||
return new CodeValue(code, label, position.intValue());
|
return new CodeValue(code, label, position.intValue(),description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> update(final JsonCommand command) {
|
public Map<String, Object> update(final JsonCommand command) {
|
||||||
@@ -78,6 +83,13 @@ public class CodeValue extends AbstractPersistable<Long> {
|
|||||||
this.label = StringUtils.defaultIfEmpty(newValue, null);
|
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();
|
final String positionParamName = CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue();
|
||||||
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
|
if (command.isChangeInIntegerSansLocaleParameterNamed(positionParamName, this.position)) {
|
||||||
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
|
final Integer newValue = command.integerValueSansLocaleOfParameterNamed(positionParamName);
|
||||||
|
|||||||
+13
@@ -55,6 +55,13 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
|||||||
final String name = this.fromApiJsonHelper.extractStringNamed(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), element);
|
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);
|
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)) {
|
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||||
// Validate input value is a valid Integer
|
// Validate input value is a valid Integer
|
||||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
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()
|
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue()).value(name).notBlank()
|
||||||
.notExceedingLengthOf(100);
|
.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)) {
|
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element)) {
|
||||||
// Validate input value is a valid Integer
|
// Validate input value is a valid Integer
|
||||||
|
|||||||
+11
-14
@@ -35,7 +35,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
private static final class CodeValueDataMapper implements RowMapper<CodeValueData> {
|
private static final class CodeValueDataMapper implements RowMapper<CodeValueData> {
|
||||||
|
|
||||||
public String schema() {
|
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 ";
|
+ " 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 Long id = rs.getLong("id");
|
||||||
final String value = rs.getString("value");
|
final String value = rs.getString("value");
|
||||||
final Integer position = rs.getInt("position");
|
final Integer position = rs.getInt("position");
|
||||||
|
final String description = rs.getString("description");
|
||||||
return CodeValueData.instance(id, value, position);
|
return CodeValueData.instance(id, value, position, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,19 +76,16 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
@Override
|
@Override
|
||||||
public CodeValueData retrieveCodeValue(final Long codeValueId) {
|
public CodeValueData retrieveCodeValue(final Long codeValueId) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||||
final String sql = "select " + rm.schema()
|
final String sql = "select " + rm.schema() + "where cv.id = ? order by position";
|
||||||
+ "where cv.id = ? order by position";
|
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm,
|
|
||||||
new Object[] { codeValueId });
|
|
||||||
} catch (final EmptyResultDataAccessException e) {
|
|
||||||
throw new CodeValueNotFoundException(codeValueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { codeValueId });
|
||||||
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
|
throw new CodeValueNotFoundException(codeValueId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user