edu.internet2.middleware.grouper.tableIndex
Class TableIndex

java.lang.Object
  extended by edu.internet2.middleware.grouper.GrouperAPI
      extended by edu.internet2.middleware.grouper.tableIndex.TableIndex
All Implemented Interfaces:
HibGrouperLifecycle, Hib3GrouperVersioned, GrouperCloneable, GrouperUtil.FieldValuable, Serializable, org.hibernate.classic.Lifecycle

public class TableIndex
extends GrouperAPI
implements Hib3GrouperVersioned

Keep track of last index for groups, stems, attribute definitions, and attribute names grab a certain number of indices, and update the table in an autonomous transaction. If it doesnt work, try again some more (20 times?). This holds the type and last index. The static methods in this class will allow safe access to an index

Author:
mchyzer
See Also:
Serialized Form

Field Summary
static String COLUMN_CREATED_ON
          column
static String COLUMN_ID
          column
static String COLUMN_LAST_INDEX_RESERVED
          column
static String COLUMN_LAST_UPDATED
          column
static String COLUMN_TYPE
          column
static String FIELD_CREATED_ON_DB
          constant for field name for: createdOnDb
static String FIELD_ID
          constant for field name for: id
static String FIELD_LAST_INDEX_RESERVED
          column
static String FIELD_LAST_UPDATED_DB
          constant for field name for: lastUpdatedDb
static String FIELD_TYPE
          constant for field name for: type
static String TABLE_GROUPER_TABLE_INDEX
          name of the grouper table index table
 
Fields inherited from class edu.internet2.middleware.grouper.GrouperAPI
COLUMN_HIBERNATE_VERSION_NUMBER, FIELD_DB_VERSION, FIELD_HIBERNATE_VERSION_NUMBER, INITIAL_VERSION_NUMBER
 
Fields inherited from interface org.hibernate.classic.Lifecycle
NO_VETO, VETO
 
Constructor Summary
TableIndex()
           
 
Method Summary
static void assertCanAssignIdIndex()
          make sure the current user can assign id index
static void clearReservedId(TableIndexType tableIndexType, long id)
          clear reserved id in case an existing one was used
static void clearReservedIds(TableIndexType tableIndexType)
          clear all ids
 GrouperAPI clone()
          deep clone the fields in this object
 TableIndex dbVersion()
          save the statGrouperTableIndexretrieving from DB
 Set<String> dbVersionDifferentFields()
          see which fields have changed compared to the DB state (last known) note that attributes will print out: attribute__attributeName
 void dbVersionReset()
          take a snapshot of the data since this is what is in the db
 void delete()
          delete this object
 boolean equals(Object other)
           
 Timestamp getCreatedOn()
          when created
 Long getCreatedOnDb()
          when created
 String getId()
           
 long getLastIndexReserved()
          last index reserved, stored in JVM
 Timestamp getLastUpdated()
          when last updated
 Long getLastUpdatedDb()
          when last updated
 TableIndexType getType()
          type of index, group, stem, attributeDef, attributeDefName, etc
 String getTypeDb()
          get string value of type for hibernate
 int hashCode()
           
 void onPreSave(HibernateSession hibernateSession)
          before a save (insert) occurs
 void onPreUpdate(HibernateSession hibernateSession)
          before an update occurs
static long reserveId(TableIndexType tableIndexType)
          get an id for this type of object, if needed, increment the index in the database
 void saveOrUpdate()
          save or update this object
 void setCreatedOn(Timestamp createdOn1)
          when created
 void setCreatedOnDb(Long createdOn1)
          when created
 void setId(String id)
          set id
 void setLastIndexReserved(long lastIndexReserved1)
          last index reserved, stored in JVM
 void setLastUpdated(Timestamp lastUpdated1)
          when last updated
 void setLastUpdatedDb(Long lastUpdated1)
          when last updated
 void setType(TableIndexType type1)
          set stem set assignment type
 void setTypeDb(String type1)
          type of index, group, stem, attributeDef, attributeDefName, etc
 String toString()
           
 
Methods inherited from class edu.internet2.middleware.grouper.GrouperAPI
dbVersionClear, dbVersionIsDifferent, fieldValue, getHibernateVersionNumber, onDelete, onLoad, onPostDelete, onPostSave, onPostUpdate, onPreDelete, onSave, onUpdate, setHibernateVersionNumber
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLE_GROUPER_TABLE_INDEX

public static final String TABLE_GROUPER_TABLE_INDEX
name of the grouper table index table

See Also:
Constant Field Values

COLUMN_CREATED_ON

public static final String COLUMN_CREATED_ON
column

See Also:
Constant Field Values

COLUMN_LAST_UPDATED

public static final String COLUMN_LAST_UPDATED
column

See Also:
Constant Field Values

COLUMN_ID

public static final String COLUMN_ID
column

See Also:
Constant Field Values

COLUMN_TYPE

public static final String COLUMN_TYPE
column

See Also:
Constant Field Values

COLUMN_LAST_INDEX_RESERVED

public static final String COLUMN_LAST_INDEX_RESERVED
column

See Also:
Constant Field Values

FIELD_CREATED_ON_DB

public static final String FIELD_CREATED_ON_DB
constant for field name for: createdOnDb

See Also:
Constant Field Values

FIELD_ID

public static final String FIELD_ID
constant for field name for: id

See Also:
Constant Field Values

FIELD_LAST_UPDATED_DB

public static final String FIELD_LAST_UPDATED_DB
constant for field name for: lastUpdatedDb

See Also:
Constant Field Values

FIELD_TYPE

public static final String FIELD_TYPE
constant for field name for: type

See Also:
Constant Field Values

FIELD_LAST_INDEX_RESERVED

public static final String FIELD_LAST_INDEX_RESERVED
column

See Also:
Constant Field Values
Constructor Detail

TableIndex

public TableIndex()
Method Detail

assertCanAssignIdIndex

public static void assertCanAssignIdIndex()
make sure the current user can assign id index


toString

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

equals

public boolean equals(Object other)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

getId

public String getId()
Returns:
id

setId

public void setId(String id)
set id

Parameters:
id -

getType

public TableIndexType getType()
type of index, group, stem, attributeDef, attributeDefName, etc

Returns:
type

getTypeDb

public String getTypeDb()
get string value of type for hibernate

Returns:
type

setType

public void setType(TableIndexType type1)
set stem set assignment type

Parameters:
type1 -

setTypeDb

public void setTypeDb(String type1)
type of index, group, stem, attributeDef, attributeDefName, etc

Parameters:
type1 -

getCreatedOn

public Timestamp getCreatedOn()
when created

Returns:
timestamp

getCreatedOnDb

public Long getCreatedOnDb()
when created

Returns:
timestamp

getLastUpdated

public Timestamp getLastUpdated()
when last updated

Returns:
timestamp

getLastUpdatedDb

public Long getLastUpdatedDb()
when last updated

Returns:
timestamp

saveOrUpdate

public void saveOrUpdate()
save or update this object


delete

public void delete()
delete this object


setCreatedOnDb

public void setCreatedOnDb(Long createdOn1)
when created

Parameters:
createdOn1 -

setCreatedOn

public void setCreatedOn(Timestamp createdOn1)
when created

Parameters:
createdOn1 -

setLastUpdated

public void setLastUpdated(Timestamp lastUpdated1)
when last updated

Parameters:
lastUpdated1 -

setLastUpdatedDb

public void setLastUpdatedDb(Long lastUpdated1)
when last updated

Parameters:
lastUpdated1 -

onPreSave

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

Specified by:
onPreSave in interface HibGrouperLifecycle
Overrides:
onPreSave in class GrouperAPI
See Also:
GrouperAPI.onPreSave(HibernateSession)

onPreUpdate

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

Specified by:
onPreUpdate in interface HibGrouperLifecycle
Overrides:
onPreUpdate in class GrouperAPI
See Also:
GrouperAPI.onPreUpdate(HibernateSession)

getLastIndexReserved

public long getLastIndexReserved()
last index reserved, stored in JVM

Returns:

setLastIndexReserved

public void setLastIndexReserved(long lastIndexReserved1)
last index reserved, stored in JVM

Parameters:
lastIndexReserved1 -

dbVersion

public TableIndex dbVersion()
save the statGrouperTableIndexretrieving from DB

Overrides:
dbVersion in class GrouperAPI
Returns:
the db version

dbVersionReset

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

Overrides:
dbVersionReset in class GrouperAPI

dbVersionDifferentFields

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

Overrides:
dbVersionDifferentFields in class GrouperAPI
Returns:
a set of attributes changed, or empty set if none
See Also:
GrouperAPI.dbVersionDifferentFields()

clone

public GrouperAPI clone()
Description copied from class: GrouperAPI
deep clone the fields in this object

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

clearReservedId

public static void clearReservedId(TableIndexType tableIndexType,
                                   long id)
clear reserved id in case an existing one was used

Parameters:
tableIndexType -

clearReservedIds

public static void clearReservedIds(TableIndexType tableIndexType)
clear all ids

Parameters:
tableIndexType -

reserveId

public static long reserveId(TableIndexType tableIndexType)
get an id for this type of object, if needed, increment the index in the database

Parameters:
tableIndexType -
Returns:
the id that can be used for the type of object