Merge pull request #848 from lingalamadhukar/MIFOSX-1049

MIFOSX-1027 Adding missed subresources
This commit is contained in:
Vishwas Babu A J
2014-04-09 21:58:50 -07:00
4 changed files with 32 additions and 20 deletions
@@ -61,12 +61,16 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
final Long codeId = command.entityId();
final Code code = this.codeRepository.findOne(codeId);
if (code == null) {
throw new CodeNotFoundException(codeId);
}
final CodeValue codeValue = CodeValue.fromJson(code, command);
this.codeValueRepository.save(codeValue);
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(codeValue.getId()) //
.withEntityId(code.getId()) //
.withSubEntityId(codeValue.getId())//
.build();
} catch (final DataIntegrityViolationException dve) {
handleCodeValueDataIntegrityIssues(command, dve);
@@ -143,7 +147,8 @@ public class CodeValueWritePlatformServiceJpaRepositoryImpl implements CodeValue
}
return new CommandProcessingResultBuilder() //
.withEntityId(codeValueId) //
.withEntityId(codeId) //
.withSubEntityId(codeValueId)//
.build();
} catch (final DataIntegrityViolationException dve) {
logger.error(dve.getMessage(), dve);
@@ -21,6 +21,7 @@ public class CommandProcessingResult {
private final Long loanId;
private final Long savingsId;
private final Long resourceId;
private final Long subResourceId;
private final String transactionId;
private final Map<String, Object> changes;
@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,
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,
transactionId, changes, productId,rollbackTransaction);
transactionId, changes, productId, rollbackTransaction, subResourceId);
}
public static CommandProcessingResult commandOnlyResult(final Long commandId) {
@@ -82,11 +83,12 @@ public class CommandProcessingResult {
this.transactionId = null;
this.changes = new HashMap<String, Object>();
this.productId = null;
this.subResourceId = null;
}
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 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.officeId = officeId;
this.groupId = groupId;
@@ -99,6 +101,7 @@ public class CommandProcessingResult {
this.transactionId = transactionId;
this.productId = productId;
this.rollbackTransaction = rollbackTransaction;
this.subResourceId = subResourceId;
}
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.changes = changesOnly;
this.productId = null;
this.subResourceId = null;
}
public Long commandId() {
@@ -172,13 +176,15 @@ public class CommandProcessingResult {
return this.productId;
}
public boolean isRollbackTransaction() {
return this.rollbackTransaction!=null && this.rollbackTransaction;
return this.rollbackTransaction != null && this.rollbackTransaction;
}
public void setRollbackTransaction(Boolean rollbackTransaction) {
this.rollbackTransaction = rollbackTransaction;
}
public Long getSubResourceId() {
return subResourceId;
}
}
@@ -21,6 +21,7 @@ public class CommandProcessingResultBuilder {
private Long savingsId;
private String resourceIdentifier;
private Long entityId;
private Long subEntityId;
private String transactionId;
private Map<String, Object> changes;
private Long productId;
@@ -28,7 +29,8 @@ public class CommandProcessingResultBuilder {
public CommandProcessingResult build() {
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) {
@@ -50,6 +52,11 @@ public class CommandProcessingResultBuilder {
this.entityId = withEntityId;
return this;
}
public CommandProcessingResultBuilder withSubEntityId(final Long withSubEntityId) {
this.subEntityId = withSubEntityId;
return this;
}
public CommandProcessingResultBuilder withOfficeId(final Long withOfficeId) {
this.officeId = withOfficeId;
@@ -96,7 +96,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) //
.withClientId(group.getId()) //
.withGroupId(group.getId()) //
.withOfficeId(group.officeId()) //
.build();
}
@@ -116,10 +116,8 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) //
.withClientId(loan.getClientId()) //
.withOfficeId(loan.getOfficeId()) //
.withLoanId(loan.getId()) //
.withGroupId(loan.getGroupId()) //
.build();
}
@@ -140,10 +138,8 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(newNote.getId()) //
.withClientId(loan.getClientId()).withOfficeId(loan.getOfficeId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId())// Loan
// can
// be
// associated
.withOfficeId(loan.getOfficeId())//
.withLoanId(loan.getId())// Loan can be associated
.build();
}
@@ -295,8 +291,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
}
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId())
.with(changes).build();
.withLoanId(loan.getId()).withOfficeId(loan.getOfficeId()).with(changes).build();
}
private CommandProcessingResult updateLoanTransactionNote(final JsonCommand command) {
@@ -321,8 +316,7 @@ public class NoteWritePlatformServiceJpaRepositoryImpl implements NoteWritePlatf
}
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(noteForUpdate.getId())
.withClientId(loan.getClientId()).withLoanId(loan.getId()).withGroupId(loan.getGroupId()).withOfficeId(loan.getOfficeId())
.with(changes).build();
.withLoanId(loan.getId()).withOfficeId(loan.getOfficeId()).with(changes).build();
}
// private CommandProcessingResult updateSavingAccountNote(final JsonCommand