String tableName = tableRs.getString("TABLE_NAME");
if (StringUtils.isNotBlank(this.tableNamePattern))
{
if (tableName.matches(this.tableNamePattern))
{
UmlClass umlClass = this.createClass(modelPackage, metadata, corePackage, tableName);
this.classes.put(tableName, umlClass);
}
}
else
{
UmlClass umlClass = this.createClass(modelPackage, metadata, corePackage, tableName);
this.classes.put(tableName, umlClass);
}
}
DbUtils.closeQuietly(tableRs);
if (this.classes.isEmpty())
{
String schemaName = "";
if (StringUtils.isNotEmpty(this.schema))
{
schemaName = " '" + this.schema + "' ";
}
StringBuffer warning = new StringBuffer("WARNING! No tables found in schema");
warning.append(schemaName);
if (StringUtils.isNotEmpty(this.tableNamePattern))
{
warning.append(" matching pattern --> '" + this.tableNamePattern + "'");
}
logger.warn(warning);
}
// add all attributes and associations to the modelPackage
Iterator tableNameIt = this.classes.keySet().iterator();
while (tableNameIt.hasNext())
{
String tableName = (String)tableNameIt.next();
UmlClass umlClass = (UmlClass)classes.get(tableName);
if (logger.isInfoEnabled())
{
logger.info("created class --> '" + umlClass.getName() + "'");
}
// create and add all associations to the package
modelPackage.getOwnedElement().addAll(this.createAssociations(metadata, corePackage, tableName));
// create and add all the attributes
umlClass.getFeature().addAll(this.createAttributes(metadata, corePackage, tableName));
modelPackage.getOwnedElement().add(umlClass);
}
}