use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.
the class JoinMetadataImpl method newIndexMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.JoinMetadata#newIndexMetadata()
*/
public IndexMetadata newIndexMetadata() {
IndexMetaData internalIdxmd = getInternal().newIndexMetaData();
IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
idxmd.parent = this;
return idxmd;
}
use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.
the class JDOMetaDataHelper method getXMLForMetaData.
/**
* Method to convert an internal class/interface metadata into the associated JDO XML metadata.
* @param cmd Metadata for the class/interface
* @param prefix Prefix for the XML (e.g " ")
* @param indent Indent for each block of XML (e.g " ")
* @return The XML
*/
public String getXMLForMetaData(AbstractClassMetaData cmd, String prefix, String indent) {
StringBuilder str = new StringBuilder();
boolean intf = (cmd instanceof InterfaceMetaData);
if (intf) {
str.append(prefix).append("<interface name=\"" + cmd.getName() + "\"");
} else {
str.append(prefix).append("<class name=\"" + cmd.getName() + "\"");
}
if (cmd.getIdentityType() != null) {
str.append("\n").append(prefix).append(" identity-type=\"" + cmd.getIdentityType() + "\"");
}
if (cmd.getObjectidClass() != null) {
str.append("\n").append(prefix).append(" objectid-class=\"" + cmd.getObjectidClass() + "\"");
}
if (!cmd.isRequiresExtent()) {
str.append("\n").append(prefix).append(" requires-extent=\"" + cmd.isRequiresExtent() + "\"");
}
if (cmd.isEmbeddedOnly()) {
str.append("\n").append(prefix).append(" embedded-only=\"" + cmd.isEmbeddedOnly() + "\"");
}
if (cmd.getPersistenceModifier() != null) {
str.append("\n").append(prefix).append(" persistence-modifier=\"" + cmd.getPersistenceModifier() + "\"");
}
if (cmd.getCatalog() != null) {
str.append("\n").append(prefix).append(" catalog=\"" + cmd.getCatalog() + "\"");
}
if (cmd.getSchema() != null) {
str.append("\n").append(prefix).append(" schema=\"" + cmd.getSchema() + "\"");
}
if (cmd.getTable() != null) {
str.append("\n").append(prefix).append(" table=\"" + cmd.getTable() + "\"");
}
if (cmd.isDetachable()) {
str.append("\n").append(prefix).append(" detachable=\"" + cmd.isDetachable() + "\"");
}
str.append(">\n");
// Identity
if (cmd.getIdentityMetaData() != null) {
str.append(getXMLForMetaData(cmd.getIdentityMetaData(), prefix + indent, indent));
}
// PrimaryKey
if (cmd.getPrimaryKeyMetaData() != null) {
str.append(getXMLForMetaData(cmd.getPrimaryKeyMetaData(), prefix + indent, indent));
}
// Inheritance
if (cmd.getInheritanceMetaData() != null) {
str.append(getXMLForMetaData(cmd.getInheritanceMetaData(), prefix + indent, indent));
}
// Add Version
if (cmd.getVersionMetaData() != null) {
str.append(getXMLForMetaData(cmd.getVersionMetaData(), prefix + indent, indent));
}
// Add joins
List<JoinMetaData> joins = cmd.getJoinMetaData();
if (joins != null) {
for (JoinMetaData joinmd : joins) {
str.append(getXMLForMetaData(joinmd, prefix + indent, indent));
}
}
// Add foreign-keys
List<ForeignKeyMetaData> foreignKeys = cmd.getForeignKeyMetaData();
if (foreignKeys != null) {
for (ForeignKeyMetaData fkmd : foreignKeys) {
str.append(getXMLForMetaData(fkmd, prefix + indent, indent));
}
}
// Add indexes
List<IndexMetaData> indexes = cmd.getIndexMetaData();
if (indexes != null) {
for (IndexMetaData idxmd : indexes) {
str.append(getXMLForMetaData(idxmd, prefix + indent, indent));
}
}
// Add unique constraints
List<UniqueMetaData> uniqueConstraints = cmd.getUniqueMetaData();
if (uniqueConstraints != null) {
for (UniqueMetaData unimd : uniqueConstraints) {
str.append(getXMLForMetaData(unimd, prefix + indent, indent));
}
}
// Add members
int numMembers = cmd.getNoOfMembers();
for (int i = 0; i < numMembers; i++) {
AbstractMemberMetaData mmd = cmd.getMetaDataForMemberAtRelativePosition(i);
str.append(getXMLForMetaData(mmd, prefix + indent, indent));
}
// Add unmapped columns
List<ColumnMetaData> unmappedColumns = cmd.getUnmappedColumns();
if (unmappedColumns != null) {
for (int i = 0; i < unmappedColumns.size(); i++) {
ColumnMetaData col = unmappedColumns.get(i);
str.append(getXMLForMetaData(col, prefix + indent, indent));
}
}
// Add queries
QueryMetaData[] queries = cmd.getQueries();
if (queries != null) {
for (int i = 0; i < queries.length; i++) {
QueryMetaData q = queries[i];
str.append(getXMLForMetaData(q, prefix + indent, indent));
}
}
// Add fetch-groups
Set<FetchGroupMetaData> fetchGroups = cmd.getFetchGroupMetaData();
if (fetchGroups != null) {
for (FetchGroupMetaData fgmd : fetchGroups) {
str.append(getXMLForMetaData(fgmd, prefix + indent, indent));
}
}
// Add extensions
processExtensions(cmd.getExtensions(), str, prefix, indent);
if (intf) {
str.append(prefix + "</interface>\n");
} else {
str.append(prefix + "</class>\n");
}
return str.toString();
}
use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.
the class KeyMetadataImpl method newIndexMetadata.
/* (non-Javadoc)
* @see javax.jdo.metadata.KeyMetadata#newIndexMetadata()
*/
public IndexMetadata newIndexMetadata() {
IndexMetaData internalIdxmd = getInternal().newIndexMetaData();
IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
idxmd.parent = this;
return idxmd;
}
use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.
the class MemberMetadataImpl method newIndexMetadata.
public IndexMetadata newIndexMetadata() {
IndexMetaData internalIdxmd = getInternal().newIndexMetaData();
IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
idxmd.parent = this;
return idxmd;
}
use of org.datanucleus.metadata.IndexMetaData in project datanucleus-api-jdo by datanucleus.
the class MemberMetadataImpl method getIndexMetadata.
public IndexMetadata getIndexMetadata() {
IndexMetaData internalIdxmd = getInternal().getIndexMetaData();
if (internalIdxmd == null) {
return null;
}
IndexMetadataImpl idxmd = new IndexMetadataImpl(internalIdxmd);
idxmd.parent = this;
return idxmd;
}
Aggregations