MIFOSX-1027 Adding missed subresources

This commit is contained in:
Madhukar
2014-04-10 09:59:51 +05:30
parent 179e1e087f
commit 145318c260
4 changed files with 32 additions and 20 deletions
@@ -61,12 +61,16 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
final Long codeId = command.entityId(); final Long codeId = command.entityId();
final Code code = this.codeRepository.findOne(codeId); final Code code = this.codeRepository.findOne(codeId);
if (code == null) {
throw new CodeNotFoundException(codeId);
}
final CodeValue codeValue = CodeValue.fromJson(code, command); final CodeValue codeValue = CodeValue.fromJson(code, command);
this.codeValueRepository.save(codeValue); this.codeValueRepository.save(codeValue);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(codeValue.getId()) // .withEntityId(code.getId()) //
.withSubEntityId(codeValue.getId())//
.build(); .build();
} catch (final DataIntegrityViolationException dve) { } catch (final DataIntegrityViolationException dve) {
handleCodeValueDataIntegrityIssues(command, dve); handleCodeValueDataIntegrityIssues(command, dve);
@@ -143,7 +147,8 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
} }
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withEntityId(codeValueId) // .withEntityId(codeId) //
.withSubEntityId(codeValueId)//
.build(); .build();
} catch (final DataIntegrityViolationException dve) { } catch (final DataIntegrityViolationException dve) {
logger.error(dve.getMessage(), dve); logger.error(dve.getMessage(), dve);
@@ -21,6 +21,7 @@ public class CommandProcessingResult {
private final Long loanId; private final Long loanId;
private final Long savingsId; private final Long savingsId;
private final Long resourceId; private final Long resourceId;
private final Long subResourceId;
private final String transactionId; private final String transactionId;
private final Map<String, Object> changes; private final Map<String, Object> changes;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@@ -30,9 +31,9 @@ public class CommandProcessingResult {
public static CommandProcessingResult fromDetails(final Long commandId, final Long officeId, final Long groupId, final Long clientId, public static CommandProcessingResult fromDetails(final Long commandId, final Long officeId, final Long groupId, final Long clientId,
final Long loanId, final Long savingsId, final String resourceIdentifier, final Long entityId, final String transactionId, final Long loanId, final Long savingsId, final String resourceIdentifier, final Long entityId, final String transactionId,
final Map<String, Object> changes, final Long productId,final Boolean rollbackTransaction) { final Map<String, Object> changes, final Long productId, final Boolean rollbackTransaction, final Long subResourceId) {
return new CommandProcessingResult(commandId, officeId, groupId, clientId, loanId, savingsId, resourceIdentifier, entityId, return new CommandProcessingResult(commandId, officeId, groupId, clientId, loanId, savingsId, resourceIdentifier, entityId,
transactionId, changes, productId,rollbackTransaction); transactionId, changes, productId, rollbackTransaction, subResourceId);
} }
public static CommandProcessingResult commandOnlyResult(final Long commandId) { public static CommandProcessingResult commandOnlyResult(final Long commandId) {
@@ -82,11 +83,12 @@ public class CommandProcessingResult {
this.transactionId = null; this.transactionId = null;
this.changes = new HashMap<String, Object>(); this.changes = new HashMap<String, Object>();
this.productId = null; this.productId = null;
this.subResourceId = null;
} }
private CommandProcessingResult(final Long commandId, final Long officeId, final Long groupId, final Long clientId, final Long loanId, private CommandProcessingResult(final Long commandId, final Long officeId, final Long groupId, final Long clientId, final Long loanId,
final Long savingsId, final String resourceIdentifier, final Long resourceId, final String transactionId, final Long savingsId, final String resourceIdentifier, final Long resourceId, final String transactionId,
final Map<String, Object> changesOnly, final Long productId, Boolean rollbackTransaction) { final Map<String, Object> changesOnly, final Long productId, Boolean rollbackTransaction, final Long subResourceId) {
this.commandId = commandId; this.commandId = commandId;
this.officeId = officeId; this.officeId = officeId;
this.groupId = groupId; this.groupId = groupId;
@@ -99,6 +101,7 @@ public class CommandProcessingResult {
this.transactionId = transactionId; this.transactionId = transactionId;
this.productId = productId; this.productId = productId;
this.rollbackTransaction = rollbackTransaction; this.rollbackTransaction = rollbackTransaction;
this.subResourceId = subResourceId;
} }
private CommandProcessingResult(final Long resourceId, final Long officeId, final Long commandId, final Map<String, Object> changesOnly) { private CommandProcessingResult(final Long resourceId, final Long officeId, final Long commandId, final Map<String, Object> changesOnly) {
@@ -117,6 +120,7 @@ public class CommandProcessingResult {
this.commandId = commandId; this.commandId = commandId;
this.changes = changesOnly; this.changes = changesOnly;
this.productId = null; this.productId = null;
this.subResourceId = null;
} }
public Long commandId() { public Long commandId() {
@@ -172,13 +176,15 @@ public class CommandProcessingResult {
return this.productId; return this.productId;
} }
public boolean isRollbackTransaction() { public boolean isRollbackTransaction() {
return this.rollbackTransaction!=null && this.rollbackTransaction; return this.rollbackTransaction != null && this.rollbackTransaction;
} }
public void setRollbackTransaction(Boolean rollbackTransaction) { public void setRollbackTransaction(Boolean rollbackTransaction) {
this.rollbackTransaction = rollbackTransaction; this.rollbackTransaction = rollbackTransaction;
} }
public Long getSubResourceId() {
return subResourceId;
}
} }
@@ -21,6 +21,7 @@ public class CommandProcessingResultBuilder {
private Long savingsId; private Long savingsId;
private String resourceIdentifier; private String resourceIdentifier;
private Long entityId; private Long entityId;
private Long subEntityId;
private String transactionId; private String transactionId;
private Map<String, Object> changes; private Map<String, Object> changes;
private Long productId; private Long productId;
@@ -28,7 +29,8 @@ public class CommandProcessingResultBuilder {
public CommandProcessingResult build() { public CommandProcessingResult build() {
return CommandProcessingResult.fromDetails(this.commandId, this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, return CommandProcessingResult.fromDetails(this.commandId, this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId,
this.resourceIdentifier, this.entityId, this.transactionId, this.changes, this.productId,this.rollbackTransaction); this.resourceIdentifier, this.entityId, this.transactionId, this.changes, this.productId, this.rollbackTransaction,
this.subEntityId);
} }
public CommandProcessingResultBuilder withCommandId(final Long withCommandId) { public CommandProcessingResultBuilder withCommandId(final Long withCommandId) {
@@ -51,6 +53,11 @@ public class CommandProcessingResultBuilder {
return this; return this;
} }
public CommandProcessingResultBuilder withSubEntityId(final Long withSubEntityId) {
this.subEntityId = withSubEntityId;
return this;
}
public CommandProcessingResultBuilder withOfficeId(final Long withOfficeId) { public CommandProcessingResultBuilder withOfficeId(final Long withOfficeId) {
this.officeId = withOfficeId; this.officeId = withOfficeId;
return this; return this;
@@ -96,7 +96,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) // .withEntityId(newNote.getId()) //
.withClientId(group.getId()) // .withGroupId(group.getId()) //
.withOfficeId(group.officeId()) // .withOfficeId(group.officeId()) //
.build(); .build();
} }
@@ -116,10 +116,8 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) // .withEntityId(newNote.getId()) //
.withClientId(loan.getClientId()) //
.withOfficeId(loan.getOfficeId()) // .withOfficeId(loan.getOfficeId()) //
.withLoanId(loan.getId()) // .withLoanId(loan.getId()) //
.withGroupId(loan.getGroupId()) //
.build(); .build();
} }
@@ -140,10 +138,8 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) // .withEntityId(newNote.getId()) //
.withClientId(loan.getClientId()).withOfficeId(loan.getOfficeId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId())// Loan .withOfficeId(loan.getOfficeId())//
// can .withLoanId(loan.getId())// Loan can be associated
// be
// associated
.build(); .build();
} }
@@ -295,8 +291,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
} }
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId()) return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId()) .withLoanId(loan.getId()).withOfficeId(loan.getOfficeId()).with(changes).build();
.with(changes).build();
} }
private CommandProcessingResult updateLoanTransactionNote(final JsonCommand command) { private CommandProcessingResult updateLoanTransactionNote(final JsonCommand command) {
@@ -321,8 +316,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
} }
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId()) return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId()) .withLoanId(loan.getId()).withOfficeId(loan.getOfficeId()).with(changes).build();
.with(changes).build();
} }
// private CommandProcessingResult updateSavingAccountNote(final JsonCommand // private CommandProcessingResult updateSavingAccountNote(final JsonCommand