org.broadleafcommerce.openadmin.dto
Class Entity

java.lang.Object
  extended by 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:
Property}, Serialized Form

Field Summary
protected  Boolean isActive
           
protected  Boolean isDeleted
           
protected  boolean isDirty
           
protected  Boolean isInactive
           
protected  Boolean isLocked
           
protected  boolean isValidationFailure
           
protected  String lockedBy
           
protected  String lockedDate
           
protected  boolean multiPartAvailableOnThread
           
protected  Map<String,Property> pMap
           
protected  Property[] properties
           
protected static long serialVersionUID
           
protected  String[] type
           
protected  Map<String,List<String>> validationErrors
           
 
Constructor Summary
Entity()
           
 
Method Summary
 void addProperty(Property property)
           
 void addValidationError(String fieldName, String errorOrErrorKey)
          Adds a single validation error to this entity.
 boolean equals(Object o)
           
 Property findProperty(String name)
           
 Boolean getActive()
           
 Boolean getDeleted()
           
 Boolean getInactive()
           
 Boolean getLocked()
           
 String getLockedBy()
           
 String getLockedDate()
           
 Map<String,Property> getPMap()
           
 Property[] getProperties()
           
 String[] getType()
           
 Map<String,List<String>> getValidationErrors()
          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.
 int hashCode()
           
 boolean isDirty()
           
 boolean isMultiPartAvailableOnThread()
           
 boolean isValidationFailure()
           
 void mergeProperties(String prefix, Entity entity)
           
 void overridePropertyValues(Entity entity)
          Replaces all property values in this entity with the values from the given entity.
 void setActive(Boolean active)
           
 void setDeleted(Boolean deleted)
           
 void setDirty(boolean dirty)
           
 void setInactive(Boolean inactive)
           
 void setLocked(Boolean locked)
           
 void setLockedBy(String lockedBy)
           
 void setLockedDate(String lockedDate)
           
 void setMultiPartAvailableOnThread(boolean multiPartAvailableOnThread)
           
 void setProperties(Property[] properties)
           
 void setType(String[] type)
           
 void setValidationErrors(Map<String,List<String>> validationErrors)
          Completely reset the validation errors for this Entity.
 void setValidationFailure(boolean validationFailure)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
See Also:
Constant Field Values

type

protected String[] type

properties

protected Property[] properties

isDirty

protected boolean isDirty

isDeleted

protected Boolean isDeleted

isInactive

protected Boolean isInactive

isActive

protected Boolean isActive

isLocked

protected Boolean isLocked

lockedBy

protected String lockedBy

lockedDate

protected String lockedDate

multiPartAvailableOnThread

protected boolean multiPartAvailableOnThread

isValidationFailure

protected boolean isValidationFailure

validationErrors

protected Map<String,List<String>> validationErrors

pMap

protected Map<String,Property> pMap
Constructor Detail

Entity

public Entity()
Method Detail

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)

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()

setValidationFailure

public void setValidationFailure(boolean validationFailure)

getValidationErrors

public Map<String,List<String>> getValidationErrors()
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

setValidationErrors

public void setValidationErrors(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:
addValidationError(String, String)

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)

getLocked

public Boolean getLocked()

setLocked

public void setLocked(Boolean locked)

getLockedBy

public String getLockedBy()

setLockedBy

public void setLockedBy(String lockedBy)

getLockedDate

public String getLockedDate()

setLockedDate

public void setLockedDate(String lockedDate)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013. All Rights Reserved.