MIFOSX-97: refactor into command handling logic, prepare for sql based approach for change detection.
This commit is contained in:
+4
-4
@@ -2,9 +2,9 @@ package org.mifosng.platform.api.infrastructure;
|
|||||||
|
|
||||||
public class ApiConstants {
|
public class ApiConstants {
|
||||||
|
|
||||||
// TODO:Vishwas Need to move these settings to the Database
|
// TODO:Vishwas Need to move these settings to the Database
|
||||||
public static final Integer MAX_FILE_UPLOAD_SIZE_IN_MB = 5;
|
public static final Integer MAX_FILE_UPLOAD_SIZE_IN_MB = 5;
|
||||||
|
|
||||||
// TODO:Vishwas Need to move these settings to the Database
|
// TODO:Vishwas Need to move these settings to the Database
|
||||||
public static final Integer MAX_IMAGE_UPLOAD_SIZE_IN_MB = 1;
|
public static final Integer MAX_IMAGE_UPLOAD_SIZE_IN_MB = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+486
-695
File diff suppressed because it is too large
Load Diff
+42
-43
@@ -31,69 +31,68 @@ import org.mifosng.platform.api.commands.UserCommand;
|
|||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
|
|
||||||
public interface PortfolioApiDataConversionService {
|
public interface PortfolioApiDataConversionService {
|
||||||
|
|
||||||
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
|
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json);
|
FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
|
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String json);
|
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
SavingProductCommand convertJsonToSavingProductCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
DepositProductCommand convertJsonToDepositProductCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
ClientCommand convertApiRequestJsonToClientCommand(Long resourceIdentifier, String json);
|
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
ClientCommand convertInternalJsonFormatToClientCommand(Long resourceIdentifier, String json, boolean checkerApproved);
|
|
||||||
|
|
||||||
ClientData convertInternalJsonFormatToClientDataChange(Long clientId, String json);
|
|
||||||
|
|
||||||
ClientCommand detectChanges(Long resourceId, String baseJson, String workingJson);
|
|
||||||
|
|
||||||
GroupCommand convertJsonToGroupCommand(Long resourceIdentifier, String json);
|
BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String json);
|
||||||
|
|
||||||
LoanApplicationCommand convertJsonToLoanApplicationCommand(Long resourceIdentifier, String json);
|
LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
SavingProductCommand convertJsonToSavingProductCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
DepositProductCommand convertJsonToDepositProductCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
ClientCommand convertApiRequestJsonToClientCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
ClientCommand convertInternalJsonFormatToClientCommand(Long resourceIdentifier, String json, boolean checkerApproved);
|
||||||
|
|
||||||
|
ClientData convertInternalJsonFormatToClientDataChange(Long clientId, String json);
|
||||||
|
|
||||||
|
ClientCommand detectChanges(Long resourceId, String baseJson, String workingJson);
|
||||||
|
|
||||||
|
GroupCommand convertJsonToGroupCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
LoanApplicationCommand convertJsonToLoanApplicationCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
LoanChargeCommand convertJsonToLoanChargeCommand(Long loanChargeId, Long loanId, String json);
|
LoanChargeCommand convertJsonToLoanChargeCommand(Long loanChargeId, Long loanId, String json);
|
||||||
|
|
||||||
LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(Long resourceIdentifier, String json);
|
LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
LoanTransactionCommand convertJsonToLoanTransactionCommand(Long resourceIdentifier, String json);
|
LoanTransactionCommand convertJsonToLoanTransactionCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(
|
AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(Long loanId, Long transactionId, String json);
|
||||||
Long loanId, Long transactionId, String json);
|
|
||||||
|
|
||||||
OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(String json);
|
OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(String json);
|
||||||
|
|
||||||
NoteCommand convertJsonToNoteCommand(Long resourceIdentifier, Long clientId, String json);
|
NoteCommand convertJsonToNoteCommand(Long resourceIdentifier, Long clientId, String json);
|
||||||
|
|
||||||
DepositAccountCommand convertJsonToDepositAccountCommand(Long resourceIdentifier, String json);
|
DepositAccountCommand convertJsonToDepositAccountCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
DepositStateTransitionCommand convertJsonToDepositStateTransitionCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json);
|
DepositStateTransitionCommand convertJsonToDepositStateTransitionCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json);
|
LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json);
|
LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json);
|
||||||
|
|
||||||
DepositAccountWithdrawalCommand convertJsonToDepositWithdrawalCommand(Long resourceIdentifier, String json);
|
DepositAccountWithdrawalCommand convertJsonToDepositWithdrawalCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
DepositAccountWithdrawInterestCommand convertJsonToDepositAccountWithdrawInterestCommand(Long resourceIdentifier, String json);
|
|
||||||
|
|
||||||
ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json);
|
|
||||||
|
|
||||||
CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json);
|
DepositAccountWithdrawInterestCommand convertJsonToDepositAccountWithdrawInterestCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier,String json);
|
ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json);
|
||||||
|
|
||||||
|
CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
|
SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier, String json);
|
||||||
}
|
}
|
||||||
+1404
-1554
File diff suppressed because it is too large
Load Diff
+77
-70
@@ -42,114 +42,121 @@ import org.mifosng.platform.api.data.StaffData;
|
|||||||
|
|
||||||
public interface PortfolioApiJsonSerializerService {
|
public interface PortfolioApiJsonSerializerService {
|
||||||
|
|
||||||
String serializeAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData);
|
String serializeAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData);
|
||||||
|
|
||||||
String serializeGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result);
|
|
||||||
|
|
||||||
String serializeAdditionalFieldsSetDataToJson(boolean prettyPrint, Collection<AdditionalFieldsSetData> result);
|
String serializeGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result);
|
||||||
|
|
||||||
String serializeDatatableDataToJson(boolean prettyPrint, Collection<DatatableData> result);
|
|
||||||
|
|
||||||
String serializePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<PermissionData> permissions);
|
|
||||||
|
|
||||||
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<RoleData> roles);
|
String serializeAdditionalFieldsSetDataToJson(boolean prettyPrint, Collection<AdditionalFieldsSetData> result);
|
||||||
|
|
||||||
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, RoleData role);
|
String serializeDatatableDataToJson(boolean prettyPrint, Collection<DatatableData> result);
|
||||||
|
|
||||||
String serializeRolePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, RolePermissionData rolePermissionData);
|
|
||||||
|
|
||||||
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<AppUserData> users);
|
String serializePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<PermissionData> permissions);
|
||||||
|
|
||||||
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user);
|
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<RoleData> roles);
|
||||||
|
|
||||||
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeData> offices);
|
String serializeRoleDataToJson(boolean prettyPrint, Set<String> responseParameters, RoleData role);
|
||||||
|
|
||||||
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
|
String serializeRolePermissionDataToJson(boolean prettyPrint, Set<String> responseParameters, RolePermissionData rolePermissionData);
|
||||||
|
|
||||||
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeTransactionData> officeTransactions);
|
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<AppUserData> users);
|
||||||
|
|
||||||
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction);
|
|
||||||
|
|
||||||
String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration);
|
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user);
|
||||||
|
|
||||||
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<FundData> funds);
|
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeData> offices);
|
||||||
|
|
||||||
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, FundData fund);
|
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
|
||||||
|
|
||||||
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<LoanProductData> products);
|
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
Collection<OfficeTransactionData> officeTransactions);
|
||||||
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanProductData loanProduct);
|
|
||||||
|
|
||||||
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingProductData> products);
|
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransaction);
|
||||||
|
|
||||||
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingProductData savingProduct);
|
String serializeConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData configuration);
|
||||||
|
|
||||||
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositProductData> products);
|
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<FundData> funds);
|
||||||
|
|
||||||
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositProductData depositProduct);
|
String serializeFundDataToJson(boolean prettyPrint, Set<String> responseParameters, FundData fund);
|
||||||
|
|
||||||
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositAccountData> accounts);
|
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<LoanProductData> products);
|
||||||
|
|
||||||
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositAccountData account);
|
String serializeLoanProductDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanProductData loanProduct);
|
||||||
|
|
||||||
String serializeClientCommandToJson(ClientCommand command);
|
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingProductData> products);
|
||||||
|
|
||||||
String serializeClientDataToJson(ClientData clientData);
|
|
||||||
|
|
||||||
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
|
|
||||||
|
|
||||||
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientData> clients);
|
|
||||||
|
|
||||||
String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientAccountSummaryCollectionData clientAccount);
|
|
||||||
|
|
||||||
String serializeGroupAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupAccountSummaryCollectionData groupAccount);
|
String serializeSavingProductDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingProductData savingProduct);
|
||||||
|
|
||||||
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups);
|
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositProductData> products);
|
||||||
|
|
||||||
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupData group);
|
String serializeDepositProductDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositProductData depositProduct);
|
||||||
|
|
||||||
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<NoteData> notes);
|
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DepositAccountData> accounts);
|
||||||
|
|
||||||
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, NoteData note);
|
String serializeDepositAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, DepositAccountData account);
|
||||||
|
|
||||||
String serializeLoanScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanScheduleData loanSchedule);
|
|
||||||
|
|
||||||
String serializeLoanAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanAccountData loanAccount);
|
String serializeClientCommandToJson(ClientCommand command);
|
||||||
|
|
||||||
String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData);
|
String serializeClientDataToJson(ClientData clientData);
|
||||||
|
|
||||||
String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanReassignmentData loanReassignmentData);
|
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData clientData);
|
||||||
|
|
||||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges);
|
String serializeClientDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientData> clients);
|
||||||
|
|
||||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge);
|
String serializeClientAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
ClientAccountSummaryCollectionData clientAccount);
|
||||||
|
|
||||||
|
String serializeGroupAccountSummaryCollectionDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
GroupAccountSummaryCollectionData groupAccount);
|
||||||
|
|
||||||
|
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<GroupData> groups);
|
||||||
|
|
||||||
|
String serializeGroupDataToJson(boolean prettyPrint, Set<String> responseParameters, GroupData group);
|
||||||
|
|
||||||
|
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<NoteData> notes);
|
||||||
|
|
||||||
|
String serializeNoteDataToJson(boolean prettyPrint, Set<String> responseParameters, NoteData note);
|
||||||
|
|
||||||
|
String serializeLoanScheduleDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanScheduleData loanSchedule);
|
||||||
|
|
||||||
|
String serializeLoanAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanAccountData loanAccount);
|
||||||
|
|
||||||
|
String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData);
|
||||||
|
|
||||||
|
String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
LoanReassignmentData loanReassignmentData);
|
||||||
|
|
||||||
|
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges);
|
||||||
|
|
||||||
|
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, ChargeData charge);
|
||||||
|
|
||||||
String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge);
|
String serializeLoanChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanChargeData charge);
|
||||||
|
|
||||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff);
|
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, StaffData staff);
|
||||||
|
|
||||||
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
|
|
||||||
|
|
||||||
String serializeEntityIdentifier(EntityIdentifier identifier);
|
String serializeStaffDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<StaffData> staff);
|
||||||
|
|
||||||
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ClientIdentifierData> clientIdentifiers);
|
|
||||||
|
|
||||||
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientIdentifierData clientIdentifierData);
|
String serializeEntityIdentifier(EntityIdentifier identifier);
|
||||||
|
|
||||||
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas);
|
|
||||||
|
|
||||||
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData);
|
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
Collection<ClientIdentifierData> clientIdentifiers);
|
||||||
|
|
||||||
String serializeCodeDataToJson(boolean prettyPrint,Set<String> responseParameters, Collection<CodeData> codes);
|
String serializeClientIdentifierDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||||
|
ClientIdentifierData clientIdentifierData);
|
||||||
|
|
||||||
String serializeCodeDataToJson(boolean prettyPrint,Set<String> responseParameters, CodeData code);
|
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<DocumentData> documentDatas);
|
||||||
|
|
||||||
String serializeMakerCheckerDataToJson(boolean prettyPrint,Set<String> responseParameters, Collection<CommandSourceData> entries);
|
|
||||||
|
|
||||||
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account);
|
String serializeDocumentDataToJson(boolean prettyPrint, Set<String> responseParameters, DocumentData documentData);
|
||||||
|
|
||||||
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingAccountData> accounts);
|
String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CodeData> codes);
|
||||||
|
|
||||||
// TODO - KW - might devide serialize up into portfolio and account to reduce interface
|
String serializeCodeDataToJson(boolean prettyPrint, Set<String> responseParameters, CodeData code);
|
||||||
String serializeChartOfAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, ChartOfAccountsData chartOfAccounts);
|
|
||||||
|
String serializeMakerCheckerDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<CommandSourceData> entries);
|
||||||
|
|
||||||
|
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, SavingAccountData account);
|
||||||
|
|
||||||
|
String serializeSavingAccountsDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<SavingAccountData> accounts);
|
||||||
|
|
||||||
|
// TODO - KW - might devide serialize up into portfolio and account to
|
||||||
|
// reduce interface
|
||||||
|
String serializeChartOfAccountDataToJson(boolean prettyPrint, Set<String> responseParameters, ChartOfAccountsData chartOfAccounts);
|
||||||
}
|
}
|
||||||
+29
-29
@@ -11,36 +11,36 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
|
|
||||||
public interface ClientWritePlatformService {
|
public interface ClientWritePlatformService {
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENT')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENT')")
|
||||||
Long createClient(ClientCommand command);
|
Long createClient(ClientCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENT')")
|
|
||||||
EntityIdentifier updateClientDetails(ClientCommand command);
|
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENT')")
|
|
||||||
EntityIdentifier deleteClient(ClientCommand command);
|
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
|
||||||
EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream);
|
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
|
||||||
EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage);
|
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')")
|
|
||||||
EntityIdentifier deleteClientImage(Long clientId);
|
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTNOTE')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENT')")
|
||||||
EntityIdentifier addClientNote(NoteCommand command);
|
EntityIdentifier updateClientDetails(ClientCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENT')")
|
||||||
EntityIdentifier updateNote(NoteCommand command);
|
EntityIdentifier deleteClient(ClientCommand command);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
||||||
Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
|
EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIMAGE')")
|
||||||
EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
|
EntityIdentifier saveOrUpdateClientImage(Long clientId, Base64EncodedImage encodedImage);
|
||||||
|
|
||||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')")
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIMAGE')")
|
||||||
EntityIdentifier deleteClientIdentifier(Long clientIdentifierId);
|
EntityIdentifier deleteClientImage(Long clientId);
|
||||||
|
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTNOTE')")
|
||||||
|
EntityIdentifier addClientNote(NoteCommand command);
|
||||||
|
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTNOTE')")
|
||||||
|
EntityIdentifier updateNote(NoteCommand command);
|
||||||
|
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'CREATE_CLIENTIDENTIFIER')")
|
||||||
|
Long addClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
|
||||||
|
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'UPDATE_CLIENTIDENTIFIER')")
|
||||||
|
EntityIdentifier updateClientIdentifier(ClientIdentifierCommand clientIdentifierCommand);
|
||||||
|
|
||||||
|
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'PORTFOLIO_MANAGEMENT_SUPER_USER', 'DELETE_CLIENTIDENTIFIER')")
|
||||||
|
EntityIdentifier deleteClientIdentifier(Long clientIdentifierId);
|
||||||
}
|
}
|
||||||
+267
-317
@@ -40,382 +40,332 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
|
private final static Logger logger = LoggerFactory.getLogger(ClientWritePlatformServiceJpaRepositoryImpl.class);
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final ClientRepository clientRepository;
|
private final ClientRepository clientRepository;
|
||||||
private final ClientIdentifierRepository clientIdentifierRepository;
|
private final ClientIdentifierRepository clientIdentifierRepository;
|
||||||
private final OfficeRepository officeRepository;
|
private final OfficeRepository officeRepository;
|
||||||
private final NoteRepository noteRepository;
|
private final NoteRepository noteRepository;
|
||||||
private final CodeValueRepository codeValueRepository;
|
private final CodeValueRepository codeValueRepository;
|
||||||
|
|
||||||
// FIXME - kw - this value is hardcoded for now but will be retrieved from configuration
|
// FIXME - kw - this value is hardcoded for now but will be retrieved from
|
||||||
private boolean makerCheckerEnabledForTask = false;
|
// configuration
|
||||||
|
private boolean makerCheckerEnabledForTask = false;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ClientWritePlatformServiceJpaRepositoryImpl(
|
public ClientWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final ClientRepository clientRepository,
|
||||||
final PlatformSecurityContext context,
|
final ClientIdentifierRepository clientIdentifierRepository, final OfficeRepository officeRepository,
|
||||||
final ClientRepository clientRepository,
|
NoteRepository noteRepository, final CodeValueRepository codeValueRepository) {
|
||||||
final ClientIdentifierRepository clientIdentifierRepository,
|
this.context = context;
|
||||||
final OfficeRepository officeRepository,
|
this.clientRepository = clientRepository;
|
||||||
NoteRepository noteRepository,
|
this.clientIdentifierRepository = clientIdentifierRepository;
|
||||||
final CodeValueRepository codeValueRepository) {
|
this.officeRepository = officeRepository;
|
||||||
this.context = context;
|
this.noteRepository = noteRepository;
|
||||||
this.clientRepository = clientRepository;
|
this.codeValueRepository = codeValueRepository;
|
||||||
this.clientIdentifierRepository = clientIdentifierRepository;
|
}
|
||||||
this.officeRepository = officeRepository;
|
|
||||||
this.noteRepository = noteRepository;
|
|
||||||
this.codeValueRepository = codeValueRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier deleteClient(final ClientCommand command) {
|
public EntityIdentifier deleteClient(final ClientCommand command) {
|
||||||
|
|
||||||
final Long clientId = command.getId();
|
final Long clientId = command.getId();
|
||||||
final Client client = this.clientRepository.findOne(clientId);
|
final Client client = this.clientRepository.findOne(clientId);
|
||||||
if (client == null || client.isDeleted()) {
|
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
|
||||||
throw new ClientNotFoundException(clientId);
|
|
||||||
}
|
|
||||||
|
|
||||||
client.delete();
|
client.delete();
|
||||||
this.clientRepository.save(client);
|
this.clientRepository.save(client);
|
||||||
|
|
||||||
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) {
|
|
||||||
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EntityIdentifier(client.getId());
|
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
return new EntityIdentifier(client.getId());
|
||||||
* Guaranteed to throw an exception no matter what the data integrity issue
|
}
|
||||||
* is.
|
|
||||||
*/
|
|
||||||
private void handleDataIntegrityIssues(final ClientCommand command,
|
|
||||||
final DataIntegrityViolationException dve) {
|
|
||||||
|
|
||||||
Throwable realCause = dve.getMostSpecificCause();
|
/*
|
||||||
if (realCause.getMessage().contains("external_id")) {
|
* Guaranteed to throw an exception no matter what the data integrity issue
|
||||||
throw new PlatformDataIntegrityException(
|
* is.
|
||||||
"error.msg.client.duplicate.externalId",
|
*/
|
||||||
"Client with externalId `" + command.getExternalId()
|
private void handleDataIntegrityIssues(final ClientCommand command, final DataIntegrityViolationException dve) {
|
||||||
+ "` already exists", "externalId",
|
|
||||||
command.getExternalId());
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.error(dve.getMessage(), dve);
|
Throwable realCause = dve.getMostSpecificCause();
|
||||||
throw new PlatformDataIntegrityException(
|
if (realCause.getMessage().contains("external_id")) { throw new PlatformDataIntegrityException(
|
||||||
"error.msg.client.unknown.data.integrity.issue",
|
"error.msg.client.duplicate.externalId", "Client with externalId `" + command.getExternalId() + "` already exists",
|
||||||
"Unknown data integrity issue with resource.");
|
"externalId", command.getExternalId()); }
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
logger.error(dve.getMessage(), dve);
|
||||||
@Override
|
throw new PlatformDataIntegrityException("error.msg.client.unknown.data.integrity.issue",
|
||||||
public Long createClient(final ClientCommand command) {
|
"Unknown data integrity issue with resource.");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
@Transactional
|
||||||
context.authenticatedUser();
|
@Override
|
||||||
|
public Long createClient(final ClientCommand command) {
|
||||||
|
|
||||||
final ClientCommandValidator validator = new ClientCommandValidator(command);
|
try {
|
||||||
validator.validateForCreate();
|
context.authenticatedUser();
|
||||||
|
|
||||||
final Office clientOffice = this.officeRepository.findOne(command.getOfficeId());
|
final ClientCommandValidator validator = new ClientCommandValidator(command);
|
||||||
if (clientOffice == null) {
|
validator.validateForCreate();
|
||||||
throw new OfficeNotFoundException(command.getOfficeId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String firstname = command.getFirstname();
|
final Office clientOffice = this.officeRepository.findOne(command.getOfficeId());
|
||||||
String lastname = command.getLastname();
|
if (clientOffice == null) { throw new OfficeNotFoundException(command.getOfficeId()); }
|
||||||
if (StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
|
||||||
lastname = command.getClientOrBusinessName();
|
|
||||||
firstname = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Client newClient = Client
|
String firstname = command.getFirstname();
|
||||||
.newClient(clientOffice, firstname, lastname,
|
String lastname = command.getLastname();
|
||||||
command.getJoiningDate(), command.getExternalId());
|
if (StringUtils.isNotBlank(command.getClientOrBusinessName())) {
|
||||||
|
lastname = command.getClientOrBusinessName();
|
||||||
|
firstname = null;
|
||||||
|
}
|
||||||
|
|
||||||
this.clientRepository.save(newClient);
|
final Client newClient = Client.newClient(clientOffice, firstname, lastname, command.getJoiningDate(), command.getExternalId());
|
||||||
|
|
||||||
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) {
|
this.clientRepository.save(newClient);
|
||||||
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return newClient.getId();
|
|
||||||
} catch (DataIntegrityViolationException dve) {
|
|
||||||
handleDataIntegrityIssues(command, dve);
|
|
||||||
return Long.valueOf(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
|
||||||
@Override
|
|
||||||
public EntityIdentifier updateClientDetails(final ClientCommand command) {
|
|
||||||
|
|
||||||
try {
|
return newClient.getId();
|
||||||
context.authenticatedUser();
|
} catch (DataIntegrityViolationException dve) {
|
||||||
|
handleDataIntegrityIssues(command, dve);
|
||||||
|
return Long.valueOf(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final ClientCommandValidator validator = new ClientCommandValidator(command);
|
@Transactional
|
||||||
validator.validateForUpdate();
|
@Override
|
||||||
|
public EntityIdentifier updateClientDetails(final ClientCommand command) {
|
||||||
|
|
||||||
Office clientOffice = null;
|
try {
|
||||||
Long officeId = command.getOfficeId();
|
context.authenticatedUser();
|
||||||
if (command.isOfficeChanged() && officeId != null) {
|
|
||||||
clientOffice = this.officeRepository.findOne(officeId);
|
|
||||||
if (clientOffice == null) {
|
|
||||||
throw new OfficeNotFoundException(command.getOfficeId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Client clientForUpdate = this.clientRepository.findOne(command.getId());
|
final ClientCommandValidator validator = new ClientCommandValidator(command);
|
||||||
if (clientForUpdate == null || clientForUpdate.isDeleted()) {
|
validator.validateForUpdate();
|
||||||
throw new ClientNotFoundException(command.getId());
|
|
||||||
}
|
|
||||||
clientForUpdate.update(clientOffice, command);
|
|
||||||
|
|
||||||
this.clientRepository.saveAndFlush(clientForUpdate);
|
Office clientOffice = null;
|
||||||
|
Long officeId = command.getOfficeId();
|
||||||
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) {
|
if (command.isOfficeChanged() && officeId != null) {
|
||||||
throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException();
|
clientOffice = this.officeRepository.findOne(officeId);
|
||||||
}
|
if (clientOffice == null) { throw new OfficeNotFoundException(command.getOfficeId()); }
|
||||||
|
}
|
||||||
|
|
||||||
return new EntityIdentifier(clientForUpdate.getId());
|
final Client clientForUpdate = this.clientRepository.findOne(command.getId());
|
||||||
} catch (DataIntegrityViolationException dve) {
|
if (clientForUpdate == null || clientForUpdate.isDeleted()) { throw new ClientNotFoundException(command.getId()); }
|
||||||
handleDataIntegrityIssues(command, dve);
|
clientForUpdate.update(clientOffice, command);
|
||||||
return new EntityIdentifier(Long.valueOf(-1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
this.clientRepository.saveAndFlush(clientForUpdate);
|
||||||
@Override
|
|
||||||
public EntityIdentifier addClientNote(final NoteCommand command) {
|
|
||||||
|
|
||||||
context.authenticatedUser();
|
if (this.makerCheckerEnabledForTask && !command.isApprovedByChecker()) { throw new RollbackTransactionAsCommandIsNotApprovedByCheckerException(); }
|
||||||
|
|
||||||
final Client clientForUpdate = this.clientRepository.findOne(command.getClientId());
|
return new EntityIdentifier(clientForUpdate.getId());
|
||||||
if (clientForUpdate == null) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
throw new ClientNotFoundException(command.getClientId());
|
handleDataIntegrityIssues(command, dve);
|
||||||
}
|
return new EntityIdentifier(Long.valueOf(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Note note = Note.clientNote(clientForUpdate, command.getNote());
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier addClientNote(final NoteCommand command) {
|
||||||
|
|
||||||
this.noteRepository.save(note);
|
context.authenticatedUser();
|
||||||
|
|
||||||
return new EntityIdentifier(note.getId());
|
final Client clientForUpdate = this.clientRepository.findOne(command.getClientId());
|
||||||
}
|
if (clientForUpdate == null) { throw new ClientNotFoundException(command.getClientId()); }
|
||||||
|
|
||||||
@Transactional
|
final Note note = Note.clientNote(clientForUpdate, command.getNote());
|
||||||
@Override
|
|
||||||
public EntityIdentifier updateNote(final NoteCommand command) {
|
|
||||||
|
|
||||||
context.authenticatedUser();
|
this.noteRepository.save(note);
|
||||||
|
|
||||||
final Note noteForUpdate = this.noteRepository.findOne(command.getId());
|
return new EntityIdentifier(note.getId());
|
||||||
if (noteForUpdate == null
|
}
|
||||||
|| noteForUpdate.isNotAgainstClientWithIdOf(command.getClientId())) {
|
|
||||||
throw new NoteNotFoundException(command.getId(),command.getClientId(), "client");
|
|
||||||
}
|
|
||||||
|
|
||||||
noteForUpdate.update(command.getNote());
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier updateNote(final NoteCommand command) {
|
||||||
|
|
||||||
return new EntityIdentifier(noteForUpdate.getId());
|
context.authenticatedUser();
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
final Note noteForUpdate = this.noteRepository.findOne(command.getId());
|
||||||
@Override
|
if (noteForUpdate == null || noteForUpdate.isNotAgainstClientWithIdOf(command.getClientId())) { throw new NoteNotFoundException(
|
||||||
public Long addClientIdentifier(final ClientIdentifierCommand command) {
|
command.getId(), command.getClientId(), "client"); }
|
||||||
|
|
||||||
String documentTypeLabel = null;
|
|
||||||
Long documentTypeId = null;
|
|
||||||
final String documentKey = command.getDocumentKey();
|
|
||||||
|
|
||||||
try {
|
|
||||||
context.authenticatedUser();
|
|
||||||
|
|
||||||
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
|
noteForUpdate.update(command.getNote());
|
||||||
validator.validateForCreate();
|
|
||||||
|
|
||||||
final Client client = this.clientRepository.findOne(command.getClientId());
|
return new EntityIdentifier(noteForUpdate.getId());
|
||||||
if (client == null || client.isDeleted()) {
|
}
|
||||||
throw new ClientNotFoundException(command.getClientId());
|
|
||||||
}
|
|
||||||
|
|
||||||
final CodeValue documentType = this.codeValueRepository.findOne(command.getDocumentTypeId());
|
@Transactional
|
||||||
if (documentType == null) {
|
@Override
|
||||||
throw new CodeValueNotFoundException(command.getDocumentTypeId());
|
public Long addClientIdentifier(final ClientIdentifierCommand command) {
|
||||||
}
|
|
||||||
documentTypeId = documentType.getId();
|
|
||||||
documentTypeLabel = documentType.getLabel();
|
|
||||||
|
|
||||||
final ClientIdentifier clientIdentifier = ClientIdentifier.createNew(client, documentType, documentKey, command.getDescription());
|
String documentTypeLabel = null;
|
||||||
|
Long documentTypeId = null;
|
||||||
|
final String documentKey = command.getDocumentKey();
|
||||||
|
|
||||||
this.clientIdentifierRepository.save(clientIdentifier);
|
try {
|
||||||
|
context.authenticatedUser();
|
||||||
|
|
||||||
return clientIdentifier.getId();
|
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
|
||||||
} catch (DataIntegrityViolationException dve) {
|
validator.validateForCreate();
|
||||||
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
|
||||||
return Long.valueOf(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@Override
|
|
||||||
public EntityIdentifier updateClientIdentifier(final ClientIdentifierCommand command) {
|
|
||||||
|
|
||||||
String documentTypeLabel = null;
|
|
||||||
Long documentTypeId = null;
|
|
||||||
String documentKey = command.getDocumentKey();
|
|
||||||
|
|
||||||
try {
|
|
||||||
context.authenticatedUser();
|
|
||||||
|
|
||||||
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
|
final Client client = this.clientRepository.findOne(command.getClientId());
|
||||||
validator.validateForUpdate();
|
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(command.getClientId()); }
|
||||||
|
|
||||||
CodeValue documentType = null;
|
final CodeValue documentType = this.codeValueRepository.findOne(command.getDocumentTypeId());
|
||||||
documentTypeId = command.getDocumentTypeId();
|
if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
|
||||||
if (command.isDocumentTypeChanged() && documentTypeId != null) {
|
documentTypeId = documentType.getId();
|
||||||
documentType = this.codeValueRepository.findOne(documentTypeId);
|
documentTypeLabel = documentType.getLabel();
|
||||||
if (documentType == null) {
|
|
||||||
throw new CodeValueNotFoundException(command.getDocumentTypeId());
|
|
||||||
}
|
|
||||||
documentTypeId = documentType.getId();
|
|
||||||
documentTypeLabel = documentType.getLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
final ClientIdentifier clientIdentifierForUpdate = this.clientIdentifierRepository.findOne(command.getId());
|
final ClientIdentifier clientIdentifier = ClientIdentifier.createNew(client, documentType, documentKey,
|
||||||
if (clientIdentifierForUpdate == null) {
|
command.getDescription());
|
||||||
throw new ClientIdentifierNotFoundException(command.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO - KW - why need to check what changed when integrity violation occurs?
|
|
||||||
if (command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
|
|
||||||
documentTypeId = command.getDocumentTypeId();
|
|
||||||
documentKey = command.getDocumentKey();
|
|
||||||
} else if (command.isDocumentTypeChanged() && !command.isDocumentKeyChanged()) {
|
|
||||||
documentTypeId = command.getDocumentTypeId();
|
|
||||||
documentKey = clientIdentifierForUpdate.getDocumentKey();
|
|
||||||
} else if (!command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
|
|
||||||
documentTypeId = clientIdentifierForUpdate.getDocumentType().getId();
|
|
||||||
documentKey = clientIdentifierForUpdate.getDocumentKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
clientIdentifierForUpdate.update(command, documentType);
|
|
||||||
|
|
||||||
this.clientIdentifierRepository.saveAndFlush(clientIdentifierForUpdate);
|
this.clientIdentifierRepository.save(clientIdentifier);
|
||||||
|
|
||||||
return new EntityIdentifier(clientIdentifierForUpdate.getId());
|
return clientIdentifier.getId();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
||||||
return new EntityIdentifier(Long.valueOf(-1));
|
return Long.valueOf(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleClientIdentifierDataIntegrityViolation(
|
@Transactional
|
||||||
final String documentTypeLabel,
|
@Override
|
||||||
final Long documentTypeId,
|
public EntityIdentifier updateClientIdentifier(final ClientIdentifierCommand command) {
|
||||||
final String documentKey,
|
|
||||||
final DataIntegrityViolationException dve) {
|
|
||||||
|
|
||||||
if (dve.getMostSpecificCause().getMessage().contains("unique_client_identifier")) {
|
|
||||||
throw new DuplicateClientIdentifierException(documentTypeLabel);
|
|
||||||
} else if (dve.getMostSpecificCause().getMessage().contains("unique_identifier_key")) {
|
|
||||||
throw new DuplicateClientIdentifierException(documentTypeId, documentTypeLabel, documentKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
// only log as error if unexpected data integrity violation.
|
|
||||||
logger.error(dve.getMessage(), dve);
|
|
||||||
throw new PlatformDataIntegrityException(
|
|
||||||
"error.msg.clientIdentifier.unknown.data.integrity.issue",
|
|
||||||
"Unknown data integrity issue with resource.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
String documentTypeLabel = null;
|
||||||
@Override
|
Long documentTypeId = null;
|
||||||
public EntityIdentifier deleteClientIdentifier(final Long clientIdentifierId) {
|
String documentKey = command.getDocumentKey();
|
||||||
final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(clientIdentifierId);
|
|
||||||
if (clientIdentifier == null) {
|
|
||||||
throw new ClientIdentifierNotFoundException(clientIdentifierId);
|
|
||||||
}
|
|
||||||
this.clientIdentifierRepository.delete(clientIdentifier);
|
|
||||||
|
|
||||||
return new EntityIdentifier(clientIdentifierId);
|
try {
|
||||||
}
|
context.authenticatedUser();
|
||||||
|
|
||||||
@Transactional
|
final ClientIdentifierCommandValidator validator = new ClientIdentifierCommandValidator(command);
|
||||||
@Override
|
validator.validateForUpdate();
|
||||||
public EntityIdentifier saveOrUpdateClientImage(Long clientId,
|
|
||||||
String imageName, InputStream inputStream) {
|
|
||||||
try {
|
|
||||||
final Client client = this.clientRepository.findOne(clientId);
|
|
||||||
String imageUploadLocation = setupForClientImageUpdate(clientId,
|
|
||||||
client);
|
|
||||||
|
|
||||||
String imageLocation = FileUtils.saveToFileSystem(inputStream,
|
CodeValue documentType = null;
|
||||||
imageUploadLocation, imageName);
|
documentTypeId = command.getDocumentTypeId();
|
||||||
|
if (command.isDocumentTypeChanged() && documentTypeId != null) {
|
||||||
|
documentType = this.codeValueRepository.findOne(documentTypeId);
|
||||||
|
if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
|
||||||
|
documentTypeId = documentType.getId();
|
||||||
|
documentTypeLabel = documentType.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
final ClientIdentifier clientIdentifierForUpdate = this.clientIdentifierRepository.findOne(command.getId());
|
||||||
return updateClientImage(clientId, client, imageLocation);
|
if (clientIdentifierForUpdate == null) { throw new ClientIdentifierNotFoundException(command.getId()); }
|
||||||
} catch (IOException ioe) {
|
|
||||||
logger.error(ioe.getMessage(), ioe);
|
|
||||||
throw new DocumentManagementException(imageName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
// TODO - KW - why need to check what changed when integrity
|
||||||
@Override
|
// violation occurs?
|
||||||
public EntityIdentifier deleteClientImage(final Long clientId) {
|
if (command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
|
||||||
|
documentTypeId = command.getDocumentTypeId();
|
||||||
final Client client = this.clientRepository.findOne(clientId);
|
documentKey = command.getDocumentKey();
|
||||||
if (client == null || client.isDeleted()) {
|
} else if (command.isDocumentTypeChanged() && !command.isDocumentKeyChanged()) {
|
||||||
throw new ClientNotFoundException(clientId);
|
documentTypeId = command.getDocumentTypeId();
|
||||||
}
|
documentKey = clientIdentifierForUpdate.getDocumentKey();
|
||||||
|
} else if (!command.isDocumentTypeChanged() && command.isDocumentKeyChanged()) {
|
||||||
// delete image from the file system
|
documentTypeId = clientIdentifierForUpdate.getDocumentType().getId();
|
||||||
if (StringUtils.isNotEmpty(client.getImageKey())) {
|
documentKey = clientIdentifierForUpdate.getDocumentKey();
|
||||||
FileUtils.deleteClientImage(clientId, client.getImageKey());
|
}
|
||||||
}
|
|
||||||
return updateClientImage(clientId, client, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
clientIdentifierForUpdate.update(command, documentType);
|
||||||
public EntityIdentifier saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
|
|
||||||
try {
|
|
||||||
final Client client = this.clientRepository.findOne(clientId);
|
|
||||||
final String imageUploadLocation = setupForClientImageUpdate(clientId, client);
|
|
||||||
|
|
||||||
final String imageLocation = FileUtils.saveToFileSystem(encodedImage, imageUploadLocation, "image");
|
this.clientIdentifierRepository.saveAndFlush(clientIdentifierForUpdate);
|
||||||
|
|
||||||
return updateClientImage(clientId, client, imageLocation);
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
logger.error(ioe.getMessage(), ioe);
|
|
||||||
throw new DocumentManagementException("image");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String setupForClientImageUpdate(final Long clientId, final Client client) {
|
return new EntityIdentifier(clientIdentifierForUpdate.getId());
|
||||||
if (client == null || client.isDeleted()) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
throw new ClientNotFoundException(clientId);
|
handleClientIdentifierDataIntegrityViolation(documentTypeLabel, documentTypeId, documentKey, dve);
|
||||||
}
|
return new EntityIdentifier(Long.valueOf(-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final String imageUploadLocation = FileUtils.generateClientImageParentDirectory(clientId);
|
private void handleClientIdentifierDataIntegrityViolation(final String documentTypeLabel, final Long documentTypeId,
|
||||||
// delete previous image from the file system
|
final String documentKey, final DataIntegrityViolationException dve) {
|
||||||
if (StringUtils.isNotEmpty(client.getImageKey())) {
|
|
||||||
FileUtils.deleteClientImage(clientId, client.getImageKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Recursively create the directory if it does not exist **/
|
if (dve.getMostSpecificCause().getMessage().contains("unique_client_identifier")) {
|
||||||
if (!new File(imageUploadLocation).isDirectory()) {
|
throw new DuplicateClientIdentifierException(documentTypeLabel);
|
||||||
new File(imageUploadLocation).mkdirs();
|
} else if (dve.getMostSpecificCause().getMessage().contains("unique_identifier_key")) { throw new DuplicateClientIdentifierException(
|
||||||
}
|
documentTypeId, documentTypeLabel, documentKey); }
|
||||||
return imageUploadLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityIdentifier updateClientImage(final Long clientId, final Client client, final String imageLocation) {
|
|
||||||
client.setImageKey(imageLocation);
|
|
||||||
this.clientRepository.save(client);
|
|
||||||
|
|
||||||
return new EntityIdentifier(clientId);
|
// only log as error if unexpected data integrity violation.
|
||||||
}
|
logger.error(dve.getMessage(), dve);
|
||||||
|
throw new PlatformDataIntegrityException("error.msg.clientIdentifier.unknown.data.integrity.issue",
|
||||||
|
"Unknown data integrity issue with resource.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier deleteClientIdentifier(final Long clientIdentifierId) {
|
||||||
|
final ClientIdentifier clientIdentifier = this.clientIdentifierRepository.findOne(clientIdentifierId);
|
||||||
|
if (clientIdentifier == null) { throw new ClientIdentifierNotFoundException(clientIdentifierId); }
|
||||||
|
this.clientIdentifierRepository.delete(clientIdentifier);
|
||||||
|
|
||||||
|
return new EntityIdentifier(clientIdentifierId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier saveOrUpdateClientImage(Long clientId, String imageName, InputStream inputStream) {
|
||||||
|
try {
|
||||||
|
final Client client = this.clientRepository.findOne(clientId);
|
||||||
|
String imageUploadLocation = setupForClientImageUpdate(clientId, client);
|
||||||
|
|
||||||
|
String imageLocation = FileUtils.saveToFileSystem(inputStream, imageUploadLocation, imageName);
|
||||||
|
|
||||||
|
return updateClientImage(clientId, client, imageLocation);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
logger.error(ioe.getMessage(), ioe);
|
||||||
|
throw new DocumentManagementException(imageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier deleteClientImage(final Long clientId) {
|
||||||
|
|
||||||
|
final Client client = this.clientRepository.findOne(clientId);
|
||||||
|
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
|
||||||
|
|
||||||
|
// delete image from the file system
|
||||||
|
if (StringUtils.isNotEmpty(client.getImageKey())) {
|
||||||
|
FileUtils.deleteClientImage(clientId, client.getImageKey());
|
||||||
|
}
|
||||||
|
return updateClientImage(clientId, client, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityIdentifier saveOrUpdateClientImage(final Long clientId, final Base64EncodedImage encodedImage) {
|
||||||
|
try {
|
||||||
|
final Client client = this.clientRepository.findOne(clientId);
|
||||||
|
final String imageUploadLocation = setupForClientImageUpdate(clientId, client);
|
||||||
|
|
||||||
|
final String imageLocation = FileUtils.saveToFileSystem(encodedImage, imageUploadLocation, "image");
|
||||||
|
|
||||||
|
return updateClientImage(clientId, client, imageLocation);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
logger.error(ioe.getMessage(), ioe);
|
||||||
|
throw new DocumentManagementException("image");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String setupForClientImageUpdate(final Long clientId, final Client client) {
|
||||||
|
if (client == null || client.isDeleted()) { throw new ClientNotFoundException(clientId); }
|
||||||
|
|
||||||
|
final String imageUploadLocation = FileUtils.generateClientImageParentDirectory(clientId);
|
||||||
|
// delete previous image from the file system
|
||||||
|
if (StringUtils.isNotEmpty(client.getImageKey())) {
|
||||||
|
FileUtils.deleteClientImage(clientId, client.getImageKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Recursively create the directory if it does not exist **/
|
||||||
|
if (!new File(imageUploadLocation).isDirectory()) {
|
||||||
|
new File(imageUploadLocation).mkdirs();
|
||||||
|
}
|
||||||
|
return imageUploadLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityIdentifier updateClientImage(final Long clientId, final Client client, final String imageLocation) {
|
||||||
|
client.setImageKey(imageLocation);
|
||||||
|
this.clientRepository.save(client);
|
||||||
|
|
||||||
|
return new EntityIdentifier(clientId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package org.mifosng.platform.infrastructure.errorhandling;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link RuntimeException} that is thrown in the case where an invalid or unknown
|
||||||
|
* command is attempted to be processed by platform.
|
||||||
|
*/
|
||||||
|
public class UnsupportedCommandException extends RuntimeException {
|
||||||
|
|
||||||
|
private final String unsupportedCommandName;
|
||||||
|
|
||||||
|
public UnsupportedCommandException(final String unsupportedCommandName) {
|
||||||
|
this.unsupportedCommandName = unsupportedCommandName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnsupportedCommandName() {
|
||||||
|
return unsupportedCommandName;
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package org.mifosng.platform.infrastructure.errorhandling;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import javax.ws.rs.core.Response.Status;
|
||||||
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
|
import org.mifosng.platform.api.data.ApiGlobalErrorResponse;
|
||||||
|
import org.mifosng.platform.api.data.ApiParameterError;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An {@link ExceptionMapper} to map {@link UnsupportedCommandException} thrown by platform into a HTTP API friendly format.
|
||||||
|
*/
|
||||||
|
@Provider
|
||||||
|
@Component
|
||||||
|
@Scope("singleton")
|
||||||
|
public class UnsupportedCommandExceptionMapper implements ExceptionMapper<UnsupportedCommandException> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response toResponse(final UnsupportedCommandException exception) {
|
||||||
|
|
||||||
|
List<ApiParameterError> errors = new ArrayList<ApiParameterError>();
|
||||||
|
|
||||||
|
StringBuilder validationErrorCode = new StringBuilder("error.msg.command.unsupported");
|
||||||
|
StringBuilder defaultEnglishMessage = new StringBuilder("The command ").append(exception.getUnsupportedCommandName()).append(" is not supported.");
|
||||||
|
ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), exception.getUnsupportedCommandName(), exception.getUnsupportedCommandName());
|
||||||
|
|
||||||
|
errors.add(error);
|
||||||
|
|
||||||
|
ApiGlobalErrorResponse invalidParameterError = ApiGlobalErrorResponse.badClientRequest(
|
||||||
|
"validation.msg.validation.errors.exist",
|
||||||
|
"Validation errors exist.", errors);
|
||||||
|
|
||||||
|
return Response.status(Status.BAD_REQUEST).entity(invalidParameterError).type(MediaType.APPLICATION_JSON).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+92
-83
@@ -19,99 +19,108 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
|||||||
@Table(name = "m_portfolio_command_source")
|
@Table(name = "m_portfolio_command_source")
|
||||||
public class CommandSource extends AbstractPersistable<Long> {
|
public class CommandSource extends AbstractPersistable<Long> {
|
||||||
|
|
||||||
@Column(name = "api_operation", length = 20)
|
@Column(name = "api_operation", length = 20)
|
||||||
private String apiOperation;
|
private String apiOperation;
|
||||||
|
|
||||||
@Column(name = "api_resource", length = 20)
|
|
||||||
private String resource;
|
|
||||||
|
|
||||||
@Column(name = "resource_id")
|
|
||||||
private Long resourceId;
|
|
||||||
|
|
||||||
@Column(name = "command_as_json", length = 1000)
|
|
||||||
private String commandAsJson;
|
|
||||||
|
|
||||||
// should maker and checker be a staff member as opposed to just any application user?
|
@Column(name = "api_resource", length = 20)
|
||||||
@SuppressWarnings("unused")
|
private String resource;
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "maker_id", nullable = false)
|
@Column(name = "resource_id")
|
||||||
private AppUser maker;
|
private Long resourceId;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@Column(name = "command_as_json", length = 1000)
|
||||||
@Column(name = "made_on_date", nullable = false)
|
private String commandAsJson;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "maker_id", nullable = false)
|
||||||
|
private AppUser maker;
|
||||||
|
|
||||||
|
@Column(name = "made_on_date", nullable = false)
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
private Date madeOnDate;
|
private Date madeOnDate;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "checker_id", nullable = true)
|
@JoinColumn(name = "checker_id", nullable = true)
|
||||||
private AppUser checker;
|
private AppUser checker;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "checked_on_date", nullable = false)
|
@Column(name = "checked_on_date", nullable = false)
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
private Date checkedOnDate;
|
private Date checkedOnDate;
|
||||||
|
|
||||||
public static CommandSource createdBy(
|
public static CommandSource createdBy(final String apiOperation, final String resource, final Long resourceId, final AppUser maker,
|
||||||
final String apiOperation,
|
final LocalDate madeOnDate) {
|
||||||
final String resource,
|
return new CommandSource(apiOperation, resource, resourceId, maker, madeOnDate);
|
||||||
final Long resourceId,
|
}
|
||||||
final AppUser maker,
|
|
||||||
final LocalDate madeOnDate) {
|
|
||||||
return new CommandSource(apiOperation, resource, resourceId, maker, madeOnDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CommandSource() {
|
protected CommandSource() {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandSource(
|
private CommandSource(final String apiOperation, final String resource, final Long resourceId, final AppUser maker,
|
||||||
final String apiOperation,
|
final LocalDate madeOnDate) {
|
||||||
final String resource,
|
this.apiOperation = StringUtils.defaultIfEmpty(apiOperation, null);
|
||||||
final Long resourceId,
|
this.resource = StringUtils.defaultIfEmpty(resource, null);
|
||||||
final AppUser maker,
|
this.resourceId = resourceId;
|
||||||
final LocalDate madeOnDate) {
|
this.maker = maker;
|
||||||
this.apiOperation = StringUtils.defaultIfEmpty(apiOperation, null);
|
this.madeOnDate = madeOnDate.toDate();
|
||||||
this.resource = StringUtils.defaultIfEmpty(resource, null);
|
}
|
||||||
this.resourceId = resourceId;
|
|
||||||
this.maker = maker;
|
|
||||||
this.madeOnDate = madeOnDate.toDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markAsChecked(final AppUser checker, final LocalDate checkedOnDate) {
|
public CommandSource copy() {
|
||||||
this.checker = checker;
|
LocalDate madeOnLocalDate = null;
|
||||||
this.checkedOnDate = checkedOnDate.toDate();
|
if (this.madeOnDate != null) {
|
||||||
}
|
madeOnLocalDate = new LocalDate(this.madeOnDate);
|
||||||
|
}
|
||||||
public void updateResourceId(final Long resourceId) {
|
return new CommandSource(this.apiOperation, this.resource, this.resourceId, this.maker, madeOnLocalDate);
|
||||||
this.resourceId = resourceId;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void updateJsonTo(final String json) {
|
|
||||||
this.commandAsJson = json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long resourceId() {
|
|
||||||
return this.resourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String json() {
|
public void markAsChecked(final AppUser checker, final LocalDate checkedOnDate) {
|
||||||
return this.commandAsJson;
|
this.checker = checker;
|
||||||
}
|
this.checkedOnDate = checkedOnDate.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isClientResource() {
|
public void updateResourceId(final Long resourceId) {
|
||||||
return this.resource.equalsIgnoreCase("CLIENTS");
|
this.resourceId = resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCreate() {
|
public void updateJsonTo(final String json) {
|
||||||
return this.apiOperation.equalsIgnoreCase("CREATE");
|
this.commandAsJson = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdate() {
|
public Long resourceId() {
|
||||||
return this.apiOperation.equalsIgnoreCase("UPDATE") && this.resourceId != null;
|
return this.resourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDelete() {
|
public String json() {
|
||||||
return this.apiOperation.equalsIgnoreCase("DELETE") && this.resourceId != null;
|
return this.commandAsJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String commandName() {
|
||||||
|
return this.apiOperation + '-' + this.resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String resourceName() {
|
||||||
|
return this.resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String operation() {
|
||||||
|
return this.apiOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isClientResource() {
|
||||||
|
return this.resource.equalsIgnoreCase("CLIENTS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCreate() {
|
||||||
|
return this.apiOperation.equalsIgnoreCase("CREATE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUpdate() {
|
||||||
|
return this.apiOperation.equalsIgnoreCase("UPDATE") && this.resourceId != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDelete() {
|
||||||
|
return this.apiOperation.equalsIgnoreCase("DELETE") && this.resourceId != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
public interface ChangeDetectionService {
|
||||||
|
|
||||||
|
String detectChanges(String operation, String resourceName, Long resourceId, String commandSerializedAsJson);
|
||||||
|
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
import org.mifosng.platform.api.commands.ClientCommand;
|
||||||
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
|
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||||
|
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||||
|
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ChangeDetectionServiceJdbc implements ChangeDetectionService {
|
||||||
|
|
||||||
|
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||||
|
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
private final ClientReadPlatformService clientReadPlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ChangeDetectionServiceJdbc(final PortfolioApiDataConversionService apiDataConversionService,
|
||||||
|
final PortfolioApiJsonSerializerService apiJsonSerializerService, final ClientReadPlatformService clientReadPlatformService) {
|
||||||
|
this.apiDataConversionService = apiDataConversionService;
|
||||||
|
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||||
|
this.clientReadPlatformService = clientReadPlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String detectChanges(final String operation, final String resourceName, final Long resourceId,
|
||||||
|
final String commandSerializedAsJson) {
|
||||||
|
|
||||||
|
String changesOnlyJson = "";
|
||||||
|
|
||||||
|
// FIXME - KW/JW - this change detection code for update of clients
|
||||||
|
// using ClientCommand can re placed when more suitable sql version is
|
||||||
|
// implemented.
|
||||||
|
final ClientData originalClient = this.clientReadPlatformService.retrieveIndividualClient(resourceId);
|
||||||
|
final ClientData changedClient = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(resourceId,
|
||||||
|
commandSerializedAsJson);
|
||||||
|
|
||||||
|
final String baseJson = this.apiJsonSerializerService.serializeClientDataToJson(originalClient);
|
||||||
|
final String workingJson = this.apiJsonSerializerService.serializeClientDataToJson(changedClient);
|
||||||
|
final ClientCommand changesOnly = this.apiDataConversionService.detectChanges(resourceId, baseJson, workingJson);
|
||||||
|
|
||||||
|
changesOnlyJson = this.apiJsonSerializerService.serializeClientCommandToJson(changesOnly);
|
||||||
|
|
||||||
|
return changesOnlyJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+113
@@ -0,0 +1,113 @@
|
|||||||
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
import org.joda.time.LocalDate;
|
||||||
|
import org.mifosng.platform.api.commands.ClientCommand;
|
||||||
|
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||||
|
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||||
|
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||||
|
import org.mifosng.platform.client.service.ClientWritePlatformService;
|
||||||
|
import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
||||||
|
import org.mifosng.platform.makerchecker.domain.CommandSource;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
|
import org.mifosng.platform.user.domain.AppUser;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ClientCommandHandler implements CommandSourceHandler {
|
||||||
|
|
||||||
|
private final PlatformSecurityContext context;
|
||||||
|
private final ChangeDetectionService changeDetectionService;
|
||||||
|
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||||
|
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
private final ClientWritePlatformService clientWritePlatformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public ClientCommandHandler(final PlatformSecurityContext context, final ChangeDetectionService changeDetectionService,
|
||||||
|
final PortfolioApiDataConversionService apiDataConversionService,
|
||||||
|
final PortfolioApiJsonSerializerService apiJsonSerializerService, final ClientWritePlatformService clientWritePlatformService) {
|
||||||
|
this.context = context;
|
||||||
|
this.changeDetectionService = changeDetectionService;
|
||||||
|
this.apiDataConversionService = apiDataConversionService;
|
||||||
|
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||||
|
this.clientWritePlatformService = clientWritePlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandSource handle(final CommandSource commandSource, final String apiRequestBodyInJson) {
|
||||||
|
|
||||||
|
final AppUser maker = context.authenticatedUser();
|
||||||
|
final LocalDate asToday = new LocalDate();
|
||||||
|
|
||||||
|
CommandSource commandSourceResult = commandSource.copy();
|
||||||
|
|
||||||
|
final Long resourceId = commandSource.resourceId();
|
||||||
|
Long newResourceId = null;
|
||||||
|
|
||||||
|
final ClientCommand command = this.apiDataConversionService.convertApiRequestJsonToClientCommand(resourceId, apiRequestBodyInJson);
|
||||||
|
final String commandSerializedAsJson = this.apiJsonSerializerService.serializeClientCommandToJson(command);
|
||||||
|
commandSourceResult.updateJsonTo(commandSerializedAsJson);
|
||||||
|
|
||||||
|
if (commandSource.isCreate()) {
|
||||||
|
try {
|
||||||
|
newResourceId = this.clientWritePlatformService.createClient(command);
|
||||||
|
commandSourceResult.markAsChecked(maker, asToday);
|
||||||
|
commandSourceResult.updateResourceId(newResourceId);
|
||||||
|
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||||
|
// swallow this rollback transaction by design
|
||||||
|
}
|
||||||
|
} else if (commandSource.isUpdate()) {
|
||||||
|
try {
|
||||||
|
final String jsonOfChangesOnly = this.changeDetectionService.detectChanges(commandSource.operation(),
|
||||||
|
commandSource.resourceName(), commandSource.resourceId(), commandSerializedAsJson);
|
||||||
|
commandSourceResult.updateJsonTo(jsonOfChangesOnly);
|
||||||
|
|
||||||
|
final ClientCommand changesOnly = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(
|
||||||
|
commandSource.resourceId(), jsonOfChangesOnly, false);
|
||||||
|
|
||||||
|
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(changesOnly);
|
||||||
|
newResourceId = result.getEntityId();
|
||||||
|
|
||||||
|
commandSourceResult.markAsChecked(maker, asToday);
|
||||||
|
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||||
|
// swallow this rollback transaction by design
|
||||||
|
}
|
||||||
|
} else if (commandSource.isDelete()) {
|
||||||
|
try {
|
||||||
|
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
|
||||||
|
newResourceId = result.getEntityId();
|
||||||
|
commandSourceResult.markAsChecked(maker, asToday);
|
||||||
|
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
||||||
|
// swallow this rollback transaction by design
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return commandSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandSource handle(final CommandSource commandSourceResult) {
|
||||||
|
|
||||||
|
Long resourceId = null;
|
||||||
|
if (commandSourceResult.isClientResource()) {
|
||||||
|
final ClientCommand command = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(
|
||||||
|
commandSourceResult.resourceId(), commandSourceResult.json(), true);
|
||||||
|
|
||||||
|
if (commandSourceResult.isCreate()) {
|
||||||
|
resourceId = this.clientWritePlatformService.createClient(command);
|
||||||
|
} else if (commandSourceResult.isUpdate()) {
|
||||||
|
|
||||||
|
// TODO - is there a case for doing change detection at this
|
||||||
|
// point also?
|
||||||
|
|
||||||
|
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(command);
|
||||||
|
resourceId = result.getEntityId();
|
||||||
|
} else if (commandSourceResult.isDelete()) {
|
||||||
|
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
|
||||||
|
resourceId = result.getEntityId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commandSourceResult.updateResourceId(resourceId);
|
||||||
|
|
||||||
|
return commandSourceResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
public interface CommandSourceHandler {
|
||||||
|
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
|
import org.mifosng.platform.infrastructure.errorhandling.UnsupportedCommandException;
|
||||||
|
import org.mifosng.platform.makerchecker.domain.CommandSource;
|
||||||
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class to delegate handling of commands to appropriate handler.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CommandSourceHandlerDelegator {
|
||||||
|
|
||||||
|
private final PlatformSecurityContext context;
|
||||||
|
private final ClientCommandHandler clientCommandHandler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CommandSourceHandlerDelegator(final PlatformSecurityContext context, final ClientCommandHandler clientCommandHandler) {
|
||||||
|
this.context = context;
|
||||||
|
this.clientCommandHandler = clientCommandHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandSource handle(final CommandSource commandSource, final String apiRequestBodyInJson) {
|
||||||
|
|
||||||
|
context.authenticatedUser();
|
||||||
|
CommandSource commandSourceResult = null;
|
||||||
|
if (commandSource.isClientResource()) {
|
||||||
|
commandSourceResult = clientCommandHandler.handle(commandSource, apiRequestBodyInJson);
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedCommandException(commandSource.commandName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return commandSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandSource handleExistingCommand(final CommandSource commandSource) {
|
||||||
|
|
||||||
|
CommandSource commandSourceResult = null;
|
||||||
|
if (commandSource.isClientResource()) {
|
||||||
|
commandSourceResult = clientCommandHandler.handle(commandSource);
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedCommandException(commandSource.commandName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return commandSourceResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
-125
@@ -1,14 +1,7 @@
|
|||||||
package org.mifosng.platform.makerchecker.service;
|
package org.mifosng.platform.makerchecker.service;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosng.platform.api.commands.ClientCommand;
|
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
|
||||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
|
||||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
|
||||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
|
||||||
import org.mifosng.platform.client.service.ClientWritePlatformService;
|
|
||||||
import org.mifosng.platform.client.service.RollbackTransactionAsCommandIsNotApprovedByCheckerException;
|
|
||||||
import org.mifosng.platform.makerchecker.domain.CommandSource;
|
import org.mifosng.platform.makerchecker.domain.CommandSource;
|
||||||
import org.mifosng.platform.makerchecker.domain.CommandSourceRepository;
|
import org.mifosng.platform.makerchecker.domain.CommandSourceRepository;
|
||||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||||
@@ -20,128 +13,58 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
public class PortfolioCommandSourceWriteServiceImpl implements PortfolioCommandSourceWritePlatformService {
|
public class PortfolioCommandSourceWriteServiceImpl implements PortfolioCommandSourceWritePlatformService {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final CommandSourceRepository commandSourceRepository;
|
private final CommandSourceRepository commandSourceRepository;
|
||||||
private final PortfolioApiDataConversionService apiDataConversionService;
|
private final CommandSourceHandlerDelegator commandSourceHandlerDelegator;
|
||||||
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
|
||||||
private final ClientWritePlatformService clientWritePlatformService;
|
|
||||||
private final ClientReadPlatformService clientReadPlatformService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public PortfolioCommandSourceWriteServiceImpl(final PlatformSecurityContext context, final CommandSourceRepository makerCheckerRepository,
|
public PortfolioCommandSourceWriteServiceImpl(final PlatformSecurityContext context,
|
||||||
final PortfolioApiDataConversionService apiDataConversionService,
|
final CommandSourceRepository makerCheckerRepository,
|
||||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
final CommandSourceHandlerDelegator commandSourceHandlerDelegator) {
|
||||||
final ClientWritePlatformService clientWritePlatformService,
|
this.context = context;
|
||||||
final ClientReadPlatformService clientReadPlatformService) {
|
this.commandSourceRepository = makerCheckerRepository;
|
||||||
this.context = context;
|
this.commandSourceHandlerDelegator = commandSourceHandlerDelegator;
|
||||||
this.commandSourceRepository = makerCheckerRepository;
|
}
|
||||||
this.apiDataConversionService = apiDataConversionService;
|
|
||||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
|
||||||
this.clientWritePlatformService = clientWritePlatformService;
|
|
||||||
this.clientReadPlatformService = clientReadPlatformService;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOT TRANSACTIONAL BY DESIGN FOR NOW
|
// NOT TRANSACTIONAL BY DESIGN FOR NOW
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier logCommandSource(final String apiOperation, final String resource, final Long resourceId, final String jsonRequestBody) {
|
public EntityIdentifier logCommandSource(final String apiOperation, final String resource, final Long resourceId,
|
||||||
|
final String apiRequestBodyInJson) {
|
||||||
final AppUser maker = context.authenticatedUser();
|
|
||||||
|
|
||||||
final LocalDate asToday = new LocalDate();
|
|
||||||
|
|
||||||
final CommandSource commandSource = CommandSource.createdBy(apiOperation, resource, resourceId, maker, asToday);
|
|
||||||
|
|
||||||
Long newResourceId = null;
|
|
||||||
if (commandSource.isClientResource()) {
|
|
||||||
|
|
||||||
// translate incoming api request json into java object catering for local and dateFormat parts of api
|
|
||||||
final ClientCommand command = this.apiDataConversionService.convertApiRequestJsonToClientCommand(resourceId, jsonRequestBody);
|
|
||||||
// produce serialized json of internal java object representation for persistence.
|
|
||||||
final String internalCommandSerializedAsJson = this.apiJsonSerializerService.serializeClientCommandToJson(command);
|
|
||||||
commandSource.updateJsonTo(internalCommandSerializedAsJson);
|
|
||||||
|
|
||||||
if (commandSource.isCreate()) {
|
|
||||||
try {
|
|
||||||
newResourceId = this.clientWritePlatformService.createClient(command);
|
|
||||||
commandSource.markAsChecked(maker, asToday);
|
|
||||||
commandSource.updateResourceId(newResourceId);
|
|
||||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
|
||||||
// swallow this rollback transaction by design
|
|
||||||
}
|
|
||||||
} else if (commandSource.isUpdate()) {
|
|
||||||
try {
|
|
||||||
// useful to employ change detection on update scenario to only store what details have changed
|
|
||||||
final ClientData originalClient = this.clientReadPlatformService.retrieveIndividualClient(resourceId);
|
|
||||||
final ClientData changedClient = this.apiDataConversionService.convertInternalJsonFormatToClientDataChange(resourceId, internalCommandSerializedAsJson);
|
|
||||||
|
|
||||||
final String baseJson = this.apiJsonSerializerService.serializeClientDataToJson(originalClient);
|
final AppUser maker = context.authenticatedUser();
|
||||||
final String workingJson = this.apiJsonSerializerService.serializeClientDataToJson(changedClient);
|
final LocalDate asToday = new LocalDate();
|
||||||
final ClientCommand changesOnly = this.apiDataConversionService.detectChanges(resourceId, baseJson, workingJson);
|
|
||||||
|
|
||||||
final String changesOnlyJson = this.apiJsonSerializerService.serializeClientCommandToJson(changesOnly);
|
final CommandSource commandSourceInput = CommandSource.createdBy(apiOperation, resource, resourceId, maker, asToday);
|
||||||
commandSource.updateJsonTo(changesOnlyJson);
|
final CommandSource commandSourceResult = this.commandSourceHandlerDelegator.handle(commandSourceInput, apiRequestBodyInJson);
|
||||||
|
commandSourceRepository.save(commandSourceResult);
|
||||||
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(changesOnly);
|
|
||||||
newResourceId = result.getEntityId();
|
|
||||||
|
|
||||||
commandSource.markAsChecked(maker, asToday);
|
|
||||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
|
||||||
// swallow this rollback transaction by design
|
|
||||||
}
|
|
||||||
} else if (commandSource.isDelete()) {
|
|
||||||
try {
|
|
||||||
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
|
|
||||||
newResourceId = result.getEntityId();
|
|
||||||
commandSource.markAsChecked(maker, asToday);
|
|
||||||
} catch (RollbackTransactionAsCommandIsNotApprovedByCheckerException e) {
|
|
||||||
// swallow this rollback transaction by design
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
commandSourceRepository.save(commandSource);
|
|
||||||
|
|
||||||
return EntityIdentifier.makerChecker(newResourceId, commandSource.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
return EntityIdentifier.makerChecker(commandSourceResult.resourceId(), commandSourceResult.getId());
|
||||||
@Override
|
}
|
||||||
public EntityIdentifier approveEntry(final Long id) {
|
|
||||||
|
|
||||||
final AppUser checker = context.authenticatedUser();
|
|
||||||
|
|
||||||
final CommandSource entity = this.commandSourceRepository.findOne(id);
|
|
||||||
entity.markAsChecked(checker, new LocalDate());
|
|
||||||
|
|
||||||
Long resourceId = null;
|
|
||||||
if (entity.isClientResource()) {
|
|
||||||
final ClientCommand command = this.apiDataConversionService.convertInternalJsonFormatToClientCommand(entity.resourceId(), entity.json(), true);
|
|
||||||
if (entity.isCreate()) {
|
|
||||||
resourceId = this.clientWritePlatformService.createClient(command);
|
|
||||||
} else if (entity.isUpdate()) {
|
|
||||||
EntityIdentifier result = this.clientWritePlatformService.updateClientDetails(command);
|
|
||||||
resourceId = result.getEntityId();
|
|
||||||
} else if (entity.isDelete()) {
|
|
||||||
EntityIdentifier result = this.clientWritePlatformService.deleteClient(command);
|
|
||||||
resourceId = result.getEntityId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.updateResourceId(resourceId);
|
|
||||||
|
|
||||||
commandSourceRepository.save(entity);
|
|
||||||
|
|
||||||
return EntityIdentifier.makerChecker(resourceId, entity.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public Long deleteEntry(final Long makerCheckerId) {
|
public EntityIdentifier approveEntry(final Long id) {
|
||||||
|
|
||||||
context.authenticatedUser();
|
final AppUser checker = context.authenticatedUser();
|
||||||
|
|
||||||
this.commandSourceRepository.delete(makerCheckerId);
|
final CommandSource commandSourceInput = this.commandSourceRepository.findOne(id);
|
||||||
|
commandSourceInput.markAsChecked(checker, new LocalDate());
|
||||||
return makerCheckerId;
|
|
||||||
}
|
final CommandSource commandSourceResult = this.commandSourceHandlerDelegator.handleExistingCommand(commandSourceInput);
|
||||||
|
|
||||||
|
commandSourceRepository.save(commandSourceResult);
|
||||||
|
|
||||||
|
return EntityIdentifier.makerChecker(commandSourceResult.resourceId(), commandSourceResult.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public Long deleteEntry(final Long makerCheckerId) {
|
||||||
|
|
||||||
|
context.authenticatedUser();
|
||||||
|
|
||||||
|
this.commandSourceRepository.delete(makerCheckerId);
|
||||||
|
|
||||||
|
return makerCheckerId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user