private boolean hasUselessSurrogateKey(final Table table) { if (!(table instanceof View) && table.getPrimaryKey() != null) { boolean hasUselessSurrogateKey = true; for (final Column column : table.getColumns()) { if (column.isPartOfPrimaryKey()) { continue; } if (!column.isPartOfForeignKey()) { hasUselessSurrogateKey = false; break; } } return hasUselessSurrogateKey; } return false; }
private Element createColumnElement(final Document dom, final Column column) { final Element eColumn = dom.createElement("column"); final String columnName = getPhysicalName(column.getName()); eColumn.setAttribute("name", getLogicalName(columnName)); eColumn.setAttribute("physicalname", columnName); setColumnTypeAttributes(eColumn, column, "table"); String requirement = null; if (column.isPartOfPrimaryKey()) { requirement = "primarykey"; } else { requirement = column.isNullable() ? "optional" : "mandatory"; } eColumn.setAttribute("requirement", requirement); return eColumn; }
public static Connectivity getConnectivity(final Column fkColumn) { if (fkColumn == null) { return Connectivity.unknown; } boolean isColumnReference; try { fkColumn.getColumnDataType(); isColumnReference = false; } catch (final Exception e) { isColumnReference = true; } if (isColumnReference) { return Connectivity.unknown; } if (fkColumn.isPartOfPrimaryKey() || fkColumn.isPartOfUniqueIndex()) { return Connectivity.zero_one; } else { return Connectivity.zero_many; } }