Merge pull request #1578 from sachinkulkarni12/CC-48
CC-48:enabling code values based on active or inactive status
This commit is contained in:
+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"), DESCRIPTION("description");
|
CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"), IS_ACTIVE("isActive");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -21,32 +21,35 @@ public class CodeValueData implements Serializable {
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final String description;
|
private final String description;
|
||||||
|
private final boolean isActive;
|
||||||
|
|
||||||
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, final boolean isActive) {
|
||||||
String description = null;
|
String description = null;
|
||||||
return new CodeValueData(id, name, position, description);
|
return new CodeValueData(id, name, position, description,isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, final boolean isActive) {
|
||||||
Integer position = null;
|
Integer position = null;
|
||||||
return new CodeValueData(id, name, position, description);
|
return new CodeValueData(id, name, position, description,isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
boolean isActive = false;
|
||||||
|
return new CodeValueData(id, name, position, description, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CodeValueData instance(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, final boolean isActive) {
|
||||||
return new CodeValueData(id, name, position, description);
|
return new CodeValueData(id, name, position, description,isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeValueData(final Long id, final String name, final Integer position, final String description) {
|
private CodeValueData(final Long id, final String name, final Integer position, final String description, final boolean isActive) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
|
|||||||
+17
-5
@@ -38,19 +38,23 @@ public class CodeValue extends AbstractPersistable<Long> {
|
|||||||
@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, final String description) {
|
@Column(name = "is_active")
|
||||||
return new CodeValue(code, label, position, description);
|
private boolean isActive;
|
||||||
|
|
||||||
|
public static CodeValue createNew(final Code code, final String label, final int position, final String description, final boolean isActive) {
|
||||||
|
return new CodeValue(code, label, position, description, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CodeValue() {
|
protected CodeValue() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeValue(final Code code, final String label, final int position, final String description) {
|
private CodeValue(final Code code, final String label, final int position, final String description, final boolean isActive) {
|
||||||
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;
|
this.description = description;
|
||||||
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String label() {
|
public String label() {
|
||||||
@@ -66,10 +70,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());
|
String description = command.stringValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue());
|
||||||
|
boolean isActive = command.booleanPrimitiveValueOfParameterNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue());
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
position = new Integer(0);
|
position = new Integer(0);
|
||||||
}
|
}
|
||||||
return new CodeValue(code, label, position.intValue(),description);
|
return new CodeValue(code, label, position.intValue(), description, isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> update(final JsonCommand command) {
|
public Map<String, Object> update(final JsonCommand command) {
|
||||||
@@ -97,10 +102,17 @@ public class CodeValue extends AbstractPersistable<Long> {
|
|||||||
this.position = newValue.intValue();
|
this.position = newValue.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String isActiveParamName = CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue();
|
||||||
|
if (command.isChangeInBooleanParameterNamed(isActiveParamName, this.isActive)) {
|
||||||
|
final Boolean newValue = command.booleanPrimitiveValueOfParameterNamed(isActiveParamName);
|
||||||
|
actualChanges.put(isActiveParamName, newValue);
|
||||||
|
this.isActive = newValue.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
return actualChanges;
|
return actualChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CodeValueData toData() {
|
public CodeValueData toData() {
|
||||||
return CodeValueData.instance(getId(), this.label, this.position);
|
return CodeValueData.instance(getId(), this.label, this.position, this.isActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
@@ -67,6 +67,9 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
|||||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue();
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +101,11 @@ public final class CodeValueCommandFromApiJsonDeserializer {
|
|||||||
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
this.fromApiJsonHelper.extractIntegerSansLocaleNamed(CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(), element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.fromApiJsonHelper.parameterExists(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element)) {
|
||||||
|
final Boolean isActive = this.fromApiJsonHelper.extractBooleanNamed(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(CODEVALUE_JSON_INPUT_PARAMS.IS_ACTIVE.getValue()).value(isActive).validateForBooleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -35,8 +35,8 @@ 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.code_description as description, 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 ";
|
+ " cv.is_active isActive from m_code_value as cv join m_code c on cv.code_id = c.id ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,7 +46,8 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
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");
|
final String description = rs.getString("description");
|
||||||
return CodeValueData.instance(id, value, position, description);
|
final boolean isActive = rs.getBoolean("isActive");
|
||||||
|
return CodeValueData.instance(id, value, position, description, isActive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
|||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
final CodeValueDataMapper rm = new CodeValueDataMapper();
|
||||||
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
|
final String sql = "select " + rm.schema() + "where c.code_name like ? and cv.is_active = 1 order by position";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] { code });
|
return this.jdbcTemplate.query(sql, rm, new Object[] { code });
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -183,7 +183,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (displayName != null) {
|
if (displayName != null) {
|
||||||
extraCriteria += " and concat(ifnull(c.firstname, ''), if(c.firstname > '',' ', '') , ifnull(c.lastname, '')) like "
|
//extraCriteria += " and concat(ifnull(c.firstname, ''), if(c.firstname > '',' ', '') , ifnull(c.lastname, '')) like "
|
||||||
|
extraCriteria += " and c.display_name like "
|
||||||
+ ApiParameterHelper.sqlEncodeString("%" + displayName + "%");
|
+ ApiParameterHelper.sqlEncodeString("%" + displayName + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +354,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
final Long subStatusId = JdbcSupport.getLong(rs, "subStatus");
|
final Long subStatusId = JdbcSupport.getLong(rs, "subStatus");
|
||||||
final String subStatusValue = rs.getString("subStatusValue");
|
final String subStatusValue = rs.getString("subStatusValue");
|
||||||
final String subStatusDesc = rs.getString("subStatusDesc");
|
final String subStatusDesc = rs.getString("subStatusDesc");
|
||||||
final CodeValueData subStatus = CodeValueData.instance(subStatusId, subStatusValue, subStatusDesc);
|
final boolean isActive = false;
|
||||||
|
final CodeValueData subStatus = CodeValueData.instance(subStatusId, subStatusValue, subStatusDesc, isActive);
|
||||||
|
|
||||||
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
||||||
final String officeName = rs.getString("officeName");
|
final String officeName = rs.getString("officeName");
|
||||||
@@ -504,7 +506,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
|||||||
final Long subStatusId = JdbcSupport.getLong(rs, "subStatus");
|
final Long subStatusId = JdbcSupport.getLong(rs, "subStatus");
|
||||||
final String subStatusValue = rs.getString("subStatusValue");
|
final String subStatusValue = rs.getString("subStatusValue");
|
||||||
final String subStatusDesc = rs.getString("subStatusDesc");
|
final String subStatusDesc = rs.getString("subStatusDesc");
|
||||||
final CodeValueData subStatus = CodeValueData.instance(subStatusId, subStatusValue, subStatusDesc);
|
final boolean isActive = false;
|
||||||
|
final CodeValueData subStatus = CodeValueData.instance(subStatusId, subStatusValue, subStatusDesc, isActive);
|
||||||
|
|
||||||
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
final Long officeId = JdbcSupport.getLong(rs, "officeId");
|
||||||
final String officeName = rs.getString("officeName");
|
final String officeName = rs.getString("officeName");
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE `m_code_value`
|
||||||
|
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `code_score`;
|
||||||
Reference in New Issue
Block a user