MIFOSX-9: Audit related work
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
DROP TABLE IF EXISTS `m_portfolio_command_source`;
|
||||
CREATE TABLE `m_portfolio_command_source` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`action_name` varchar(50) NOT NULL,
|
||||
`entity_name` varchar(50) NOT NULL,
|
||||
`office_id` bigint(20) DEFAULT NULL,
|
||||
`group_id` bigint(20) DEFAULT NULL,
|
||||
`client_id` bigint(20) DEFAULT NULL,
|
||||
`loan_id` bigint(20) DEFAULT NULL,
|
||||
`api_get_url` varchar(100) NOT NULL,
|
||||
`resource_id` bigint(20) DEFAULT NULL,
|
||||
`command_as_json` text NOT NULL,
|
||||
`maker_id` bigint(20) NOT NULL,
|
||||
`made_on_date` datetime NOT NULL,
|
||||
`checker_id` bigint(20) DEFAULT NULL,
|
||||
`checked_on_date` datetime DEFAULT NULL,
|
||||
`processing_result_enum` smallint(5) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK_m_maker_m_appuser` (`maker_id`),
|
||||
KEY `FK_m_checker_m_appuser` (`checker_id`),
|
||||
KEY `action_name` (`action_name`),
|
||||
KEY `entity_name` (`entity_name`,`resource_id`),
|
||||
KEY `made_on_date` (`made_on_date`),
|
||||
KEY `checked_on_date` (`checked_on_date`),
|
||||
KEY `processing_result_enum` (`processing_result_enum`),
|
||||
CONSTRAINT `FK_m_checker_m_appuser` FOREIGN KEY (`checker_id`) REFERENCES `m_appuser` (`id`),
|
||||
CONSTRAINT `FK_m_maker_m_appuser` FOREIGN KEY (`maker_id`) REFERENCES `m_appuser` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
+4
-4
@@ -24,7 +24,7 @@ import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializ
|
||||
import org.mifosplatform.accounting.service.GLAccountReadPlatformService;
|
||||
import org.mifosplatform.accounting.service.GLAccountWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
@@ -109,7 +109,7 @@ public class GLAccountsApiResource {
|
||||
|
||||
final Long coaId = glAccountWritePlatformService.createGLAccount(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new EntityIdentifier(coaId));
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new CommandProcessingResult(coaId));
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -122,7 +122,7 @@ public class GLAccountsApiResource {
|
||||
|
||||
final Long coaId = glAccountWritePlatformService.updateGLAccount(glAccountId, command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new EntityIdentifier(coaId));
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new CommandProcessingResult(coaId));
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -133,6 +133,6 @@ public class GLAccountsApiResource {
|
||||
|
||||
this.glAccountWritePlatformService.deleteGLAccount(glAccountId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(glAccountId)).build();
|
||||
return Response.ok(new CommandProcessingResult(glAccountId)).build();
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,7 +25,7 @@ import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializ
|
||||
import org.mifosplatform.accounting.service.GLClosureReadPlatformService;
|
||||
import org.mifosplatform.accounting.service.GLClosureWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeLookup;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -105,7 +105,7 @@ public class GLClosuresApiResource {
|
||||
|
||||
final Long coaId = glClosureWritePlatformService.createGLClosure(command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new EntityIdentifier(coaId));
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new CommandProcessingResult(coaId));
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -118,7 +118,7 @@ public class GLClosuresApiResource {
|
||||
|
||||
final Long coaId = glClosureWritePlatformService.updateGLClosure(glClosureId, command);
|
||||
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new EntityIdentifier(coaId));
|
||||
return this.apiJsonSerializerService.serializeEntityIdentifier(new CommandProcessingResult(coaId));
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -129,6 +129,6 @@ public class GLClosuresApiResource {
|
||||
|
||||
this.glClosureWritePlatformService.deleteGLClosure(glClosureId);
|
||||
|
||||
return Response.ok(new EntityIdentifier(glClosureId)).build();
|
||||
return Response.ok(new CommandProcessingResult(glClosureId)).build();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -7,12 +7,12 @@ import org.mifosplatform.accounting.api.data.GLAccountData;
|
||||
import org.mifosplatform.accounting.api.data.GLClosureData;
|
||||
import org.mifosplatform.accounting.api.data.GLJournalEntryData;
|
||||
import org.mifosplatform.accounting.api.data.JournalEntryIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
|
||||
public interface AccountingApiJsonSerializerService {
|
||||
|
||||
String serializeEntityIdentifier(final EntityIdentifier identifier);
|
||||
String serializeEntityIdentifier(final CommandProcessingResult identifier);
|
||||
|
||||
String serializeJournalEntryIdentifier(final JournalEntryIdentifier identifier);
|
||||
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.mifosplatform.accounting.api.data.GLJournalEntryData;
|
||||
import org.mifosplatform.accounting.api.data.JournalEntryIdentifier;
|
||||
import org.mifosplatform.accounting.api.infrastructure.AccountingApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.GoogleGsonSerializerHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -46,7 +46,7 @@ public class GoogleGsonAccountingApiJsonSerializerService implements AccountingA
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeEntityIdentifier(final EntityIdentifier identifier) {
|
||||
public String serializeEntityIdentifier(final CommandProcessingResult identifier) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(DATA_PARAMETERS, false,
|
||||
DATA_PARAMETERS);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, identifier);
|
||||
|
||||
@@ -7,56 +7,40 @@ import org.joda.time.DateTime;
|
||||
*/
|
||||
public final class AuditData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String actionName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String entityName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String apiOperation;
|
||||
@SuppressWarnings("unused")
|
||||
private final String resource;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long resourceId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String subResource;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long subResourceId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String maker;
|
||||
@SuppressWarnings("unused")
|
||||
private final DateTime madeOnDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final String checker;
|
||||
@SuppressWarnings("unused")
|
||||
private final DateTime checkedOnDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final String processingResult;
|
||||
@SuppressWarnings("unused")
|
||||
private final String commandAsJson;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String actionName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String entityName;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long resourceId;
|
||||
@SuppressWarnings("unused")
|
||||
private final String maker;
|
||||
@SuppressWarnings("unused")
|
||||
private final DateTime madeOnDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final String checker;
|
||||
@SuppressWarnings("unused")
|
||||
private final DateTime checkedOnDate;
|
||||
@SuppressWarnings("unused")
|
||||
private final String processingResult;
|
||||
@SuppressWarnings("unused")
|
||||
private final String commandAsJson;
|
||||
|
||||
public AuditData(final Long id, final String actionName,
|
||||
final String entityName, final String apiOperation,
|
||||
final String resource, final Long resourceId,
|
||||
final String subResource, final Long subResourceId,
|
||||
final String maker, final DateTime madeOnDate,
|
||||
final String checker, final DateTime checkedOnDate,
|
||||
final String processingResult, final String commandAsJson) {
|
||||
public AuditData(final Long id, final String actionName, final String entityName, final Long resourceId, final String maker,
|
||||
final DateTime madeOnDate, final String checker, final DateTime checkedOnDate, final String processingResult,
|
||||
final String commandAsJson) {
|
||||
|
||||
this.id = id;
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.apiOperation = apiOperation;
|
||||
this.resource = resource;
|
||||
this.resourceId = resourceId;
|
||||
this.subResource = subResource;
|
||||
this.subResourceId = subResourceId;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDate;
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate;
|
||||
this.commandAsJson = commandAsJson;
|
||||
this.processingResult = processingResult;
|
||||
}
|
||||
this.id = id;
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.resourceId = resourceId;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDate;
|
||||
this.checker = checker;
|
||||
this.checkedOnDate = checkedOnDate;
|
||||
this.commandAsJson = commandAsJson;
|
||||
this.processingResult = processingResult;
|
||||
}
|
||||
}
|
||||
+106
-135
@@ -25,171 +25,142 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
|
||||
private final static Logger logger = LoggerFactory
|
||||
.getLogger(AuditReadPlatformServiceImpl.class);
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final AppUserReadPlatformService appUserReadPlatformService;
|
||||
private final static Logger logger = LoggerFactory.getLogger(AuditReadPlatformServiceImpl.class);
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final AppUserReadPlatformService appUserReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final TenantAwareRoutingDataSource dataSource,
|
||||
final AppUserReadPlatformService appUserReadPlatformService) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.appUserReadPlatformService = appUserReadPlatformService;
|
||||
}
|
||||
@Autowired
|
||||
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
final AppUserReadPlatformService appUserReadPlatformService) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.appUserReadPlatformService = appUserReadPlatformService;
|
||||
}
|
||||
|
||||
private static final class AuditMapper implements RowMapper<AuditData> {
|
||||
private static final class AuditMapper implements RowMapper<AuditData> {
|
||||
|
||||
public String schema(boolean includeJson) {
|
||||
public String schema(boolean includeJson) {
|
||||
|
||||
String commandAsJsonString = "";
|
||||
if (includeJson)
|
||||
commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
String commandAsJsonString = "";
|
||||
if (includeJson) commandAsJsonString = ", aud.command_as_json as commandAsJson ";
|
||||
|
||||
return " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName, aud.api_operation as apiOperation, "
|
||||
+ " aud.api_resource as resource, aud.resource_id as resourceId, aud.api_subresource as subResource, aud.subresource_id as subResourceId,"
|
||||
+ " mk.username as maker, aud.made_on_date as madeOnDate, ck.username as checker, aud.checked_on_date as checkedOnDate, ev.enum_message_property as processingResult "
|
||||
+ commandAsJsonString
|
||||
+ " from m_portfolio_command_source aud "
|
||||
+ " left join m_appuser mk on mk.id = aud.maker_id"
|
||||
+ " left join m_appuser ck on ck.id = aud.checker_id"
|
||||
+ " left join r_enum_value ev on ev.enum_name = 'processing_result_enum' and ev.enum_id = aud.processing_result_enum";
|
||||
}
|
||||
return " aud.id as id, aud.action_name as actionName, aud.entity_name as entityName," + " aud.resource_id as resourceId,"
|
||||
+ " mk.username as maker, aud.made_on_date as madeOnDate, "
|
||||
+ "ck.username as checker, aud.checked_on_date as checkedOnDate, ev.enum_message_property as processingResult "
|
||||
+ commandAsJsonString + " from m_portfolio_command_source aud " + " left join m_appuser mk on mk.id = aud.maker_id"
|
||||
+ " left join m_appuser ck on ck.id = aud.checker_id"
|
||||
+ " left join r_enum_value ev on ev.enum_name = 'processing_result_enum' and ev.enum_id = aud.processing_result_enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuditData mapRow(final ResultSet rs,
|
||||
@SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
@Override
|
||||
public AuditData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = rs.getLong("id");
|
||||
final String actionName = rs.getString("actionName");
|
||||
final String entityName = rs.getString("entityName");
|
||||
final String apiOperation = rs.getString("apiOperation");
|
||||
final String resource = rs.getString("resource");
|
||||
final Long resourceId = JdbcSupport.getLong(rs, "resourceId");
|
||||
final String subResource = rs.getString("subResource");
|
||||
final Long subResourceId = JdbcSupport.getLong(rs, "subResourceId");
|
||||
final String maker = rs.getString("maker");
|
||||
final DateTime madeOnDate = JdbcSupport.getDateTime(rs,
|
||||
"madeOnDate");
|
||||
final String checker = rs.getString("checker");
|
||||
final DateTime checkedOnDate = JdbcSupport.getDateTime(rs,
|
||||
"checkedOnDate");
|
||||
final String processingResult = rs.getString("processingResult");
|
||||
String commandAsJson;
|
||||
// commandAsJson might not be on the select list of columns
|
||||
try {
|
||||
commandAsJson = rs.getString("commandAsJson");
|
||||
} catch (SQLException e) {
|
||||
commandAsJson = null;
|
||||
}
|
||||
return new AuditData(id, actionName, entityName, apiOperation,
|
||||
resource, resourceId, subResource, subResourceId, maker,
|
||||
madeOnDate, checker, checkedOnDate, processingResult,
|
||||
commandAsJson);
|
||||
}
|
||||
}
|
||||
final Long id = rs.getLong("id");
|
||||
final String actionName = rs.getString("actionName");
|
||||
final String entityName = rs.getString("entityName");
|
||||
final Long resourceId = JdbcSupport.getLong(rs, "resourceId");
|
||||
final String maker = rs.getString("maker");
|
||||
final DateTime madeOnDate = JdbcSupport.getDateTime(rs, "madeOnDate");
|
||||
final String checker = rs.getString("checker");
|
||||
final DateTime checkedOnDate = JdbcSupport.getDateTime(rs, "checkedOnDate");
|
||||
final String processingResult = rs.getString("processingResult");
|
||||
String commandAsJson;
|
||||
// commandAsJson might not be on the select list of columns
|
||||
try {
|
||||
commandAsJson = rs.getString("commandAsJson");
|
||||
} catch (SQLException e) {
|
||||
commandAsJson = null;
|
||||
}
|
||||
return new AuditData(id, actionName, entityName, resourceId, maker, madeOnDate, checker, checkedOnDate, processingResult,
|
||||
commandAsJson);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AuditData> retrieveAuditEntries(String extraCriteria,
|
||||
boolean includeJson) {
|
||||
context.authenticatedUser();
|
||||
@Override
|
||||
public Collection<AuditData> retrieveAuditEntries(String extraCriteria, boolean includeJson) {
|
||||
context.authenticatedUser();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
|
||||
String sql = "select " + rm.schema(includeJson);
|
||||
if (StringUtils.isNotBlank(extraCriteria))
|
||||
sql += " where (" + extraCriteria + ")";
|
||||
sql += " order by aud.id DESC";
|
||||
logger.info("sql: " + sql);
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
String sql = "select " + rm.schema(includeJson);
|
||||
if (StringUtils.isNotBlank(extraCriteria)) sql += " where (" + extraCriteria + ")";
|
||||
sql += " order by aud.id DESC";
|
||||
logger.info("sql: " + sql);
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuditData retrieveAuditEntry(Long auditId) {
|
||||
context.authenticatedUser();
|
||||
@Override
|
||||
public AuditData retrieveAuditEntry(Long auditId) {
|
||||
context.authenticatedUser();
|
||||
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
final AuditMapper rm = new AuditMapper();
|
||||
|
||||
String sql = "select " + rm.schema(true);
|
||||
sql += " where aud.id = " + auditId;
|
||||
String sql = "select " + rm.schema(true);
|
||||
sql += " where aud.id = " + auditId;
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
|
||||
}
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuditSearchData retrieveSearchTemplate() {
|
||||
Collection<AppUserLookup> appUsers = appUserReadPlatformService
|
||||
.retrieveSearchTemplate();
|
||||
@Override
|
||||
public AuditSearchData retrieveSearchTemplate() {
|
||||
Collection<AppUserLookup> appUsers = appUserReadPlatformService.retrieveSearchTemplate();
|
||||
|
||||
ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
List<String> actionNames = this.jdbcTemplate.query(mapper.schema(),
|
||||
mapper, new Object[] {});
|
||||
ActionNamesMapper mapper = new ActionNamesMapper();
|
||||
List<String> actionNames = this.jdbcTemplate.query(mapper.schema(), mapper, new Object[] {});
|
||||
|
||||
EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
List<String> entityNames = this.jdbcTemplate.query(mapper2.schema(),
|
||||
mapper2, new Object[] {});
|
||||
EntityNamesMapper mapper2 = new EntityNamesMapper();
|
||||
List<String> entityNames = this.jdbcTemplate.query(mapper2.schema(), mapper2, new Object[] {});
|
||||
|
||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
Collection<ProcessingResultLookup> processingResults = this.jdbcTemplate
|
||||
.query(mapper3.schema(), mapper3, new Object[] {});
|
||||
ProcessingResultsMapper mapper3 = new ProcessingResultsMapper();
|
||||
Collection<ProcessingResultLookup> processingResults = this.jdbcTemplate.query(mapper3.schema(), mapper3, new Object[] {});
|
||||
|
||||
return new AuditSearchData(appUsers, actionNames, entityNames,
|
||||
processingResults);
|
||||
}
|
||||
return new AuditSearchData(appUsers, actionNames, entityNames, processingResults);
|
||||
}
|
||||
|
||||
private static final class ActionNamesMapper implements RowMapper<String> {
|
||||
private static final class ActionNamesMapper implements RowMapper<String> {
|
||||
|
||||
@Override
|
||||
public String mapRow(final ResultSet rs,
|
||||
@SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
@Override
|
||||
public String mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
return rs.getString("actionName");
|
||||
}
|
||||
return rs.getString("actionName");
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
public String schema() {
|
||||
|
||||
return " SELECT distinct(action_name) as actionName FROM m_permission "
|
||||
+ " where action_name is not null and action_name <> 'READ' "
|
||||
+ " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||
}
|
||||
return " SELECT distinct(action_name) as actionName FROM m_permission "
|
||||
+ " where action_name is not null and action_name <> 'READ' "
|
||||
+ " order by if(action_name in ('CREATE', 'DELETE', 'UPDATE'), action_name, 'ZZZ'), action_name";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final class EntityNamesMapper implements RowMapper<String> {
|
||||
private static final class EntityNamesMapper implements RowMapper<String> {
|
||||
|
||||
@Override
|
||||
public String mapRow(final ResultSet rs,
|
||||
@SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
return rs.getString("entityName");
|
||||
}
|
||||
@Override
|
||||
public String mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
return rs.getString("entityName");
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return " select distinct(entity_name) as entityName from m_permission where action_name is not null and action_name <> 'READ' "
|
||||
+ " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||
}
|
||||
}
|
||||
public String schema() {
|
||||
return " select distinct(entity_name) as entityName from m_permission where action_name is not null and action_name <> 'READ' "
|
||||
+ " order by if(grouping = 'datatable', 'ZZZ', entity_name), entity_name";
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ProcessingResultsMapper implements
|
||||
RowMapper<ProcessingResultLookup> {
|
||||
private static final class ProcessingResultsMapper implements RowMapper<ProcessingResultLookup> {
|
||||
|
||||
@Override
|
||||
public ProcessingResultLookup mapRow(final ResultSet rs,
|
||||
@SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
Long id = JdbcSupport.getLong(rs, "id");
|
||||
String processingResult = rs.getString("processingResult");
|
||||
@Override
|
||||
public ProcessingResultLookup mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
Long id = JdbcSupport.getLong(rs, "id");
|
||||
String processingResult = rs.getString("processingResult");
|
||||
|
||||
return new ProcessingResultLookup(id, processingResult);
|
||||
}
|
||||
return new ProcessingResultLookup(id, processingResult);
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
return " select enum_id as id, enum_message_property as processingResult from r_enum_value where enum_name = 'processing_result_enum' "
|
||||
+ " order by enum_id";
|
||||
}
|
||||
}
|
||||
public String schema() {
|
||||
return " select enum_id as id, enum_message_property as processingResult from r_enum_value where enum_name = 'processing_result_enum' "
|
||||
+ " order by enum_id";
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -22,7 +22,7 @@ import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
@@ -76,7 +76,7 @@ public class CommandsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String approveMakerCheckerEntry(@PathParam("commandId") final Long commandId, @QueryParam("command") final String commandParam) {
|
||||
|
||||
EntityIdentifier result = null;
|
||||
CommandProcessingResult result = null;
|
||||
if (is(commandParam, "approve")) {
|
||||
result = this.writePlatformService.approveEntry(commandId);
|
||||
} else {
|
||||
@@ -98,6 +98,6 @@ public class CommandsApiResource {
|
||||
|
||||
final Long id = this.writePlatformService.deleteEntry(commandId);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(EntityIdentifier.commandOnlyResult(id));
|
||||
return this.toApiJsonSerializer.serialize(CommandProcessingResult.commandOnlyResult(id));
|
||||
}
|
||||
}
|
||||
+32
-47
@@ -25,22 +25,30 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "entity_name", nullable = true, length = 100)
|
||||
private String entityName;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "office_id")
|
||||
private Long officeId;
|
||||
|
||||
@Column(name = "api_operation", length = 30)
|
||||
private String apiOperation;
|
||||
|
||||
@Column(name = "api_resource", length = 100)
|
||||
private String resource;
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "group_id")
|
||||
private Long groupId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "client_id")
|
||||
private Long clientId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "loan_id")
|
||||
private Long loanId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "api_get_url", length = 100)
|
||||
private String resourceGetUrl;
|
||||
|
||||
@Column(name = "resource_id")
|
||||
private Long resourceId;
|
||||
|
||||
@Column(name = "api_subresource", length = 100)
|
||||
private String subResource;
|
||||
|
||||
@Column(name = "subresource_id")
|
||||
private Long subResourceId;
|
||||
|
||||
@Column(name = "command_as_json", length = 1000)
|
||||
private String commandAsJson;
|
||||
|
||||
@@ -69,24 +77,22 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
private Integer processingResult;
|
||||
|
||||
public static CommandSource fullEntryFrom(final CommandWrapper wrapper, final JsonCommand command, final AppUser maker) {
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.operation(), wrapper.resourceName(), command.resourceId(),
|
||||
wrapper.subResourceName(), command.subResourceId(), command.json(), maker, DateTime.now());
|
||||
return new CommandSource(wrapper.actionName(), wrapper.entityName(), wrapper.getHref(), command.entityId(), command.json(), maker, DateTime.now());
|
||||
}
|
||||
|
||||
protected CommandSource() {
|
||||
//
|
||||
}
|
||||
|
||||
private CommandSource(final String actionName, final String entityName, final String apiOperation, final String resource, final Long resourceId,
|
||||
final String subResource, final Long subResourceId, final String commandSerializedAsJson, final AppUser maker,
|
||||
private CommandSource(
|
||||
final String actionName, final String entityName, final String href,
|
||||
final Long resourceId,
|
||||
final String commandSerializedAsJson, final AppUser maker,
|
||||
final DateTime madeOnDateTime) {
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.apiOperation = StringUtils.defaultIfEmpty(apiOperation, null);
|
||||
this.resource = StringUtils.defaultIfEmpty(resource, null);
|
||||
this.resourceGetUrl = href;
|
||||
this.resourceId = resourceId;
|
||||
this.subResource = StringUtils.defaultIfEmpty(subResource, null);
|
||||
this.subResourceId = subResourceId;
|
||||
this.commandAsJson = commandSerializedAsJson;
|
||||
this.maker = maker;
|
||||
this.madeOnDate = madeOnDateTime.toDate();
|
||||
@@ -103,10 +109,6 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void updateSubResourceId(final Long subResourceId) {
|
||||
this.subResourceId = subResourceId;
|
||||
}
|
||||
|
||||
public void updateJsonTo(final String json) {
|
||||
this.commandAsJson = json;
|
||||
}
|
||||
@@ -123,18 +125,6 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
return this.commandAsJson;
|
||||
}
|
||||
|
||||
public String commandName() {
|
||||
return this.apiOperation + '-' + this.resource;
|
||||
}
|
||||
|
||||
public String resourceName() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public String operation() {
|
||||
return this.apiOperation;
|
||||
}
|
||||
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
@@ -147,23 +137,18 @@ public class CommandSource extends AbstractPersistable<Long> {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
|
||||
public String getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public Long getResourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public String getSubResource() {
|
||||
return this.subResource;
|
||||
}
|
||||
|
||||
public Long getSubResourceId() {
|
||||
return this.subResourceId;
|
||||
}
|
||||
|
||||
public void markAsAwaitingApproval() {
|
||||
this.processingResult = CommandProcessingResultType.AWAITING_APPROVAL.getValue();
|
||||
}
|
||||
|
||||
public void updateForAudit(final Long officeId, final Long groupId, final Long clientId, final Long loanId) {
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
}
|
||||
}
|
||||
+133
-79
@@ -3,43 +3,61 @@ package org.mifosplatform.commands.domain;
|
||||
public class CommandWrapper {
|
||||
|
||||
private final Long commandId;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long officeId;
|
||||
private final Long groupId;
|
||||
private final Long clientId;
|
||||
private final Long loanId;
|
||||
private final String actionName;
|
||||
private final String entityName;
|
||||
private final String apiOperation;
|
||||
private final String resource;
|
||||
private final Long resourceId;
|
||||
private final String subResource;
|
||||
private final Long subResourceId;
|
||||
private final String taskPermissionName;
|
||||
private final Long entityId;
|
||||
private final String href;
|
||||
private final String json;
|
||||
private final Long apptableId;
|
||||
private final Long datatableId;
|
||||
|
||||
public static CommandWrapper wrap(final String actionName, final String enityName, final String apiOperation, final String resource,
|
||||
final Long resourceId) {
|
||||
return new CommandWrapper(null, actionName, enityName, apiOperation, resource, resourceId, null, null);
|
||||
}
|
||||
|
||||
public static CommandWrapper wrap(final String actionName, final String enityName, final String apiOperation, final String resource,
|
||||
final Long resourceId, final String subResource, final Long subRescourceId) {
|
||||
return new CommandWrapper(null, actionName, enityName, apiOperation, resource, resourceId, subResource, subRescourceId);
|
||||
public static CommandWrapper wrap(final String actionName, final String enityName, final Long resourceId) {
|
||||
return new CommandWrapper(null, actionName, enityName, resourceId);
|
||||
}
|
||||
|
||||
public static CommandWrapper fromExistingCommand(final Long commandId, final String actionName, final String enityName,
|
||||
final String apiOperation, final String resource, final Long resourceId, final String subResource, final Long subRescourceId) {
|
||||
return new CommandWrapper(commandId, actionName, enityName, apiOperation, resource, resourceId, subResource, subRescourceId);
|
||||
final Long resourceId) {
|
||||
return new CommandWrapper(commandId, actionName, enityName, resourceId);
|
||||
}
|
||||
|
||||
private CommandWrapper(final Long commandId, final String actionName, final String enityName, final String apiOperation,
|
||||
final String resource, final Long resourceId, final String subResource, final Long subResourceId) {
|
||||
private CommandWrapper(final Long commandId, final String actionName, final String enityName, final Long resourceId) {
|
||||
this.commandId = commandId;
|
||||
this.officeId = null;
|
||||
this.groupId = null;
|
||||
this.clientId = null;
|
||||
this.loanId = null;
|
||||
this.actionName = actionName;
|
||||
this.entityName = enityName;
|
||||
this.apiOperation = apiOperation;
|
||||
this.resource = resource;
|
||||
this.resourceId = resourceId;
|
||||
this.subResource = subResource;
|
||||
this.subResourceId = subResourceId;
|
||||
this.taskPermissionName = actionName + "_" + entityName;
|
||||
this.entityId = resourceId;
|
||||
this.apptableId = null;
|
||||
this.datatableId = null;
|
||||
this.href = null;
|
||||
this.json = null;
|
||||
}
|
||||
|
||||
public String commandName() {
|
||||
return this.apiOperation + '-' + this.resource;
|
||||
public CommandWrapper(final Long officeId, final Long groupId, final Long clientId, final Long loanId, final String actionName,
|
||||
final String entityName, final Long entityId, final Long apptableId, final Long datatableId, final String href,
|
||||
final String json) {
|
||||
this.commandId = null;
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.actionName = actionName;
|
||||
this.entityName = entityName;
|
||||
this.taskPermissionName = actionName + "_" + entityName;
|
||||
this.entityId = entityId;
|
||||
this.apptableId = apptableId;
|
||||
this.datatableId = datatableId;
|
||||
this.href = href;
|
||||
this.json = json;
|
||||
}
|
||||
|
||||
public Long commandId() {
|
||||
@@ -55,117 +73,141 @@ public class CommandWrapper {
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public String resourceName() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public Long subResourceId() {
|
||||
return this.subResourceId;
|
||||
}
|
||||
|
||||
public String subResourceName() {
|
||||
return this.subResource;
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public String taskPermissionName() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
|
||||
public String operation() {
|
||||
return this.apiOperation;
|
||||
public boolean isCreate() {
|
||||
return this.actionName.equalsIgnoreCase("CREATE");
|
||||
}
|
||||
|
||||
public boolean isCreate() {
|
||||
return this.apiOperation.equalsIgnoreCase("CREATE");
|
||||
public String getTaskPermissionName() {
|
||||
return this.taskPermissionName;
|
||||
}
|
||||
|
||||
public String getHref() {
|
||||
return this.href;
|
||||
}
|
||||
|
||||
public String getJson() {
|
||||
return this.json;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return this.entityName;
|
||||
}
|
||||
|
||||
public Long getEntityId() {
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public Long getApptableId() {
|
||||
return this.apptableId;
|
||||
}
|
||||
|
||||
public Long getDatatableId() {
|
||||
return this.datatableId;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
// permissions resource has special update which involves no resource.
|
||||
return (isPermissionResource() && isUpdateOperation()) || (isCurrencyResource() && isUpdateOperation())
|
||||
|| (isUpdateOperation() && this.resourceId != null);
|
||||
|| (isUpdateOperation() && this.entityId != null);
|
||||
}
|
||||
|
||||
private boolean isUpdateOperation() {
|
||||
return this.apiOperation.equalsIgnoreCase("UPDATE");
|
||||
return this.actionName.equalsIgnoreCase("UPDATE");
|
||||
}
|
||||
|
||||
public boolean isDelete() {
|
||||
return this.apiOperation.equalsIgnoreCase("DELETE") && this.resourceId != null;
|
||||
return isDeleteOperation() && this.entityId != null;
|
||||
}
|
||||
|
||||
private boolean isDeleteOperation() {
|
||||
return this.actionName.equalsIgnoreCase("DELETE");
|
||||
}
|
||||
|
||||
public boolean isUpdateRolePermissions() {
|
||||
return this.apiOperation.equalsIgnoreCase("UPDATEPERMISSIONS") && this.resourceId != null;
|
||||
return this.actionName.equalsIgnoreCase("PERMISSIONS") && this.entityId != null;
|
||||
}
|
||||
|
||||
public boolean isPermissionResource() {
|
||||
return this.resource.equalsIgnoreCase("PERMISSIONS");
|
||||
return this.entityName.equalsIgnoreCase("PERMISSION");
|
||||
}
|
||||
|
||||
public boolean isRoleResource() {
|
||||
return this.resource.equalsIgnoreCase("ROLES");
|
||||
return this.entityName.equalsIgnoreCase("ROLE");
|
||||
}
|
||||
|
||||
public boolean isUserResource() {
|
||||
return this.resource.equalsIgnoreCase("USERS");
|
||||
return this.entityName.equalsIgnoreCase("USER");
|
||||
}
|
||||
|
||||
public boolean isCurrencyResource() {
|
||||
return this.resource.equalsIgnoreCase("CURRENCIES");
|
||||
return this.entityName.equalsIgnoreCase("CURRENCY");
|
||||
}
|
||||
|
||||
public boolean isCodeResource() {
|
||||
return this.resource.equalsIgnoreCase("CODES");
|
||||
return this.entityName.equalsIgnoreCase("CODE");
|
||||
}
|
||||
|
||||
public boolean isStaffResource() {
|
||||
return this.resource.equalsIgnoreCase("STAFF");
|
||||
return this.entityName.equalsIgnoreCase("STAFF");
|
||||
}
|
||||
|
||||
public boolean isFundResource() {
|
||||
return this.resource.equalsIgnoreCase("FUNDS");
|
||||
return this.entityName.equalsIgnoreCase("FUND");
|
||||
}
|
||||
|
||||
public boolean isOfficeResource() {
|
||||
return this.resource.equalsIgnoreCase("OFFICES");
|
||||
return this.entityName.equalsIgnoreCase("OFFICE");
|
||||
}
|
||||
|
||||
public boolean isOfficeTransactionResource() {
|
||||
return this.resource.equalsIgnoreCase("OFFICETRANSACTIONS");
|
||||
return this.entityName.equalsIgnoreCase("OFFICETRANSACTION");
|
||||
}
|
||||
|
||||
public boolean isChargeDefinitionResource() {
|
||||
return this.resource.equalsIgnoreCase("CHARGES");
|
||||
return this.entityName.equalsIgnoreCase("CHARGE");
|
||||
}
|
||||
|
||||
public boolean isLoanProductResource() {
|
||||
return this.resource.equalsIgnoreCase("LOANPRODUCTS");
|
||||
return this.entityName.equalsIgnoreCase("LOANPRODUCT");
|
||||
}
|
||||
|
||||
public boolean isClientResource() {
|
||||
return this.resource.equalsIgnoreCase("CLIENTS");
|
||||
return this.entityName.equalsIgnoreCase("CLIENT");
|
||||
}
|
||||
|
||||
public boolean isClientIdentifierResource() {
|
||||
return isClientResource() && isIdentifiersSubResource();
|
||||
return this.entityName.equals("CLIENTIDENTIFIER");
|
||||
}
|
||||
|
||||
public boolean isClientNoteResource() {
|
||||
return isClientResource() && isNotesSubResource();
|
||||
}
|
||||
|
||||
public boolean isNotesSubResource() {
|
||||
return "NOTES".equalsIgnoreCase(this.subResource);
|
||||
}
|
||||
|
||||
public boolean isIdentifiersSubResource() {
|
||||
return "IDENTIFIERS".equalsIgnoreCase(this.subResource);
|
||||
return this.entityName.equals("CLIENTNOTE");
|
||||
}
|
||||
|
||||
public boolean isLoanResource() {
|
||||
return this.resource.equalsIgnoreCase("LOANS");
|
||||
return this.entityName.equalsIgnoreCase("LOAN");
|
||||
}
|
||||
|
||||
public boolean isLoanChargeResource() {
|
||||
return this.entityName.equalsIgnoreCase("LOANCHARGE");
|
||||
}
|
||||
|
||||
public boolean isApproveLoanApplication() {
|
||||
@@ -221,9 +263,9 @@ public class CommandWrapper {
|
||||
}
|
||||
|
||||
public boolean isDeleteLoanCharge() {
|
||||
return this.actionName.equalsIgnoreCase("DELETE") && this.entityName.equalsIgnoreCase("LOANCHARGE");
|
||||
return isDeleteOperation() && this.entityName.equalsIgnoreCase("LOANCHARGE");
|
||||
}
|
||||
|
||||
|
||||
public boolean isUpdateLoanCharge() {
|
||||
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("LOANCHARGE");
|
||||
}
|
||||
@@ -240,15 +282,27 @@ public class CommandWrapper {
|
||||
return this.actionName.equalsIgnoreCase("BULKREASSIGN") && this.entityName.equalsIgnoreCase("LOAN");
|
||||
}
|
||||
|
||||
public boolean isDatatableResource() {
|
||||
return this.resource.toUpperCase().startsWith("DATATABLES");
|
||||
}
|
||||
public boolean isDatatableResource() {
|
||||
return this.apptableId != null;
|
||||
}
|
||||
|
||||
public boolean isDeleteMultiple() {
|
||||
return isDatatableResource() && this.apiOperation.equalsIgnoreCase("DELETE_MULTIPLE");
|
||||
}
|
||||
public boolean isDeleteOneToOne() {
|
||||
return isDatatableResource() && isDeleteOperation() && this.apptableId != null;
|
||||
}
|
||||
|
||||
public boolean isDeleteMultiple() {
|
||||
return isDatatableResource() && isDeleteOperation() && this.apptableId != null && this.datatableId != null;
|
||||
}
|
||||
|
||||
public boolean isUpdateMultiple() {
|
||||
return isDatatableResource() && this.apiOperation.equalsIgnoreCase("UPDATE_MULTIPLE");
|
||||
}
|
||||
public boolean isUpdateOneToOne() {
|
||||
return isDatatableResource() && isUpdateOperation() && this.apptableId != null;
|
||||
}
|
||||
|
||||
public boolean isUpdateMultiple() {
|
||||
return isDatatableResource() && isUpdateOperation() && this.apptableId != null && this.datatableId != null;
|
||||
}
|
||||
|
||||
public String commandName() {
|
||||
return this.actionName + "_" + this.entityName;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package org.mifosplatform.commands.handler;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface NewCommandSourceHandler {
|
||||
|
||||
EntityIdentifier processCommand(JsonCommand command);
|
||||
CommandProcessingResult processCommand(JsonCommand command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,12 +2,12 @@ package org.mifosplatform.commands.service;
|
||||
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface CommandProcessingService {
|
||||
|
||||
EntityIdentifier processAndLogCommand(CommandWrapper wrapper, JsonCommand command, boolean isApprovedByChecker);
|
||||
CommandProcessingResult processAndLogCommand(CommandWrapper wrapper, JsonCommand command, boolean isApprovedByChecker);
|
||||
|
||||
EntityIdentifier logCommand(CommandWrapper wrapper, JsonCommand command);
|
||||
CommandProcessingResult logCommand(CommandWrapper wrapper, JsonCommand command);
|
||||
|
||||
}
|
||||
|
||||
+385
@@ -0,0 +1,385 @@
|
||||
package org.mifosplatform.commands.service;
|
||||
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
|
||||
public class CommandWrapperBuilder {
|
||||
|
||||
private Long officeId;
|
||||
private Long groupId;
|
||||
private Long clientId;
|
||||
private Long loanId;
|
||||
private String actionName;
|
||||
private String entityName;
|
||||
private Long entityId;
|
||||
private String href;
|
||||
private String json;
|
||||
private Long apptableId;
|
||||
private Long datatableId;
|
||||
|
||||
public CommandWrapper build() {
|
||||
return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.actionName, this.entityName, this.entityId, this.apptableId, this.datatableId,
|
||||
this.href, this.json);
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withEntityId(final Long withId) {
|
||||
this.entityId = withId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withLoanId(final Long withLoanId) {
|
||||
this.loanId = withLoanId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withClientId(final Long withClientId) {
|
||||
this.clientId = withClientId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withJson(final String withJson) {
|
||||
this.json = withJson;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withUrl(final String withUrl) {
|
||||
this.href = withUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updatePermissions() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "PERMISSION";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createRole() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "ROLE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateRole() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "ROLE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateRolePermissions() {
|
||||
this.actionName = "PERMISSIONS";
|
||||
this.entityName = "ROLE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createUser() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "USER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateUser() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "USER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteUser() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "USER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createOffice() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "OFFICE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateOffice() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "OFFICE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createOfficeTransaction() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "OFFICETRANSACTION";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createStaff() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "STAFF";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateStaff() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "STAFF";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createFund() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "FUND";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateFund() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "FUND";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateCurrencies() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CURRENCY";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createCode() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CODE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateCode() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CODE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteCode() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "CODE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createCharge() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateCharge() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteCharge() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "CHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createLoanProduct() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "LOANPRODUCT";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateLoanProduct() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "LOANPRODUCT";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createClientIdentifier() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CLIENTIDENTIFIER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateClientIdentifier() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CLIENTIDENTIFIER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteClientIdentifier() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "CLIENTIDENTIFIER";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createClientNote() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CLIENTNOTE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateClientNote() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CLIENTNOTE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createClient() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "CLIENT";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateClient() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "CLIENT";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteClient() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "CLIENT";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createDatatable(final String datatable, final Long apptableId, final Long datatableId) {
|
||||
this.apptableId = apptableId;
|
||||
this.datatableId = datatableId;
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = datatable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateDatatable(final String datatable, final Long apptableId, final Long datatableId) {
|
||||
this.apptableId = apptableId;
|
||||
this.datatableId = datatableId;
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = datatable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteDatatable(final String datatable, final Long apptableId, final Long datatableId) {
|
||||
this.apptableId = apptableId;
|
||||
this.datatableId = datatableId;
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = datatable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createLoanCharge() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateLoanCharge() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder waiveLoanCharge() {
|
||||
this.actionName = "WAIVE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteLoanCharge() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "LOANCHARGE";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder loanRepaymentTransaction() {
|
||||
this.actionName = "REPAYMENT";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder waiveInterestPortionTransaction() {
|
||||
this.actionName = "WAIVEINTERESTPORTION";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder writeOffLoanTransaction() {
|
||||
this.actionName = "WRITEOFF";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder closeLoanAsRescheduledTransaction() {
|
||||
this.actionName = "CLOSEASRESCHEDULED";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder closeLoanTransaction() {
|
||||
this.actionName = "CLOSE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder adjustTransaction() {
|
||||
this.actionName = "ADJUST";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder createLoanApplication() {
|
||||
this.actionName = "CREATE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder updateLoanApplication() {
|
||||
this.actionName = "UPDATE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder deleteLoanApplication() {
|
||||
this.actionName = "DELETE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder rejectLoanApplication() {
|
||||
this.actionName = "REJECT";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder withdrawLoanApplication() {
|
||||
this.actionName = "WITHDRAW";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder approveLoanApplication() {
|
||||
this.actionName = "APPROVE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder disburseLoanApplication() {
|
||||
this.actionName = "DISBURSE";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder undoLoanApplicationApproval() {
|
||||
this.actionName = "APPROVALUNDO";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder undoLoanApplicationDisbursal() {
|
||||
this.actionName = "DISBURSALUNDO";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder assignLoanOfficer() {
|
||||
this.actionName = "UPDATELOANOFFICER";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder assignLoanOfficersInBulk() {
|
||||
this.actionName = "BULKREASSIGN";
|
||||
this.entityName = "LOAN";
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -1,15 +1,13 @@
|
||||
package org.mifosplatform.commands.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface PortfolioCommandSourceWritePlatformService {
|
||||
|
||||
EntityIdentifier logCommandSource(String actionName, String entityName, String apiOperation, String resource, Long resourceId, String subResource,
|
||||
Long subRescourceId, String json);
|
||||
CommandProcessingResult logCommandSource(CommandWrapper commandRequest);
|
||||
|
||||
EntityIdentifier logCommandSource(String actionName, String entityName, String apiOperation, String resource, Long resourceId, String json);
|
||||
|
||||
EntityIdentifier approveEntry(Long id);
|
||||
CommandProcessingResult approveEntry(Long id);
|
||||
|
||||
Long deleteEntry(Long makerCheckerId);
|
||||
}
|
||||
+14
-42
@@ -5,7 +5,7 @@ import org.mifosplatform.commands.domain.CommandSource;
|
||||
import org.mifosplatform.commands.domain.CommandSourceRepository;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
||||
@@ -34,46 +34,17 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier logCommandSource(final String actionName, final String entityName, final String apiOperation,
|
||||
final String resource, final Long resourceId, final String subResource, final Long subRescourceId, final String json) {
|
||||
public CommandProcessingResult logCommandSource(final CommandWrapper wrapper) {
|
||||
|
||||
final String taskPermissionName = actionName + "_" + entityName;
|
||||
context.authenticatedUser().validateHasPermissionTo(taskPermissionName);
|
||||
context.authenticatedUser().validateHasPermissionTo(wrapper.getTaskPermissionName());
|
||||
|
||||
final CommandWrapper wrapper = CommandWrapper.wrap(actionName, entityName, apiOperation, resource, resourceId, subResource,
|
||||
subRescourceId);
|
||||
EntityIdentifier result = null;
|
||||
final String json = wrapper.getJson();
|
||||
CommandProcessingResult result = null;
|
||||
try {
|
||||
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
|
||||
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, entityName, resourceId, subRescourceId);
|
||||
final boolean isApprovedByChecker = false;
|
||||
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||
|
||||
final String jsonToUse = StringUtils.defaultIfEmpty(e.getJsonOfChangesOnly(), json);
|
||||
|
||||
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonToUse);
|
||||
final JsonCommand command = JsonCommand.from(jsonToUse, parsedCommand, this.fromApiJsonHelper, entityName, resourceId, subRescourceId);
|
||||
|
||||
result = this.processAndLogCommandService.logCommand(wrapper, command);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier logCommandSource(final String actionName, final String entityName, final String apiOperation, final String resource,
|
||||
final Long resourceId, final String json) {
|
||||
|
||||
final String taskPermissionName = actionName + "_" + entityName;
|
||||
context.authenticatedUser().validateHasPermissionTo(taskPermissionName);
|
||||
|
||||
final CommandWrapper wrapper = CommandWrapper.wrap(actionName, entityName, apiOperation, resource, resourceId);
|
||||
|
||||
EntityIdentifier result = null;
|
||||
try {
|
||||
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(json);
|
||||
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, entityName, resourceId, null);
|
||||
final JsonCommand command = JsonCommand.from(json, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
|
||||
wrapper.getEntityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(),
|
||||
wrapper.getDatatableId());
|
||||
|
||||
final boolean isApprovedByChecker = false;
|
||||
result = this.processAndLogCommandService.processAndLogCommand(wrapper, command, isApprovedByChecker);
|
||||
@@ -82,7 +53,9 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
final String jsonToUse = StringUtils.defaultIfEmpty(e.getJsonOfChangesOnly(), json);
|
||||
|
||||
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonToUse);
|
||||
final JsonCommand command = JsonCommand.from(jsonToUse, parsedCommand, this.fromApiJsonHelper, entityName, resourceId, null);
|
||||
final JsonCommand command = JsonCommand.from(jsonToUse, parsedCommand, this.fromApiJsonHelper, wrapper.getEntityName(),
|
||||
wrapper.getEntityId(), wrapper.getGroupId(), wrapper.getClientId(), wrapper.getLoanId(), wrapper.getApptableId(),
|
||||
wrapper.getDatatableId());
|
||||
|
||||
result = this.processAndLogCommandService.logCommand(wrapper, command);
|
||||
}
|
||||
@@ -91,19 +64,18 @@ public class PortfolioCommandSourceWritePlatformServiceImpl implements Portfolio
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier approveEntry(final Long commandId) {
|
||||
public CommandProcessingResult approveEntry(final Long commandId) {
|
||||
|
||||
final CommandSource commandSourceInput = this.commandSourceRepository.findOne(commandId);
|
||||
|
||||
context.authenticatedUser().validateHasCheckerPermissionTo(commandSourceInput.getPermissionCode());
|
||||
|
||||
final CommandWrapper wrapper = CommandWrapper.fromExistingCommand(commandId, commandSourceInput.getActionName(),
|
||||
commandSourceInput.getEntityName(), commandSourceInput.operation(), commandSourceInput.resourceName(),
|
||||
commandSourceInput.resourceId(), commandSourceInput.getSubResource(), commandSourceInput.getSubResourceId());
|
||||
commandSourceInput.getEntityName(), commandSourceInput.resourceId());
|
||||
|
||||
final JsonElement parsedCommand = this.fromApiJsonHelper.parse(commandSourceInput.json());
|
||||
final JsonCommand command = JsonCommand.fromExistingCommand(commandId, commandSourceInput.json(), parsedCommand,
|
||||
this.fromApiJsonHelper, commandSourceInput.resourceId(), commandSourceInput.getSubResourceId());
|
||||
this.fromApiJsonHelper, commandSourceInput.resourceId());
|
||||
|
||||
final boolean makerCheckerApproval = true;
|
||||
return this.processAndLogCommandService.processAndLogCommand(wrapper, command, makerCheckerApproval);
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
private static final class CommandSourceMapper implements RowMapper<CommandSourceData> {
|
||||
|
||||
public String schema() {
|
||||
return " mc.id as id, mc.api_operation as taskOperation, mc.api_resource as taskEntity, mc.resource_id as entityId,"
|
||||
return " mc.id as id, mc.action_name as taskOperation, mc.entity_name as taskEntity, mc.resource_id as entityId,"
|
||||
+ "mc.command_as_json as taskJson, mc.made_on_date as madeOnDate from m_portfolio_command_source mc ";
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
|
||||
final CommandSourceMapper rm = new CommandSourceMapper();
|
||||
final String sql = "select " + rm.schema()
|
||||
+ " where mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.api_resource ASC, mc.api_operation ASC";
|
||||
+ " where mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.api_resource ASC, mc.action_name ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class PortfolioCommandsReadPlatformServiceImpl implements PortfolioComman
|
||||
final CommandSourceMapper rm = new CommandSourceMapper();
|
||||
final String sql = "select "
|
||||
+ rm.schema()
|
||||
+ " where mc.api_resource like ? and mc.resource_id = ? and mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.api_operation ASC";
|
||||
+ " where mc.entity_name like ? and mc.resource_id = ? and mc.checker_id is null and mc.processing_result_enum = 2 order by mc.made_on_date DESC, mc.action_name ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { apiResource, resourceId });
|
||||
}
|
||||
|
||||
+33
-31
@@ -9,7 +9,8 @@ import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.exception.UnsupportedCommandException;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.service.ConfigurationDomainService;
|
||||
@@ -44,13 +45,13 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, final boolean isApprovedByChecker) {
|
||||
public CommandProcessingResult processAndLogCommand(final CommandWrapper wrapper, final JsonCommand command, final boolean isApprovedByChecker) {
|
||||
|
||||
final NewCommandSourceHandler handler = findCommandHandler(wrapper);
|
||||
final EntityIdentifier result = handler.processCommand(command);
|
||||
final CommandProcessingResult result = handler.processCommand(command);
|
||||
|
||||
final AppUser maker = context.authenticatedUser();
|
||||
|
||||
|
||||
CommandSource commandSourceResult = null;
|
||||
if (command.commandId() != null) {
|
||||
commandSourceResult = this.commandSourceRepository.findOne(command.commandId());
|
||||
@@ -59,8 +60,8 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
commandSourceResult = CommandSource.fullEntryFrom(wrapper, command, maker);
|
||||
}
|
||||
commandSourceResult.updateResourceId(result.resourceId());
|
||||
commandSourceResult.updateSubResourceId(result.subResourceId());
|
||||
|
||||
commandSourceResult.updateForAudit(result.getOfficeId(), result.getGroupId(), result.getClientId(), result.getLoanId());
|
||||
|
||||
String changesOnlyJson = null;
|
||||
if (result.hasChanges()) {
|
||||
changesOnlyJson = this.toApiJsonSerializer.serializeResult(result.getChanges());
|
||||
@@ -75,14 +76,15 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
commandSourceRepository.save(commandSourceResult);
|
||||
}
|
||||
|
||||
if (this.configurationDomainService.isMakerCheckerEnabledForTask(wrapper.taskPermissionName()) && !isApprovedByChecker) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(changesOnlyJson); }
|
||||
if (this.configurationDomainService.isMakerCheckerEnabledForTask(wrapper.taskPermissionName()) && !isApprovedByChecker) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(
|
||||
changesOnlyJson); }
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier logCommand(final CommandWrapper wrapper, final JsonCommand command) {
|
||||
public CommandProcessingResult logCommand(final CommandWrapper wrapper, final JsonCommand command) {
|
||||
|
||||
final AppUser maker = context.authenticatedUser();
|
||||
|
||||
@@ -92,28 +94,27 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
commandSourceRepository.save(commandSourceResult);
|
||||
}
|
||||
|
||||
return EntityIdentifier.resourceResult(commandSourceResult.resourceId(), commandSourceResult.getId());
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(commandSourceResult.resourceId()).build();
|
||||
}
|
||||
|
||||
private NewCommandSourceHandler findCommandHandler(final CommandWrapper wrapper) {
|
||||
NewCommandSourceHandler handler = null;
|
||||
|
||||
if (wrapper.isDatatableResource()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = applicationContext.getBean("createDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateMultiple()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = applicationContext.getBean("createDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateMultiple()) {
|
||||
handler = applicationContext.getBean("updateOneToManyDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdate()) {
|
||||
handler = applicationContext.getBean("updateOneToOneDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDeleteMultiple()) {
|
||||
handler = applicationContext.getBean("deleteOneToManyDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDelete()) {
|
||||
handler = applicationContext.getBean("deleteOneToOneDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
} else if (wrapper.isUpdateOneToOne()) {
|
||||
handler = applicationContext.getBean("updateOneToOneDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDeleteMultiple()) {
|
||||
handler = applicationContext.getBean("deleteOneToManyDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDeleteOneToOne()) {
|
||||
handler = applicationContext.getBean("deleteOneToOneDatatableEntryCommandHandler", NewCommandSourceHandler.class);
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
}
|
||||
else if (wrapper.isClientNoteResource()) {
|
||||
} else if (wrapper.isClientNoteResource()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = applicationContext.getBean("createClientNoteCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdate()) {
|
||||
@@ -132,7 +133,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
} else if (wrapper.isClientResource() && !wrapper.isNotesSubResource() && !wrapper.isIdentifiersSubResource()) {
|
||||
} else if (wrapper.isClientResource() && !wrapper.isClientNoteResource() && !wrapper.isClientIdentifierResource()) {
|
||||
if (wrapper.isCreate()) {
|
||||
handler = applicationContext.getBean("createClientCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdate()) {
|
||||
@@ -226,7 +227,6 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
} else if (wrapper.isLoanResource()) {
|
||||
|
||||
if (wrapper.isApproveLoanApplication()) {
|
||||
handler = applicationContext.getBean("loanApplicationApprovalCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUndoApprovalOfLoanApplication()) {
|
||||
@@ -251,14 +251,6 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
handler = applicationContext.getBean("closeLoanCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isCloseLoanAsRescheduled()) {
|
||||
handler = applicationContext.getBean("closeLoanAsRescheduledCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isAddLoanCharge()) {
|
||||
handler = applicationContext.getBean("addLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDeleteLoanCharge()) {
|
||||
handler = applicationContext.getBean("deleteLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateLoanCharge()) {
|
||||
handler = applicationContext.getBean("updateLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isWaiveLoanCharge()) {
|
||||
handler = applicationContext.getBean("waiveLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateLoanOfficer()) {
|
||||
handler = applicationContext.getBean("updateLoanOfficerCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isBulkUpdateLoanOfficer()) {
|
||||
@@ -272,6 +264,16 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
} else if (wrapper.isLoanChargeResource()) {
|
||||
if (wrapper.isAddLoanCharge()) {
|
||||
handler = applicationContext.getBean("addLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isDeleteLoanCharge()) {
|
||||
handler = applicationContext.getBean("deleteLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isUpdateLoanCharge()) {
|
||||
handler = applicationContext.getBean("updateLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
} else if (wrapper.isWaiveLoanCharge()) {
|
||||
handler = applicationContext.getBean("waiveLoanChargeCommandHandler", NewCommandSourceHandler.class);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedCommandException(wrapper.commandName());
|
||||
}
|
||||
|
||||
+15
-7
@@ -17,11 +17,13 @@ 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.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -75,9 +77,11 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createCode(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "CODE", "CREATE", "codes", null,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createCode().withUrl("/codes").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@@ -99,9 +103,11 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateCode(@PathParam("codeId") final Long codeId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CODE", "UPDATE", "codes",
|
||||
codeId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCode().withUrl("/codes").withEntityId(codeId).withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@@ -111,9 +117,11 @@ public class CodesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteCode(@PathParam("codeId") final Long codeId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "CODE", "DELETE", "codes",
|
||||
codeId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCode().withUrl("/codes").withEntityId(codeId).withJson("{}")
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@ package org.mifosplatform.infrastructure.codes.handler;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -20,7 +20,7 @@ public class CreateCodeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.createCode(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ package org.mifosplatform.infrastructure.codes.handler;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -20,8 +20,8 @@ public class DeleteCodeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.deleteCode(command.resourceId());
|
||||
return this.writePlatformService.deleteCode(command.entityId());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -3,7 +3,7 @@ package org.mifosplatform.infrastructure.codes.handler;
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -20,8 +20,8 @@ public class UpdateCodeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.updateCode(command.resourceId(), command);
|
||||
return this.writePlatformService.updateCode(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package org.mifosplatform.infrastructure.codes.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface CodeWritePlatformService {
|
||||
|
||||
EntityIdentifier createCode(JsonCommand command);
|
||||
CommandProcessingResult createCode(JsonCommand command);
|
||||
|
||||
EntityIdentifier updateCode(Long codeId, JsonCommand command);
|
||||
CommandProcessingResult updateCode(Long codeId, JsonCommand command);
|
||||
|
||||
EntityIdentifier deleteCode(Long codeId);
|
||||
CommandProcessingResult deleteCode(Long codeId);
|
||||
}
|
||||
+9
-8
@@ -9,7 +9,8 @@ import org.mifosplatform.infrastructure.codes.exception.CodeNotFoundException;
|
||||
import org.mifosplatform.infrastructure.codes.exception.SystemDefinedCodeCannotBeChangedException;
|
||||
import org.mifosplatform.infrastructure.codes.serialization.CodeCommandFromApiJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
@@ -38,7 +39,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createCode(final JsonCommand command) {
|
||||
public CommandProcessingResult createCode(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -49,15 +50,15 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
final Code code = Code.fromJson(command);
|
||||
this.codeRepository.save(code);
|
||||
|
||||
return EntityIdentifier.resourceResult(code.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(code.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateCode(final Long codeId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateCode(final Long codeId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -71,7 +72,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
this.codeRepository.save(code);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(codeId, changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(codeId).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleCodeDataIntegrityIssues(command, dve);
|
||||
return null;
|
||||
@@ -80,7 +81,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteCode(final Long codeId) {
|
||||
public CommandProcessingResult deleteCode(final Long codeId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -89,7 +90,7 @@ public class CodeWritePlatformServiceJpaRepositoryImpl implements CodeWritePlatf
|
||||
|
||||
this.codeRepository.delete(code);
|
||||
|
||||
return new EntityIdentifier(code.getId());
|
||||
return new CommandProcessingResultBuilder().withEntityId(codeId).build();
|
||||
}
|
||||
|
||||
private Code retrieveCodeBy(final Long codeId) {
|
||||
|
||||
+49
-22
@@ -29,52 +29,79 @@ public final class JsonCommand {
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
private final Long commandId;
|
||||
private final Long resourceId;
|
||||
private final Long subResourceId;
|
||||
private final String entityName;
|
||||
private final Long groupId;
|
||||
private final Long clientId;
|
||||
private final Long loanId;
|
||||
private final String entityName;
|
||||
private final Long apptableId;
|
||||
private final Long datatableId;
|
||||
|
||||
public static JsonCommand from(final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
|
||||
final String entityName, final Long resourceId, final Long subResourceId) {
|
||||
return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, subResourceId);
|
||||
}
|
||||
|
||||
public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
|
||||
final Long resourceId, final Long subResourceId) {
|
||||
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, null, resourceId, subResourceId);
|
||||
final String entityName, final Long resourceId, final Long groupId, final Long clientId, final Long loanId,
|
||||
final Long apptableId, final Long datatableId) {
|
||||
return new JsonCommand(null, jsonCommand, parsedCommand, fromApiJsonHelper, entityName, resourceId, groupId, clientId, loanId,
|
||||
apptableId, datatableId);
|
||||
}
|
||||
|
||||
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand, final FromJsonHelper fromApiJsonHelper,
|
||||
final String entityName, final Long resourceId, final Long subResourceId) {
|
||||
public static JsonCommand fromExistingCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
|
||||
final FromJsonHelper fromApiJsonHelper, final Long resourceId) {
|
||||
return new JsonCommand(commandId, jsonCommand, parsedCommand, fromApiJsonHelper, null, resourceId, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public JsonCommand(final Long commandId, final String jsonCommand, final JsonElement parsedCommand,
|
||||
final FromJsonHelper fromApiJsonHelper, final String entityName, final Long resourceId, final Long groupId,
|
||||
final Long clientId, final Long loanId, final Long apptableId, final Long datatableId) {
|
||||
this.commandId = commandId;
|
||||
this.jsonCommand = jsonCommand;
|
||||
this.parsedCommand = parsedCommand;
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
this.entityName = entityName;
|
||||
this.entityName = entityName;
|
||||
this.resourceId = resourceId;
|
||||
this.subResourceId = subResourceId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.apptableId = apptableId;
|
||||
this.datatableId = datatableId;
|
||||
}
|
||||
|
||||
public String json() {
|
||||
return this.jsonCommand;
|
||||
}
|
||||
|
||||
|
||||
public JsonElement parsedJson() {
|
||||
return this.parsedCommand;
|
||||
}
|
||||
|
||||
|
||||
public Long commandId() {
|
||||
return this.commandId;
|
||||
}
|
||||
|
||||
|
||||
public String entityName() {
|
||||
return this.entityName;
|
||||
return this.entityName;
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
|
||||
public Long entityId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long subResourceId() {
|
||||
return this.subResourceId;
|
||||
|
||||
public Long getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public Long getApptableId() {
|
||||
return this.apptableId;
|
||||
}
|
||||
|
||||
public Long getDatatableId() {
|
||||
return this.datatableId;
|
||||
}
|
||||
|
||||
private boolean differenceExists(final LocalDate baseValue, final LocalDate workingCopyValue) {
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the successful result of an REST API call that results in
|
||||
* processing a command.
|
||||
*/
|
||||
public class CommandProcessingResult {
|
||||
|
||||
private Long commandId;
|
||||
private Long officeId;
|
||||
private final Long groupId;
|
||||
private final Long clientId;
|
||||
private final Long loanId;
|
||||
private Long resourceId;
|
||||
private Map<String, Object> changes;
|
||||
|
||||
public static CommandProcessingResult fromDetails(final Long commandId, final Long officeId, final Long groupId, final Long clientId,
|
||||
final Long loanId, final Long entityId, final Map<String, Object> changes) {
|
||||
return new CommandProcessingResult(commandId, officeId, groupId, clientId, loanId, entityId, changes);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult commandOnlyResult(final Long commandId) {
|
||||
return new CommandProcessingResult(null, null, commandId, null);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult resourceResult(final Long resourceId, final Long commandId) {
|
||||
return new CommandProcessingResult(resourceId, null, commandId, null);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult resourceResult(final Long resourceId, final Long commandId, final Map<String, Object> changes) {
|
||||
return new CommandProcessingResult(resourceId, null, commandId, changes);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult subResourceResult(final Long resourceId, final Long subResourceId, final Long commandId) {
|
||||
return new CommandProcessingResult(resourceId, subResourceId, commandId, null);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult subResourceResult(final Long resourceId, final Long subResourceId, final Long commandId,
|
||||
final Map<String, Object> changes) {
|
||||
return new CommandProcessingResult(resourceId, subResourceId, commandId, changes);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult withChanges(final Long resourceId, final Map<String, Object> changes) {
|
||||
return new CommandProcessingResult(resourceId, null, null, changes);
|
||||
}
|
||||
|
||||
public static CommandProcessingResult empty() {
|
||||
return new CommandProcessingResult(Long.valueOf(-1), Long.valueOf(-1), Long.valueOf(-1), null);
|
||||
}
|
||||
|
||||
public CommandProcessingResult(final Long entityId) {
|
||||
this.resourceId = entityId;
|
||||
this.officeId = null;
|
||||
this.groupId = null;
|
||||
this.clientId = null;
|
||||
this.loanId = null;
|
||||
this.changes = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
private CommandProcessingResult(final Long commandId, final Long officeId, final Long groupId, final Long clientId, final Long loanId,
|
||||
final Long resourceId, final Map<String, Object> changesOnly) {
|
||||
this.commandId = commandId;
|
||||
this.officeId = officeId;
|
||||
this.groupId = groupId;
|
||||
this.clientId = clientId;
|
||||
this.loanId = loanId;
|
||||
this.resourceId = resourceId;
|
||||
this.changes = changesOnly;
|
||||
}
|
||||
|
||||
private CommandProcessingResult(final Long resourceId, final Long officeId, final Long commandId, final Map<String, Object> changesOnly) {
|
||||
this.resourceId = resourceId;
|
||||
this.officeId = officeId;
|
||||
this.groupId = null;
|
||||
this.clientId = null;
|
||||
this.loanId = null;
|
||||
this.commandId = commandId;
|
||||
this.changes = changesOnly;
|
||||
}
|
||||
|
||||
public Long commandId() {
|
||||
return this.commandId;
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(Long officeId) {
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return this.clientId;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public Map<String, Object> getChanges() {
|
||||
Map<String, Object> checkIfEmpty = null;
|
||||
if (this.changes != null && !this.changes.isEmpty()) {
|
||||
checkIfEmpty = this.changes;
|
||||
}
|
||||
return checkIfEmpty;
|
||||
}
|
||||
|
||||
public boolean hasChanges() {
|
||||
final boolean noChanges = this.changes == null || this.changes.isEmpty();
|
||||
return !noChanges;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the successful result of an REST API call that results in
|
||||
* processing a command.
|
||||
*/
|
||||
public class CommandProcessingResultBuilder {
|
||||
|
||||
private Long commandId;
|
||||
private Long officeId;
|
||||
private Long groupId;
|
||||
private Long clientId;
|
||||
private Long loanId;
|
||||
private Long entityId;
|
||||
private Map<String, Object> changes;
|
||||
|
||||
public CommandProcessingResult build() {
|
||||
return CommandProcessingResult.fromDetails(commandId, officeId, groupId, clientId, loanId, entityId, changes);
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
|
||||
this.commandId = withCommandId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder with(final Map<String, Object> withChanges) {
|
||||
this.changes = withChanges;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withEntityId(final Long withEntityId) {
|
||||
this.entityId = withEntityId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withOfficeId(final Long withOfficeId) {
|
||||
this.officeId = withOfficeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withClientId(final Long withClientId) {
|
||||
this.clientId = withClientId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withGroupId(final Long withGroupId) {
|
||||
this.groupId = withGroupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandProcessingResultBuilder withLoanId(final Long withLoanId) {
|
||||
this.loanId = withLoanId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents the successful result of an REST API call.
|
||||
*
|
||||
* FIXME - KW - Rename to CommandProcessingResult - make immutable
|
||||
*/
|
||||
public class EntityIdentifier {
|
||||
|
||||
private Long commandId;
|
||||
private Long resourceId;
|
||||
private Long subResourceId;
|
||||
|
||||
private Map<String, Object> changes;
|
||||
|
||||
public static EntityIdentifier commandOnlyResult(final Long commandId) {
|
||||
return new EntityIdentifier(null, null, commandId, null);
|
||||
}
|
||||
|
||||
public static EntityIdentifier resourceResult(final Long resourceId, final Long commandId) {
|
||||
return new EntityIdentifier(resourceId, null, commandId, null);
|
||||
}
|
||||
|
||||
public static EntityIdentifier resourceResult(final Long resourceId, final Long commandId, final Map<String, Object> changes) {
|
||||
return new EntityIdentifier(resourceId, null, commandId, changes);
|
||||
}
|
||||
|
||||
public static EntityIdentifier subResourceResult(final Long resourceId, final Long subResourceId, final Long commandId) {
|
||||
return new EntityIdentifier(resourceId, subResourceId, commandId, null);
|
||||
}
|
||||
|
||||
public static EntityIdentifier subResourceResult(final Long resourceId, final Long subResourceId, final Long commandId, final Map<String, Object> changes) {
|
||||
return new EntityIdentifier(resourceId, subResourceId, commandId, changes);
|
||||
}
|
||||
|
||||
public static EntityIdentifier withChanges(final Long resourceId, final Map<String, Object> changes) {
|
||||
return new EntityIdentifier(resourceId, null, null, changes);
|
||||
}
|
||||
|
||||
public static EntityIdentifier empty() {
|
||||
return new EntityIdentifier(Long.valueOf(-1), Long.valueOf(-1), Long.valueOf(-1), null);
|
||||
}
|
||||
|
||||
protected EntityIdentifier() {
|
||||
//
|
||||
}
|
||||
|
||||
public EntityIdentifier(final Long entityId) {
|
||||
this.resourceId = entityId;
|
||||
this.changes = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
private EntityIdentifier(final Long resourceId, final Long subResourceId, final Long commandId, final Map<String, Object> changesOnly) {
|
||||
this.resourceId = resourceId;
|
||||
this.subResourceId = subResourceId;
|
||||
this.commandId = commandId;
|
||||
this.changes = changesOnly;
|
||||
}
|
||||
|
||||
public Long commandId() {
|
||||
return this.commandId;
|
||||
}
|
||||
|
||||
public Long resourceId() {
|
||||
return this.resourceId;
|
||||
}
|
||||
|
||||
public Long subResourceId() {
|
||||
return this.subResourceId;
|
||||
}
|
||||
|
||||
public Map<String, Object> getChanges() {
|
||||
Map<String, Object> checkIfEmpty = null;
|
||||
if (this.changes != null && !this.changes.isEmpty()) {
|
||||
checkIfEmpty = this.changes;
|
||||
}
|
||||
return checkIfEmpty;
|
||||
}
|
||||
|
||||
public boolean hasChanges() {
|
||||
final boolean noChanges = this.changes == null || this.changes.isEmpty();
|
||||
return !noChanges;
|
||||
}
|
||||
}
|
||||
+30
-18
@@ -15,9 +15,11 @@ 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.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
@@ -70,7 +72,7 @@ public class DataTableApiResource {
|
||||
|
||||
this.readWriteNonCoreDataService.registerDatatable(datatable, apptable);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(EntityIdentifier.empty());
|
||||
return this.toApiJsonSerializer.serialize(CommandProcessingResult.empty());
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -81,7 +83,7 @@ public class DataTableApiResource {
|
||||
|
||||
this.readWriteNonCoreDataService.deregisterDatatable(datatable);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(EntityIdentifier.empty());
|
||||
return this.toApiJsonSerializer.serialize(CommandProcessingResult.empty());
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -139,10 +141,12 @@ public class DataTableApiResource {
|
||||
public String newDatatableEntry(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.commandsSourceWritePlatformService.logCommandSource("CREATE", datatable, "CREATE",
|
||||
"datatables/" + datatable, apptableId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createDatatable(datatable, apptableId, null)
|
||||
.withUrl("/datatables/" + datatable).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -152,10 +156,12 @@ public class DataTableApiResource {
|
||||
public String updateDatatableEntryOnetoOne(@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", datatable, "UPDATE",
|
||||
"datatables/" + datatable, apptableId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, null)
|
||||
.withUrl("/datatables/" + datatable).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -166,10 +172,12 @@ public class DataTableApiResource {
|
||||
@PathParam("apptableId") final Long apptableId, @PathParam("datatableId") final Long datatableId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", datatable,
|
||||
"UPDATE_MULTIPLE", "datatables/" + datatable, apptableId, "datatables/" + datatable, datatableId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateDatatable(datatable, apptableId, datatableId)
|
||||
.withUrl("/datatables/" + datatable + "/" + apptableId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -178,10 +186,12 @@ public class DataTableApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId) {
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.commandsSourceWritePlatformService.logCommandSource("DELETE", datatable, "DELETE",
|
||||
"datatables/" + datatable, apptableId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, null)
|
||||
.withUrl("/datatables/" + datatable).withJson("{}").build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -191,9 +201,11 @@ public class DataTableApiResource {
|
||||
public String deleteDatatableEntries(@PathParam("datatable") final String datatable, @PathParam("apptableId") final Long apptableId,
|
||||
@PathParam("datatableId") final Long datatableId) {
|
||||
|
||||
final EntityIdentifier entityIdentifier = this.commandsSourceWritePlatformService.logCommandSource("DELETE", datatable,
|
||||
"DELETE_MULTIPLE", "datatables/" + datatable, apptableId, "datatables/" + datatable, datatableId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteDatatable(datatable, apptableId, datatableId)
|
||||
.withUrl("/datatables/" + datatable + "/" + apptableId).withJson("{}").build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+16
-17
@@ -2,32 +2,31 @@ package org.mifosplatform.infrastructure.dataqueries.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class CreateDatatableEntryCommandHandler implements
|
||||
NewCommandSourceHandler {
|
||||
public class CreateDatatableEntryCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public CreateDatatableEntryCommandHandler(
|
||||
final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
@Autowired
|
||||
public CreateDatatableEntryCommandHandler(final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
this.writePlatformService.newDatatableEntry(command.entityName(),
|
||||
command.resourceId(), command);
|
||||
this.writePlatformService.newDatatableEntry(command.entityName(), command.getApptableId(), command);
|
||||
|
||||
return EntityIdentifier.resourceResult(command.resourceId(),
|
||||
command.commandId());
|
||||
}
|
||||
// FIXME - kw - need to find office and either group/client/loan that
|
||||
// this datatable is against.
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getApptableId()).build();
|
||||
}
|
||||
}
|
||||
+14
-16
@@ -2,31 +2,29 @@ package org.mifosplatform.infrastructure.dataqueries.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class DeleteOneToManyDatatableEntryCommandHandler implements
|
||||
NewCommandSourceHandler {
|
||||
public class DeleteOneToManyDatatableEntryCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public DeleteOneToManyDatatableEntryCommandHandler(
|
||||
final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
@Autowired
|
||||
public DeleteOneToManyDatatableEntryCommandHandler(final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
this.writePlatformService.deleteDatatableEntry(command.entityName(), command.resourceId(), command.subResourceId());
|
||||
this.writePlatformService.deleteDatatableEntry(command.entityName(), command.getApptableId(), command.getDatatableId());
|
||||
|
||||
return EntityIdentifier.subResourceResult(command.resourceId(), command.subResourceId(),
|
||||
command.commandId());
|
||||
}
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getDatatableId()).build();
|
||||
}
|
||||
}
|
||||
+14
-16
@@ -2,31 +2,29 @@ package org.mifosplatform.infrastructure.dataqueries.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class DeleteOneToOneDatatableEntryCommandHandler implements
|
||||
NewCommandSourceHandler {
|
||||
public class DeleteOneToOneDatatableEntryCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public DeleteOneToOneDatatableEntryCommandHandler(
|
||||
final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
@Autowired
|
||||
public DeleteOneToOneDatatableEntryCommandHandler(final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
this.writePlatformService.deleteDatatableEntries(command.entityName(), command.resourceId());
|
||||
this.writePlatformService.deleteDatatableEntries(command.entityName(), command.getApptableId());
|
||||
|
||||
return EntityIdentifier.resourceResult(command.resourceId(),
|
||||
command.commandId());
|
||||
}
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getApptableId()).build();
|
||||
}
|
||||
}
|
||||
+15
-16
@@ -4,31 +4,30 @@ import java.util.Map;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class UpdateOneToManyDatatableEntryCommandHandler implements
|
||||
NewCommandSourceHandler {
|
||||
public class UpdateOneToManyDatatableEntryCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
private final ReadWriteNonCoreDataService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
public UpdateOneToManyDatatableEntryCommandHandler(
|
||||
final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
@Autowired
|
||||
public UpdateOneToManyDatatableEntryCommandHandler(final ReadWriteNonCoreDataService writePlatformService) {
|
||||
this.writePlatformService = writePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(), command.resourceId(), command.subResourceId(), command);
|
||||
final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(),
|
||||
command.getApptableId(), command.getDatatableId(), command);
|
||||
|
||||
return EntityIdentifier.subResourceResult(command.resourceId(), command.subResourceId(),
|
||||
command.commandId(), changes);
|
||||
}
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getDatatableId()).with(changes).build();
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -4,7 +4,8 @@ import java.util.Map;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,10 +23,12 @@ public class UpdateOneToOneDatatableEntryCommandHandler implements NewCommandSou
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToOne(command.entityName(), command.resourceId(), command);
|
||||
final Map<String, Object> changes = this.writePlatformService.updateDatatableEntryOneToOne(command.entityName(), command.getApptableId(),
|
||||
command);
|
||||
|
||||
return EntityIdentifier.resourceResult(command.resourceId(), command.commandId(), changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(command.getApptableId()).with(changes)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+603
-827
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -24,7 +24,7 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.ApiConstants;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
@@ -106,7 +106,7 @@ public class DocumentManagementApiResource {
|
||||
|
||||
Long documentId = this.documentWritePlatformService.createDocument(documentCommand, inputStream);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(EntityIdentifier.resourceResult(documentId, null));
|
||||
return this.toApiJsonSerializer.serialize(CommandProcessingResult.resourceResult(documentId, null));
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -141,7 +141,7 @@ public class DocumentManagementApiResource {
|
||||
documentCommand = new DocumentCommand(modifiedParams, documentId, entityType, entityId, name, null, null, null, description,
|
||||
null);
|
||||
}
|
||||
EntityIdentifier identifier = this.documentWritePlatformService.updateDocument(documentCommand, inputStream);
|
||||
CommandProcessingResult identifier = this.documentWritePlatformService.updateDocument(documentCommand, inputStream);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(identifier);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class DocumentManagementApiResource {
|
||||
final DocumentCommand documentCommand = new DocumentCommand(null, documentId, entityType, entityId, null, null, null, null, null,
|
||||
null);
|
||||
|
||||
final EntityIdentifier documentIdentifier = this.documentWritePlatformService.deleteDocument(documentCommand);
|
||||
final CommandProcessingResult documentIdentifier = this.documentWritePlatformService.deleteDocument(documentCommand);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(documentIdentifier);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.infrastructure.documentmanagement.service;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.command.DocumentCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@@ -12,9 +12,9 @@ public interface DocumentWritePlatformService {
|
||||
Long createDocument(DocumentCommand documentCommand, InputStream inputStream);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_m_guarantor_external')")
|
||||
EntityIdentifier updateDocument(DocumentCommand documentCommand, InputStream inputStream);
|
||||
CommandProcessingResult updateDocument(DocumentCommand documentCommand, InputStream inputStream);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_m_guarantor_external')")
|
||||
EntityIdentifier deleteDocument(DocumentCommand documentCommand);
|
||||
CommandProcessingResult deleteDocument(DocumentCommand documentCommand);
|
||||
|
||||
}
|
||||
+5
-5
@@ -4,7 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.command.DocumentCommand;
|
||||
@@ -77,7 +77,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateDocument(final DocumentCommand documentCommand, final InputStream inputStream) {
|
||||
public CommandProcessingResult updateDocument(final DocumentCommand documentCommand, final InputStream inputStream) {
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
|
||||
|
||||
this.documentRepository.saveAndFlush(documentForUpdate);
|
||||
|
||||
return new EntityIdentifier(documentForUpdate.getId());
|
||||
return new CommandProcessingResult(documentForUpdate.getId());
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.document.unknown.data.integrity.issue",
|
||||
@@ -127,7 +127,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteDocument(final DocumentCommand documentCommand) {
|
||||
public CommandProcessingResult deleteDocument(final DocumentCommand documentCommand) {
|
||||
context.authenticatedUser();
|
||||
|
||||
validateParentEntityType(documentCommand);
|
||||
@@ -138,7 +138,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
|
||||
|
||||
this.documentRepository.delete(document);
|
||||
deleteFile(document.getName(), document.getLocation());
|
||||
return new EntityIdentifier(document.getId());
|
||||
return new CommandProcessingResult(document.getId());
|
||||
}
|
||||
|
||||
private void deleteFile(String documentName, String location) {
|
||||
|
||||
+7
-3
@@ -13,9 +13,11 @@ 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.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -70,9 +72,11 @@ public class CurrenciesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateCurrencies(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CURRENCY", "UPDATE", "currencies",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCurrencies().withUrl("/currencies").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.monetary.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class UpdateCurrencyCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.updateAllowedCurrencies(command);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package org.mifosplatform.organisation.monetary.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface CurrencyWritePlatformService {
|
||||
|
||||
EntityIdentifier updateAllowedCurrencies(JsonCommand command);
|
||||
CommandProcessingResult updateAllowedCurrencies(JsonCommand command);
|
||||
|
||||
}
|
||||
+4
-3
@@ -8,7 +8,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.command.CurrencyCommand;
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||
@@ -42,7 +43,7 @@ public class CurrencyWritePlatformServiceJpaRepositoryImpl implements CurrencyWr
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateAllowedCurrencies(final JsonCommand command) {
|
||||
public CommandProcessingResult updateAllowedCurrencies(final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -69,6 +70,6 @@ public class CurrencyWritePlatformServiceJpaRepositoryImpl implements CurrencyWr
|
||||
this.organisationCurrencyRepository.deleteAll();
|
||||
this.organisationCurrencyRepository.save(allowedCurrencies);
|
||||
|
||||
return EntityIdentifier.withChanges(null, changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).with(changes).build();
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -14,9 +14,11 @@ 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.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -86,9 +88,10 @@ public class OfficeTransactionsApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String transferMoneyFrom(final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createOfficeTransaction().withUrl("/officetransactions").withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "OFFICETRANSACTION", "CREATE",
|
||||
"officetransactions", null, apiRequestBodyAsJson);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+11
-5
@@ -18,10 +18,12 @@ 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.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -97,8 +99,10 @@ public class OfficesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createOffice(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "OFFICE", "CREATE", "offices",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createOffice().withUrl("/offices").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -128,8 +132,10 @@ public class OfficesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateOffice(@PathParam("officeId") final Long officeId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "OFFICE", "UPDATE", "offices",
|
||||
officeId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateOffice().withUrl("/offices").withEntityId(officeId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.office.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.office.service.OfficeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateOfficeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.createOffice(command);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.office.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.office.service.OfficeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateOfficeTransactionCommandHandler implements NewCommandSourceHa
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.externalBranchMoneyTransfer(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.office.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.office.service.OfficeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateOfficeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.updateOffice(command.resourceId(), command);
|
||||
return this.writePlatformService.updateOffice(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package org.mifosplatform.organisation.office.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface OfficeWritePlatformService {
|
||||
|
||||
EntityIdentifier createOffice(JsonCommand command);
|
||||
CommandProcessingResult createOffice(JsonCommand command);
|
||||
|
||||
EntityIdentifier updateOffice(Long officeId, JsonCommand command);
|
||||
CommandProcessingResult updateOffice(Long officeId, JsonCommand command);
|
||||
|
||||
EntityIdentifier externalBranchMoneyTransfer(JsonCommand command);
|
||||
CommandProcessingResult externalBranchMoneyTransfer(JsonCommand command);
|
||||
}
|
||||
+16
-9
@@ -3,7 +3,8 @@ package org.mifosplatform.organisation.office.service;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.exception.NoAuthorizationException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -57,7 +58,7 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createOffice(final JsonCommand command) {
|
||||
public CommandProcessingResult createOffice(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
@@ -76,16 +77,17 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
|
||||
this.officeRepository.save(office);
|
||||
|
||||
return EntityIdentifier.resourceResult(office.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(office.getId())
|
||||
.withOfficeId(office.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleOfficeDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateOffice(final Long officeId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateOffice(final Long officeId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
final AppUser currentUser = context.authenticatedUser();
|
||||
@@ -106,16 +108,17 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
this.officeRepository.saveAndFlush(office);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(office.getId(), changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(office.getId())
|
||||
.withOfficeId(office.getId()).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleOfficeDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier externalBranchMoneyTransfer(final JsonCommand command) {
|
||||
public CommandProcessingResult externalBranchMoneyTransfer(final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -123,13 +126,16 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
.json());
|
||||
moneyTransferCommand.validateBranchTransfer();
|
||||
|
||||
Long officeId = null;
|
||||
Office fromOffice = null;
|
||||
if (moneyTransferCommand.getFromOfficeId() != null) {
|
||||
fromOffice = this.officeRepository.findOne(moneyTransferCommand.getFromOfficeId());
|
||||
officeId = fromOffice.getId();
|
||||
}
|
||||
Office toOffice = null;
|
||||
if (moneyTransferCommand.getToOfficeId() != null) {
|
||||
toOffice = this.officeRepository.findOne(moneyTransferCommand.getToOfficeId());
|
||||
officeId = toOffice.getId();
|
||||
}
|
||||
|
||||
if (fromOffice == null && toOffice == null) { throw new OfficeNotFoundException(moneyTransferCommand.getToOfficeId()); }
|
||||
@@ -145,7 +151,8 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
|
||||
this.officeMonetaryTransferRepository.save(entity);
|
||||
|
||||
return EntityIdentifier.resourceResult(entity.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(entity.getId()).withOfficeId(officeId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+11
-5
@@ -18,9 +18,11 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -85,9 +87,11 @@ public class StaffApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createStaff(final String apiRequestBodyAsJson) {
|
||||
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createStaff().withUrl("/staff").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "STAFF", "CREATE", "staff",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -117,9 +121,11 @@ public class StaffApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateStaff(@PathParam("staffId") final Long staffId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "STAFF", "UPDATE", "staff",
|
||||
staffId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateStaff().withUrl("/staff").withEntityId(staffId).withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,4 +134,8 @@ public class Staff extends AbstractAuditableCustom<AppUser, Long> {
|
||||
public boolean identifiedBy(final Staff staff) {
|
||||
return getId().equals(staff.getId());
|
||||
}
|
||||
|
||||
public Long officeId() {
|
||||
return this.office.getId();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.staff.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.staff.service.StaffWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateStaffCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.createStaff(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.staff.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.organisation.staff.service.StaffWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateStaffCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.updateStaff(command.resourceId(), command);
|
||||
return this.writePlatformService.updateStaff(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.mifosplatform.organisation.staff.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface StaffWritePlatformService {
|
||||
|
||||
EntityIdentifier createStaff(final JsonCommand command);
|
||||
CommandProcessingResult createStaff(final JsonCommand command);
|
||||
|
||||
EntityIdentifier updateStaff(final Long staffId, final JsonCommand command);
|
||||
CommandProcessingResult updateStaff(final Long staffId, final JsonCommand command);
|
||||
}
|
||||
+11
-8
@@ -4,7 +4,8 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
@@ -44,7 +45,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createStaff(final JsonCommand command) {
|
||||
public CommandProcessingResult createStaff(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -61,16 +62,17 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
|
||||
|
||||
this.staffRepository.save(staff);
|
||||
|
||||
return EntityIdentifier.resourceResult(staff.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(staff.getId())
|
||||
.withOfficeId(officeId).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleStaffDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateStaff(final Long staffId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateStaff(final Long staffId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -78,7 +80,7 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
|
||||
final StaffCommand staffCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
staffCommand.validateForUpdate();
|
||||
|
||||
Staff staffForUpdate = this.staffRepository.findOne(staffId);
|
||||
final Staff staffForUpdate = this.staffRepository.findOne(staffId);
|
||||
if (staffForUpdate == null) { throw new StaffNotFoundException(staffId); }
|
||||
|
||||
final Map<String, Object> changesOnly = staffForUpdate.update(command);
|
||||
@@ -95,10 +97,11 @@ public class StaffWritePlatformServiceJpaRepositoryImpl implements StaffWritePla
|
||||
this.staffRepository.save(staffForUpdate);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(staffForUpdate.getId(), changesOnly);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(staffId)
|
||||
.withOfficeId(staffForUpdate.officeId()).with(changesOnly).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleStaffDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-7
@@ -17,9 +17,11 @@ 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.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -108,8 +110,10 @@ public class ChargesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createCharge(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "CHARGE", "CREATE", "charges",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createCharge().withUrl("/charges").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -120,8 +124,10 @@ public class ChargesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateCharge(@PathParam("chargeId") final Long chargeId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CHARGE", "UPDATE", "charges",
|
||||
chargeId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCharge().withUrl("/charges").withEntityId(chargeId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -132,8 +138,10 @@ public class ChargesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteCharge(@PathParam("chargeId") final Long chargeId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "CHARGE", "DELETE", "charges",
|
||||
chargeId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCharge().withUrl("/charges").withEntityId(chargeId)
|
||||
.withJson("{}").build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.charge.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.charge.service.ChargeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateChargeDefinitionCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.createCharge(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.charge.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.charge.service.ChargeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class DeleteChargeDefinitionCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.deleteCharge(command.resourceId());
|
||||
return this.clientWritePlatformService.deleteCharge(command.entityId());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.charge.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.charge.service.ChargeWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateChargeDefinitionCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.updateCharge(command.resourceId(), command);
|
||||
return this.clientWritePlatformService.updateCharge(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package org.mifosplatform.portfolio.charge.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface ChargeWritePlatformService {
|
||||
|
||||
EntityIdentifier createCharge(JsonCommand command);
|
||||
CommandProcessingResult createCharge(JsonCommand command);
|
||||
|
||||
EntityIdentifier updateCharge(Long chargeId, JsonCommand command);
|
||||
CommandProcessingResult updateCharge(Long chargeId, JsonCommand command);
|
||||
|
||||
EntityIdentifier deleteCharge(Long chargeId);
|
||||
CommandProcessingResult deleteCharge(Long chargeId);
|
||||
}
|
||||
|
||||
+20
-19
@@ -3,7 +3,8 @@ package org.mifosplatform.portfolio.charge.service;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.charge.command.ChargeDefinitionCommand;
|
||||
@@ -28,9 +29,8 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP
|
||||
private final ChargeRepository chargeRepository;
|
||||
|
||||
@Autowired
|
||||
public ChargeWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
final ChargeDefinitionCommandFromApiJsonDeserializer fromApiJsonDeserializer,
|
||||
final ChargeRepository chargeRepository) {
|
||||
public ChargeWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
final ChargeDefinitionCommandFromApiJsonDeserializer fromApiJsonDeserializer, final ChargeRepository chargeRepository) {
|
||||
this.context = context;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
this.chargeRepository = chargeRepository;
|
||||
@@ -38,63 +38,63 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createCharge(final JsonCommand command) {
|
||||
public CommandProcessingResult createCharge(final JsonCommand command) {
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
|
||||
final ChargeDefinitionCommand chargeDefinitionCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
chargeDefinitionCommand.validateForCreate();
|
||||
|
||||
final Charge charge = Charge.fromJson(command);
|
||||
this.chargeRepository.save(charge);
|
||||
|
||||
return EntityIdentifier.resourceResult(charge.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(charge.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateCharge(final Long chargeId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateCharge(final Long chargeId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
|
||||
final ChargeDefinitionCommand chargeDefinitionCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
chargeDefinitionCommand.validateForUpdate();
|
||||
|
||||
final Charge chargeForUpdate = this.chargeRepository.findOne(chargeId);
|
||||
if (chargeForUpdate == null) { throw new ChargeNotFoundException(chargeId); }
|
||||
|
||||
|
||||
final Map<String, Object> changes = chargeForUpdate.update(command);
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
this.chargeRepository.save(chargeForUpdate);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(chargeForUpdate.getId(), changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(chargeId).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteCharge(final Long chargeId) {
|
||||
public CommandProcessingResult deleteCharge(final Long chargeId) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final Charge chargeForDelete = this.chargeRepository.findOne(chargeId);
|
||||
if (chargeForDelete == null || chargeForDelete.isDeleted()) { throw new ChargeNotFoundException(chargeId); }
|
||||
|
||||
|
||||
chargeForDelete.delete();
|
||||
|
||||
chargeRepository.save(chargeForDelete);
|
||||
|
||||
return EntityIdentifier.resourceResult(chargeForDelete.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withEntityId(chargeForDelete.getId()).build();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -104,10 +104,11 @@ public class ChargeWritePlatformServiceJpaRepositoryImpl implements ChargeWriteP
|
||||
private void handleDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||
|
||||
Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("name")) {
|
||||
if (realCause.getMessage().contains("name")) {
|
||||
final String name = command.stringValueOfParameterNamed("name");
|
||||
throw new PlatformDataIntegrityException("error.msg.charge.duplicate.name",
|
||||
"Charge with name `" + name +"` already exists", "name", name); }
|
||||
throw new PlatformDataIntegrityException("error.msg.charge.duplicate.name", "Charge with name `" + name + "` already exists",
|
||||
"name", name);
|
||||
}
|
||||
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.charge.unknown.data.integrity.issue",
|
||||
|
||||
+17
-7
@@ -17,11 +17,13 @@ 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.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -98,8 +100,10 @@ public class ClientIdentifiersApiResource {
|
||||
public String createClientIdentifier(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) {
|
||||
|
||||
try {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "CLIENTIDENTIFIER", "CREATE",
|
||||
"clients", clientId, "identifiers", null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientIdentifier().withClientId(clientId)
|
||||
.withUrl("/clients/" + clientId + "/identifiers").withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
} catch (DuplicateClientIdentifierException e) {
|
||||
@@ -143,8 +147,11 @@ public class ClientIdentifiersApiResource {
|
||||
@PathParam("identifierId") final Long clientIdentifierId, final String apiRequestBodyAsJson) {
|
||||
|
||||
try {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CLIENTIDENTIFIER", "UPDATE",
|
||||
"clients", clientId, "identifiers", clientIdentifierId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientIdentifier()
|
||||
.withUrl("/clients/" + clientId + "/identifiers").withClientId(clientId).withEntityId(clientIdentifierId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
} catch (DuplicateClientIdentifierException e) {
|
||||
@@ -166,8 +173,11 @@ public class ClientIdentifiersApiResource {
|
||||
public String deleteClientIdentifier(@PathParam("clientId") final Long clientId,
|
||||
@PathParam("identifierId") final Long clientIdentifierId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "CLIENTIDENTIFIER", "DELETE",
|
||||
"clients", clientId, "identifiers", clientIdentifierId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClientIdentifier()
|
||||
.withUrl("/clients/" + clientId + "/identifiers").withClientId(clientId).withEntityId(clientIdentifierId).withJson("{}")
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.ApiConstants;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
@@ -69,7 +69,7 @@ public class ClientImagesApiResource {
|
||||
FileUtils.validateImageMimeType(bodyPart.getMediaType().toString());
|
||||
FileUtils.validateFileSizeWithinPermissibleRange(fileSize, fileDetails.getFileName(), ApiConstants.MAX_FILE_UPLOAD_SIZE_IN_MB);
|
||||
|
||||
final EntityIdentifier result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, fileDetails.getFileName(),
|
||||
final CommandProcessingResult result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, fileDetails.getFileName(),
|
||||
inputStream);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
@@ -85,7 +85,7 @@ public class ClientImagesApiResource {
|
||||
|
||||
final Base64EncodedImage base64EncodedImage = FileUtils.extractImageFromDataURL(jsonRequestBody);
|
||||
|
||||
final EntityIdentifier result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, base64EncodedImage);
|
||||
final CommandProcessingResult result = this.clientWritePlatformService.saveOrUpdateClientImage(clientId, base64EncodedImage);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class ClientImagesApiResource {
|
||||
public String deleteClientImage(@PathParam("clientId") final Long clientId) {
|
||||
this.clientWritePlatformService.deleteClientImage(clientId);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(new EntityIdentifier(clientId));
|
||||
return this.toApiJsonSerializer.serialize(new CommandProcessingResult(clientId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-5
@@ -16,9 +16,11 @@ 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.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -71,8 +73,10 @@ public class ClientNotesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String addNewClientNote(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "CLIENTNOTE", "CREATE",
|
||||
"clients", clientId, "notes", null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientNote().withUrl("/clients/" + clientId + "/notes")
|
||||
.withClientId(clientId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -99,8 +103,10 @@ public class ClientNotesApiResource {
|
||||
public String updateClientNote(@PathParam("clientId") final Long clientId, @PathParam("noteId") final Long noteId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CLIENTNOTE", "UPDATE",
|
||||
"clients", clientId, "notes", noteId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientNote().withUrl("/clients/" + clientId + "/notes")
|
||||
.withClientId(clientId).withEntityId(noteId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+19
-9
@@ -22,12 +22,14 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.commands.data.CommandSourceData;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -89,7 +91,8 @@ public class ClientsApiResource {
|
||||
// FIXME - kw - rather than exposing SQL through the api can we not just
|
||||
// pass parameter we want to search by and build up sql like is done for
|
||||
// other parameters?
|
||||
final String extraCriteria = buildSqlStringFromClientCriteria(sqlSearch, officeId, externalId, displayName, firstName, lastName, hierarchy);
|
||||
final String extraCriteria = buildSqlStringFromClientCriteria(sqlSearch, officeId, externalId, displayName, firstName, lastName,
|
||||
hierarchy);
|
||||
|
||||
final Collection<ClientData> clients = this.clientReadPlatformService.retrieveAllIndividualClients(extraCriteria);
|
||||
|
||||
@@ -150,7 +153,8 @@ public class ClientsApiResource {
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService.retrieveIndividualClient(clientId);
|
||||
if (settings.isTemplate()) {
|
||||
// FIXME - KW - no need for special OfficeLookup object, just use OfficeData and only populate with id, name, nameDecorated
|
||||
// FIXME - KW - no need for special OfficeLookup object, just use
|
||||
// OfficeData and only populate with id, name, nameDecorated
|
||||
final List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(officeReadPlatformService.retrieveAllOfficesForLookup());
|
||||
clientData = ClientData.templateOnTop(clientData, allowedOffices);
|
||||
}
|
||||
@@ -216,8 +220,10 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createClient(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "CLIENT", "CREATE", "clients",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createClient().withUrl("/clients").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -228,8 +234,10 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateClient(@PathParam("clientId") final Long clientId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "CLIENT", "UPDATE", "clients",
|
||||
clientId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClient().withUrl("/clients").withEntityId(clientId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -240,8 +248,10 @@ public class ClientsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteClient(@PathParam("clientId") final Long clientId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "CLIENT", "DELETE", "clients",
|
||||
clientId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClient().withUrl("/clients").withEntityId(clientId)
|
||||
.withJson("{}").build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_client")
|
||||
public class Client extends AbstractPersistable<Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "account_no", length=40, unique=true, nullable=false)
|
||||
private String accountNumber;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class Client extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
private Client(final Office office, final String firstName, final String lastName, final LocalDate openingDate, final String externalId) {
|
||||
this.accountNumber = new RandomPasswordGenerator(25).generate();
|
||||
this.accountNumber = new RandomPasswordGenerator(19).generate();
|
||||
this.office = office;
|
||||
if (StringUtils.isNotBlank(externalId)) {
|
||||
this.externalId = externalId.trim();
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.createClient(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class CreateClientIdentifierCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.addClientIdentifier(command.resourceId(), command);
|
||||
return this.clientWritePlatformService.addClientIdentifier(command.getClientId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class CreateClientNoteCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.addClientNote(command.resourceId(), command);
|
||||
return this.clientWritePlatformService.addClientNote(command.getClientId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class DeleteClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.deleteClient(command.resourceId());
|
||||
return this.clientWritePlatformService.deleteClient(command.entityId());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class DeleteClientIdentifierCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.deleteClientIdentifier(command.resourceId(), command.subResourceId(), command.commandId());
|
||||
return this.clientWritePlatformService.deleteClientIdentifier(command.getClientId(), command.entityId(), command.commandId());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateClientCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.updateClient(command.resourceId(), command);
|
||||
return this.clientWritePlatformService.updateClient(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateClientIdentifierCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.updateClientIdentifier(command.resourceId(), command.subResourceId(), command);
|
||||
return this.clientWritePlatformService.updateClientIdentifier(command.getClientId(), command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.client.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.client.service.ClientWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateClientNoteCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.clientWritePlatformService.updateClientNote(command.resourceId(), command.subResourceId(), command);
|
||||
return this.clientWritePlatformService.updateClientNote(command.getClientId(), command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -3,34 +3,34 @@ package org.mifosplatform.portfolio.client.service;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ClientWritePlatformService {
|
||||
|
||||
EntityIdentifier createClient(JsonCommand command);
|
||||
CommandProcessingResult createClient(JsonCommand command);
|
||||
|
||||
EntityIdentifier updateClient(Long clientId, JsonCommand command);
|
||||
CommandProcessingResult updateClient(Long clientId, JsonCommand command);
|
||||
|
||||
EntityIdentifier deleteClient(Long clientId);
|
||||
CommandProcessingResult deleteClient(Long clientId);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
||||
EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream);
|
||||
CommandProcessingResult saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
||||
EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage);
|
||||
CommandProcessingResult saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')")
|
||||
EntityIdentifier deleteClientImage(Long clientId);
|
||||
CommandProcessingResult deleteClientImage(Long clientId);
|
||||
|
||||
EntityIdentifier addClientNote(Long clientId, JsonCommand command);
|
||||
CommandProcessingResult addClientNote(Long clientId, JsonCommand command);
|
||||
|
||||
EntityIdentifier updateClientNote(Long clientId, Long noteId, JsonCommand command);
|
||||
CommandProcessingResult updateClientNote(Long clientId, Long noteId, JsonCommand command);
|
||||
|
||||
EntityIdentifier addClientIdentifier(Long clientId, JsonCommand command);
|
||||
CommandProcessingResult addClientIdentifier(Long clientId, JsonCommand command);
|
||||
|
||||
EntityIdentifier updateClientIdentifier(Long clientId, Long clientIdentifierId, JsonCommand command);
|
||||
CommandProcessingResult updateClientIdentifier(Long clientId, Long clientIdentifierId, JsonCommand command);
|
||||
|
||||
EntityIdentifier deleteClientIdentifier(Long clientId, Long clientIdentifierId, Long commandId);
|
||||
CommandProcessingResult deleteClientIdentifier(Long clientId, Long clientIdentifierId, Long commandId);
|
||||
}
|
||||
+46
-30
@@ -10,7 +10,8 @@ import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValueRepository;
|
||||
import org.mifosplatform.infrastructure.codes.exception.CodeValueNotFoundException;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.domain.Base64EncodedImage;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.service.FileUtils;
|
||||
@@ -79,15 +80,17 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteClient(final Long clientId) {
|
||||
public CommandProcessingResult deleteClient(final Long clientId) {
|
||||
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
|
||||
|
||||
final Long officeId = client.getOffice().getId();
|
||||
|
||||
client.delete();
|
||||
this.clientRepository.save(client);
|
||||
|
||||
return EntityIdentifier.resourceResult(clientId, null);
|
||||
return new CommandProcessingResultBuilder().withOfficeId(officeId).withClientId(clientId).withEntityId(clientId).build();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -111,7 +114,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createClient(final JsonCommand command) {
|
||||
public CommandProcessingResult createClient(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -127,22 +130,24 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
final Client newClient = Client.fromJson(clientOffice, command);
|
||||
this.clientRepository.save(newClient);
|
||||
|
||||
// now use client account identifier generator to generate proper account number
|
||||
|
||||
// now use client account identifier generator to generate proper
|
||||
// account number
|
||||
AccountIdentifierGenerator generator = new ClientAccountIdentifierGenerator(newClient.getId(), 9);
|
||||
newClient.updateAccountIdentifier(generator.generate());
|
||||
this.clientRepository.save(newClient);
|
||||
|
||||
return EntityIdentifier.resourceResult(newClient.getId(), null);
|
||||
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(clientOffice.getId())
|
||||
.withClientId(newClient.getId()).withEntityId(newClient.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateClient(final Long clientId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateClient(final Long clientId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -167,22 +172,23 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
this.clientRepository.save(clientForUpdate);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(clientId, changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId())
|
||||
.withOfficeId(clientForUpdate.getOffice().getId()).withClientId(clientId).withEntityId(clientId).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return new EntityIdentifier(Long.valueOf(-1));
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier addClientNote(final Long clientId, final JsonCommand command) {
|
||||
public CommandProcessingResult addClientNote(final Long clientId, final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
final ClientNoteCommand clientNoteCommand = this.clientNoteFromApiJsonDeserializer.commandFromApiJson(command.json());
|
||||
clientNoteCommand.validate();
|
||||
|
||||
|
||||
final Client clientForUpdate = this.clientRepository.findOne(clientId);
|
||||
if (clientForUpdate == null) { throw new ClientNotFoundException(clientId); }
|
||||
|
||||
@@ -190,12 +196,13 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
this.noteRepository.save(note);
|
||||
|
||||
return EntityIdentifier.subResourceResult(clientId, note.getId(), command.commandId());
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(clientForUpdate.getOffice().getId())
|
||||
.withClientId(clientId).withEntityId(note.getId()).build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateClientNote(final Long clientId, final Long noteId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateClientNote(final Long clientId, final Long noteId, final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -206,18 +213,21 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
if (noteForUpdate == null || noteForUpdate.isNotAgainstClientWithIdOf(clientId)) { throw new NoteNotFoundException(noteId,
|
||||
clientId, "client"); }
|
||||
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
|
||||
final Map<String, Object> changes = noteForUpdate.update(command);
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
this.noteRepository.save(noteForUpdate);
|
||||
}
|
||||
|
||||
return EntityIdentifier.subResourceResult(clientId, noteId, command.commandId(), changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(client.getOffice().getId())
|
||||
.withClientId(clientId).withEntityId(noteId).with(changes).build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier addClientIdentifier(final Long clientId, final JsonCommand command) {
|
||||
public CommandProcessingResult addClientIdentifier(final Long clientId, final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
final ClientIdentifierCommand clientIdentifierCommand = this.clientIdentifierCommandFromApiJsonDeserializer
|
||||
@@ -241,16 +251,17 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
this.clientIdentifierRepository.save(clientIdentifier);
|
||||
|
||||
return EntityIdentifier.subResourceResult(clientId, clientIdentifier.getId(), command.commandId());
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(client.getOffice().getId())
|
||||
.withClientId(clientId).withEntityId(clientIdentifier.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateClientIdentifier(final Long clientId, final Long identifierId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateClientIdentifier(final Long clientId, final Long identifierId, final JsonCommand command) {
|
||||
|
||||
context.authenticatedUser();
|
||||
final ClientIdentifierCommand clientIdentifierCommand = this.clientIdentifierCommandFromApiJsonDeserializer
|
||||
@@ -291,10 +302,13 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
if (!changes.isEmpty()) {
|
||||
this.clientIdentifierRepository.saveAndFlush(clientIdentifierForUpdate);
|
||||
}
|
||||
return EntityIdentifier.subResourceResult(clientId, identifierId, command.commandId(), changes);
|
||||
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withOfficeId(client.getOffice().getId())
|
||||
.withClientId(clientId).withEntityId(identifierId).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
||||
return new EntityIdentifier(Long.valueOf(-1));
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,17 +331,19 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteClientIdentifier(final Long clientId, final Long identifierId, final Long commandId) {
|
||||
public CommandProcessingResult deleteClientIdentifier(final Long clientId, final Long identifierId, final Long commandId) {
|
||||
final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(identifierId);
|
||||
if (clientIdentifier == null) { throw new ClientIdentifierNotFoundException(identifierId); }
|
||||
this.clientIdentifierRepository.delete(clientIdentifier);
|
||||
|
||||
return EntityIdentifier.subResourceResult(clientId, identifierId, commandId);
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
return new CommandProcessingResultBuilder().withCommandId(commandId).withOfficeId(client.getOffice().getId())
|
||||
.withClientId(clientId).withEntityId(identifierId).build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream) {
|
||||
public CommandProcessingResult saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream) {
|
||||
try {
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
String imageUploadLocation = setupForClientImageUpdate(clientId, client);
|
||||
@@ -343,7 +359,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteClientImage(final Long clientId) {
|
||||
public CommandProcessingResult deleteClientImage(final Long clientId) {
|
||||
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
|
||||
@@ -356,7 +372,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
|
||||
public CommandProcessingResult saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
|
||||
try {
|
||||
final Client client = this.clientRepository.findOne(clientId);
|
||||
final String imageUploadLocation = setupForClientImageUpdate(clientId, client);
|
||||
@@ -386,10 +402,10 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
return imageUploadLocation;
|
||||
}
|
||||
|
||||
private EntityIdentifier updateClientImage(final Long clientId, final Client client, final String imageLocation) {
|
||||
private CommandProcessingResult updateClientImage(final Long clientId, final Client client, final String imageLocation) {
|
||||
client.setImageKey(imageLocation);
|
||||
this.clientRepository.save(client);
|
||||
|
||||
return new EntityIdentifier(clientId);
|
||||
return new CommandProcessingResult(clientId);
|
||||
}
|
||||
}
|
||||
+11
-5
@@ -16,10 +16,12 @@ 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.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -76,8 +78,10 @@ public class FundsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String createFund(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "FUND", "CREATE", "funds", null,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createFund().withUrl("/funds").withJson(apiRequestBodyAsJson)
|
||||
.build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -102,8 +106,10 @@ public class FundsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String updateFund(@PathParam("fundId") final Long fundId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "FUND", "UPDATE", "funds",
|
||||
fundId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFund().withUrl("/funds").withEntityId(fundId)
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.fund.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.fund.service.FundWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class CreateFundCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.createFund(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.fund.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.fund.service.FundWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class UpdateFundCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.updateFund(command.resourceId(), command);
|
||||
return this.writePlatformService.updateFund(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.mifosplatform.portfolio.fund.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
|
||||
public interface FundWritePlatformService {
|
||||
|
||||
EntityIdentifier createFund(JsonCommand command);
|
||||
CommandProcessingResult createFund(JsonCommand command);
|
||||
|
||||
EntityIdentifier updateFund(Long fundId, JsonCommand command);
|
||||
CommandProcessingResult updateFund(Long fundId, JsonCommand command);
|
||||
}
|
||||
+8
-7
@@ -3,7 +3,8 @@ package org.mifosplatform.portfolio.fund.service;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
@@ -38,7 +39,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createFund(final JsonCommand command) {
|
||||
public CommandProcessingResult createFund(final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -50,16 +51,16 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf
|
||||
|
||||
this.fundRepository.save(fund);
|
||||
|
||||
return EntityIdentifier.resourceResult(fund.getId(), null);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(fund.getId()).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleFundDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateFund(final Long fundId, final JsonCommand command) {
|
||||
public CommandProcessingResult updateFund(final Long fundId, final JsonCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -75,10 +76,10 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf
|
||||
this.fundRepository.saveAndFlush(fund);
|
||||
}
|
||||
|
||||
return EntityIdentifier.withChanges(fund.getId(), changes);
|
||||
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(fund.getId()).with(changes).build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleFundDataIntegrityIssues(command, dve);
|
||||
return EntityIdentifier.empty();
|
||||
return CommandProcessingResult.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -156,7 +156,7 @@ public class GroupsApiResource {
|
||||
|
||||
final GroupCommand command = this.apiDataConversionService.convertJsonToGroupCommand(null, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.createGroup(command);
|
||||
CommandProcessingResult entityIdentifier = this.groupWritePlatformService.createGroup(command);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class GroupsApiResource {
|
||||
|
||||
final GroupCommand command = this.apiDataConversionService.convertJsonToGroupCommand(groupId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.updateGroup(command);
|
||||
CommandProcessingResult entityIdentifier = this.groupWritePlatformService.updateGroup(command);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class GroupsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteGroup(@PathParam("groupId") final Long groupId) {
|
||||
|
||||
EntityIdentifier entityIdentifier = this.groupWritePlatformService.deleteGroup(groupId);
|
||||
CommandProcessingResult entityIdentifier = this.groupWritePlatformService.deleteGroup(groupId);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(entityIdentifier);
|
||||
}
|
||||
|
||||
+16
-17
@@ -23,7 +23,7 @@ import org.mifosplatform.useradministration.domain.AppUser;
|
||||
public class Group extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "office_id", nullable = false)
|
||||
private Office office;
|
||||
|
||||
@@ -33,13 +33,11 @@ public class Group extends AbstractAuditableCustom<AppUser, Long> {
|
||||
@Column(name = "external_id", length = 100, unique = true)
|
||||
private String externalId;
|
||||
|
||||
@Column(name = "is_deleted", nullable=false)
|
||||
@Column(name = "is_deleted", nullable = false)
|
||||
private boolean deleted = false;
|
||||
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name = "m_group_client",
|
||||
joinColumns = @JoinColumn(name = "group_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "client_id"))
|
||||
@JoinTable(name = "m_group_client", joinColumns = @JoinColumn(name = "group_id"), inverseJoinColumns = @JoinColumn(name = "client_id"))
|
||||
private Set<Client> clientMembers;
|
||||
|
||||
public Group() {
|
||||
@@ -48,10 +46,10 @@ public class Group extends AbstractAuditableCustom<AppUser, Long> {
|
||||
this.clientMembers = new HashSet<Client>();
|
||||
}
|
||||
|
||||
public static Group newGroup(Office office, String name, String externalId, Set<Client> clientMembers){
|
||||
public static Group newGroup(Office office, String name, String externalId, Set<Client> clientMembers) {
|
||||
return new Group(office, name, externalId, clientMembers);
|
||||
}
|
||||
|
||||
|
||||
public Group(Office office, String name, String externalId, Set<Client> clientMembers) {
|
||||
this.office = office;
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
@@ -64,11 +62,11 @@ public class Group extends AbstractAuditableCustom<AppUser, Long> {
|
||||
} else {
|
||||
this.externalId = null;
|
||||
}
|
||||
if (clientMembers != null){
|
||||
if (clientMembers != null) {
|
||||
this.clientMembers = clientMembers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void update(final GroupCommand command, final Office groupOffice, final Set<Client> clientMembers) {
|
||||
if (command.isExternalIdChanged()) {
|
||||
this.externalId = command.getExternalId();
|
||||
@@ -81,22 +79,23 @@ public class Group extends AbstractAuditableCustom<AppUser, Long> {
|
||||
if (command.isNameChanged()) {
|
||||
this.name = command.getName();
|
||||
}
|
||||
|
||||
if (clientMembers != null && command.isClientMembersChanged()){
|
||||
|
||||
if (clientMembers != null && command.isClientMembersChanged()) {
|
||||
this.clientMembers = clientMembers;
|
||||
}
|
||||
}
|
||||
|
||||
public void addClientMember(final Client member){
|
||||
|
||||
public void addClientMember(final Client member) {
|
||||
this.clientMembers.add(member);
|
||||
}
|
||||
|
||||
public boolean hasClientAsMember(final Client client){
|
||||
public boolean hasClientAsMember(final Client client) {
|
||||
return this.clientMembers.contains(client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete is a <i>soft delete</i>. Updates flag on group so it wont appear in query/report results.
|
||||
* Delete is a <i>soft delete</i>. Updates flag on group so it wont appear
|
||||
* in query/report results.
|
||||
*
|
||||
* Any fields with unique constraints and prepended with id of record.
|
||||
*/
|
||||
|
||||
+4
-4
@@ -1,18 +1,18 @@
|
||||
package org.mifosplatform.portfolio.group.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.group.command.GroupCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface GroupWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_GROUP')")
|
||||
EntityIdentifier createGroup(GroupCommand command);
|
||||
CommandProcessingResult createGroup(GroupCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_GROUP')")
|
||||
EntityIdentifier updateGroup(GroupCommand command);
|
||||
CommandProcessingResult updateGroup(GroupCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_GROUP')")
|
||||
EntityIdentifier deleteGroup(Long groupId);
|
||||
CommandProcessingResult deleteGroup(Long groupId);
|
||||
|
||||
}
|
||||
|
||||
+9
-9
@@ -3,7 +3,7 @@ package org.mifosplatform.portfolio.group.service;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
@@ -50,7 +50,7 @@ public class GroupWritePlatformServiceJpaRepositoryImpl implements GroupWritePla
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier createGroup(GroupCommand command) {
|
||||
public CommandProcessingResult createGroup(GroupCommand command) {
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
@@ -68,16 +68,16 @@ public class GroupWritePlatformServiceJpaRepositoryImpl implements GroupWritePla
|
||||
|
||||
this.groupRepository.saveAndFlush(newGroup);
|
||||
|
||||
return new EntityIdentifier(newGroup.getId());
|
||||
return new CommandProcessingResult(newGroup.getId());
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleGroupDataIntegrityIssues(command, dve);
|
||||
return new EntityIdentifier(Long.valueOf(-1));
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier updateGroup(GroupCommand command) {
|
||||
public CommandProcessingResult updateGroup(GroupCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
@@ -105,16 +105,16 @@ public class GroupWritePlatformServiceJpaRepositoryImpl implements GroupWritePla
|
||||
|
||||
groupRepository.saveAndFlush(groupForUpdate);
|
||||
|
||||
return new EntityIdentifier(groupForUpdate.getId());
|
||||
return new CommandProcessingResult(groupForUpdate.getId());
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleGroupDataIntegrityIssues(command, dve);
|
||||
return new EntityIdentifier(Long.valueOf(-1));
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier deleteGroup(Long groupId) {
|
||||
public CommandProcessingResult deleteGroup(Long groupId) {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
@@ -125,7 +125,7 @@ public class GroupWritePlatformServiceJpaRepositoryImpl implements GroupWritePla
|
||||
groupForDelete.delete();
|
||||
this.groupRepository.save(groupForDelete);
|
||||
|
||||
return new EntityIdentifier(groupId);
|
||||
return new CommandProcessingResult(groupId);
|
||||
}
|
||||
|
||||
private Set<Client> assembleSetOfClients(final GroupCommand command) {
|
||||
|
||||
+7
-3
@@ -16,9 +16,11 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
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;
|
||||
@@ -97,8 +99,10 @@ public class BulkLoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String loanReassignment(final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("BULKREASSIGN", "LOAN", "N/A", "loans",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficersInBulk().withUrl("/loans/loanreassignment")
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+19
-9
@@ -19,9 +19,11 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
@@ -102,8 +104,10 @@ public class LoanChargesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String addLoanCharge(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "LOANCHARGE", "N/A", "loans",
|
||||
loanId, "charges", null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanCharge().withUrl("/loans/" + loanId + "/charges")
|
||||
.withLoanId(loanId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -115,8 +119,10 @@ public class LoanChargesApiResource {
|
||||
public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("loanChargeId") final Long loanChargeId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "LOANCHARGE", "N/A", "loans",
|
||||
loanId, "charges", loanChargeId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge().withUrl("/loans/" + loanId + "/charges")
|
||||
.withLoanId(loanId).withEntityId(loanChargeId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -130,8 +136,10 @@ public class LoanChargesApiResource {
|
||||
|
||||
String json = "";
|
||||
if (is(commandParam, "waive")) {
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("WAIVE", "LOANCHARGE", "N/A", "loans",
|
||||
loanId, "charges", loanChargeId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().waiveLoanCharge().withUrl("/loans/" + loanId + "/charges")
|
||||
.withLoanId(loanId).withEntityId(loanChargeId).withJson("{}").build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
json = this.toApiJsonSerializer.serialize(result);
|
||||
} else {
|
||||
@@ -147,8 +155,10 @@ public class LoanChargesApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "LOANCHARGE", "N/A", "loans",
|
||||
loanId, "charges", loanChargeId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanCharge().withUrl("/loans/" + loanId + "/charges")
|
||||
.withLoanId(loanId).withEntityId(loanChargeId).withJson("{}").build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+24
-15
@@ -16,9 +16,11 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||
@@ -115,22 +117,25 @@ public class LoanTransactionsApiResource {
|
||||
public String executeLoanTransaction(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
EntityIdentifier result = null;
|
||||
CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans/" + loanId + "/transactions").withLoanId(loanId)
|
||||
.withJson(apiRequestBodyAsJson);
|
||||
|
||||
CommandProcessingResult result = null;
|
||||
if (is(commandParam, "repayment")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("REPAYMENT", "LOAN", "N/A", "loans", loanId, "transactions",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.loanRepaymentTransaction().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "waiveinterest")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("WAIVEINTERESTPORTION", "LOAN", "N/A", "loans", loanId,
|
||||
"transactions", null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.waiveInterestPortionTransaction().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "writeoff")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("WRITEOFF", "LOAN", "N/A", "loans", loanId, "transactions",
|
||||
null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.writeOffLoanTransaction().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "close-rescheduled")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("CLOSEASRESCHEDULED", "LOAN", "N/A", "loans", loanId,
|
||||
"transactions", null, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.closeLoanAsRescheduledTransaction().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "close")) {
|
||||
result = this.commandsSourceWritePlatformService
|
||||
.logCommandSource("CLOSE", "LOAN", "N/A", "loans", loanId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.closeLoanTransaction().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam); }
|
||||
@@ -145,9 +150,13 @@ public class LoanTransactionsApiResource {
|
||||
public String adjustLoanTransaction(@PathParam("loanId") final Long loanId, @PathParam("transactionId") final Long transactionId,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("ADJUST", "LOAN", "N/A", "loans", loanId,
|
||||
"transactions", transactionId, apiRequestBodyAsJson);
|
||||
|
||||
CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans/" + loanId + "/transactions").withLoanId(loanId).withEntityId(transactionId)
|
||||
.withJson(apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.adjustTransaction().build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
}
|
||||
+35
-22
@@ -20,11 +20,13 @@ import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiRequestParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonQuery;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
@@ -331,8 +333,10 @@ public class LoansApiResource {
|
||||
return this.loanScheduleToApiJsonSerializer.serialize(settings, loanSchedule, new HashSet<String>());
|
||||
}
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("CREATE", "LOAN", "CREATE", "loans", null,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanApplication().withUrl("/loans")
|
||||
.withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -343,8 +347,10 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String modifyLoanApplication(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATE", "LOAN", "UPDATE", "loans",
|
||||
loanId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanApplication().withUrl("/loans").withLoanId(loanId)
|
||||
.withEntityId(loanId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -355,8 +361,10 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String deleteLoanApplication(@PathParam("loanId") final Long loanId) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("DELETE", "LOAN", "DELETE", "loans",
|
||||
loanId, "{}");
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanApplication().withUrl("/loans").withLoanId(loanId)
|
||||
.withEntityId(loanId).withJson("{}").build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
@@ -368,28 +376,31 @@ public class LoansApiResource {
|
||||
public String stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
||||
final String apiRequestBodyAsJson) {
|
||||
|
||||
EntityIdentifier result = null;
|
||||
final CommandWrapperBuilder builder = new CommandWrapperBuilder().withUrl("/loans").withLoanId(loanId).withEntityId(loanId)
|
||||
.withJson(apiRequestBodyAsJson);
|
||||
|
||||
CommandProcessingResult result = null;
|
||||
|
||||
if (is(commandParam, "reject")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("REJECT", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.rejectLoanApplication().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "withdrewbyclient")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("WITHDRAW", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.withdrawLoanApplication().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "approve")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("APPROVE", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.approveLoanApplication().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "disburse")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("DISBURSE", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.disburseLoanApplication().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
if (is(commandParam, "undoapproval")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("APPROVALUNDO", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.undoLoanApplicationApproval().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "undodisbursal")) {
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource("DISBURSALUNDO", "LOAN", "N/A", "loans", loanId,
|
||||
apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = builder.undoLoanApplicationDisbursal().build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
}
|
||||
|
||||
if (result == null) { throw new UnrecognizedQueryParamException("command", commandParam); }
|
||||
@@ -429,8 +440,10 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String assignLoanOfficer(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) {
|
||||
|
||||
final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("UPDATELOANOFFICER", "LOAN", "N/A",
|
||||
"loans", loanId, apiRequestBodyAsJson);
|
||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().assignLoanOfficer().withUrl("/loans").withLoanId(loanId)
|
||||
.withEntityId(loanId).withJson(apiRequestBodyAsJson).build();
|
||||
|
||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
+42
-14
@@ -75,7 +75,6 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
@JoinColumn(name = "guarantor_id")
|
||||
private Client guarantor;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "group_id")
|
||||
private Group group;
|
||||
@@ -212,7 +211,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
final Set<LoanCharge> loanCharges) {
|
||||
final LoanStatus status = null;
|
||||
LoanProductRelatedDetail loanRepaymentScheduleDetail = loanSchedule.loanProductRelatedDetail();
|
||||
return new Loan(client, null, fund, officer, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, status, loanCharges);
|
||||
return new Loan(client, null, fund, officer, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, status,
|
||||
loanCharges);
|
||||
}
|
||||
|
||||
public static Loan newGroupLoanApplication(final Group group, final LoanProduct loanProduct, final Fund fund, final Staff officer,
|
||||
@@ -220,12 +220,13 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
final Set<LoanCharge> loanCharges) {
|
||||
final LoanStatus status = null;
|
||||
LoanProductRelatedDetail loanRepaymentScheduleDetail = loanSchedule.loanProductRelatedDetail();
|
||||
return new Loan(null, group, fund, officer, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, status, loanCharges);
|
||||
return new Loan(null, group, fund, officer, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, status,
|
||||
loanCharges);
|
||||
}
|
||||
|
||||
public static Loan newIndividualLoanApplicationFromGroup(final Client client, final Group group, final LoanProduct loanProduct, final Fund fund,
|
||||
final Staff officer, final LoanTransactionProcessingStrategy transactionProcessingStrategy, final LoanSchedule loanSchedule,
|
||||
final Set<LoanCharge> loanCharges) {
|
||||
public static Loan newIndividualLoanApplicationFromGroup(final Client client, final Group group, final LoanProduct loanProduct,
|
||||
final Fund fund, final Staff officer, final LoanTransactionProcessingStrategy transactionProcessingStrategy,
|
||||
final LoanSchedule loanSchedule, final Set<LoanCharge> loanCharges) {
|
||||
final LoanStatus status = null;
|
||||
LoanProductRelatedDetail loanRepaymentScheduleDetail = loanSchedule.loanProductRelatedDetail();
|
||||
return new Loan(client, group, fund, officer, transactionProcessingStrategy, loanProduct, loanRepaymentScheduleDetail, status,
|
||||
@@ -236,9 +237,9 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
//
|
||||
}
|
||||
|
||||
private Loan(final Client client, final Group group, Fund fund, Staff loanOfficer, final LoanTransactionProcessingStrategy transactionProcessingStrategy,
|
||||
final LoanProduct loanProduct, final LoanProductRelatedDetail loanRepaymentScheduleDetail, final LoanStatus loanStatus,
|
||||
final Set<LoanCharge> loanCharges) {
|
||||
private Loan(final Client client, final Group group, Fund fund, Staff loanOfficer,
|
||||
final LoanTransactionProcessingStrategy transactionProcessingStrategy, final LoanProduct loanProduct,
|
||||
final LoanProductRelatedDetail loanRepaymentScheduleDetail, final LoanStatus loanStatus, final Set<LoanCharge> loanCharges) {
|
||||
this.client = client;
|
||||
this.group = group;
|
||||
this.fund = fund;
|
||||
@@ -436,12 +437,13 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
public LoanTransaction waiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine loanLifecycleStateMachine, final Map<String, Object> changes) {
|
||||
public LoanTransaction waiveLoanCharge(final LoanCharge loanCharge, final LoanLifecycleStateMachine loanLifecycleStateMachine,
|
||||
final Map<String, Object> changes) {
|
||||
|
||||
validateLoanIsNotClosed(loanCharge);
|
||||
|
||||
final Money amountWaived = loanCharge.waive(loanCurrency());
|
||||
|
||||
|
||||
changes.put("amount", amountWaived.getAmount());
|
||||
|
||||
Money feeChargesWaived = Money.of(loanCurrency(), loanCharge.amount());
|
||||
@@ -665,7 +667,7 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
Arrays.sort(newLoanChargeData);
|
||||
return !Arrays.equals(existingLoanChargeData, newLoanChargeData);
|
||||
}
|
||||
|
||||
|
||||
private Set<LoanCharge> getNullPointerSafeLoanCharges() {
|
||||
Set<LoanCharge> loanCharges = this.charges;
|
||||
if (this.charges == null) {
|
||||
@@ -968,8 +970,8 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
final LoanSchedule loanSchedule = new LoanSchedule(loanScheduleGenerator, applicationCurrency, principal, interestRatePerPeriod,
|
||||
interestRatePeriodFrequencyType, defaultAnnualNominalInterestRate, interestMethod, interestCalculationPeriodMethod,
|
||||
repaymentEvery, repaymentPeriodFrequencyType, numberOfRepayments, amortizationMethod, loanTermFrequency,
|
||||
loanTermPeriodFrequencyType, getNullPointerSafeLoanCharges(), this.getDisbursementDate(), this.getExpectedFirstRepaymentOnDate(),
|
||||
this.getInterestChargedFromDate(), inArrearsTolerance);
|
||||
loanTermPeriodFrequencyType, getNullPointerSafeLoanCharges(), this.getDisbursementDate(),
|
||||
this.getExpectedFirstRepaymentOnDate(), this.getInterestChargedFromDate(), inArrearsTolerance);
|
||||
|
||||
final LoanScheduleData generatedData = loanSchedule.generate();
|
||||
|
||||
@@ -1922,4 +1924,30 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
Long clientId = null;
|
||||
if (this.client != null) {
|
||||
clientId = this.client.getId();
|
||||
}
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public Long getGroupId() {
|
||||
Long groupId = null;
|
||||
if (this.group != null) {
|
||||
groupId = this.group.getId();
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
Long officeId = null;
|
||||
if (this.client != null) {
|
||||
officeId = this.client.getOffice().getId();
|
||||
} else {
|
||||
// officeId = this.group.getOffice().getId();
|
||||
}
|
||||
return officeId;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -20,7 +20,7 @@ import javax.ws.rs.core.UriInfo;
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService;
|
||||
import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.command.GuarantorCommand;
|
||||
import org.mifosplatform.portfolio.loanaccount.gaurantor.data.GuarantorData;
|
||||
@@ -82,7 +82,7 @@ public class GuarantorsApiResource {
|
||||
this.guarantorWritePlatformService.createGuarantor(loanId, command);
|
||||
|
||||
// returns the loan Identifier for which the guarantor was associated
|
||||
return Response.ok().entity(new EntityIdentifier(loanId)).build();
|
||||
return Response.ok().entity(new CommandProcessingResult(loanId)).build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -93,7 +93,7 @@ public class GuarantorsApiResource {
|
||||
|
||||
this.guarantorWritePlatformService.updateGuarantor(loanId, command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(loanId)).build();
|
||||
return Response.ok().entity(new CommandProcessingResult(loanId)).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@@ -101,6 +101,6 @@ public class GuarantorsApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteGuarantor(@PathParam("loanId") final Long loanId) {
|
||||
this.guarantorWritePlatformService.removeGuarantor(loanId);
|
||||
return Response.ok(new EntityIdentifier(loanId)).build();
|
||||
return Response.ok(new CommandProcessingResult(loanId)).build();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class AddLoanChargeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.addLoanCharge(command.resourceId(), command);
|
||||
return this.writePlatformService.addLoanCharge(command.getLoanId(), command);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,7 +20,7 @@ public class BulkUpdateLoanOfficerCommandHandler implements NewCommandSourceHand
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.bulkLoanReassignment(command);
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class CloseLoanAsRescheduledCommandHandler implements NewCommandSourceHan
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.closeAsRescheduled(command.resourceId(), command);
|
||||
return this.writePlatformService.closeAsRescheduled(command.getLoanId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class CloseLoanCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.closeLoan(command.resourceId(), command);
|
||||
return this.writePlatformService.closeLoan(command.getLoanId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class DeleteLoanChargeCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.deleteLoanCharge(command.resourceId(), command.subResourceId(), command);
|
||||
return this.writePlatformService.deleteLoanCharge(command.getLoanId(), command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class DisburseLoanCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.disburseLoan(command.resourceId(), command);
|
||||
return this.writePlatformService.disburseLoan(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanApplicationWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class LoanApplicationApprovalCommandHandler implements NewCommandSourceHa
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.approveLoanApplication(command.resourceId(), command);
|
||||
return this.writePlatformService.approveLoanApplication(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanApplicationWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class LoanApplicationApprovalUndoCommandHandler implements NewCommandSour
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.undoLoanApplicationApproval(command.resourceId(), command);
|
||||
return this.writePlatformService.undoLoanApplicationApproval(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanApplicationWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class LoanApplicationDeletionCommandHandler implements NewCommandSourceHa
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.deleteLoanApplication(command.resourceId());
|
||||
return this.writePlatformService.deleteLoanApplication(command.entityId());
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package org.mifosplatform.portfolio.loanaccount.handler;
|
||||
|
||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.EntityIdentifier;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanApplicationWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,8 +20,8 @@ public class LoanApplicationModificationCommandHandler implements NewCommandSour
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EntityIdentifier processCommand(final JsonCommand command) {
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
|
||||
return this.writePlatformService.modifyLoanApplication(command.resourceId(), command);
|
||||
return this.writePlatformService.modifyLoanApplication(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user