java.lang.Object
edu.internet2.middleware.grouperClient.jdbc.GcPersistableHelper
public class GcPersistableHelper
extends Object
-
Constructor Summary
Constructors
-
Method Summary
Get the name of the column to store the field value in from the Persistable annotation or field name.
Get the fields that have been specified as compound primary key fields.
static boolean
If the table is like a status table and default to update
Find the Persistable annotation on the field, return null if there is not one.
Find the PersistableClass annotation on the class, or parent classes, return null if there is not one.
static boolean
Whether the class has at least one Persistable(Field or Class) annnotation on the class itself or on any field.
A list of heirachical fields from the entire object structure.
static boolean
Whether the field is a compound primary key, check Persistable annotation if there is one on the field, default false.
static boolean
Whether the field should be persisted to the database, check Persistable field and class level annotations.
static boolean
Whether the field is a primary key, check Persistable annotation if there is one on the field, default false.
static boolean
Whether the field should be selected from the database, check Persistable field and class level annotations.
Get the oracle underscore name e.g.
Get the field that has been specified as the primary key - will return null if the class has compound column primary keys.
static boolean
Whether the primary key is manually assigned.
Get the sequence name for the primary key field.
Get the name of the database table to store the object in from the Persistable annotation or the class name.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
GcPersistableHelper
public GcPersistableHelper()
-
Method Details
-
oracleStandardNameFromJava
public static String oracleStandardNameFromJava(String javaName)
Get the oracle underscore name e.g. javaNameHere -> JAVA_NAME_HERE.
- Parameters:
javaName
- is the java convention name.
- Returns:
- the oracle underscore name based on the java name.
-
columnName
Get the name of the column to store the field value in from the Persistable annotation or field name.
- Parameters:
field
- is the field to get the name from.
- Returns:
- the column name.
-
isPrimaryKey
public static boolean isPrimaryKey(Field field)
Whether the field is a primary key, check Persistable annotation if there is one on the field, default false.
- Parameters:
field
- is the field to check.
- Returns:
- true if so.
-
isCompoundPrimaryKey
public static boolean isCompoundPrimaryKey(Field field)
Whether the field is a compound primary key, check Persistable annotation if there is one on the field, default false.
- Parameters:
field
- is the field to check.
- Returns:
- true if so.
-
tableName
Get the name of the database table to store the object in from the Persistable annotation or the class name.
- Parameters:
clazz
- is the field to check.
- Returns:
- true if so.
-
defaultUpdate
public static boolean defaultUpdate(Class<? extends Object> clazz)
If the table is like a status table and default to update
- Parameters:
clazz
- is the field to check.
- Returns:
- true if so.
-
hasPersistableAnnotation
public static boolean hasPersistableAnnotation(Class<? extends Object> clazz)
Whether the class has at least one Persistable(Field or Class) annnotation on the class itself or on any field.
- Parameters:
clazz
- is the field to check.
- Returns:
- true if so.
-
heirarchicalFields
A list of heirachical fields from the entire object structure.
- Parameters:
clazz
- is the child class.
- Returns:
- the list.
-
isSelect
public static boolean isSelect(Field field,
Class<?> clazz)
Whether the field should be selected from the database, check Persistable field and class level annotations.
- Parameters:
field
- is the field to check.
clazz
- is teh type of object we are checking.
- Returns:
- true if so.
-
isPersist
public static boolean isPersist(Field field,
Class<?> clazz)
Whether the field should be persisted to the database, check Persistable field and class level annotations.
- Parameters:
field
- is the field to check.
clazz
- is teh type of object we are checking.
- Returns:
- true if so.
-
findPersistableClassAnnotation
Find the PersistableClass annotation on the class, or parent classes, return null if there is not one.
- Parameters:
clazz
- is the class to find it on.
- Returns:
- the annotation or null.
-
findPersistableAnnotation
Find the Persistable annotation on the field, return null if there is not one.
- Parameters:
field
- is the field to find it on.
- Returns:
- the annotation or null.
-
primaryKeyField
Get the field that has been specified as the primary key - will return null if the class has compound column primary keys.
- Parameters:
clazz
- is the class to check for the field on.
- Returns:
- the primary key field.
-
compoundPrimaryKeyFields
Get the fields that have been specified as compound primary key fields.
- Parameters:
clazz
- is the class to check for the field on.
- Returns:
- the primary key field.
-
primaryKeySequenceName
public static String primaryKeySequenceName(Field primaryKeyField)
Get the sequence name for the primary key field.
- Parameters:
primaryKeyField
- is the field with the annotation for primary key and sequence on it.
- Returns:
- the sequence name or a failure.
-
primaryKeyManuallyAssigned
public static boolean primaryKeyManuallyAssigned(Field primaryKeyField)
Whether the primary key is manually assigned.
- Parameters:
primaryKeyField
- is the field with the annotation for primary key and sequence on it.
- Returns:
- the sequence name or a failure.