Class ChangedNowValidationService

java.lang.Object
org.cxbox.core.service.ChangedNowValidationService

@Service public class ChangedNowValidationService extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.cxbox.api.data.dto.DataResponseDTO.ChangedNowParam
    buildCnangedNowParam(HashSet<String> changedNowKeys, org.cxbox.api.data.dto.DataResponseDTO changedNowDTO)
    This method builds a new CnangedNowParam
    boolean
    isChangedNowData(org.cxbox.api.data.dto.DataResponseDTO data)
    Checks whether the input data contains fields that have been changed in the current request.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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_NOW key and returns true if it exists and is not empty.

      Parameters:
      data - the input data from the frontend, which may contain changed fields
      Returns:
      true if there are changed fields under the CHANGED_NOW key; false otherwise
    • 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 type MultivalueField, 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 data
      requestDto - 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 changed
      changedNowDTO - the data transfer object containing detailed information about the changes
      Returns:
      a fully constructed CnangedNowParam instance encapsulating the change data