Class Entity
java.lang.Object
org.broadleafcommerce.openadmin.dto.Entity
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalValidationError(String errorOrErrorKey) Adds a validation error to this entity that is not tied to any specific property.voidaddGlobalValidationErrors(List<String> errorOrErrorKeys) Similar toaddGlobalValidationError(String)except with a list of errorsvoidaddProperty(Property property) voidaddValidationError(String fieldName, String errorOrErrorKey) Adds a single validation error to this entity.booleanfindProperty(String name) getPMap()Property[]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.String[]getType()Deprecated.inthashCode()booleanisDirty()booleanbooleanisPreAdd()booleanvoidmergeProperties(String prefix, Entity entity) voidoverridePropertyValues(Entity entity) Replaces all property values in this entity with the values from the given entity.removeProperty(String name) voidvoidsetDeleted(Boolean deleted) voidsetDeployDate(Date deployDate) voidsetDirty(boolean dirty) voidsetGlobalValidationErrors(List<String> globalValidationErrors) voidsetInactive(Boolean inactive) voidsetIsPreAdd(boolean isPreAdd) voidsetMultiPartAvailableOnThread(boolean multiPartAvailableOnThread) voidsetProperties(Property[] properties) voidsetPropertyValidationErrors(Map<String, List<String>> validationErrors) Completely reset the validation errors for this Entity.voidvoidsetValidationErrors(Map<String, List<String>> validationErrors) Deprecated.usesetPropertyValidationErrors(Map)insteadvoidsetValidationFailure(boolean validationFailure) toString()
-
Field Details
-
serialVersionUID
protected static final long serialVersionUID- See Also:
-
type
-
properties
-
isDirty
protected boolean isDirty -
deployDate
-
isDeleted
-
isInactive
-
isActive
-
multiPartAvailableOnThread
protected boolean multiPartAvailableOnThread -
isValidationFailure
protected boolean isValidationFailure -
isPreAdd
protected boolean isPreAdd -
validationErrors
-
globalValidationErrors
-
pMap
-
-
Constructor Details
-
Entity
public Entity()
-
-
Method Details
-
getType
-
setType
-
getPMap
-
getProperties
-
setProperties
-
mergeProperties
-
overridePropertyValues
Replaces all property values in this entity with the values from the given entity. This also resets thepMap- Parameters:
entity-
-
findProperty
-
addProperty
-
removeProperty
-
addValidationError
Adds a single validation error to this entity. This will also set the entire entity in an error state by invokingsetValidationFailure(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 andgetGlobalValidationErrors()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.usegetPropertyValidationErrors()instead- Returns:
-
setValidationErrors
Deprecated.usesetPropertyValidationErrors(Map)instead -
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
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 viaaddValidationError(String, String). This will also set the entire entity in an error state by invokingsetValidationFailure(boolean).- Parameters:
validationErrors-- See Also:
-
addGlobalValidationError
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 useaddValidationError(String, String)instead.- Parameters:
errorOrErrorKey-
-
addGlobalValidationErrors
Similar toaddGlobalValidationError(String)except with a list of errors- Parameters:
errorOrErrorKeys-
-
getGlobalValidationErrors
-
setGlobalValidationErrors
-
getActive
-
setActive
-
getDeleted
-
setDeleted
-
getInactive
-
setInactive
-
getDeployDate
-
setDeployDate
-
toString
-
equals
-
hashCode
public int hashCode()
-
getPropertyValidationErrors()instead