|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.force.sdk.jpa.PersistenceUtils
public final class PersistenceUtils
Class for general utility methods needed while persisting and retrieving objects.
Field Summary | |
---|---|
static String |
JOIN_FILTER
prefix for member metadata extensions on join filters. |
static String |
PICKLIST_VALUE_FIELD_PREFIX
prefix for member metadata extensions on picklist values. |
Method Summary | ||
---|---|---|
static String |
getEntityName(org.datanucleus.metadata.AbstractClassMetaData acmd)
Return the name of the entity, first checking the name attribute of the annotations and then defaulting to the entity name on the metadata object. |
|
static String |
getFieldName(org.datanucleus.metadata.AbstractMemberMetaData ammd,
Map<String,String> extensions)
Get the name of a field for use with JPA. |
|
static String |
getFieldNameFromJPAAnnotation(org.datanucleus.metadata.AbstractMemberMetaData ammd)
Returns the name of a column as specified in a JPA annotation (can possibly be null). |
|
static com.sforce.soap.metadata.FieldType |
getFieldTypeFromForceAnnotation(Map<String,String> extensions)
Utility method to get the field type from a map of extensions. |
|
static String |
getForceApiName(org.datanucleus.metadata.AbstractMemberMetaData ammd,
org.datanucleus.OMFContext omf)
Utility method to determine the name of a field based on the member metadata. |
|
static Map<String,String> |
getForceExtensions(org.datanucleus.metadata.MetaData md)
Utility method that returns only the Force.com specific extensions for a piece of metadata (either an entity or a field). |
|
static
|
getMemberAnnotation(Member member,
Class<T> annotationClass)
Returns the annotation of type T on a field or method, e.g. |
|
static org.datanucleus.metadata.AbstractClassMetaData |
getMemberElementClassMetaData(org.datanucleus.metadata.AbstractMemberMetaData ammd,
org.datanucleus.ClassLoaderResolver clr,
org.datanucleus.metadata.MetaDataManager mdm)
Get the class metadata for a member's type. |
|
static Object |
getMemberValue(org.datanucleus.metadata.AbstractClassMetaData acmd,
int position,
Object entity)
Retrieve the value stored at a particular position in an entity. |
|
static Object |
getMemberValue(Member member,
Object entity)
Retrive the value of a field on an entity via reflection. |
|
static boolean |
hasNoSchema(org.datanucleus.metadata.AbstractClassMetaData acmd)
An entity does not have schema if it would not directly represent an object in Force.com, e.g. |
|
static boolean |
isMultiPicklist(org.datanucleus.metadata.AbstractMemberMetaData ammd)
A check for whether a field is a multiselect picklist or a single select picklist. |
|
static boolean |
isNonPersistedColumn(org.datanucleus.metadata.AbstractMemberMetaData ammd)
Check for whether a column has a Persistence Modifier that is anything other than PERSISTENT. |
|
static boolean |
isOrdinalEnum(org.datanucleus.metadata.AbstractMemberMetaData ammd)
A check to see if a field has an ordinal enum type, i.e. |
|
static boolean |
isReadOnlySchema(org.datanucleus.metadata.AbstractClassMetaData acmd,
boolean checkHierarchy)
Performs various checks to see if the schema is read only (i.e. |
|
static boolean |
isRelationship(org.datanucleus.metadata.AbstractMemberMetaData ammd)
Check for whether the field is a ManyToOne or OneToMany relationship (the only relationships currently supported). |
|
static boolean |
isVirtualSchema(org.datanucleus.metadata.AbstractClassMetaData acmd)
A JPA entity is virtual schema if it is not backed by an object on Force.com (e.g. |
|
static String |
prependNamespace(String namespace,
String name)
Util method to prepend a namespace to a name, namespace can be null. |
|
static void |
setFieldValue(Class clazz,
org.datanucleus.metadata.AbstractClassMetaData acmd,
int position,
Object entity,
Object value)
Sets the value of a field on an entity. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PICKLIST_VALUE_FIELD_PREFIX
public static final String JOIN_FILTER
Method Detail |
---|
public static String getEntityName(org.datanucleus.metadata.AbstractClassMetaData acmd)
acmd
- the metadata object of the JPA entity
public static boolean hasNoSchema(org.datanucleus.metadata.AbstractClassMetaData acmd)
acmd
- the metadata object of the JPA entity
public static boolean isReadOnlySchema(org.datanucleus.metadata.AbstractClassMetaData acmd, boolean checkHierarchy)
acmd
- the metadata object of the JPA entitycheckHierarchy
- generally, we don't need to check the hierarchy if we're creating fields, but
if we're creating tables we need to check the parent to see if the parent object
is read only
public static boolean isVirtualSchema(org.datanucleus.metadata.AbstractClassMetaData acmd)
acmd
- the metadata object of the JPA entity
public static boolean isNonPersistedColumn(org.datanucleus.metadata.AbstractMemberMetaData ammd)
ammd
- the metadata object representing a column or field
public static Map<String,String> getForceExtensions(org.datanucleus.metadata.MetaData md)
md
- The metadata containing extensions
public static com.sforce.soap.metadata.FieldType getFieldTypeFromForceAnnotation(Map<String,String> extensions)
extensions
- a Map of Force.com extensions on a metadata object
public static boolean isOrdinalEnum(org.datanucleus.metadata.AbstractMemberMetaData ammd)
ammd
- the metadata object of a picklist field
public static boolean isMultiPicklist(org.datanucleus.metadata.AbstractMemberMetaData ammd)
ammd
- the metadata object of a picklist field
public static boolean isRelationship(org.datanucleus.metadata.AbstractMemberMetaData ammd)
ammd
- the metadata object for a field
public static Object getMemberValue(org.datanucleus.metadata.AbstractClassMetaData acmd, int position, Object entity) throws IllegalAccessException, InvocationTargetException
acmd
- the class metadata for the entity that holds the valueposition
- the position of the field you want the value forentity
- the actual entity that contains the value
IllegalAccessException
- thrown if the field cannot be accessed
InvocationTargetException
- thrown if the field's get method cannot be invokedpublic static Object getMemberValue(Member member, Object entity) throws IllegalAccessException, InvocationTargetException
member
- the Member object for a particular field on an entityentity
- the entity that contains the value
IllegalAccessException
- thrown if the member cannot be accessed
InvocationTargetException
- thrown if the member's get method cannot be invokedpublic static <T extends Annotation> T getMemberAnnotation(Member member, Class<T> annotationClass)
T
- an Annotation typemember
- the member representing a particular field or methodannotationClass
- the class of the annotation object that should be returned
public static void setFieldValue(Class clazz, org.datanucleus.metadata.AbstractClassMetaData acmd, int position, Object entity, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
clazz
- The entity classacmd
- metadata object for the entityposition
- the position of the field that should be setentity
- the instance of the entity being updatedvalue
- the value that should be set on the field
SecurityException
- thrown if the field cannot be accessed
NoSuchFieldException
- thrown if the field does not exist
IllegalArgumentException
- thrown if the set fails
IllegalAccessException
- thrown if the set failspublic static String getForceApiName(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.OMFContext omf)
ammd
- the metadata object for the field we're retrieving a name foromf
- the Object Manager Factory context
public static String prependNamespace(String namespace, String name)
namespace
- A possibly null namespace stringname
- the name of a field or object
public static org.datanucleus.metadata.AbstractClassMetaData getMemberElementClassMetaData(org.datanucleus.metadata.AbstractMemberMetaData ammd, org.datanucleus.ClassLoaderResolver clr, org.datanucleus.metadata.MetaDataManager mdm)
ammd
- The member whose class metadata you want to retriveclr
- the classloader resolver to usemdm
- the metadata manager to use
public static String getFieldName(org.datanucleus.metadata.AbstractMemberMetaData ammd, Map<String,String> extensions)
ammd
- the metadata object for the field we're retrieving a name forextensions
- the Force.com extensions for this metadata (see getForceExtensions}
public static String getFieldNameFromJPAAnnotation(org.datanucleus.metadata.AbstractMemberMetaData ammd)
ammd
- the metadata object for the field we're retrieving a name for
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |