eu.etaxonomy.cdm.model.common
Class IdentifiableEntity<S extends IIdentifiableEntityCacheStrategy>

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.CdmBase
      extended by eu.etaxonomy.cdm.model.common.VersionableEntity
          extended by eu.etaxonomy.cdm.model.common.AnnotatableEntity
              extended by eu.etaxonomy.cdm.model.common.IdentifiableEntity<S>
All Implemented Interfaces:
IAnnotatableEntity, ICdmBase, IIdentifiableEntity, ISourceable<IdentifiableSource>, IVersionableEntity, Serializable, Cloneable
Direct Known Subclasses:
Classification, DescriptionBase, IdentifiableMediaEntity, Media, PolytomousKey, Sequence, TaxonBase, TaxonNameBase, TermBase

@MappedSuperclass
public abstract class IdentifiableEntity<S extends IIdentifiableEntityCacheStrategy>
extends AnnotatableEntity
implements IIdentifiableEntity

Superclass for the primary CDM classes that can be referenced from outside via LSIDs and contain a simple generated title string as a label for human reading. All subclasses inherit the ability to store additional properties that are stored as Extensions, basically a string value with a type term. Any number of right statements can be attached as well as multiple OriginalSourceBase objects. Original sources carry a reference to the source, an ID within that source and the original title/label of this object as it was used in that source (originalNameString). A Taxon for example that was taken from 2 sources like FaunaEuropaea and IPNI would have two originalSource objects. The originalSource representing that taxon as it was found in IPNI would contain IPNI as the reference, the IPNI id of the taxon and the name of the taxon exactly as it was used in IPNI.

Version:
1.0
Author:
m.doering
See Also:
Serialized Form

Field Summary
protected  S cacheStrategy
           
static boolean NOT_PROTECTED
           
static boolean PROTECTED
           
protected  boolean protectedTitleCache
           
protected  String titleCache
           
 
Fields inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
annotations, markers
 
Fields inherited from class eu.etaxonomy.cdm.model.common.CdmBase
uuid
 
Constructor Summary
protected IdentifiableEntity()
           
 
Method Summary
 void addCredit(Credit credit)
           
 void addCredit(Credit credit, int index)
           
 void addExtension(Extension extension)
           
 void addExtension(String value, ExtensionType extensionType)
           
 void addRights(Rights right)
           
 void addSource(IdentifiableSource source)
          Adds a source to this object
 IdentifiableSource addSource(String id, String idNamespace, Reference citation, String microCitation)
          Adds a source that is newly created by its components.
 Object clone()
          Clones this versionable entity.
 int compareTo(IdentifiableEntity identifiableEntity)
           
 String generateTitle()
           
 S getCacheStrategy()
          Returns the cache strategy used to generate several strings corresponding to this identifiable entity (in particular taxon name caches and author strings).
 List<Credit> getCredits()
           
 Credit getCredits(Integer index)
           
 byte[] getData()
          By default, we expect most cdm objects to be abstract things i.e.
 Set<Extension> getExtensions()
           
 Set<String> getExtensions(ExtensionType type)
           
 Set<String> getExtensions(UUID extensionTypeUuid)
           
 LSID getLsid()
           
 Set<Rights> getRights()
           
 Set<IdentifiableSource> getSources()
          Returns the set of original sources (citations) for this sourceable object
 String getTitleCache()
           
protected  String getTruncatedCache(String cache)
           
protected  void initListener()
           
 boolean isProtectedTitleCache()
           
protected  boolean regenerateTitleCache()
          The titleCache will be regenerated from scratch if not protected
 void removeCredit(Credit credit)
           
 void removeCredit(int index)
           
 void removeExtension(Extension extension)
           
 void removeRights(Rights right)
           
 void removeSource(IdentifiableSource source)
          Removes a source from this object
 void setCacheStrategy(S cacheStrategy)
           
 void setLsid(LSID lsid)
           
 void setProtectedTitleCache(boolean protectedTitleCache)
           
 void setTitleCache(String titleCache)
          Sets the title cache without changing the protectCache flag
 void setTitleCache(String titleCache, boolean protectCache)
           
 String toString()
          Overrides Object.toString().
 
Methods inherited from class eu.etaxonomy.cdm.model.common.AnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, hasMarker, hasMarker, removeAnnotation, removeMarker
 
Methods inherited from class eu.etaxonomy.cdm.model.common.VersionableEntity
equals, getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from class eu.etaxonomy.cdm.model.common.CdmBase
addPropertyChangeListener, addPropertyChangeListener, clone, deproxy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCreated, getCreatedBy, getId, getUuid, hashCode, hasListeners, instanceToString, invokeSetMethod, invokeSetMethodWithNull, isInstanceOf, removePropertyChangeListener, removePropertyChangeListener, setCreated, setCreatedBy, setId, setUuid
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.IAnnotatableEntity
addAnnotation, addMarker, getAnnotations, getMarkers, hasMarker, hasMarker, removeAnnotation, removeMarker
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.IVersionableEntity
getUpdated, getUpdatedBy, setUpdated, setUpdatedBy
 
Methods inherited from interface eu.etaxonomy.cdm.model.common.ICdmBase
getCreated, getCreatedBy, getId, getUuid, setCreated, setCreatedBy, setId, setUuid
 

Field Detail

PROTECTED

public static final boolean PROTECTED
See Also:
Constant Field Values

NOT_PROTECTED

public static final boolean NOT_PROTECTED
See Also:
Constant Field Values

titleCache

@NotEmpty(groups=Level2.class)
@Size(max=255)
@Fields(value={@Field(store=YES),@Field(name="titleCache__sort",analyze=NO,store=YES)})
@FieldBridge(impl=StripHtmlBridge.class)
protected String titleCache

protectedTitleCache

protected boolean protectedTitleCache

cacheStrategy

protected S extends IIdentifiableEntityCacheStrategy cacheStrategy
Constructor Detail

IdentifiableEntity

protected IdentifiableEntity()
Method Detail

initListener

protected void initListener()

getData

public byte[] getData()
By default, we expect most cdm objects to be abstract things i.e. unable to return a data representation. Specific subclasses (e.g. Sequence) can override if necessary.

Specified by:
getData in interface IIdentifiableEntity

getTitleCache

public String getTitleCache()
Specified by:
getTitleCache in interface IIdentifiableEntity

regenerateTitleCache

protected boolean regenerateTitleCache()
The titleCache will be regenerated from scratch if not protected

Returns:
true if title cache was regenerated, false otherwise

setTitleCache

public void setTitleCache(String titleCache)
Description copied from interface: IIdentifiableEntity
Sets the title cache without changing the protectCache flag

Specified by:
setTitleCache in interface IIdentifiableEntity
See Also:
IIdentifiableEntity.setTitleCache(String, boolean)

setTitleCache

public void setTitleCache(String titleCache,
                          boolean protectCache)
Specified by:
setTitleCache in interface IIdentifiableEntity

getTruncatedCache

protected String getTruncatedCache(String cache)
Parameters:
cache -
Returns:

getLsid

public LSID getLsid()
Specified by:
getLsid in interface IIdentifiableEntity

setLsid

public void setLsid(LSID lsid)
Specified by:
setLsid in interface IIdentifiableEntity

getRights

public Set<Rights> getRights()
Specified by:
getRights in interface IIdentifiableEntity

addRights

public void addRights(Rights right)
Specified by:
addRights in interface IIdentifiableEntity

removeRights

public void removeRights(Rights right)
Specified by:
removeRights in interface IIdentifiableEntity

getCredits

public List<Credit> getCredits()
Specified by:
getCredits in interface IIdentifiableEntity

getCredits

public Credit getCredits(Integer index)
Specified by:
getCredits in interface IIdentifiableEntity

addCredit

public void addCredit(Credit credit)
Specified by:
addCredit in interface IIdentifiableEntity

addCredit

public void addCredit(Credit credit,
                      int index)
Specified by:
addCredit in interface IIdentifiableEntity

removeCredit

public void removeCredit(Credit credit)
Specified by:
removeCredit in interface IIdentifiableEntity

removeCredit

public void removeCredit(int index)
Specified by:
removeCredit in interface IIdentifiableEntity

getExtensions

public Set<Extension> getExtensions()
Specified by:
getExtensions in interface IIdentifiableEntity

getExtensions

public Set<String> getExtensions(ExtensionType type)
Parameters:
type -
Returns:
a Set of extension value strings

getExtensions

public Set<String> getExtensions(UUID extensionTypeUuid)
Parameters:
extensionTypeUuid -
Returns:
a Set of extension value strings

addExtension

public void addExtension(String value,
                         ExtensionType extensionType)

addExtension

public void addExtension(Extension extension)
Specified by:
addExtension in interface IIdentifiableEntity

removeExtension

public void removeExtension(Extension extension)
Specified by:
removeExtension in interface IIdentifiableEntity

isProtectedTitleCache

public boolean isProtectedTitleCache()
Specified by:
isProtectedTitleCache in interface IIdentifiableEntity

setProtectedTitleCache

public void setProtectedTitleCache(boolean protectedTitleCache)
Specified by:
setProtectedTitleCache in interface IIdentifiableEntity

getSources

public Set<IdentifiableSource> getSources()
Description copied from interface: ISourceable
Returns the set of original sources (citations) for this sourceable object

Specified by:
getSources in interface ISourceable<IdentifiableSource>
Returns:

addSource

public void addSource(IdentifiableSource source)
Description copied from interface: ISourceable
Adds a source to this object

Specified by:
addSource in interface ISourceable<IdentifiableSource>

addSource

public IdentifiableSource addSource(String id,
                                    String idNamespace,
                                    Reference citation,
                                    String microCitation)
Description copied from interface: ISourceable
Adds a source that is newly created by its components. If all components are null no source is added.

Specified by:
addSource in interface ISourceable<IdentifiableSource>

removeSource

public void removeSource(IdentifiableSource source)
Description copied from interface: ISourceable
Removes a source from this object

Specified by:
removeSource in interface ISourceable<IdentifiableSource>

toString

public String toString()
Description copied from class: CdmBase
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 CdmBase.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>

Specified by:
toString in interface IIdentifiableEntity
Overrides:
toString in class CdmBase
See Also:
Object.toString()

compareTo

public int compareTo(IdentifiableEntity identifiableEntity)

getCacheStrategy

public S getCacheStrategy()
Returns the cache strategy used to generate several strings corresponding to this identifiable entity (in particular taxon name caches and author strings).

Returns:
the cache strategy used for this identifiable entity
See Also:
IIdentifiableEntityCacheStrategy

setCacheStrategy

public void setCacheStrategy(S cacheStrategy)
See Also:
getCacheStrategy()

generateTitle

public String generateTitle()
Specified by:
generateTitle in interface IIdentifiableEntity

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from class: VersionableEntity
Clones this versionable entity. Set fields for nextVersion, previousVersion, updated, updatedBy and createdBy are set to null The id is set to 0. The uuid is created new. The createdWhen is set to the current date.

Overrides:
clone in class AnnotatableEntity
Throws:
CloneNotSupportedException
See Also:
Object.clone()


Copyright © 2007-2013 EDIT. All Rights Reserved.