edu.internet2.middleware.grouper
Class GroupType

java.lang.Object
  extended by edu.internet2.middleware.grouper.GrouperAPI
      extended by edu.internet2.middleware.grouper.GroupType
All Implemented Interfaces:
HibGrouperLifecycle, Hib3GrouperVersioned, GrouperCloneable, GrouperHasContext, GrouperUtil.FieldValuable, XmlImportable<GroupType>, XmlImportableBase<GroupType>, Serializable, Comparable, org.hibernate.classic.Lifecycle

public class GroupType
extends GrouperAPI
implements GrouperHasContext, Serializable, Hib3GrouperVersioned, Comparable, XmlImportable<GroupType>

Schema specification for a Group type.

Version:
$Id: GroupType.java,v 1.89 2009-06-10 05:31:35 mchyzer Exp $
Author:
blair christensen.
See Also:
Serialized Form

Field Summary
static String COLUMN_OLD_ID
          old id col for id conversion
static String COLUMN_OLD_TYPE_UUID
          old uuid id col for id conversion
static String COLUMN_TYPE_UUID
          uuid col in db
static String FIELD_CREATE_TIME
          constant for field name for: createTime
static String FIELD_CREATOR_UUID
          constant for field name for: creatorUUID
static String FIELD_DB_VERSION
          constant for field name for: dbVersion
static String FIELD_IS_ASSIGNABLE
          constant for field name for: isAssignable
static String FIELD_IS_INTERNAL
          constant for field name for: isInternal
static String FIELD_NAME
          constant for field name for: name
static String FIELD_UUID
          constant for field name for: uuid
static long serialVersionUID
           
static String TABLE_GROUPER_TYPES
          name of table for grouper_types
 
Fields inherited from class edu.internet2.middleware.grouper.GrouperAPI
COLUMN_HIBERNATE_VERSION_NUMBER, FIELD_HIBERNATE_VERSION_NUMBER, INITIAL_VERSION_NUMBER
 
Fields inherited from interface org.hibernate.classic.Lifecycle
NO_VETO, VETO
 
Constructor Summary
GroupType()
           
 
Method Summary
 Field addAttribute(GrouperSession s, String name, Privilege read, Privilege write, boolean required)
          Add a custom attribute Field to a custom GroupType.
 Field addAttribute(GrouperSession s, String name, Privilege read, Privilege write, boolean required, boolean exceptionIfExists)
          Add a custom attribute Field to a custom GroupType.
 Field addList(GrouperSession s, String name, Privilege read, Privilege write)
          Add a custom list Field to a custom GroupType.
 Field addOrUpdateAttribute(GrouperSession s, String name, Privilege read, Privilege write, boolean required)
          Add a custom attribute Field to a custom GroupType.
 GroupType clone()
          deep clone the fields in this object
 int compareTo(Object o)
           
static GroupType createType(GrouperSession s, String name)
          Create a new GroupType.
static GroupType createType(GrouperSession s, String name, boolean exceptionIfExists)
          Create a new GroupType.
 GroupType dbVersion()
          save the state when retrieving from DB
 Set<String> dbVersionDifferentFields()
          note, these are massaged so that name, extension, etc look like normal fields.
 void dbVersionReset()
          take a snapshot of the data since this is what is in the db
 void delete(GrouperSession s)
          Delete a custom GroupType definition.
 void deleteField(GrouperSession s, String name)
          Delete a custom Field from a custom GroupType.
 boolean equals(Object other)
           
 String getContextId()
          context id of the transaction
 long getCreateTime()
           
 String getCreatorUuid()
           
 Set<Field> getFields()
           
 boolean getIsAssignable()
           
 boolean getIsInternal()
           
 String getName()
           
 String getUuid()
           
 int hashCode()
           
 Field internal_addField(GrouperSession s, String name, FieldType type, Privilege read, Privilege write, boolean required, boolean exceptionIfExists, boolean updateIfExists, boolean[] changedArray, String uuid)
          add a field if it is not already there
static GroupType internal_createType(GrouperSession s, String name, boolean isAssignable, boolean isInternal, boolean exceptionIfExists, boolean[] changed, String uuid)
           
 boolean isSystemType()
           
 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
 void setContextId(String contextId1)
          context id of the transaction
 void setCreateTime(long createTime)
           
 void setCreatorUuid(String creatorUUID)
           
 void setFields(Set fields)
           
 void setIsAssignable(boolean isAssignable)
           
 void setIsInternal(boolean isInternal)
           
 void setName(String name)
           
 void setUuid(String uuid)
           
 void store()
          store this object to the DB.
 String toString()
           
 void xmlCopyBusinessPropertiesToExisting(GroupType existingRecord)
          copy business (non update) properties to an existing record
 boolean xmlDifferentBusinessProperties(GroupType other)
          see if the non update cols are different (e.g.
 boolean xmlDifferentUpdateProperties(GroupType other)
          see if the update cols are different (e.g.
 String xmlGetId()
          set id key in db
 GroupType xmlRetrieveByIdOrKey()
          retrieve from db by id or key.
 GroupType xmlSaveBusinessProperties(GroupType existingRecord)
          save the business properties (not update properties)
 void xmlSaveUpdateProperties()
          save the udpate properties (e.g.
 void xmlSetId(String theId)
          set id key in db
 XmlExportGroupType xmlToExportGroupType(GrouperVersion grouperVersion)
          convert to xml bean for export
 String xmlToString()
          convert to string for log
 
Methods inherited from class edu.internet2.middleware.grouper.GrouperAPI
dbVersionClear, dbVersionIsDifferent, fieldValue, getHibernateVersionNumber, onDelete, onLoad, onSave, onUpdate, setHibernateVersionNumber
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TABLE_GROUPER_TYPES

public static final String TABLE_GROUPER_TYPES
name of table for grouper_types

See Also:
Constant Field Values

COLUMN_TYPE_UUID

public static final String COLUMN_TYPE_UUID
uuid col in db

See Also:
Constant Field Values

COLUMN_OLD_ID

public static final String COLUMN_OLD_ID
old id col for id conversion

See Also:
Constant Field Values

COLUMN_OLD_TYPE_UUID

public static final String COLUMN_OLD_TYPE_UUID
old uuid id col for id conversion

See Also:
Constant Field Values

FIELD_CREATE_TIME

public static final String FIELD_CREATE_TIME
constant for field name for: createTime

See Also:
Constant Field Values

FIELD_CREATOR_UUID

public static final String FIELD_CREATOR_UUID
constant for field name for: creatorUUID

See Also:
Constant Field Values

FIELD_DB_VERSION

public static final String FIELD_DB_VERSION
constant for field name for: dbVersion

See Also:
Constant Field Values

FIELD_IS_ASSIGNABLE

public static final String FIELD_IS_ASSIGNABLE
constant for field name for: isAssignable

See Also:
Constant Field Values

FIELD_IS_INTERNAL

public static final String FIELD_IS_INTERNAL
constant for field name for: isInternal

See Also:
Constant Field Values

FIELD_NAME

public static final String FIELD_NAME
constant for field name for: name

See Also:
Constant Field Values

FIELD_UUID

public static final String FIELD_UUID
constant for field name for: uuid

See Also:
Constant Field Values

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

GroupType

public GroupType()
Method Detail

createType

public static GroupType createType(GrouperSession s,
                                   String name)
                            throws InsufficientPrivilegeException,
                                   SchemaException
Create a new GroupType.

Create a new custom group type that can be assigned to existing or new groups. If the type already exists, a SchemaException will be thrown. If the subject is not root-like, an InsufficientPrivilegeException will be thrown.

 try {
   GroupType type = GroupType.createType(s, "my custom type");
 }
 catch (InsufficientPrivilegeException eIP) {
   // Subject not privileged to add group types.
 }
 catch (SchemaException eS) {
   // Type not created
 }
 

Parameters:
s - Create type within this session context.
name - Create type with this name.
Returns:
New GroupType.
Throws:
InsufficientPrivilegeException
SchemaException

createType

public static GroupType createType(GrouperSession s,
                                   String name,
                                   boolean exceptionIfExists)
                            throws InsufficientPrivilegeException,
                                   SchemaException
Create a new GroupType.

Create a new custom group type that can be assigned to existing or new groups. If the type already exists, a SchemaException will be thrown. If the subject is not root-like, an InsufficientPrivilegeException will be thrown.

 try {
   GroupType type = GroupType.createType(s, "my custom type");
 }
 catch (InsufficientPrivilegeException eIP) {
   // Subject not privileged to add group types.
 }
 catch (SchemaException eS) {
   // Type not created
 }
 

Parameters:
s - Create type within this session context.
name - Create type with this name.
exceptionIfExists -
Returns:
New GroupType.
Throws:
InsufficientPrivilegeException
SchemaException

getContextId

public String getContextId()
context id of the transaction

Returns:
context id

setContextId

public void setContextId(String contextId1)
context id of the transaction

Specified by:
setContextId in interface GrouperHasContext
Parameters:
contextId1 -

addAttribute

public Field addAttribute(GrouperSession s,
                          String name,
                          Privilege read,
                          Privilege write,
                          boolean required)
                   throws InsufficientPrivilegeException,
                          SchemaException
Add a custom attribute Field to a custom GroupType. try { Field myAttr = type.addAttribute( "my attribute", AccessPrivilege.VIEW, AccessPrivilege.UPDATE, false ); } catch (InsufficientPrivilegeException eIP) { // Not privileged to add attribute } catch (SchemaException eS) { // Invalid schema }

Parameters:
s - Add attribute within this session context.
name - Name of attribute.
read - Privilege required to write to this Field.
write - Privilege required to write to this Field.
required - Is this attribute required.
Returns:
field
Throws:
InsufficientPrivilegeException
SchemaException

addAttribute

public Field addAttribute(GrouperSession s,
                          String name,
                          Privilege read,
                          Privilege write,
                          boolean required,
                          boolean exceptionIfExists)
                   throws InsufficientPrivilegeException,
                          SchemaException
Add a custom attribute Field to a custom GroupType. try { Field myAttr = type.addAttribute( "my attribute", AccessPrivilege.VIEW, AccessPrivilege.UPDATE, false ); } catch (InsufficientPrivilegeException eIP) { // Not privileged to add attribute } catch (SchemaException eS) { // Invalid schema }

Parameters:
s - Add attribute within this session context.
name - Name of attribute.
read - Privilege required to write to this Field.
write - Privilege required to write to this Field.
required - Is this attribute required.
exceptionIfExists -
Returns:
field
Throws:
InsufficientPrivilegeException
SchemaException

addOrUpdateAttribute

public Field addOrUpdateAttribute(GrouperSession s,
                                  String name,
                                  Privilege read,
                                  Privilege write,
                                  boolean required)
                           throws InsufficientPrivilegeException,
                                  SchemaException
Add a custom attribute Field to a custom GroupType. try { Field myAttr = type.addAttribute( "my attribute", AccessPrivilege.VIEW, AccessPrivilege.UPDATE, false ); } catch (InsufficientPrivilegeException eIP) { // Not privileged to add attribute } catch (SchemaException eS) { // Invalid schema }

Parameters:
s - Add attribute within this session context.
name - Name of attribute.
read - Privilege required to write to this Field.
write - Privilege required to write to this Field.
required - Is this attribute required.
Returns:
field
Throws:
InsufficientPrivilegeException
SchemaException

addList

public Field addList(GrouperSession s,
                     String name,
                     Privilege read,
                     Privilege write)
              throws InsufficientPrivilegeException,
                     SchemaException
Add a custom list Field to a custom GroupType. try { Field myList = type.addList( s, "my list", AccessPrivilege.VIEW, AccessPrivilege.UPDATE ); } catch (InsufficientPrivilegeException eIP) { // Not privileged to add list } catch (SchemaException eS) { // Invalid schema }

Parameters:
s - Add list within this session context.
name - Name of list.
read - Privilege required to write to this Field.
write - Privilege required to write to this Field.
Returns:
field
Throws:
InsufficientPrivilegeException
SchemaException

delete

public void delete(GrouperSession s)
            throws InsufficientPrivilegeException,
                   SchemaException
Delete a custom GroupType definition.

 try {
   aGroupType.delete(s);
 }
 catch (InsufficientPrivilegeException eIP) {
   // Subject not privileged to delete group type.
 }
 catch (SchemaException eS) {
   // Type could not be deleted
 }
 

Parameters:
s - Delete type within this session context.
Throws:
InsufficientPrivilegeException
SchemaException
Since:
1.0

deleteField

public void deleteField(GrouperSession s,
                        String name)
                 throws InsufficientPrivilegeException,
                        SchemaException
Delete a custom Field from a custom GroupType.

Delete a field from this group type. If the field does not exist in this type a SchemaException will be thrown. If the subject is not root-like, an InsufficientPrivilegeException will be thrown.

 try {
   type.deleteField(s, "my field");
   );
 }
 catch (InsufficientPrivilegeException eIP) {
   // Not privileged to delete field
 }
 catch (SchemaException eS) {
   // Invalid schema
 }
 

Parameters:
s - Delete field within this session context.
name - Name of field to delete.
Throws:
InsufficientPrivilegeException
SchemaException

isSystemType

public boolean isSystemType()
Returns:
true if system type

internal_createType

public static GroupType internal_createType(GrouperSession s,
                                            String name,
                                            boolean isAssignable,
                                            boolean isInternal,
                                            boolean exceptionIfExists,
                                            boolean[] changed,
                                            String uuid)
                                     throws InsufficientPrivilegeException,
                                            SchemaException
Parameters:
s -
name -
isAssignable -
isInternal -
exceptionIfExists -
changed - boolean array, the fisrt index will be in it existed already
uuid - to use or null for one to be assigned
Returns:
the type
Throws:
InsufficientPrivilegeException
SchemaException

internal_addField

public Field internal_addField(GrouperSession s,
                               String name,
                               FieldType type,
                               Privilege read,
                               Privilege write,
                               boolean required,
                               boolean exceptionIfExists,
                               boolean updateIfExists,
                               boolean[] changedArray,
                               String uuid)
                        throws InsufficientPrivilegeException,
                               SchemaException
add a field if it is not already there

Parameters:
s -
name -
type -
read -
write -
required -
exceptionIfExists -
updateIfExists -
changedArray - is an array of 1 if you want to know if this method changed anything, else null
uuid -
Returns:
the field
Throws:
InsufficientPrivilegeException
SchemaException

equals

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

getCreateTime

public long getCreateTime()
Returns:
create time
Since:
1.2.0

getCreatorUuid

public String getCreatorUuid()
Returns:
creator uuid
Since:
1.2.0

getFields

public Set<Field> getFields()
Returns:
fields
Since:
1.2.0

getIsAssignable

public boolean getIsAssignable()
Returns:
if assignable
Since:
1.2.0

getIsInternal

public boolean getIsInternal()
Returns:
if internal
Since:
1.2.0

getName

public String getName()
Returns:
name
Since:
1.2.0

getUuid

public String getUuid()
Returns:
uuid
Since:
1.2.0

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
hash code
Since:
1.2.0

setCreateTime

public void setCreateTime(long createTime)
Parameters:
createTime -
Since:
1.2.0

setCreatorUuid

public void setCreatorUuid(String creatorUUID)
Parameters:
creatorUUID -
Since:
1.2.0

setFields

public void setFields(Set fields)
Parameters:
fields -
Since:
1.2.0

setIsAssignable

public void setIsAssignable(boolean isAssignable)
Parameters:
isAssignable -
Since:
1.2.0

setIsInternal

public void setIsInternal(boolean isInternal)
Parameters:
isInternal -
Since:
1.2.0

setName

public void setName(String name)
Parameters:
name -
Since:
1.2.0

setUuid

public void setUuid(String uuid)
Parameters:
uuid -
Since:
1.2.0

toString

public String toString()
Overrides:
toString in class Object
Returns:
string
Since:
1.2.0

onPostDelete

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

Specified by:
onPostDelete in interface HibGrouperLifecycle
Overrides:
onPostDelete in class GrouperAPI
See Also:
GrouperAPI.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
Overrides:
onPostSave in class GrouperAPI
See Also:
GrouperAPI.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
Overrides:
onPostUpdate in class GrouperAPI
See Also:
GrouperAPI.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
Overrides:
onPreDelete in class GrouperAPI
See Also:
GrouperAPI.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
Overrides:
onPreSave in class GrouperAPI
See Also:
GrouperAPI.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
Overrides:
onPreUpdate in class GrouperAPI
See Also:
GrouperAPI.onPreUpdate(edu.internet2.middleware.grouper.hibernate.HibernateSession)

dbVersion

public GroupType dbVersion()
save the state when retrieving from DB

Overrides:
dbVersion in class GrouperAPI
Returns:
the dbVersion

dbVersionDifferentFields

public Set<String> dbVersionDifferentFields()
note, these are massaged so that name, extension, etc look like normal fields. access with fieldValue()

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

dbVersionReset

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

Overrides:
dbVersionReset in class GrouperAPI

clone

public GroupType clone()
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()

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(java.lang.Object)

store

public void store()
store this object to the DB.


xmlCopyBusinessPropertiesToExisting

public void xmlCopyBusinessPropertiesToExisting(GroupType existingRecord)
Description copied from interface: XmlImportableBase
copy business (non update) properties to an existing record

Specified by:
xmlCopyBusinessPropertiesToExisting in interface XmlImportableBase<GroupType>
See Also:
XmlImportableBase.xmlCopyBusinessPropertiesToExisting(java.lang.Object)

xmlDifferentBusinessProperties

public boolean xmlDifferentBusinessProperties(GroupType other)
Description copied from interface: XmlImportableBase
see if the non update cols are different (e.g. name)

Specified by:
xmlDifferentBusinessProperties in interface XmlImportableBase<GroupType>
Parameters:
other - the one to compare with
Returns:
true if so
See Also:
XmlImportableBase.xmlDifferentBusinessProperties(java.lang.Object)

xmlDifferentUpdateProperties

public boolean xmlDifferentUpdateProperties(GroupType other)
Description copied from interface: XmlImportableBase
see if the update cols are different (e.g. last updated)

Specified by:
xmlDifferentUpdateProperties in interface XmlImportableBase<GroupType>
Parameters:
other - the one to compare with
Returns:
true if so
See Also:
XmlImportableBase.xmlDifferentUpdateProperties(java.lang.Object)

xmlRetrieveByIdOrKey

public GroupType xmlRetrieveByIdOrKey()
Description copied from interface: XmlImportable
retrieve from db by id or key. throws exception if duplicate

Specified by:
xmlRetrieveByIdOrKey in interface XmlImportable<GroupType>
Returns:
the object or null if not found
See Also:
XmlImportable.xmlRetrieveByIdOrKey()

xmlSaveBusinessProperties

public GroupType xmlSaveBusinessProperties(GroupType existingRecord)
Description copied from interface: XmlImportableBase
save the business properties (not update properties)

Specified by:
xmlSaveBusinessProperties in interface XmlImportableBase<GroupType>
Parameters:
existingRecord - null if insert, the object if exists in DB generally just copy the hibernate version number, and last updated to the object and store it
Returns:
the new object or existing
See Also:
XmlImportableBase.xmlSaveBusinessProperties(java.lang.Object)

xmlSaveUpdateProperties

public void xmlSaveUpdateProperties()
Description copied from interface: XmlImportableBase
save the udpate properties (e.g. last updated). Note, this is done with a sql update statement, not with hibernate

Specified by:
xmlSaveUpdateProperties in interface XmlImportableBase<GroupType>
See Also:
XmlImportableBase.xmlSaveUpdateProperties()

xmlToExportGroupType

public XmlExportGroupType xmlToExportGroupType(GrouperVersion grouperVersion)
convert to xml bean for export

Parameters:
grouperVersion -
Returns:
xml bean

xmlGetId

public String xmlGetId()
Description copied from interface: XmlImportableBase
set id key in db

Specified by:
xmlGetId in interface XmlImportableBase<GroupType>
Returns:
id
See Also:
XmlImportableBase.xmlGetId()

xmlSetId

public void xmlSetId(String theId)
Description copied from interface: XmlImportableBase
set id key in db

Specified by:
xmlSetId in interface XmlImportableBase<GroupType>
See Also:
XmlImportableBase.xmlSetId(java.lang.String)

xmlToString

public String xmlToString()
Description copied from interface: XmlImportableBase
convert to string for log

Specified by:
xmlToString in interface XmlImportableBase<GroupType>
Returns:
the string value for log
See Also:
XmlImportableBase.xmlToString()