if (values != null && values.length > 0)
{
uniqueKeys = new HashSet<UniqueMetaData>(values.length);
for (int j=0;j<values.length;j++)
{
UniqueMetaData unimd = JDOAnnotationUtils.getUniqueMetaData(values[j].name(),
values[j].table(), "" + values[j].deferred(), values[j].members(), values[j].columns());
if (unimd.getNumberOfColumns() == 0 && unimd.getNumberOfMembers() == 0)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044205", cls.getName()));
}
else
{
uniqueKeys.add(unimd);
}
}
}
}
else if (annName.equals(JDOAnnotationUtils.UNIQUE))
{
// Single Unique constraint for the class
String name = (String)annotationValues.get("name");
String table = (String)annotationValues.get("table");
String deferred = (String)annotationValues.get("deferred");
String[] members = (String[])annotationValues.get("members");
Column[] columns = (Column[])annotationValues.get("columns");
UniqueMetaData unimd = JDOAnnotationUtils.getUniqueMetaData(name, table, deferred, members, columns);
if (unimd.getNumberOfColumns() == 0 && unimd.getNumberOfMembers() == 0)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044205", cls.getName()));
}
else
{
uniqueKeys = new HashSet<UniqueMetaData>(1);
uniqueKeys.add(unimd);
}
}
else if (annName.equals(JDOAnnotationUtils.FOREIGNKEYS))
{
// Multiple FKs for the class
ForeignKey[] values = (ForeignKey[])annotationValues.get("value");
if (values != null && values.length > 0)
{
fks = new HashSet<ForeignKeyMetaData>(values.length);
for (int j=0;j<values.length;j++)
{
String deleteAction = JDOAnnotationUtils.getForeignKeyActionString(values[j].deleteAction());
String updateAction = JDOAnnotationUtils.getForeignKeyActionString(values[j].deleteAction());
ForeignKeyMetaData fkmd = JDOAnnotationUtils.getFKMetaData(values[j].name(),
values[j].table(), values[j].unique(), "" + values[j].deferred(),
deleteAction, updateAction, values[j].members(), values[j].columns());
if (fkmd.getNumberOfColumns() == 0 && fkmd.getNumberOfMembers() == 0)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044206", cls.getName()));
}
else
{
fks.add(fkmd);
}
}
}
}
else if (annName.equals(JDOAnnotationUtils.FOREIGNKEY))
{
// Single FK constraint for the class
String name = (String)annotationValues.get("name");
String table = (String)annotationValues.get("table");
String unique = (String)annotationValues.get("unique");
String deferred = (String)annotationValues.get("deferred");
String deleteAction = JDOAnnotationUtils.getForeignKeyActionString(
(ForeignKeyAction)annotationValues.get("deleteAction"));
String updateAction = JDOAnnotationUtils.getForeignKeyActionString(
(ForeignKeyAction)annotationValues.get("updateAction"));
String[] members = (String[])annotationValues.get("members");
Column[] columns = (Column[])annotationValues.get("columns");
ForeignKeyMetaData fkmd = JDOAnnotationUtils.getFKMetaData(name, table, unique, deferred,
deleteAction, updateAction, members, columns);
if (fkmd.getNumberOfColumns() == 0 && fkmd.getNumberOfMembers() == 0)
{
NucleusLogger.METADATA.warn(LOCALISER.msg("044206", cls.getName()));
}
else
{
fks = new HashSet<ForeignKeyMetaData>(1);
fks.add(fkmd);
}
}
else if (annName.equals(JDOAnnotationUtils.COLUMNS))
{
// Unmapped column specification
Column[] cols = (Column[])annotationValues.get("value");
if (cols != null && cols.length > 0)
{
unmappedColumns = new ColumnMetaData[cols.length];
for (int j=0;j<cols.length;j++)
{
unmappedColumns[j] =
JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(cols[j]);
JDOAnnotationUtils.addExtensionsToMetaData(unmappedColumns[j], cols[j].extensions());
}
}
}
else if (annName.equals(JDOAnnotationUtils.CACHEABLE))
{
String cache = (String)annotationValues.get("value");
if (cache != null)
{
cacheable = cache;
}
}
else if (annName.equals(JDOAnnotationUtils.EXTENSIONS))
{
Extension[] values = (Extension[])annotationValues.get("value");
if (values != null && values.length > 0)
{
extensions = new HashSet<ExtensionMetaData>(values.length);
for (int j=0;j<values.length;j++)
{
ExtensionMetaData extmd = new ExtensionMetaData(values[j].vendorName(),
values[j].key().toString(), values[j].value().toString());
extensions.add(extmd);
}
}
}
else if (annName.equals(JDOAnnotationUtils.EXTENSION))
{
ExtensionMetaData extmd = new ExtensionMetaData((String)annotationValues.get("vendorName"),
(String)annotationValues.get("key"), (String)annotationValues.get("value"));
extensions = new HashSet<ExtensionMetaData>(1);
extensions.add(extmd);
}
else
{
if (!annName.equals(JDOAnnotationUtils.PERSISTENCE_CAPABLE) &&
!annName.equals(JDOAnnotationUtils.PERSISTENCE_AWARE))
{
NucleusLogger.METADATA.error(LOCALISER.msg("044203", cls.getName(),
annotations[i].getName()));
}
}
}
}
// Either PersistenceCapable, PersistenceAware or PersistentInterface so build up the metadata
NucleusLogger.METADATA.info(LOCALISER.msg("044200", cls.getName(), "JDO"));
if (cmd instanceof ClassMetaData)
{
pmd.addClass((ClassMetaData)cmd);
}
else if (cmd instanceof InterfaceMetaData)
{
pmd.addInterface((InterfaceMetaData)cmd);
}
if (embeddedOnly)
{
cmd.setEmbeddedOnly(true);
}
if (idmd != null)
{
// Datastore identity
idmd.setParent(cmd);
cmd.setIdentityMetaData(idmd);
}
if (pkmd != null)
{
// Primary Key
pkmd.setParent(cmd);
cmd.setPrimaryKeyMetaData(pkmd);
}
if (vermd != null)
{
// Version
vermd.setParent(cmd);
cmd.setVersionMetaData(vermd);
}
if (inhmd != null)
{
// Inheritance
if (dismd != null)
{
inhmd.setDiscriminatorMetaData(dismd);
}
inhmd.setParent(cmd);
cmd.setInheritanceMetaData(inhmd);
}
else if (dismd != null)
{
inhmd = new InheritanceMetaData();
inhmd.setDiscriminatorMetaData(dismd);
cmd.setInheritanceMetaData(inhmd);
}
if (joins != null && joins.length > 0)
{
// Joins
for (int i=0;i<joins.length;i++)
{
cmd.addJoin(joins[i]);
}
}
if (queries != null && queries.length > 0)
{
// Named Queries
for (int i=0;i<queries.length;i++)
{
queries[i].setParent(cmd);
cmd.addQuery(queries[i]);
}
}
if (fetchGroups != null && fetchGroups.length > 0)
{
// Fetch Groups
for (int i=0;i<fetchGroups.length;i++)
{
fetchGroups[i].setParent(cmd);
cmd.addFetchGroup(fetchGroups[i]);
}
}
if (seqmd != null)
{
// Sequence - currently only allowing 1 per class (should really be on the package)
cmd.getPackageMetaData().addSequence(seqmd);
}
if (indices != null)
{
Iterator iter = indices.iterator();
while (iter.hasNext())
{
IndexMetaData idxmd = (IndexMetaData)iter.next();
idxmd.setParent(cmd);
cmd.addIndex(idxmd);
}
}
if (uniqueKeys != null)
{
Iterator iter = uniqueKeys.iterator();
while (iter.hasNext())
{
UniqueMetaData unimd = (UniqueMetaData)iter.next();
unimd.setParent(cmd);
cmd.addUniqueConstraint(unimd);
}
}
if (fks != null)
{