edu.internet2.middleware.grouper
Class GrouperAPI

java.lang.Object
  extended by edu.internet2.middleware.grouper.GrouperAPI
All Implemented Interfaces:
HibGrouperLifecycle, GrouperCloneable, GrouperUtil.FieldValuable, Serializable, org.hibernate.classic.Lifecycle
Direct Known Subclasses:
Attribute, AttributeAssign, AttributeAssignAction, AttributeAssignActionSet, AttributeAssignValue, AttributeDef, AttributeDefName, AttributeDefNameSet, AttributeDefScope, AuditEntry, AuditType, ChangeLogConsumer, ChangeLogEntry, ChangeLogType, Composite, ExternalSubject, ExternalSubjectAttribute, Field, Group, GrouperMessageHibernate, GrouperPIT, GroupSet, GroupType, GroupTypeTuple, Member, Membership, PermissionEntryBase, RegistrySubject, RoleSet, ServiceRoleView, Stem, StemSet, TableIndex

public abstract class GrouperAPI
extends Object
implements GrouperUtil.FieldValuable, Serializable, HibGrouperLifecycle, org.hibernate.classic.Lifecycle, GrouperCloneable

Base Grouper API class.

Since:
1.2.0
Version:
$Id: GrouperAPI.java,v 1.23 2009-11-01 14:57:22 mchyzer Exp $
Author:
blair christensen.
See Also:
Serialized Form

Field Summary
static String COLUMN_HIBERNATE_VERSION_NUMBER
          column
static String FIELD_DB_VERSION
          field name for db version
static String FIELD_HIBERNATE_VERSION_NUMBER
          constant name of field (and javabean property) for hibernateVersion
static long INITIAL_VERSION_NUMBER
           
 
Fields inherited from interface org.hibernate.classic.Lifecycle
NO_VETO, VETO
 
Constructor Summary
GrouperAPI()
           
 
Method Summary
abstract  GrouperAPI clone()
          deep clone the fields in this object
 Object dbVersion()
          version of this object in the database
 void dbVersionClear()
          set to null (e.g.
 Set<String> dbVersionDifferentFields()
          see which fields have changed compared to the DB state (last known) note that attributes will print out: attribute__attributeName
 boolean dbVersionIsDifferent()
          see if the state of this object has changed compared to the DB state (last known)
 void dbVersionReset()
          take a snapshot of the data since this is what is in the db
 Object fieldValue(String fieldName)
          call this method to get the field value (e.g.
 Long getHibernateVersionNumber()
          hibernate increments with each insert/update (-1 means insert, 0+ means update, null means 0)
 boolean onDelete(org.hibernate.Session s)
           
 void onLoad(org.hibernate.Session s, Serializable id)
           
 void onPostDelete(HibernateSession hibernateSession)
          after a delete occurs
 void onPostSave(HibernateSession hibernateSession)
          after a save (insert) occurs
 void onPostUpdate(HibernateSession hibernateSession)
          after an update occurs
 void onPreDelete(HibernateSession hibernateSession)
          before a delete (insert) occurs
 void onPreSave(HibernateSession hibernateSession)
          before a save (insert) occurs
 void onPreUpdate(HibernateSession hibernateSession)
          before an update occurs
 boolean onSave(org.hibernate.Session s)
           
 boolean onUpdate(org.hibernate.Session s)
           
 void setHibernateVersionNumber(Long hibernateVersionNumber)
          hibernate increments with each insert/update (-1 means insert, 0+ means update, null means 0)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_VERSION_NUMBER

public static final long INITIAL_VERSION_NUMBER
See Also:
Constant Field Values

COLUMN_HIBERNATE_VERSION_NUMBER

public static final String COLUMN_HIBERNATE_VERSION_NUMBER
column

See Also:
Constant Field Values

FIELD_DB_VERSION

public static final String FIELD_DB_VERSION
field name for db version

See Also:
Constant Field Values

FIELD_HIBERNATE_VERSION_NUMBER

public static final String FIELD_HIBERNATE_VERSION_NUMBER
constant name of field (and javabean property) for hibernateVersion

See Also:
Constant Field Values
Constructor Detail

GrouperAPI

public GrouperAPI()
Method Detail

fieldValue

public Object fieldValue(String fieldName)
call this method to get the field value (e.g. from dbVersionDifferentFields). some objects have different interpretations (e.g. Group will process attribute__whatever)

Specified by:
fieldValue in interface GrouperUtil.FieldValuable
Parameters:
fieldName -
Returns:
the value

dbVersion

public Object dbVersion()
version of this object in the database

Returns:
the db version

dbVersionIsDifferent

public boolean dbVersionIsDifferent()
see if the state of this object has changed compared to the DB state (last known)

Returns:
true if changed, false if not

dbVersionDifferentFields

public Set<String> dbVersionDifferentFields()
see which fields have changed compared to the DB state (last known) note that attributes will print out: attribute__attributeName

Returns:
a set of attributes changed, or empty set if none

dbVersionReset

public void dbVersionReset()
take a snapshot of the data since this is what is in the db


dbVersionClear

public void dbVersionClear()
set to null (e.g. on delete)


onDelete

public boolean onDelete(org.hibernate.Session s)
                 throws org.hibernate.CallbackException
Specified by:
onDelete in interface org.hibernate.classic.Lifecycle
Throws:
org.hibernate.CallbackException
See Also:
Lifecycle.onDelete(org.hibernate.Session)

onLoad

public void onLoad(org.hibernate.Session s,
                   Serializable id)
Specified by:
onLoad in interface org.hibernate.classic.Lifecycle
See Also:
Lifecycle.onLoad(org.hibernate.Session, java.io.Serializable)

onPostDelete

public void onPostDelete(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
after a delete occurs

Specified by:
onPostDelete in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPostDelete(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onPostSave

public void onPostSave(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
after a save (insert) occurs

Specified by:
onPostSave in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPostSave(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onPostUpdate

public void onPostUpdate(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
after an update occurs

Specified by:
onPostUpdate in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPostUpdate(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onPreDelete

public void onPreDelete(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
before a delete (insert) occurs

Specified by:
onPreDelete in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPreDelete(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onPreSave

public void onPreSave(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
before a save (insert) occurs

Specified by:
onPreSave in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPreSave(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onPreUpdate

public void onPreUpdate(HibernateSession hibernateSession)
Description copied from interface: HibGrouperLifecycle
before an update occurs

Specified by:
onPreUpdate in interface HibGrouperLifecycle
See Also:
HibGrouperLifecycle.onPreUpdate(edu.internet2.middleware.grouper.hibernate.HibernateSession)

onSave

public boolean onSave(org.hibernate.Session s)
               throws org.hibernate.CallbackException
Specified by:
onSave in interface org.hibernate.classic.Lifecycle
Throws:
org.hibernate.CallbackException
See Also:
Lifecycle.onSave(org.hibernate.Session)

onUpdate

public boolean onUpdate(org.hibernate.Session s)
                 throws org.hibernate.CallbackException
Specified by:
onUpdate in interface org.hibernate.classic.Lifecycle
Throws:
org.hibernate.CallbackException
See Also:
Lifecycle.onUpdate(org.hibernate.Session)

clone

public abstract GrouperAPI clone()
deep clone the fields in this object

Specified by:
clone in interface GrouperCloneable
Overrides:
clone in class Object
Returns:
the clone of the object
See Also:
Object.clone()

getHibernateVersionNumber

public Long getHibernateVersionNumber()
hibernate increments with each insert/update (-1 means insert, 0+ means update, null means 0)

Returns:
the hibernateVersion

setHibernateVersionNumber

public void setHibernateVersionNumber(Long hibernateVersionNumber)
hibernate increments with each insert/update (-1 means insert, 0+ means update, null means 0)

Parameters:
hibernateVersionNumber - the hibernateVersion to set