Integrate Trifon's change from trunk revision 5799
Feature: [ 2028151 ] Dynamic column lenght validation http://sourceforge.net/tracker/index.php?func=detail&aid=2028151&group_id=176962&atid=883808
This commit is contained in:
parent
185a04088c
commit
5c4d6def6f
|
@ -566,13 +566,14 @@ public class ModelClassGenerator
|
||||||
// String length check
|
// String length check
|
||||||
if (clazz.equals(String.class) && fieldLength > 0)
|
if (clazz.equals(String.class) && fieldLength > 0)
|
||||||
{
|
{
|
||||||
|
sb.append( "\t\tint fieldLength = p_info.getFieldLength( COLUMNNAME_").append( columnName ).append( " );" ).append(NL);
|
||||||
sb.append ("\n\t\tif (");
|
sb.append ("\n\t\tif (");
|
||||||
if (!isMandatory)
|
if (!isMandatory)
|
||||||
sb.append(columnName).append(" != null && ");
|
sb.append(columnName).append(" != null && ");
|
||||||
sb.append(columnName).append(".length() > ").append(fieldLength).append(")").append(NL)
|
sb.append(columnName).append(".length() > fieldLength ").append(")").append(NL)
|
||||||
.append("\t\t{").append(NL)
|
.append("\t\t{").append(NL)
|
||||||
.append("\t\t\tlog.warning(\"Length > ").append(fieldLength).append(" - truncated\");").append(NL)
|
.append("\t\t\tlog.warning(\"Length > \" + fieldLength + \" - truncated\");").append(NL)
|
||||||
.append("\t\t\t").append(columnName).append(" = ").append(columnName).append(".substring(0, ").append(fieldLength).append(");").append(NL)
|
.append("\t\t\t").append(columnName).append(" = ").append( columnName ).append(".substring(0, fieldLength ").append(");").append(NL)
|
||||||
.append("\t\t}").append(NL)
|
.append("\t\t}").append(NL)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +600,7 @@ public class ModelClassGenerator
|
||||||
else if (clazz.equals(BigDecimal.class))
|
else if (clazz.equals(BigDecimal.class))
|
||||||
mandatory.append("Env.ZERO");
|
mandatory.append("Env.ZERO");
|
||||||
else if (clazz.equals(Timestamp.class))
|
else if (clazz.equals(Timestamp.class))
|
||||||
mandatory.append("new Timestamp(System.currentTimeMillis())");
|
mandatory.append("new Timestamp( System.currentTimeMillis() )");
|
||||||
else
|
else
|
||||||
mandatory.append("null");
|
mandatory.append("null");
|
||||||
mandatory.append(");").append(NL);
|
mandatory.append(");").append(NL);
|
||||||
|
|
|
@ -605,6 +605,20 @@ public class POInfo implements Serializable
|
||||||
return m_columns[index].FieldLength;
|
return m_columns[index].FieldLength;
|
||||||
} // getFieldLength
|
} // getFieldLength
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Column FieldLength
|
||||||
|
* @param columnName Column Name
|
||||||
|
* @return field length or 0
|
||||||
|
*/
|
||||||
|
public int getFieldLength (String columnName)
|
||||||
|
{
|
||||||
|
int index = getColumnIndex( columnName );
|
||||||
|
if (index >= 0) {
|
||||||
|
return getFieldLength( index );
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate Content
|
* Validate Content
|
||||||
* @param index index
|
* @param index index
|
||||||
|
|
Loading…
Reference in New Issue