Class Entity

java.lang.Object
org.broadleafcommerce.openadmin.dto.Entity
All Implemented Interfaces:
Serializable

public class Entity extends Object implements Serializable
Generic DTO for a domain object. Each property of the domain object is represented by the 'properties' instance variable which allows for further display metadata to be stored.
Author:
jfischer
See Also:
  • Field Details

    • serialVersionUID

      protected static final long serialVersionUID
      See Also:
    • type

      protected String[] type
    • properties

      protected Property[] properties
    • isDirty

      protected boolean isDirty
    • deployDate

      protected Date deployDate
    • isDeleted

      protected Boolean isDeleted
    • isInactive

      protected Boolean isInactive
    • isActive

      protected Boolean isActive
    • multiPartAvailableOnThread

      protected boolean multiPartAvailableOnThread
    • isValidationFailure

      protected boolean isValidationFailure
    • isPreAdd

      protected boolean isPreAdd
    • validationErrors

      protected Map<String,List<String>> validationErrors
    • globalValidationErrors

      protected List<String> globalValidationErrors
    • pMap

      protected Map<String,Property> pMap
  • Constructor Details

    • Entity

      public Entity()
  • Method Details

    • getType

      public String[] getType()
    • setType

      public void setType(String[] type)
    • getPMap

      public Map<String,Property> getPMap()
    • getProperties

      public Property[] getProperties()
    • setProperties

      public void setProperties(Property[] properties)
    • mergeProperties

      public void mergeProperties(String prefix, Entity entity)
    • overridePropertyValues

      public void overridePropertyValues(Entity entity)
      Replaces all property values in this entity with the values from the given entity. This also resets the pMap
      Parameters:
      entity -
    • findProperty

      public Property findProperty(String name)
    • addProperty

      public void addProperty(Property property)
    • removeProperty

      public Property removeProperty(String name)
    • addValidationError

      public void addValidationError(String fieldName, String errorOrErrorKey)
      Adds a single validation error to this entity. This will also set the entire entity in an error state by invoking setValidationFailure(boolean).
      Parameters:
      fieldName - - the field that is in error. This works on top-level properties (like a 'manufacturer' field on a Product entity) but can also work on properties gleaned from a related entity (like 'defaultSku.weight.weightUnitOfMeasure' on a Product entity)
      errorOrErrorKey - - the error message to present to a user. Could be the actual error message or a key to a property in messages.properties to support different locales
    • isDirty

      public boolean isDirty()
    • setDirty

      public void setDirty(boolean dirty)
    • isMultiPartAvailableOnThread

      public boolean isMultiPartAvailableOnThread()
    • setMultiPartAvailableOnThread

      public void setMultiPartAvailableOnThread(boolean multiPartAvailableOnThread)
    • isValidationFailure

      public boolean isValidationFailure()
      Returns:
      if this entity has failed validation. This will also check the getPropertyValidationErrors() map and getGlobalValidationErrors() if this boolean has not been explicitly set
    • setValidationFailure

      public void setValidationFailure(boolean validationFailure)
    • isPreAdd

      public boolean isPreAdd()
    • setIsPreAdd

      public void setIsPreAdd(boolean isPreAdd)
    • getValidationErrors

      @Deprecated public Map<String,List<String>> getValidationErrors()
      Deprecated.
      Returns:
    • setValidationErrors

      @Deprecated public void setValidationErrors(Map<String,List<String>> validationErrors)
      Deprecated.
    • getPropertyValidationErrors

      public Map<String,List<String>> getPropertyValidationErrors()
      Validation error map where the key corresponds to the property that failed validation (which could be dot-separated) and the value corresponds to a list of the error messages, in the case of multiple errors on the same field.

      For instance, you might have a configuration where the field is both a Required validator and a regex validator. The validation map in this case might contain something like:

      defaultSku.name => ['This field is required', 'Cannot have numbers in name']

      Returns:
      a map keyed by property name to the list of error messages for that property
    • setPropertyValidationErrors

      public void setPropertyValidationErrors(Map<String,List<String>> validationErrors)
      Completely reset the validation errors for this Entity. In most cases it is more appropriate to use the convenience method for adding a single error via addValidationError(String, String). This will also set the entire entity in an error state by invoking setValidationFailure(boolean).
      Parameters:
      validationErrors -
      See Also:
    • addGlobalValidationError

      public void addGlobalValidationError(String errorOrErrorKey)
      Adds a validation error to this entity that is not tied to any specific property. If you need to tie this to a property then you should use addValidationError(String, String) instead.
      Parameters:
      errorOrErrorKey -
    • addGlobalValidationErrors

      public void addGlobalValidationErrors(List<String> errorOrErrorKeys)
      Similar to addGlobalValidationError(String) except with a list of errors
      Parameters:
      errorOrErrorKeys -
    • getGlobalValidationErrors

      public List<String> getGlobalValidationErrors()
    • setGlobalValidationErrors

      public void setGlobalValidationErrors(List<String> globalValidationErrors)
    • getActive

      public Boolean getActive()
    • setActive

      public void setActive(Boolean active)
    • getDeleted

      public Boolean getDeleted()
    • setDeleted

      public void setDeleted(Boolean deleted)
    • getInactive

      public Boolean getInactive()
    • setInactive

      public void setInactive(Boolean inactive)
    • getDeployDate

      public Date getDeployDate()
    • setDeployDate

      public void setDeployDate(Date deployDate)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object