Class EjbConversionHelper
- java.lang.Object
-
- com.sun.jdo.spi.persistence.support.ejb.ejbc.EjbConversionHelper
-
- All Implemented Interfaces:
ConversionHelper
public class EjbConversionHelper extends Object implements ConversionHelper
-
-
Field Summary
-
Fields inherited from interface com.sun.jdo.api.persistence.mapping.ejb.ConversionHelper
MANY, ONE
-
-
Constructor Summary
Constructors Constructor Description EjbConversionHelper(NameMapper nameMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplyDefaultUnknownPKClassStrategy(String ejbName)Returns flag whether the mapping conversion should apply the default strategy for dealing with unknown primary key classes.booleanensureValidation()Returns the flag whether the mapping conversion should validate all fields against schema columns.booleangenerateFields()Returns the flag whether the mapping conversion should generate relationship fields and primary key fields to support run-time.Object[]getFields(String ejbName)IfgenerateFieldsistrue, then this method will return an array of cmp + cmr + pseudo cmr fields, otherwise the method will return an array of cmp + cmr fields.StringgetGeneratedPKFieldName()Returns the name used for generated primary key fields.ListgetGeneratedRelationships(String ejbName)Returns a list of generated relationship field names.StringgetGeneratedVersionFieldNamePrefix()Returns the prefix used for generated version fields.StringgetInverseFieldName(String ejbName, String fieldName)This method return the fieldName of relation role on the other end.StringgetMappedClassName(String ejbName)Computes the name of the TP implementation class for a bean.StringgetMultiplicity(String ejbName, String fieldName)getMultiplicity of the other role on the relationship Please note that multiplicity is JDO styleStringgetRelationshipFieldContent(String ejbName, String fieldName)Return the name of the opposite roles ejb-nameStringgetRelationshipFieldType(String ejbName, String fieldName)This API will only be called from MappingFile when multiplicity is Many on the other role.booleanhasField(String ejbName, String fieldName)IfgenerateFieldsistrue, then this method will check if the field is one of the cmp + cmr + pseudo cmr fields, otherwise the method will check if the field is one of the cmp + cmr fields.booleanisGeneratedField(String ejbName, String fieldName)Returnstrueif the field is generated.booleanisGeneratedRelationship(String ejbName, String fieldName)Flag whether the conversion helper generated the relationship fieldbooleanisKey(String ejbName, String fieldName, boolean candidate)The boolean argument candidate is ignored in this case.booleanrelatedObjectsAreDeleted(String beanName, String fieldName)voidsetEnsureValidation(boolean isValidating)Sets the flag whether the mapping conversion should validate all fields against schema columns.voidsetGenerateFields(boolean generateFields)Sets the flag whether the mapping conversion should generate relationship fields, primary key fields, and version fields to support run-time.
-
-
-
Constructor Detail
-
EjbConversionHelper
public EjbConversionHelper(NameMapper nameMapper)
-
-
Method Detail
-
getMappedClassName
public String getMappedClassName(String ejbName)
Description copied from interface:ConversionHelperComputes the name of the TP implementation class for a bean.- Specified by:
getMappedClassNamein interfaceConversionHelper- Parameters:
ejbName- 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
public boolean hasField(String ejbName, String fieldName)
IfgenerateFieldsistrue, then this method will check if the field is one of the cmp + cmr + pseudo cmr fields, otherwise the method will check if the field is one of the cmp + cmr fields.- Specified by:
hasFieldin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the beanfieldName- The name of a container managed field in the named bean- Returns:
trueif the bean contains the field, otherwise returnfalse
-
getFields
public Object[] getFields(String ejbName)
IfgenerateFieldsistrue, then this method will return an array of cmp + cmr + pseudo cmr fields, otherwise the method will return an array of cmp + cmr fields.- Specified by:
getFieldsin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the bean- Returns:
- an array of fields in the ejb bean
-
isKey
public boolean isKey(String ejbName, String fieldName, boolean candidate)
The boolean argument candidate is ignored in this case.- Specified by:
isKeyin interfaceConversionHelper- Parameters:
ejbName- 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.
-
getRelationshipFieldType
public String getRelationshipFieldType(String ejbName, String fieldName)
This API will only be called from MappingFile when multiplicity is Many on the other role.- Specified by:
getRelationshipFieldTypein interfaceConversionHelper- 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".
-
getMultiplicity
public String getMultiplicity(String ejbName, String fieldName)
getMultiplicity of the other role on the relationship Please note that multiplicity is JDO style- Specified by:
getMultiplicityin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the beanfieldName- The name of a container managed field in the named bean.- Returns:
- The String values "One" or "Many".
-
getRelationshipFieldContent
public String getRelationshipFieldContent(String ejbName, String fieldName)
Description copied from interface:ConversionHelperReturn the name of the opposite roles ejb-name- Specified by:
getRelationshipFieldContentin interfaceConversionHelper- 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.
-
getInverseFieldName
public String getInverseFieldName(String ejbName, String fieldName)
This method return the fieldName of relation role on the other end.- Specified by:
getInverseFieldNamein interfaceConversionHelper- 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
public boolean applyDefaultUnknownPKClassStrategy(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 whengenerateFieldsreturnstrue.- Specified by:
applyDefaultUnknownPKClassStrategyin interfaceConversionHelper- Parameters:
ejbName- The value of the ejb-name element for a bean.- Returns:
trueto apply the default unknown PK Class Strategy,falseotherwise
-
getGeneratedPKFieldName
public String getGeneratedPKFieldName()
Returns the name used for generated primary key fields.- Specified by:
getGeneratedPKFieldNamein interfaceConversionHelper- Returns:
- a string for key field name
-
getGeneratedVersionFieldNamePrefix
public String getGeneratedVersionFieldNamePrefix()
Returns the prefix used for generated version fields.- Specified by:
getGeneratedVersionFieldNamePrefixin interfaceConversionHelper- Returns:
- a string for version field name prefix
-
relatedObjectsAreDeleted
public boolean relatedObjectsAreDeleted(String beanName, String fieldName)
- Specified by:
relatedObjectsAreDeletedin interfaceConversionHelper- Parameters:
beanName- The ejb-name element for the beanfieldName- 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
public 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 evengenerateFieldsisfalsebecause it holds version column information.- Specified by:
generateFieldsin interfaceConversionHelper- Returns:
trueto generate fields in the dot-mapping file (if they are not present).
-
setGenerateFields
public 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.- Specified by:
setGenerateFieldsin interfaceConversionHelper- Parameters:
generateFields- a flag which indicates whether fields should be generated
-
ensureValidation
public boolean ensureValidation()
Returns the flag whether the mapping conversion should validate all fields against schema columns.- Specified by:
ensureValidationin interfaceConversionHelper- Returns:
trueto validate all the fields in the dot-mapping file.
-
setEnsureValidation
public void setEnsureValidation(boolean isValidating)
Sets the flag whether the mapping conversion should validate all fields against schema columns.- Specified by:
setEnsureValidationin interfaceConversionHelper- Parameters:
isValidating- a boolean of indicating validating fields or not
-
isGeneratedField
public boolean isGeneratedField(String ejbName, String fieldName)
Returnstrueif the field is generated. There are three types of generated fields: generated relationships, unknown primary key fields, and version consistency fields.- Specified by:
isGeneratedFieldin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the beanfieldName- The name of a container managed field in the named bean- Returns:
trueif the field is generated;falseotherwise.
-
isGeneratedRelationship
public boolean isGeneratedRelationship(String ejbName, String fieldName)
Description copied from interface:ConversionHelperFlag whether the conversion helper generated the relationship field- Specified by:
isGeneratedRelationshipin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the beanfieldName- The name of a container managed field in the named bean.- Returns:
trueif the field was created by the conversion helper.
-
getGeneratedRelationships
public List getGeneratedRelationships(String ejbName)
Returns a list of generated relationship field names.- Specified by:
getGeneratedRelationshipsin interfaceConversionHelper- Parameters:
ejbName- The ejb-name element for the bean- Returns:
- a list of generated relationship field names
-
-