MIFOSX-97: add configuration option for enabling,disabling maker checker at global level.
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
DROP TABLE IF EXISTS `c_configuration`;
|
||||||
|
CREATE TABLE `c_configuration` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(50) DEFAULT NULL,
|
||||||
|
`enabled` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
INSERT INTO `c_configuration`
|
||||||
|
(`name`, `enabled`)
|
||||||
|
VALUES
|
||||||
|
('maker-checker', 0);
|
||||||
|
|
||||||
|
INSERT INTO `m_permission`
|
||||||
|
(`id`,
|
||||||
|
`grouping`,
|
||||||
|
`code`,
|
||||||
|
`entity_name`,
|
||||||
|
`action_name`,
|
||||||
|
`can_maker_checker`)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
419,
|
||||||
|
'configuration',
|
||||||
|
'UPDATE_CONFIGURATION',
|
||||||
|
'CONFIGURATION',
|
||||||
|
'UPDATE'
|
||||||
|
,1);
|
||||||
@@ -146,6 +146,10 @@ public class CommandWrapper {
|
|||||||
return this.actionName.equalsIgnoreCase("PERMISSIONS") && this.entityId != null;
|
return this.actionName.equalsIgnoreCase("PERMISSIONS") && this.entityId != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConfigurationResource() {
|
||||||
|
return this.entityName.equalsIgnoreCase("CONFIGURATION");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPermissionResource() {
|
public boolean isPermissionResource() {
|
||||||
return this.entityName.equalsIgnoreCase("PERMISSION");
|
return this.entityName.equalsIgnoreCase("PERMISSION");
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -393,4 +393,12 @@ public class CommandWrapperBuilder {
|
|||||||
this.entityName = "LOAN";
|
this.entityName = "LOAN";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandWrapperBuilder updateGlobalConfiguration() {
|
||||||
|
this.actionName = "UPDATE";
|
||||||
|
this.entityName = "CONFIGURATION";
|
||||||
|
this.entityId = null;
|
||||||
|
this.href = "/configurations";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+8
-4
@@ -8,12 +8,12 @@ import org.mifosplatform.commands.domain.CommandSourceRepository;
|
|||||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
import org.mifosplatform.commands.exception.UnsupportedCommandException;
|
import org.mifosplatform.commands.exception.UnsupportedCommandException;
|
||||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.organisation.monetary.service.ConfigurationDomainService;
|
|
||||||
import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
||||||
import org.mifosplatform.useradministration.domain.AppUser;
|
import org.mifosplatform.useradministration.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -47,6 +47,8 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, final boolean isApprovedByChecker) {
|
public CommandProcessingResult processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, final boolean isApprovedByChecker) {
|
||||||
|
|
||||||
|
final boolean rollbackTransaction = this.configurationDomainService.isMakerCheckerEnabledForTask(wrapper.taskPermissionName()) && !isApprovedByChecker;
|
||||||
|
|
||||||
final NewCommandSourceHandler handler = findCommandHandler(wrapper);
|
final NewCommandSourceHandler handler = findCommandHandler(wrapper);
|
||||||
final CommandProcessingResult result = handler.processCommand(command);
|
final CommandProcessingResult result = handler.processCommand(command);
|
||||||
|
|
||||||
@@ -76,8 +78,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
commandSourceRepository.save(commandSourceResult);
|
commandSourceRepository.save(commandSourceResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.configurationDomainService.isMakerCheckerEnabledForTask(wrapper.taskPermissionName()) && !isApprovedByChecker) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(
|
if (rollbackTransaction) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(changesOnlyJson); }
|
||||||
changesOnlyJson); }
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,10 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
private NewCommandSourceHandler findCommandHandler(final CommandWrapper wrapper) {
|
private NewCommandSourceHandler findCommandHandler(final CommandWrapper wrapper) {
|
||||||
NewCommandSourceHandler handler = null;
|
NewCommandSourceHandler handler = null;
|
||||||
|
|
||||||
if (wrapper.isDatatableResource()) {
|
if (wrapper.isConfigurationResource()) {
|
||||||
|
handler = applicationContext.getBean("updateGlobalConfigurationCommandHandler", NewCommandSourceHandler.class);
|
||||||
|
}
|
||||||
|
else if (wrapper.isDatatableResource()) {
|
||||||
if (wrapper.isCreate()) {
|
if (wrapper.isCreate()) {
|
||||||
handler = applicationContext.getBean("createDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
handler = applicationContext.getBean("createDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isUpdateMultiple()) {
|
} else if (wrapper.isUpdateMultiple()) {
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.api;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
|
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||||
|
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationData;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.service.ConfigurationReadPlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||||
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Path("/configurations")
|
||||||
|
@Component
|
||||||
|
@Scope("singleton")
|
||||||
|
public class GlobalConfigurationApiResource {
|
||||||
|
|
||||||
|
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("globalConfiguration"));
|
||||||
|
|
||||||
|
private final String resourceNameForPermissions = "CURRENCY";
|
||||||
|
|
||||||
|
private final PlatformSecurityContext context;
|
||||||
|
private final ConfigurationReadPlatformService readPlatformService;
|
||||||
|
private final DefaultToApiJsonSerializer<GlobalConfigurationData> toApiJsonSerializer;
|
||||||
|
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||||
|
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GlobalConfigurationApiResource(final PlatformSecurityContext context,
|
||||||
|
final ConfigurationReadPlatformService readPlatformService,
|
||||||
|
final DefaultToApiJsonSerializer<GlobalConfigurationData> toApiJsonSerializer,
|
||||||
|
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||||
|
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||||
|
this.context = context;
|
||||||
|
this.readPlatformService = readPlatformService;
|
||||||
|
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||||
|
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||||
|
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public String retrieveConfiguration(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||||
|
|
||||||
|
final GlobalConfigurationData configurationData = this.readPlatformService.retrieveGlobalConfiguration();
|
||||||
|
|
||||||
|
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
|
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public String updateConfiguration(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
|
Map<String, String> configurationParameters = ApiParameterHelper.asMap(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
|
Map<String, Object> globalConfiguration = new HashMap<String, Object>();
|
||||||
|
globalConfiguration.put("globalConfiguration", configurationParameters);
|
||||||
|
|
||||||
|
final String apiRequestJson = this.toApiJsonSerializer.serialize(globalConfiguration);
|
||||||
|
|
||||||
|
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
|
||||||
|
.updateGlobalConfiguration() //
|
||||||
|
.withJson(apiRequestJson) //
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
|
||||||
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.command;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable command for updating global configuration settings.
|
||||||
|
*/
|
||||||
|
public class UpdateGlobalConfigurationCommand {
|
||||||
|
|
||||||
|
private final Map<String, Boolean> globalConfiguration;
|
||||||
|
|
||||||
|
public UpdateGlobalConfigurationCommand(final Map<String, Boolean> globalConfigurationMap) {
|
||||||
|
this.globalConfiguration = globalConfigurationMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Boolean> getGlobalConfiguration() {
|
||||||
|
return this.globalConfiguration;
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for global configuration.
|
||||||
|
*/
|
||||||
|
public class GlobalConfigurationData {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final List<GlobalConfigurationPropertyData> globalConfiguration;
|
||||||
|
|
||||||
|
public GlobalConfigurationData(final List<GlobalConfigurationPropertyData> globalConfiguration) {
|
||||||
|
this.globalConfiguration = globalConfiguration;
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for global configuration property.
|
||||||
|
*/
|
||||||
|
public class GlobalConfigurationPropertyData {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private String name;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled) {
|
||||||
|
this.name = name;
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.mifosplatform.organisation.monetary.service;
|
package org.mifosplatform.infrastructure.configuration.domain;
|
||||||
|
|
||||||
public interface ConfigurationDomainService {
|
public interface ConfigurationDomainService {
|
||||||
|
|
||||||
+11
-8
@@ -1,6 +1,7 @@
|
|||||||
package org.mifosplatform.organisation.monetary.service;
|
package org.mifosplatform.infrastructure.configuration.domain;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
||||||
import org.mifosplatform.useradministration.domain.Permission;
|
import org.mifosplatform.useradministration.domain.Permission;
|
||||||
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
import org.mifosplatform.useradministration.domain.PermissionRepository;
|
||||||
import org.mifosplatform.useradministration.exception.PermissionNotFoundException;
|
import org.mifosplatform.useradministration.exception.PermissionNotFoundException;
|
||||||
@@ -11,15 +12,13 @@ import org.springframework.stereotype.Service;
|
|||||||
public class ConfigurationDomainServiceJpa implements ConfigurationDomainService {
|
public class ConfigurationDomainServiceJpa implements ConfigurationDomainService {
|
||||||
|
|
||||||
private final PermissionRepository permissionRepository;
|
private final PermissionRepository permissionRepository;
|
||||||
|
private final GlobalConfigurationRepository globalConfigurationRepository;
|
||||||
/*
|
|
||||||
* hard code to false to disable maker checker across the board.
|
|
||||||
*/
|
|
||||||
private final boolean makerCheckerGloablConfigurationEnabled = false;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository) {
|
public ConfigurationDomainServiceJpa(final PermissionRepository permissionRepository,
|
||||||
|
final GlobalConfigurationRepository globalConfigurationRepository) {
|
||||||
this.permissionRepository = permissionRepository;
|
this.permissionRepository = permissionRepository;
|
||||||
|
this.globalConfigurationRepository = globalConfigurationRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -29,6 +28,10 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
final Permission thisTask = this.permissionRepository.findOneByCode(taskPermissionCode);
|
final Permission thisTask = this.permissionRepository.findOneByCode(taskPermissionCode);
|
||||||
if (thisTask == null) { throw new PermissionNotFoundException(taskPermissionCode); }
|
if (thisTask == null) { throw new PermissionNotFoundException(taskPermissionCode); }
|
||||||
|
|
||||||
return thisTask.hasMakerCheckerEnabled() && this.makerCheckerGloablConfigurationEnabled;
|
final String makerCheckerConfigurationProperty = "maker-checker";
|
||||||
|
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByName(makerCheckerConfigurationProperty);
|
||||||
|
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(makerCheckerConfigurationProperty); }
|
||||||
|
|
||||||
|
return thisTask.hasMakerCheckerEnabled() && property.isEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.domain;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "c_configuration")
|
||||||
|
public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Column(name = "name", nullable = false)
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
@Column(name = "enabled", nullable = false)
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
protected GlobalConfigurationProperty() {
|
||||||
|
this.name = null;
|
||||||
|
this.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalConfigurationProperty(final String name, final boolean enabled) {
|
||||||
|
this.name = name;
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateTo(final boolean value) {
|
||||||
|
final boolean updated = this.enabled != value;
|
||||||
|
this.enabled = value;
|
||||||
|
return updated;
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.domain;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
public interface GlobalConfigurationRepository extends JpaRepository<GlobalConfigurationProperty, Long>,
|
||||||
|
JpaSpecificationExecutor<GlobalConfigurationProperty> {
|
||||||
|
|
||||||
|
GlobalConfigurationProperty findOneByName(String name);
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.exception;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link RuntimeException} thrown when global configuration properties are
|
||||||
|
* not found.
|
||||||
|
*/
|
||||||
|
public class GlobalConfigurationPropertyNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||||
|
|
||||||
|
public GlobalConfigurationPropertyNotFoundException(final String propertyName) {
|
||||||
|
super("error.msg.configuration.property.invalid", "Configuration property `" + propertyName + "` does not exist", propertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.handler;
|
||||||
|
|
||||||
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.service.GlobalConfigurationWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UpdateGlobalConfigurationCommandHandler implements NewCommandSourceHandler {
|
||||||
|
|
||||||
|
private final GlobalConfigurationWritePlatformService writePlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public UpdateGlobalConfigurationCommandHandler(final GlobalConfigurationWritePlatformService writePlatformService) {
|
||||||
|
this.writePlatformService = writePlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||||
|
|
||||||
|
return this.writePlatformService.update(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.serialization;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.command.UpdateGlobalConfigurationCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.AbstractFromApiJsonDeserializer;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.FromApiJsonDeserializer;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link FromApiJsonDeserializer} for
|
||||||
|
* {@link UpdateGlobalConfigurationCommand}'s.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public final class GlobalConfigurationCommandFromApiJsonDeserializer extends
|
||||||
|
AbstractFromApiJsonDeserializer<UpdateGlobalConfigurationCommand> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters supported for this command.
|
||||||
|
*/
|
||||||
|
private final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("globalConfiguration"));
|
||||||
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GlobalConfigurationCommandFromApiJsonDeserializer(final FromJsonHelper fromApiJsonHelper) {
|
||||||
|
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpdateGlobalConfigurationCommand commandFromApiJson(final String json) {
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
|
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||||
|
fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, supportedParameters);
|
||||||
|
|
||||||
|
return fromApiJsonHelper.fromJson(json, UpdateGlobalConfigurationCommand.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.service;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationData;
|
||||||
|
|
||||||
|
public interface ConfigurationReadPlatformService {
|
||||||
|
|
||||||
|
GlobalConfigurationData retrieveGlobalConfiguration();
|
||||||
|
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.service;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationData;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationPropertyData;
|
||||||
|
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||||
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPlatformService {
|
||||||
|
|
||||||
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
private final PlatformSecurityContext context;
|
||||||
|
private final RowMapper<GlobalConfigurationPropertyData> rm;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ConfigurationReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||||
|
this.context = context;
|
||||||
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
|
||||||
|
rm = new GlobalConfigurationRowMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GlobalConfigurationData retrieveGlobalConfiguration() {
|
||||||
|
|
||||||
|
context.authenticatedUser();
|
||||||
|
|
||||||
|
final String sql = "SELECT c.name, c.enabled FROM c_configuration c order by c.id";
|
||||||
|
final List<GlobalConfigurationPropertyData> globalConfiguration = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
|
|
||||||
|
return new GlobalConfigurationData(globalConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class GlobalConfigurationRowMapper implements RowMapper<GlobalConfigurationPropertyData> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GlobalConfigurationPropertyData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
|
|
||||||
|
final String name = rs.getString("name");
|
||||||
|
final boolean enabled = rs.getBoolean("enabled");
|
||||||
|
|
||||||
|
return new GlobalConfigurationPropertyData(name, enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.service;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
|
||||||
|
public interface GlobalConfigurationWritePlatformService {
|
||||||
|
|
||||||
|
CommandProcessingResult update(JsonCommand command);
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package org.mifosplatform.infrastructure.configuration.service;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.mifosplatform.infrastructure.configuration.command.UpdateGlobalConfigurationCommand;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.GlobalConfigurationProperty;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.GlobalConfigurationRepository;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.exception.GlobalConfigurationPropertyNotFoundException;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.serialization.GlobalConfigurationCommandFromApiJsonDeserializer;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements GlobalConfigurationWritePlatformService {
|
||||||
|
|
||||||
|
private final PlatformSecurityContext context;
|
||||||
|
private final GlobalConfigurationRepository repository;
|
||||||
|
private final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public GlobalConfigurationWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||||
|
final GlobalConfigurationRepository codeRepository, final GlobalConfigurationCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||||
|
this.context = context;
|
||||||
|
this.repository = codeRepository;
|
||||||
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult update(final JsonCommand command) {
|
||||||
|
|
||||||
|
context.authenticatedUser();
|
||||||
|
|
||||||
|
final UpdateGlobalConfigurationCommand configurationCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||||
|
|
||||||
|
final Map<String, Boolean> params = configurationCommand.getGlobalConfiguration();
|
||||||
|
|
||||||
|
final Map<String, Object> changes = new LinkedHashMap<String, Object>(params.size());
|
||||||
|
final Map<String, Boolean> propertiesMap = new LinkedHashMap<String, Boolean>(1);
|
||||||
|
for (String propertyName : params.keySet()) {
|
||||||
|
final GlobalConfigurationProperty property = retrieveBy(propertyName);
|
||||||
|
|
||||||
|
Boolean value = params.get(propertyName);
|
||||||
|
boolean updated = property.updateTo(value);
|
||||||
|
|
||||||
|
if (updated) {
|
||||||
|
propertiesMap.put(propertyName, value);
|
||||||
|
this.repository.save(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!propertiesMap.isEmpty()) {
|
||||||
|
changes.put("globalConfiguration", propertiesMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).with(changes).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private GlobalConfigurationProperty retrieveBy(final String propertyName) {
|
||||||
|
final GlobalConfigurationProperty property = this.repository.findOneByName(propertyName);
|
||||||
|
if (property == null) { throw new GlobalConfigurationPropertyNotFoundException(propertyName); }
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -1,7 +1,10 @@
|
|||||||
package org.mifosplatform.infrastructure.core.api;
|
package org.mifosplatform.infrastructure.core.api;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
@@ -122,4 +125,16 @@ public class ApiParameterHelper {
|
|||||||
String twoSingleQuotes = "''";
|
String twoSingleQuotes = "''";
|
||||||
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
return singleQuote + StringUtils.replace(str, singleQuote, twoSingleQuotes, -1) + singleQuote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> asMap(MultivaluedMap<String, String> queryParameters) {
|
||||||
|
|
||||||
|
final Map<String, String> map = new HashMap<String, String>(queryParameters.size());
|
||||||
|
|
||||||
|
for (String parameterName : queryParameters.keySet()) {
|
||||||
|
List<String> values = queryParameters.get(parameterName);
|
||||||
|
map.put(parameterName, values.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
-13
@@ -1,9 +1,7 @@
|
|||||||
package org.mifosplatform.infrastructure.core.api;
|
package org.mifosplatform.infrastructure.core.api;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -14,7 +12,6 @@ import org.mifosplatform.infrastructure.security.domain.PlatformUser;
|
|||||||
import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder;
|
import org.mifosplatform.infrastructure.security.service.PlatformPasswordEncoder;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Immutable representation of a command.
|
* Immutable representation of a command.
|
||||||
@@ -186,16 +183,6 @@ public final class JsonCommand {
|
|||||||
return stringValueOfParameterNamed("locale");
|
return stringValueOfParameterNamed("locale");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Boolean> mapValueOfParameterNamed(final String parameterName) {
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
|
||||||
|
|
||||||
if (parsedCommand.getAsJsonObject().has(parameterName)) {
|
|
||||||
parsedCommand.getAsJsonObject().get(parameterName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fromApiJsonHelper.extractMap(typeOfMap, jsonCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChangeInLongParameterNamed(final String parameterName, final Long existingValue) {
|
public boolean isChangeInLongParameterNamed(final String parameterName, final Long existingValue) {
|
||||||
boolean isChanged = false;
|
boolean isChanged = false;
|
||||||
if (parameterExists(parameterName)) {
|
if (parameterExists(parameterName)) {
|
||||||
|
|||||||
+4
-4
@@ -21,7 +21,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
|||||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.organisation.monetary.data.ConfigurationData;
|
import org.mifosplatform.organisation.monetary.data.ApplicationCurrencyConfigurationData;
|
||||||
import org.mifosplatform.organisation.monetary.service.OrganisationCurrencyReadPlatformService;
|
import org.mifosplatform.organisation.monetary.service.OrganisationCurrencyReadPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -38,13 +38,13 @@ public class CurrenciesApiResource {
|
|||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final OrganisationCurrencyReadPlatformService readPlatformService;
|
private final OrganisationCurrencyReadPlatformService readPlatformService;
|
||||||
private final DefaultToApiJsonSerializer<ConfigurationData> toApiJsonSerializer;
|
private final DefaultToApiJsonSerializer<ApplicationCurrencyConfigurationData> toApiJsonSerializer;
|
||||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public CurrenciesApiResource(final PlatformSecurityContext context, final OrganisationCurrencyReadPlatformService readPlatformService,
|
public CurrenciesApiResource(final PlatformSecurityContext context, final OrganisationCurrencyReadPlatformService readPlatformService,
|
||||||
final DefaultToApiJsonSerializer<ConfigurationData> toApiJsonSerializer,
|
final DefaultToApiJsonSerializer<ApplicationCurrencyConfigurationData> toApiJsonSerializer,
|
||||||
final ApiRequestParameterHelper apiRequestParameterHelper,
|
final ApiRequestParameterHelper apiRequestParameterHelper,
|
||||||
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@@ -61,7 +61,7 @@ public class CurrenciesApiResource {
|
|||||||
|
|
||||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
|
||||||
|
|
||||||
final ConfigurationData configurationData = this.readPlatformService.retrieveCurrencyConfiguration();
|
final ApplicationCurrencyConfigurationData configurationData = this.readPlatformService.retrieveCurrencyConfiguration();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
|
||||||
|
|||||||
+3
-3
@@ -3,16 +3,16 @@ package org.mifosplatform.organisation.monetary.data;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Immutable data object for configuration.
|
* Immutable data object for application currency.
|
||||||
*/
|
*/
|
||||||
public class ConfigurationData {
|
public class ApplicationCurrencyConfigurationData {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Collection<CurrencyData> selectedCurrencyOptions;
|
private final Collection<CurrencyData> selectedCurrencyOptions;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Collection<CurrencyData> currencyOptions;
|
private final Collection<CurrencyData> currencyOptions;
|
||||||
|
|
||||||
public ConfigurationData(final Collection<CurrencyData> currencyOptions, final Collection<CurrencyData> selectedCurrencyOptions) {
|
public ApplicationCurrencyConfigurationData(final Collection<CurrencyData> currencyOptions, final Collection<CurrencyData> selectedCurrencyOptions) {
|
||||||
this.currencyOptions = currencyOptions;
|
this.currencyOptions = currencyOptions;
|
||||||
this.selectedCurrencyOptions = selectedCurrencyOptions;
|
this.selectedCurrencyOptions = selectedCurrencyOptions;
|
||||||
}
|
}
|
||||||
+27
-26
@@ -10,20 +10,20 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
|||||||
@Table(name = "m_currency")
|
@Table(name = "m_currency")
|
||||||
public class ApplicationCurrency extends AbstractPersistable<Long> {
|
public class ApplicationCurrency extends AbstractPersistable<Long> {
|
||||||
|
|
||||||
@Column(name = "code", nullable = false, length=3)
|
@Column(name = "code", nullable = false, length = 3)
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
@Column(name = "decimal_places", nullable = false)
|
@Column(name = "decimal_places", nullable = false)
|
||||||
private final Integer decimalPlaces;
|
private final Integer decimalPlaces;
|
||||||
|
|
||||||
@Column(name = "name", nullable = false, length=50)
|
@Column(name = "name", nullable = false, length = 50)
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@Column(name = "internationalized_name_code", nullable = false, length=50)
|
@Column(name = "internationalized_name_code", nullable = false, length = 50)
|
||||||
private final String nameCode;
|
private final String nameCode;
|
||||||
|
|
||||||
@Column(name = "display_symbol", nullable = true, length=10)
|
@Column(name = "display_symbol", nullable = true, length = 10)
|
||||||
private final String displaySymbol;
|
private final String displaySymbol;
|
||||||
|
|
||||||
protected ApplicationCurrency() {
|
protected ApplicationCurrency() {
|
||||||
this.code = null;
|
this.code = null;
|
||||||
@@ -33,31 +33,32 @@ public class ApplicationCurrency extends AbstractPersistable<Long> {
|
|||||||
this.displaySymbol = null;
|
this.displaySymbol = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationCurrency(final String code, final String name, final int decimalPlaces, final String nameCode, final String displaySymbol) {
|
public ApplicationCurrency(final String code, final String name, final int decimalPlaces, final String nameCode,
|
||||||
|
final String displaySymbol) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.decimalPlaces = decimalPlaces;
|
this.decimalPlaces = decimalPlaces;
|
||||||
this.nameCode = nameCode;
|
this.nameCode = nameCode;
|
||||||
this.displaySymbol = displaySymbol;
|
this.displaySymbol = displaySymbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return this.code;
|
return this.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDecimalPlaces() {
|
public Integer getDecimalPlaces() {
|
||||||
return this.decimalPlaces;
|
return this.decimalPlaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameCode() {
|
public String getNameCode() {
|
||||||
return nameCode;
|
return nameCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplaySymbol() {
|
public String getDisplaySymbol() {
|
||||||
return displaySymbol;
|
return displaySymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
package org.mifosplatform.organisation.monetary.service;
|
package org.mifosplatform.organisation.monetary.service;
|
||||||
|
|
||||||
import org.mifosplatform.organisation.monetary.data.ConfigurationData;
|
import org.mifosplatform.organisation.monetary.data.ApplicationCurrencyConfigurationData;
|
||||||
|
|
||||||
public interface OrganisationCurrencyReadPlatformService {
|
public interface OrganisationCurrencyReadPlatformService {
|
||||||
|
|
||||||
ConfigurationData retrieveCurrencyConfiguration();
|
ApplicationCurrencyConfigurationData retrieveCurrencyConfiguration();
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.monetary.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosplatform.organisation.monetary.data.ConfigurationData;
|
import org.mifosplatform.organisation.monetary.data.ApplicationCurrencyConfigurationData;
|
||||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -18,7 +18,7 @@ public class OrganisationCurrencyReadPlatformServiceImpl implements Organisation
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigurationData retrieveCurrencyConfiguration() {
|
public ApplicationCurrencyConfigurationData retrieveCurrencyConfiguration() {
|
||||||
|
|
||||||
final List<CurrencyData> selectedCurrencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies();
|
final List<CurrencyData> selectedCurrencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||||
final List<CurrencyData> currencyOptions = this.currencyReadPlatformService.retrieveAllPlatformCurrencies();
|
final List<CurrencyData> currencyOptions = this.currencyReadPlatformService.retrieveAllPlatformCurrencies();
|
||||||
@@ -26,6 +26,6 @@ public class OrganisationCurrencyReadPlatformServiceImpl implements Organisation
|
|||||||
// remove selected currency options
|
// remove selected currency options
|
||||||
currencyOptions.removeAll(selectedCurrencyOptions);
|
currencyOptions.removeAll(selectedCurrencyOptions);
|
||||||
|
|
||||||
return new ConfigurationData(currencyOptions, selectedCurrencyOptions);
|
return new ApplicationCurrencyConfigurationData(currencyOptions, selectedCurrencyOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user