{
boolean hasClassPrefix = false;
boolean hasModelPrefix = false;
boolean hasAlternateName = false;
ModelClass modelClass = modelField.getModelClass();
JPoxClassMetadata classMetadata = (JPoxClassMetadata) modelClass.getMetadata( JPoxClassMetadata.ID );
JPoxModelMetadata modelMetadata = (JPoxModelMetadata) modelClass.getModel().getMetadata( JPoxModelMetadata.ID );
String prefix = "";
if ( StringUtils.isNotEmpty( modelMetadata.getColumnPrefix() ) )
{
prefix = modelMetadata.getColumnPrefix().trim();
hasModelPrefix = true;
}
if ( StringUtils.isNotEmpty( classMetadata.getColumnPrefix() ) )
{
prefix = classMetadata.getColumnPrefix();
hasClassPrefix = true;
}
String columnName = "";
if ( StringUtils.isNotEmpty( fieldMetadata.getColumnName() ) )
{
columnName = prefix + fieldMetadata.getColumnName();
hasAlternateName = true;
}
else
{
columnName = prefix + modelField.getName();
}
if ( sqlReservedWords.isKeyword( columnName ) )
{
StringBuffer emsg = new StringBuffer();
/* ----------------------------------------------------------------
* SQL Reserved Word Violation: 'ROLES'
* Context: TABLE NAME
*/
emsg.append( EOL ).append( ERROR_LINE ).append( EOL );
emsg.append( " SQL Reserved Word Violation: " ).append( columnName ).append( EOL );
emsg.append( " Context: COLUMN NAME" ).append( EOL );
emsg.append( " " ).append( EOL );
/* In Model:
* <model jpox.column-prefix="">
* <class jpox.column-prefix="">
* <name>JdoRole</name>
* <fields>
* <field jpox.column="">
* <name>operation</name>
* </field>
* </fields>
* </class>
* </model>
*/
emsg.append( " In Model:" ).append( EOL );
emsg.append( " <model" );
if ( hasModelPrefix )
{
emsg.append( " jpox.column-prefix=\"" ).append( modelMetadata.getColumnPrefix() ).append( "\"" );
}
emsg.append( ">" ).append( EOL );
emsg.append( " <class" );
if ( hasClassPrefix )
{
emsg.append( " jpox.column-prefix=\"" ).append( classMetadata.getColumnPrefix() ).append( "\"" );
}
emsg.append( ">" ).append( EOL );
emsg.append( " <name>" ).append( modelClass.getName() ).append( "</name>" ).append( EOL );
emsg.append( " <fields>" ).append( EOL );
emsg.append( " <field" );
if ( hasAlternateName )
{
emsg.append( " jpox.column=\"" ).append( fieldMetadata.getColumnName() ).append( "\"" );
}
emsg.append( ">" ).append( EOL );
emsg.append( " <name>" ).append( modelField.getName() ).append( "</name>" ).append( EOL );
emsg.append( " <field>" ).append( EOL );
emsg.append( " </fields>" ).append( EOL );
emsg.append( " </class>" ).append( EOL );
emsg.append( " </model>" ).append( EOL );
emsg.append( " " ).append( EOL );
/* Violation Source(s): Oracle (WARNING)
* SQL 99 (ERROR)
*
* Severity: ERROR - You must change this name for maximum
* compatibility amoungst JDBC SQL Servers.
*
* Severity: WARNING - You are encouraged to change this name
* for maximum compatibility amoungst JDBC SQL Servers.
*/
boolean hasError = appendKeywordSourceViolations( columnName, emsg );
/* Suggestions: 1) Use a different model column prefix in
* <model jpox.column-prefix="DIFFERENT_">
* 2) Use a different class column prefix in
* <class jpox.column-prefix="DIFFERENT_">
* 3) Use a different alternate column name using
* <field jpox.column="DIFFERENT">
* 4) Use a different field name in
* <class>
* <name>Foo</name>
* <fields>
* <field>
* <name>DIFFERENT</name>
* </field>
* </fields>
* </class>
* ----------------------------------------------------------------
*/
emsg.append( " Suggestions: 1) Use a different model column prefix in" ).append( EOL );
emsg.append( " <model jpox.column-prefix=\"DIFFERENT_\">" ).append( EOL );
emsg.append( " 2) Use a different class column prefix in" ).append( EOL );
emsg.append( " <class jpox.column-prefix=\"DIFFERENT_\">" ).append( EOL );
emsg.append( " 3) Use a different alternate column name using" ).append( EOL );
emsg.append( " <field jpox.column=\"DIFFERENT\">" ).append( EOL );
emsg.append( " 4) Use a different field name in" ).append( EOL );
emsg.append( " <class>" ).append( EOL );
emsg.append( " <name>" ).append( modelClass.getName() ).append( "</name>" ).append( EOL );
emsg.append( " <fields>" ).append( EOL );
emsg.append( " <field>" ).append( EOL );
emsg.append( " <name>DIFFERENT</name>" ).append( EOL );
emsg.append( " <field>" ).append( EOL );
emsg.append( " </fields>" ).append( EOL );