Search in sources :

Example 6 with IndexMetaData

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;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 7 with IndexMetaData

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();
}
Also used : UniqueMetaData(org.datanucleus.metadata.UniqueMetaData) IndexMetaData(org.datanucleus.metadata.IndexMetaData) QueryMetaData(org.datanucleus.metadata.QueryMetaData) InterfaceMetaData(org.datanucleus.metadata.InterfaceMetaData) JoinMetaData(org.datanucleus.metadata.JoinMetaData) ForeignKeyMetaData(org.datanucleus.metadata.ForeignKeyMetaData) ColumnMetaData(org.datanucleus.metadata.ColumnMetaData) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) FetchGroupMetaData(org.datanucleus.metadata.FetchGroupMetaData)

Example 8 with IndexMetaData

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;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 9 with IndexMetaData

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;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Example 10 with IndexMetaData

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;
}
Also used : IndexMetaData(org.datanucleus.metadata.IndexMetaData)

Aggregations

IndexMetaData (org.datanucleus.metadata.IndexMetaData)27 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)5 ForeignKeyMetaData (org.datanucleus.metadata.ForeignKeyMetaData)5 ColumnMetaData (org.datanucleus.metadata.ColumnMetaData)4 DiscriminatorMetaData (org.datanucleus.metadata.DiscriminatorMetaData)4 JoinMetaData (org.datanucleus.metadata.JoinMetaData)4 PrimaryKeyMetaData (org.datanucleus.metadata.PrimaryKeyMetaData)4 HashSet (java.util.HashSet)3 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)3 FetchGroupMetaData (org.datanucleus.metadata.FetchGroupMetaData)3 InvalidMetaDataException (org.datanucleus.metadata.InvalidMetaDataException)3 KeyMetaData (org.datanucleus.metadata.KeyMetaData)3 OrderMetaData (org.datanucleus.metadata.OrderMetaData)3 UniqueMetaData (org.datanucleus.metadata.UniqueMetaData)3 Set (java.util.Set)2 AttributeConverter (javax.jdo.AttributeConverter)2 Column (javax.jdo.annotations.Column)2 Extension (javax.jdo.annotations.Extension)2 ForeignKeyAction (javax.jdo.annotations.ForeignKeyAction)2 Persistent (javax.jdo.annotations.Persistent)2