*/
private void addLocalField(
SourceElement foreignKey,
ControllerState controllerState)
{
SourceElement foreignTable = foreignKey.getChild(
TorqueSchemaElementName.TABLE);
String referencedBySuffix = getLocalReferencedBySuffix(
foreignKey, controllerState);
// the field name for the variable used
String localFieldName = (String) controllerState.getOption(
TemplateOptionName.OM_LOCAL_FIELD_NAME_PREFIX)
+ foreignTable.getAttribute(
TableAttributeName.DB_OBJECT_CLASS_NAME)
+ controllerState.getOption(
TemplateOptionName.OM_LOCAL_FIELD_NAME_SUFFIX)
+ referencedBySuffix;
// the field name to create the getter and setter names
String getterSetterFieldName
= (String) foreignTable.getAttribute(
TableAttributeName.DB_OBJECT_CLASS_NAME)
+ referencedBySuffix;
SourceElement localFieldElement
= new SourceElement(
ForeignKeyChildElementName.LOCAL_FIELD);
localFieldElement.setAttribute(
JavaFieldAttributeName.FIELD_NAME,
localFieldName.toString());
localFieldElement.setAttribute(
JavaFieldAttributeName.PROPERTY_NAME,
getterSetterFieldName.toString());
String fieldType = (String) foreignTable.getAttribute(
TableAttributeName.DB_OBJECT_CLASS_NAME);
localFieldElement.setAttribute(
JavaFieldAttributeName.FIELD_TYPE,
fieldType);
localFieldElement.setAttribute(
JavaFieldAttributeName.DEFAULT_VALUE,
"null");
{
String getterName = FieldHelper.getGetterName(
getterSetterFieldName,
fieldType,
controllerState);
localFieldElement.setAttribute(
JavaFieldAttributeName.GETTER_NAME,
getterName);
}
{
String setterName = FieldHelper.getSetterName(
getterSetterFieldName);
localFieldElement.setAttribute(
JavaFieldAttributeName.SETTER_NAME,
setterName);
}
{
String fillerName = FieldHelper.getFillerName(
getterSetterFieldName,
"",
controllerState);
localFieldElement.setAttribute(
JavaFieldAttributeName.FILLER_NAME,
fillerName);
}
foreignKey.getChildren().add(localFieldElement);
}