class JpaIdColumnVisitor extends BaseTreeVisitor {
@Override
public boolean onStartNode(ProjectPath path) {
JpaColumn jpaColumn = (JpaColumn) path.getObject();
DbAttribute dbAttribute = new DbAttribute(jpaColumn.getName());
JpaId jpaId = path.firstInstanceOf(JpaId.class);
dbAttribute.setType(jpaId.getDefaultJdbcType());
dbAttribute.setMaxLength(jpaColumn.getLength());
dbAttribute.setMandatory(true);
dbAttribute.setPrimaryKey(true);
if (jpaColumn.getScale() > 0) {
dbAttribute.setScale(jpaColumn.getScale());
}
if (jpaColumn.getPrecision() > 0) {
dbAttribute.setAttributePrecision(jpaColumn.getPrecision());
}
if (jpaColumn.getTable() == null) {
recordConflict(path, "No table defined for JpaColumn '"
+ jpaColumn.getName()
+ "'");
return false;
}
DbEntity entity = targetPath.firstInstanceOf(DataMap.class).getDbEntity(
jpaColumn.getTable());
if (entity == null) {
recordConflict(path, "Invalid table definition for JpaColumn: "
+ jpaColumn.getTable()
+ "'");
return false;
}
entity.addAttribute(dbAttribute);