com.sun.jdo.api.persistence.mapping.ejb
Interface ConversionHelper


public interface ConversionHelper

Helper interface for the MappingFile. The mapping file classes use an object that implements this interface to assist in the conversion from the sun-cmp-mapping file, into a TP dot-mapping file. The APIs to the deployment descriptors differ at deployment time and at development time. This interface provides a level of abstraction for the needed information.

Version:
1.0
Author:
vkraemer

Field Summary
static java.lang.String MANY
           
static java.lang.String ONE
           
 
Method Summary
 boolean applyDefaultUnknownPKClassStrategy(java.lang.String ejbName)
          Returns flag whether the mapping conversion should apply the default strategy for dealing with unknown primary key classes.
 boolean ensureValidation()
          Returns the flag whether the mapping conversion should validate all fields against schema columns.
 boolean generateFields()
          Returns the flag whether the mapping conversion should generate relationship fields and primary key fields to support run-time.
 java.lang.Object[] getFields(java.lang.String beanName)
           
 java.lang.String getGeneratedPKFieldName()
          Returns the name used for generated primary key fields.
 java.util.List getGeneratedRelationships(java.lang.String ejbName)
          Returns a list of generated relationship field names.
 java.lang.String getGeneratedVersionFieldNamePrefix()
          Returns the prefix used for generated version fields.
 java.lang.String getInverseFieldName(java.lang.String ejbName, java.lang.String fieldName)
           
 java.lang.String getMappedClassName(java.lang.String beanName)
          Computes the name of the TP implementation class for a bean.
 java.lang.String getMultiplicity(java.lang.String ejbName, java.lang.String fieldName)
           
 java.lang.String getRelationshipFieldContent(java.lang.String ejbName, java.lang.String fieldName)
          Return the name of the opposite roles ejb-name
 java.lang.String getRelationshipFieldType(java.lang.String ejbName, java.lang.String fieldName)
           
 boolean hasField(java.lang.String beanName, java.lang.String fieldName)
           
 boolean isGeneratedField(java.lang.String ejbName, java.lang.String fieldName)
          Returns true if the field is generated.
 boolean isGeneratedRelationship(java.lang.String ejbName, java.lang.String fieldName)
          Flag whether the conversion helper generated the relationship field
 boolean isKey(java.lang.String beanName, java.lang.String fieldName, boolean candidate)
          Compute the keyness of a field.
 boolean relatedObjectsAreDeleted(java.lang.String ejbName, java.lang.String fieldName)
           
 void setEnsureValidation(boolean isValidating)
          Sets the flag whether the mapping conversion should validate all fields against schema columns.
 void setGenerateFields(boolean generateFields)
          Sets the flag whether the mapping conversion should generate relationship fields, primary key fields, and version fields to support run-time.
 

Field Detail

ONE

static final java.lang.String ONE
See Also:
Constant Field Values

MANY

static final java.lang.String MANY
See Also:
Constant Field Values
Method Detail

getMappedClassName

java.lang.String getMappedClassName(java.lang.String beanName)
Computes the name of the TP implementation class for a bean.

Parameters:
beanName - The value of the ejb-name element for a bean.
Returns:
The full name of the TP class that implements the fields and relationships of an EJB.

hasField

boolean hasField(java.lang.String beanName,
                 java.lang.String fieldName)
Parameters:
beanName - Name of bean to investigate for field.
fieldName - Name of field sought in named bean.
Returns:
True if the named bean has the named field

getFields

java.lang.Object[] getFields(java.lang.String beanName)

isKey

boolean isKey(java.lang.String beanName,
              java.lang.String fieldName,
              boolean candidate)
Compute the keyness of a field. The value returned is the keyness of the field, if it is computable. If it is not, the candidate value is returned.

Parameters:
beanName - The value of the ejb-name element for a bean.
fieldName - The name of a container managed field in the named bean.
candidate - The value "proposed" by the content of the sun-cmp-mapping file.
Returns:
The real value of the keyness of a field. This may be different than the candidate value, if the correct values of a fields keyness can be computed from available data.

getRelationshipFieldContent

java.lang.String getRelationshipFieldContent(java.lang.String ejbName,
                                             java.lang.String fieldName)
Return the name of the opposite roles ejb-name

Parameters:
ejbName - The value of the ejb-name element for a bean.
fieldName - The name of a container managed field in the named bean.
Returns:
The ejb-name of the bean that is referenced by a relationship field. This is the ejb-name of the "other" roles relationship-role-source.

getMultiplicity

java.lang.String getMultiplicity(java.lang.String ejbName,
                                 java.lang.String fieldName)
Parameters:
ejbName - The ejb-name element for the bean
fieldName - The name of a container managed field in the named bean.
Returns:
The String values "One" or "Many".

getRelationshipFieldType

java.lang.String getRelationshipFieldType(java.lang.String ejbName,
                                          java.lang.String fieldName)
Parameters:
ejbName - The value of the ejb-name element for a bean.
fieldName - The name of a container managed field in the named bean.
Returns:
The String values "One" or "Many".

getInverseFieldName

java.lang.String getInverseFieldName(java.lang.String ejbName,
                                     java.lang.String fieldName)
Parameters:
ejbName - The value of the ejb-name element for a bean.
fieldName - The name of a container managed field in the named bean.
Returns:
The String values "One" or "Many".

applyDefaultUnknownPKClassStrategy

boolean applyDefaultUnknownPKClassStrategy(java.lang.String ejbName)
Returns flag whether the mapping conversion should apply the default strategy for dealing with unknown primary key classes. This method will only be called when generateFields() returns true.

Parameters:
ejbName - The value of the ejb-name element for a bean.
Returns:
true to apply the default unknown PK Class Strategy, false otherwise

getGeneratedPKFieldName

java.lang.String getGeneratedPKFieldName()
Returns the name used for generated primary key fields.

Returns:
a string for key field name

getGeneratedVersionFieldNamePrefix

java.lang.String getGeneratedVersionFieldNamePrefix()
Returns the prefix used for generated version fields.

Returns:
a string for version field name prefix

relatedObjectsAreDeleted

boolean relatedObjectsAreDeleted(java.lang.String ejbName,
                                 java.lang.String fieldName)
Parameters:
ejbName - The ejb-name element for the bean
fieldName - The name of a container managed field in the named bean.
Returns:
boolean flag indicating whether the objects in this collection field are to be deleted when this field' owning object is deleted.

generateFields

boolean generateFields()
Returns the flag whether the mapping conversion should generate relationship fields and primary key fields to support run-time. The version field is always created even generateFields() is false because it holds version column information.

Returns:
true to generate fields in the dot-mapping file (if they are not present).

setGenerateFields

void setGenerateFields(boolean generateFields)
Sets the flag whether the mapping conversion should generate relationship fields, primary key fields, and version fields to support run-time.

Parameters:
generateFields - a flag which indicates whether fields should be generated

ensureValidation

boolean ensureValidation()
Returns the flag whether the mapping conversion should validate all fields against schema columns.

Returns:
true to validate all the fields in the dot-mapping file.

setEnsureValidation

void setEnsureValidation(boolean isValidating)
Sets the flag whether the mapping conversion should validate all fields against schema columns.

Parameters:
isValidating - a boolean of indicating validating fields or not

isGeneratedField

boolean isGeneratedField(java.lang.String ejbName,
                         java.lang.String fieldName)
Returns true if the field is generated. There are three types of generated fields: generated relationships, unknown primary key fields, and version consistency fields.

Parameters:
ejbName - The ejb-name element for the bean
fieldName - The name of a container managed field in the named bean
Returns:
true if the field is generated; false otherwise.

isGeneratedRelationship

boolean isGeneratedRelationship(java.lang.String ejbName,
                                java.lang.String fieldName)
Flag whether the conversion helper generated the relationship field

Parameters:
ejbName - The ejb-name element for the bean
fieldName - The name of a container managed field in the named bean.
Returns:
true if the field was created by the conversion helper.

getGeneratedRelationships

java.util.List getGeneratedRelationships(java.lang.String ejbName)
Returns a list of generated relationship field names.

Parameters:
ejbName - The ejb-name element for the bean
Returns:
a list of generated relationship field names


Copyright © 2012 GlassFish Community. All Rights Reserved.