com.force.sdk.jpa.table
Class TableImpl

java.lang.Object
  extended by com.force.sdk.jpa.table.TableImpl

public class TableImpl
extends Object

Represents an object (custom or standard) in Force.com.

Author:
Fiaz Hossain

Constructor Summary
TableImpl(String defaultNamespace, TableName tableName, com.sforce.soap.partner.DescribeSObjectResult result, ForceManagedConnection mconn)
          Create a TableImpl for an entity.
TableImpl(TableName tableName, org.datanucleus.metadata.AbstractClassMetaData acmd)
          Constructor used for virtual schema (aka tables that aren't actually backed by an object, like Owner).
 
Method Summary
 void createFields(org.datanucleus.metadata.AbstractClassMetaData cmd, ForceStoreManager storeManager)
          Create custom fields only.
 void createTableAndFields(org.datanucleus.metadata.AbstractClassMetaData cmd, ForceStoreManager storeManager, ForceManagedConnection mconn)
          Create the custom objects and fields for schema creation.
 boolean exists()
          Check existence of a table in the organization used by the application.
 ColumnImpl getColumnAt(org.datanucleus.metadata.AbstractClassMetaData acmd, int fieldNumber)
          Retrieve a Force.com column from the given JPA class metadata at the given field position.
 ColumnImpl getColumnAt(int columnIndex)
          Retrieves a Force.com column at the given index.
 ColumnImpl getColumnByForceApiName(String columnName)
          Retrieves a Force.com column with a fully qualified Force.com API name.
 ColumnImpl getColumnByJavaName(String columnName)
          Retrieves a Force.com column with a Java field name.
 ColumnImpl getColumnFor(org.datanucleus.metadata.AbstractClassMetaData acmd, org.datanucleus.metadata.AbstractMemberMetaData ammd)
          Retrieve a Force.com column with the given JPA field metadata.
 List<ColumnImpl> getColumnsFor(org.datanucleus.metadata.AbstractClassMetaData acmd, org.datanucleus.metadata.AbstractMemberMetaData ammd, ForceStoreManager storeManager, List<ColumnImpl> columns)
          Retrieve a list of Force.com columns with the given JPA field metadata.
 ColumnImpl getExternalIdColumn()
           
 List<ColumnImpl> getListOfColumns()
           
 ForceTableMetaData getMetaData(org.datanucleus.metadata.AbstractClassMetaData cmd)
          Retrieves Force.com table metadata for the given JPA class metadata.
 String getPKFieldName(org.datanucleus.metadata.AbstractClassMetaData acmd)
          Retrieves the primary key Force.com API field name for the given class metadata.
 boolean getTableAlreadyExistsInOrg()
           
 TableName getTableName()
           
 boolean isValid()
          Entities are considered valid if they exist in the Force.com database.
 void refresh(com.sforce.soap.partner.DescribeSObjectResult result, ForceManagedConnection mconn)
          refresh the describe result to verify that objects have been created as we expected.
 void registerJavaColumn(String javaFieldName, ColumnImpl column)
          Register a column impl (with specific Force.com attributes, like the API name) under its field or property name in java.
 void setIsValid(boolean isValid)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableImpl

public TableImpl(String defaultNamespace,
                 TableName tableName,
                 com.sforce.soap.partner.DescribeSObjectResult result,
                 ForceManagedConnection mconn)
Create a TableImpl for an entity.

Parameters:
defaultNamespace - the namespace of the organization connecting to Force.com, to be used by default
tableName - the table name of the entity
result - the result of an API describe
mconn - the managed connection to the Force.com APIs

TableImpl

public TableImpl(TableName tableName,
                 org.datanucleus.metadata.AbstractClassMetaData acmd)
Constructor used for virtual schema (aka tables that aren't actually backed by an object, like Owner).

Parameters:
tableName - the table name of the entity
acmd - the class metadata
Method Detail

isValid

public boolean isValid()
Entities are considered valid if they exist in the Force.com database. However, during schema creation the table may be invalidated, but should return to valid after a describe call confirms its existence. Use exists() instead if you want to find out if the table exists in the org

Returns:
true if the table has been validated as existing in the Force.com database, false doesn't necessarily mean it will not be created

setIsValid

public void setIsValid(boolean isValid)

exists

public boolean exists()
Check existence of a table in the organization used by the application.

Returns:
true if the entity was already in the org before the application starts up or it has already been created

getExternalIdColumn

public ColumnImpl getExternalIdColumn()

getColumnByForceApiName

public ColumnImpl getColumnByForceApiName(String columnName)
Retrieves a Force.com column with a fully qualified Force.com API name.

Parameters:
columnName - a fully qualified Force.com API name
Returns:
a Force.com column registered with this TableImpl or null if no column with the given name exists

getColumnByJavaName

public ColumnImpl getColumnByJavaName(String columnName)
Retrieves a Force.com column with a Java field name.

Make sure if you're calling this that it happens after schema creation, because this will not be populated until all the class metadata has been fully initialized.

Parameters:
columnName - a Java field name
Returns:
a Force.com column registered with this TableImpl or null if no column with the given name exists

registerJavaColumn

public void registerJavaColumn(String javaFieldName,
                               ColumnImpl column)
Register a column impl (with specific Force.com attributes, like the API name) under its field or property name in java.

Parameters:
javaFieldName - the name of a field or property in java
column - the column object corresponding to this field

getColumnAt

public ColumnImpl getColumnAt(int columnIndex)
Retrieves a Force.com column at the given index.

Parameters:
columnIndex - index of the Force.com column registered with this TableImpl
Returns:
the Force.com column at the given index
Throws:
org.datanucleus.exceptions.NucleusException - if the given index is out of bounds

getListOfColumns

public List<ColumnImpl> getListOfColumns()

getTableName

public TableName getTableName()

toString

public String toString()
Overrides:
toString in class Object

getColumnsFor

public List<ColumnImpl> getColumnsFor(org.datanucleus.metadata.AbstractClassMetaData acmd,
                                      org.datanucleus.metadata.AbstractMemberMetaData ammd,
                                      ForceStoreManager storeManager,
                                      List<ColumnImpl> columns)
Retrieve a list of Force.com columns with the given JPA field metadata.

This method can handle embedded JPA metadata.

Parameters:
acmd - JPA class metadata
ammd - JPA field metadata
storeManager - ForceStoreManager
columns - list which will collect all embedded Force.com columns
Returns:
a list of Force.com columns registered with this TableImpl

getColumnAt

public ColumnImpl getColumnAt(org.datanucleus.metadata.AbstractClassMetaData acmd,
                              int fieldNumber)
Retrieve a Force.com column from the given JPA class metadata at the given field position.

Parameters:
acmd - JPA class metadata
fieldNumber - JPA field position
Returns:
a Force.com column registered with this TableImpl

getColumnFor

public ColumnImpl getColumnFor(org.datanucleus.metadata.AbstractClassMetaData acmd,
                               org.datanucleus.metadata.AbstractMemberMetaData ammd)
Retrieve a Force.com column with the given JPA field metadata.

Parameters:
acmd - JPA class metadata
ammd - JPA field metadata
Returns:
a Force.com column registered with this TableImpl
Throws:
org.datanucleus.exceptions.NucleusUserException - if no Force.com column can be found for the given JPA field metadata

getPKFieldName

public String getPKFieldName(org.datanucleus.metadata.AbstractClassMetaData acmd)
Retrieves the primary key Force.com API field name for the given class metadata.

Parameters:
acmd - JPA class metadata
Returns:
a Force.com API primary key field name

createTableAndFields

public void createTableAndFields(org.datanucleus.metadata.AbstractClassMetaData cmd,
                                 ForceStoreManager storeManager,
                                 ForceManagedConnection mconn)
Create the custom objects and fields for schema creation. This method should only be called if it has been verified that schema creation for tables is enabled

Parameters:
cmd - the class metadata for the table being created
storeManager - the store manager
mconn - the managed connection to the Force.com APIs

createFields

public void createFields(org.datanucleus.metadata.AbstractClassMetaData cmd,
                         ForceStoreManager storeManager)
Create custom fields only. If autoCreateTables is false but autoCreateColumns is true, this method should be called. It assumes that the table already exists in the org or has already been created

Parameters:
cmd - the class metadata for the table containing the fields to be created
storeManager - the store manager

refresh

public void refresh(com.sforce.soap.partner.DescribeSObjectResult result,
                    ForceManagedConnection mconn)
refresh the describe result to verify that objects have been created as we expected.

Parameters:
result - the describe result for this entity
mconn - the managed connection to the Force.com APIs

getTableAlreadyExistsInOrg

public boolean getTableAlreadyExistsInOrg()

getMetaData

public ForceTableMetaData getMetaData(org.datanucleus.metadata.AbstractClassMetaData cmd)
Retrieves Force.com table metadata for the given JPA class metadata.

Parameters:
cmd - JPA class metadata
Returns:
ForceTableMetaData


Copyright © 2011. All Rights Reserved.