eu.etaxonomy.cdm.model.common
Class CdmBase

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.CdmBase
All Implemented Interfaces:
ICdmBase, Serializable, Cloneable
Direct Known Subclasses:
CdmMetaData, GrantedAuthorityImpl, Group, LSIDAuthority, User, VersionableEntity, View

@MappedSuperclass
public abstract class CdmBase
extends Object
implements Serializable, ICdmBase, Cloneable

The base class for all CDM domain classes implementing UUIDs and bean property change event firing. It provides a globally unique UUID and keeps track of creation date and person. The UUID is the same for different versions (see VersionableEntity) of a CDM object, so a locally unique id exists in addition that allows to safely access and store several objects (=version) with the same UUID. This class together with the eu.etaxonomy.cdm.aspectj.PropertyChangeAspect will fire bean change events to all registered listeners. Listener registration and event firing is done with the help of the PropertyChangeSupport class.

Author:
m.doering
See Also:
Serialized Form

Field Summary
protected  UUID uuid
           
 
Constructor Summary
CdmBase()
          Class constructor assigning a unique UUID and creation date.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          see PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          see PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)
 Object clone()
           
protected  void clone(CdmBase clone)
           
static
<T extends CdmBase>
T
deproxy(Object object, Class<T> clazz)
          These methods are present due to HHH-1517 - that in a one-to-many relationship with a superclass at the "one" end, the proxy created by hibernate is the superclass, and not the subclass, resulting in a classcastexception when you try to cast it.
 boolean equals(Object obj)
          Is true if UUID is the same for the passed Object and this one.
 void firePropertyChange(PropertyChangeEvent evt)
           
 void firePropertyChange(String property, boolean oldval, boolean newval)
           
 void firePropertyChange(String property, float oldval, float newval)
           
 void firePropertyChange(String property, int oldval, int newval)
           
 void firePropertyChange(String property, Object oldval, Object newval)
           
 void firePropertyChange(String property, String oldval, String newval)
           
 org.joda.time.DateTime getCreated()
           
 User getCreatedBy()
           
 int getId()
          Returns local unique identifier for the concrete subclass
 UUID getUuid()
           
 int hashCode()
          Overrides Object.hashCode() See hibernate109, geocities or ibm for more information about equals and hashcode.
 boolean hasListeners(String propertyName)
           
 String instanceToString()
          This returns an String that identifies the cdm instacne well without being necessarily unique.
protected  void invokeSetMethod(Method method, Object object)
           
protected  void invokeSetMethodWithNull(Method method, Object object)
           
 boolean isInstanceOf(Class<? extends CdmBase> clazz)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
          see PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
 void setCreated(org.joda.time.DateTime created)
          Sets the timestamp this object was created.
 void setCreatedBy(User createdBy)
           
 void setId(int id)
          Assigns a unique local ID to this object.
 void setUuid(UUID uuid)
           
 String toString()
          Overrides Object.toString().
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

uuid

@NotNull
@Field(store=YES,
       index=YES,
       analyze=NO)
@FieldBridge(impl=UuidBridge.class)
protected UUID uuid
Constructor Detail

CdmBase

public CdmBase()
Class constructor assigning a unique UUID and creation date. UUID can be changed later via setUuid method.

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
see PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)

Parameters:
listener -

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
see PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
see PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)


removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
See Also:
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)

hasListeners

public boolean hasListeners(String propertyName)

firePropertyChange

public void firePropertyChange(String property,
                               String oldval,
                               String newval)

firePropertyChange

public void firePropertyChange(String property,
                               int oldval,
                               int newval)

firePropertyChange

public void firePropertyChange(String property,
                               float oldval,
                               float newval)

firePropertyChange

public void firePropertyChange(String property,
                               boolean oldval,
                               boolean newval)

firePropertyChange

public void firePropertyChange(String property,
                               Object oldval,
                               Object newval)

firePropertyChange

public void firePropertyChange(PropertyChangeEvent evt)

getUuid

public UUID getUuid()
Specified by:
getUuid in interface ICdmBase

setUuid

public void setUuid(UUID uuid)
Specified by:
setUuid in interface ICdmBase

getId

public int getId()
Description copied from interface: ICdmBase
Returns local unique identifier for the concrete subclass

Specified by:
getId in interface ICdmBase
Returns:

setId

public void setId(int id)
Description copied from interface: ICdmBase
Assigns a unique local ID to this object. Because of the EJB3 @Id and @GeneratedValue annotation this id will be set automatically by the persistence framework when object is saved.

Specified by:
setId in interface ICdmBase

getCreated

public org.joda.time.DateTime getCreated()
Specified by:
getCreated in interface ICdmBase

setCreated

public void setCreated(org.joda.time.DateTime created)
Description copied from interface: ICdmBase
Sets the timestamp this object was created. Most databases cannot store milliseconds, so they are removed by this method. Caution: We are planning to replace the Calendar class with a different datetime representation which is more suitable for hibernate see TRAC ticket

Specified by:
setCreated in interface ICdmBase

getCreatedBy

public User getCreatedBy()
Specified by:
getCreatedBy in interface ICdmBase

setCreatedBy

public void setCreatedBy(User createdBy)
Specified by:
setCreatedBy in interface ICdmBase

deproxy

public static <T extends CdmBase> T deproxy(Object object,
                                            Class<T> clazz)
                                 throws ClassCastException
These methods are present due to HHH-1517 - that in a one-to-many relationship with a superclass at the "one" end, the proxy created by hibernate is the superclass, and not the subclass, resulting in a classcastexception when you try to cast it. Hopefully this will be resolved through improvements with the creation of proxy objects by hibernate and the following methods will become redundant, but for the time being . . .

Type Parameters:
T -
Parameters:
object -
clazz -
Returns:
Throws:
ClassCastException

isInstanceOf

public boolean isInstanceOf(Class<? extends CdmBase> clazz)
                     throws ClassCastException
Throws:
ClassCastException

equals

public boolean equals(Object obj)
Is true if UUID is the same for the passed Object and this one.

Overrides:
equals in class Object
See Also:
See {@link http://www.hibernate.org/109.html hibernate109}, {@link http://www.geocities.com/technofundo/tech/java/equalhash.html geocities} or {@link http://www.ibm.com/developerworks/java/library/j-jtp05273.html ibm} for more information about equals and hashcode.

hashCode

public int hashCode()
Overrides Object.hashCode() See hibernate109, geocities or ibm for more information about equals and hashcode.

Overrides:
hashCode in class Object

toString

public String toString()
Overrides Object.toString(). This returns an String that identifies the object well without being necessarily unique. Internally the method is delegating the call to {link instanceToString().
Specification: This method should never call other object' methods so it can be well used for debugging without problems like lazy loading, unreal states etc.

Note: If overriding this method's javadoc always copy or link the above requirement. If not overwritten by a subclass method returns the class, id and uuid as a string for any CDM object.

For example: Taxon#13<b5938a98-c1de-4dda-b040-d5cc5bfb3bc0>

Overrides:
toString in class Object
See Also:
Object.toString()

instanceToString

public String instanceToString()
This returns an String that identifies the cdm instacne well without being necessarily unique. The string representation combines the class name the id and uuid.

For example: Taxon#13<b5938a98-c1de-4dda-b040-d5cc5bfb3bc0>

Returns:

invokeSetMethod

protected void invokeSetMethod(Method method,
                               Object object)

invokeSetMethodWithNull

protected void invokeSetMethodWithNull(Method method,
                                       Object object)

clone

protected void clone(CdmBase clone)

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2007-2013 EDIT. All Rights Reserved.