add system defined checks to codes
This commit is contained in:
+4
-3
@@ -1543,13 +1543,14 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
|||||||
public CodeCommand convertApiRequestJsonToCodeCommand(final Long resourceIdentifier, final String json) {
|
public CodeCommand convertApiRequestJsonToCodeCommand(final Long resourceIdentifier, final String json) {
|
||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||||
|
|
||||||
Set<String> supportedParams = new HashSet<String>(Arrays.asList("name"));
|
Set<String> supportedParams = new HashSet<String>(Arrays.asList("name","is_system_defined"));
|
||||||
|
|
||||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||||
|
|
||||||
|
|
||||||
// no difference between api request json format and internal command
|
// no difference between api request json format and internal command
|
||||||
// json format.
|
// json format.
|
||||||
return this.portfolioCommandDeserializerService.deserializeCodeCommand(resourceIdentifier, json, false);
|
return this.portfolioCommandDeserializerService.deserializeCodeCommand(resourceIdentifier, json, false);
|
||||||
|
|||||||
+2
-1
@@ -131,8 +131,9 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo
|
|||||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||||
|
|
||||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||||
|
final boolean isSystemDefined = helper.extractBooleanNamed("isSystemDefined", element, parametersPassedInRequest);
|
||||||
|
|
||||||
return new CodeCommand(parametersPassedInRequest, makerCheckerApproval, codeId, name);
|
return new CodeCommand(parametersPassedInRequest, makerCheckerApproval, codeId, name,isSystemDefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.mifosng.platform.exceptions;
|
||||||
|
|
||||||
|
public class CodeExceptionRule extends AbstractPlatformDomainRuleException
|
||||||
|
{
|
||||||
|
public CodeExceptionRule()
|
||||||
|
{
|
||||||
|
super("error.msg.code.systemdefined","This code is system defined and cannot be modified or deleted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
-2
@@ -18,15 +18,21 @@ public class CodeCommand {
|
|||||||
private final transient Set<String> parametersPassedInRequest;
|
private final transient Set<String> parametersPassedInRequest;
|
||||||
private final transient boolean makerCheckerApproval;
|
private final transient boolean makerCheckerApproval;
|
||||||
private final transient Long id;
|
private final transient Long id;
|
||||||
|
private final transient boolean isSystemDefined;
|
||||||
|
|
||||||
public CodeCommand(final Set<String> modifiedParameters, final boolean makerCheckerApproval, final Long id, final String name) {
|
public CodeCommand(final Set<String> modifiedParameters, final boolean makerCheckerApproval, final Long id, final String name,final boolean isSystemDefined) {
|
||||||
this.parametersPassedInRequest = modifiedParameters;
|
this.parametersPassedInRequest = modifiedParameters;
|
||||||
this.makerCheckerApproval = makerCheckerApproval;
|
this.makerCheckerApproval = makerCheckerApproval;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.isSystemDefined = isSystemDefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public boolean getisSystemDefined() {
|
||||||
|
return isSystemDefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -18,7 +18,15 @@ public class Code extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "code_name", length = 100)
|
@Column(name = "code_name", length = 100)
|
||||||
private String codeName;
|
private String codeName;
|
||||||
|
|
||||||
public static Code createNew(final String codeName) {
|
@SuppressWarnings("unused")
|
||||||
|
@Column(name = "is_system_defined")
|
||||||
|
private boolean isSystemDefined;
|
||||||
|
|
||||||
|
public boolean getisSystemDefined() {
|
||||||
|
return isSystemDefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Code createNew(final String codeName) {
|
||||||
return new Code(codeName);
|
return new Code(codeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user