new Object[] {this});
IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
Iterator indexIter = tableIndexInfo.getChildren().iterator();
while (indexIter.hasNext())
{
IndexInfo indexInfo = (IndexInfo)indexIter.next();
boolean isUnique = !((Boolean)indexInfo.getProperty("non_unique")).booleanValue();
if (isUnique)
{
// Only utilise unique indexes
short idxType = ((Short)indexInfo.getProperty("type")).shortValue();
if (idxType == DatabaseMetaData.tableIndexStatistic)
{
// Ignore
continue;
}
String keyName = (String)indexInfo.getProperty("index_name");
DatastoreIdentifier idxName = idFactory.newIdentifier(IdentifierType.CANDIDATE_KEY, keyName);
CandidateKey key = (CandidateKey) candidateKeysByName.get(idxName);
if (key == null)
{
key = new CandidateKey(this);
key.setName(keyName);
candidateKeysByName.put(idxName, key);
}
// Set the column
int colSeq = ((Short)indexInfo.getProperty("ordinal_position")).shortValue() - 1;
DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierType.COLUMN,
(String)indexInfo.getProperty("column_name"));
Column col = columnsByName.get(colName);
if (col != null)
{
key.setDatastoreField(colSeq, col);
}