Merge branch 'FINERACT-50' into develop
This commit is contained in:
+2
-1
@@ -28,7 +28,8 @@ public class CodeConstants {
|
||||
* value
|
||||
***/
|
||||
public static enum CODEVALUE_JSON_INPUT_PARAMS {
|
||||
CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"), IS_ACTIVE("isActive");
|
||||
CODEVALUE_ID("id"), NAME("name"), POSITION("position"), DESCRIPTION("description"), IS_ACTIVE("isActive"),
|
||||
IS_MANDATORY("isMandatory");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
+6
-1
@@ -46,6 +46,7 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.infrastructure.codes.CodeConstants.CODEVALUE_JSON_INPUT_PARAMS;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -58,7 +59,11 @@ public class CodeValuesApiResource {
|
||||
/**
|
||||
* The set of parameters that are supported in response for {@link CodeData}
|
||||
*/
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "name", "position", "description"));
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(CODEVALUE_JSON_INPUT_PARAMS.CODEVALUE_ID.getValue(),
|
||||
CODEVALUE_JSON_INPUT_PARAMS.NAME.getValue(), CODEVALUE_JSON_INPUT_PARAMS.POSITION.getValue(),
|
||||
CODEVALUE_JSON_INPUT_PARAMS.IS_MANDATORY.getValue(),
|
||||
CODEVALUE_JSON_INPUT_PARAMS.DESCRIPTION.getValue()));
|
||||
private final String resourceNameForPermissions = "CODEVALUE";
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
+40
-10
@@ -34,35 +34,51 @@ public class CodeValueData implements Serializable {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final String description;
|
||||
private final boolean isActive;
|
||||
private final boolean active;
|
||||
private final boolean mandatory;
|
||||
|
||||
public static CodeValueData instance(final Long id, final String name, final Integer position, final boolean isActive) {
|
||||
public static CodeValueData instance(final Long id, final String name, final Integer position,
|
||||
final boolean isActive, final boolean mandatory) {
|
||||
String description = null;
|
||||
return new CodeValueData(id, name, position, description,isActive);
|
||||
return new CodeValueData(id, name, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
public static CodeValueData instance(final Long id, final String name, final String description, final boolean isActive) {
|
||||
public static CodeValueData instance(final Long id, final String name, final String description,
|
||||
final boolean isActive, final boolean mandatory) {
|
||||
Integer position = null;
|
||||
return new CodeValueData(id, name, position, description,isActive);
|
||||
return new CodeValueData(id, name, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
public static CodeValueData instance(final Long id, final String name, final String description,
|
||||
final boolean isActive) {
|
||||
Integer position = null;
|
||||
boolean mandatory = false;
|
||||
|
||||
return new CodeValueData(id, name, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
public static CodeValueData instance(final Long id, final String name) {
|
||||
String description = null;
|
||||
Integer position = null;
|
||||
boolean isActive = false;
|
||||
return new CodeValueData(id, name, position, description, isActive);
|
||||
boolean mandatory = false;
|
||||
|
||||
return new CodeValueData(id, name, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
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,isActive);
|
||||
public static CodeValueData instance(final Long id, final String name, final Integer position,
|
||||
final String description, final boolean isActive, final boolean mandatory) {
|
||||
return new CodeValueData(id, name, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
private CodeValueData(final Long id, final String name, final Integer position, final String description, final boolean isActive) {
|
||||
private CodeValueData(final Long id, final String name, final Integer position, final String description,
|
||||
final boolean active, final boolean mandatory) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.position = position;
|
||||
this.description = description;
|
||||
this.isActive = isActive;
|
||||
this.active = active;
|
||||
this.mandatory = mandatory;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -72,4 +88,18 @@ public class CodeValueData implements Serializable {
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mandatory
|
||||
*/
|
||||
public boolean isMandatory() {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -53,22 +53,27 @@ public class CodeValue extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "is_active")
|
||||
private boolean isActive;
|
||||
|
||||
@Column(name = "is_mandatory")
|
||||
private boolean mandatory;
|
||||
|
||||
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);
|
||||
final boolean isActive, final boolean mandatory) {
|
||||
return new CodeValue(code, label, position, description, isActive, mandatory);
|
||||
}
|
||||
|
||||
protected CodeValue() {
|
||||
//
|
||||
}
|
||||
|
||||
private CodeValue(final Code code, final String label, final int position, final String description, final boolean isActive) {
|
||||
private CodeValue(final Code code, final String label, final int position, final String description,
|
||||
final boolean isActive, final boolean mandatory) {
|
||||
this.code = code;
|
||||
this.label = StringUtils.defaultIfEmpty(label, null);
|
||||
this.position = position;
|
||||
this.description = description;
|
||||
this.isActive = isActive;
|
||||
this.mandatory = mandatory;
|
||||
}
|
||||
|
||||
public String label() {
|
||||
@@ -92,7 +97,16 @@ public class CodeValue extends AbstractPersistable<Long> {
|
||||
if (position == null) {
|
||||
position = new Integer(0);
|
||||
}
|
||||
return new CodeValue(code, label, position.intValue(), description, isActive);
|
||||
|
||||
Boolean mandatory = command.booleanPrimitiveValueOfParameterNamed(
|
||||
CODEVALUE_JSON_INPUT_PARAMS.IS_MANDATORY.getValue());
|
||||
|
||||
// if the "mandatory" Boolean object is null, then set it to false by default
|
||||
if (mandatory == null) {
|
||||
mandatory = false;
|
||||
}
|
||||
|
||||
return new CodeValue(code, label, position.intValue(), description, isActive, mandatory);
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
@@ -131,6 +145,6 @@ public class CodeValue extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
public CodeValueData toData() {
|
||||
return CodeValueData.instance(getId(), this.label, this.position, this.isActive);
|
||||
return CodeValueData.instance(getId(), this.label, this.position, this.isActive, this.mandatory);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -49,7 +49,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
|
||||
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,"
|
||||
+ " cv.is_active isActive from m_code_value as cv join m_code c on cv.code_id = c.id ";
|
||||
+ " cv.is_active isActive, cv.is_mandatory as mandatory from m_code_value as cv join m_code c on cv.code_id = c.id ";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,7 +60,9 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
final Integer position = rs.getInt("position");
|
||||
final String description = rs.getString("description");
|
||||
final boolean isActive = rs.getBoolean("isActive");
|
||||
return CodeValueData.instance(id, value, position, description, isActive);
|
||||
final boolean mandatory = rs.getBoolean("mandatory");
|
||||
|
||||
return CodeValueData.instance(id, value, position, description, isActive, mandatory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
alter table `m_code_value` add `is_mandatory` tinyint(1) not null default '0';
|
||||
Reference in New Issue
Block a user