Package org.cxbox.core.service
Class ChangedNowValidationService
java.lang.Object
org.cxbox.core.service.ChangedNowValidationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.cxbox.api.data.dto.DataResponseDTO.ChangedNowParambuildCnangedNowParam(HashSet<String> changedNowKeys, org.cxbox.api.data.dto.DataResponseDTO changedNowDTO) This method builds a newCnangedNowParambooleanisChangedNowData(org.cxbox.api.data.dto.DataResponseDTO data) Checks whether the input data contains fields that have been changed in the current request.voidvalidateChangedNowFields(Map<String, ?> changedNow, org.cxbox.api.data.dto.DataResponseDTO changedNowDTO, org.cxbox.api.data.dto.DataResponseDTO requestDto) Checks whether the data received in the changedNow tag from the frontend matches the values in the data tag.
-
Constructor Details
-
ChangedNowValidationService
public ChangedNowValidationService()
-
-
Method Details
-
isChangedNowData
public boolean isChangedNowData(org.cxbox.api.data.dto.DataResponseDTO data) Checks whether the input data contains fields that have been changed in the current request.This method looks for a nested map under the
CHANGED_NOWkey and returnstrueif it exists and is not empty.- Parameters:
data- the input data from the frontend, which may contain changed fields- Returns:
trueif there are changed fields under theCHANGED_NOWkey;falseotherwise
-
validateChangedNowFields
public void validateChangedNowFields(Map<String, ?> changedNow, org.cxbox.api.data.dto.DataResponseDTO changedNowDTO, org.cxbox.api.data.dto.DataResponseDTO requestDto) Checks whether the data received in the changedNow tag from the frontend matches the values in the data tag.This method compares the values of each field by name. For standard objects, it uses
Objects.equals(Object, Object). For fields of typeMultivalueField, it verifies whether all values in the new object exist in the old object.If a mismatch is detected, an error is logged indicating the differing values. No exception is thrown to avoid interrupting the application flow.
- Parameters:
changedNow- a map containing the names of fields to check (values in the map are ignored)changedNowDTO- an object representing the "new" state of the datarequestDto- an object representing the "old" or original state of the data
-
buildCnangedNowParam
public org.cxbox.api.data.dto.DataResponseDTO.ChangedNowParam buildCnangedNowParam(HashSet<String> changedNowKeys, org.cxbox.api.data.dto.DataResponseDTO changedNowDTO) This method builds a new
CnangedNowParam- Parameters:
changedNowKeys- a set of keys that represent the fields or values that have been changedchangedNowDTO- the data transfer object containing detailed information about the changes- Returns:
- a fully constructed
CnangedNowParaminstance encapsulating the change data
-