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 TypeMethodDescriptionvoid
addGlobalValidationError
(String errorOrErrorKey) Adds a validation error to this entity that is not tied to any specific property.void
addGlobalValidationErrors
(List<String> errorOrErrorKeys) Similar toaddGlobalValidationError(String)
except with a list of errorsvoid
addProperty
(Property property) void
addValidationError
(String fieldName, String errorOrErrorKey) Adds a single validation error to this entity.boolean
findProperty
(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.int
hashCode()
boolean
isDirty()
boolean
boolean
isPreAdd()
boolean
void
mergeProperties
(String prefix, Entity entity) void
overridePropertyValues
(Entity entity) Replaces all property values in this entity with the values from the given entity.removeProperty
(String name) void
void
setDeleted
(Boolean deleted) void
setDeployDate
(Date deployDate) void
setDirty
(boolean dirty) void
setGlobalValidationErrors
(List<String> globalValidationErrors) void
setInactive
(Boolean inactive) void
setIsPreAdd
(boolean isPreAdd) void
setMultiPartAvailableOnThread
(boolean multiPartAvailableOnThread) void
setProperties
(Property[] properties) void
setPropertyValidationErrors
(Map<String, List<String>> validationErrors) Completely reset the validation errors for this Entity.void
void
setValidationErrors
(Map<String, List<String>> validationErrors) Deprecated.usesetPropertyValidationErrors(Map)
insteadvoid
setValidationFailure
(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