Package org.datanucleus.metadata

Examples of org.datanucleus.metadata.PropertyMetaData


     * @param attrs The attributes
     * @return The PropertyMetaData
     */
    protected PropertyMetaData newPropertyObject(MetaData md, Attributes attrs)
    {
        PropertyMetaData pmd = new PropertyMetaData(md, getAttr(attrs,"name"));
        pmd.setPersistenceModifier(getAttr(attrs,"persistence-modifier"));
        pmd.setDeleteAction(getAttr(attrs,"delete-action"));
        pmd.setPrimaryKey(getAttr(attrs,"primary-key"));
        pmd.setDefaultFetchGroup(getAttr(attrs,"default-fetch-group"));
        pmd.setEmbedded(getAttr(attrs,"embedded"));
        pmd.setSerialised(getAttr(attrs,"serialized"));
        pmd.setDependent(getAttr(attrs,"dependent"));
        pmd.setNullValue(NullValue.getNullValue(getAttr(attrs,"null-value")));
        pmd.setMappedBy(getAttr(attrs,"mapped-by"));
        pmd.setColumn(getAttr(attrs,"column"));
        pmd.setIndexed(IndexedValue.getIndexedValue(getAttr(attrs,"indexed")));
        pmd.setUnique(getAttr(attrs,"unique"));
        pmd.setTable(getAttr(attrs, "table"));
        pmd.setLoadFetchGroup(getAttr(attrs,"load-fetch-group"));
        pmd.setRecursionDepth(getAttr(attrs,"recursion-depth"));
        pmd.setValueStrategy(getAttr(attrs,"value-strategy"));
        pmd.setSequence(getAttr(attrs,"sequence"));
        pmd.setFieldTypes(getAttr(attrs,"field-type"));
        pmd.setFieldName(getAttr(attrs,"field-name"));
        String cacheableAttr = getAttr(attrs, "cacheable");
        if (cacheableAttr != null)
        {
            pmd.setCacheable(cacheableAttr.equalsIgnoreCase("false") ? false : true);
        }
        return pmd;
    }   
View Full Code Here


            {
                MetaData parent = getStack();
                if (parent instanceof AbstractClassMetaData)
                {
                    AbstractClassMetaData acmd = (AbstractClassMetaData)parent;
                    PropertyMetaData propmd = newPropertyObject(acmd, attrs);
                    acmd.addMember(propmd);
                    pushStack(propmd);
                }
                else if (parent instanceof EmbeddedMetaData)
                {
                    EmbeddedMetaData emd = (EmbeddedMetaData)parent;
                    PropertyMetaData propmd = newPropertyObject(emd, attrs);
                    emd.addMember(propmd);
                    pushStack(propmd);
                }
                else if (parent instanceof ImplementsMetaData)
                {
                    ImplementsMetaData implmd = (ImplementsMetaData)parent;
                    PropertyMetaData propmd = newPropertyObject(implmd, attrs);
                    implmd.addProperty(propmd);
                    pushStack(propmd);
                }
                else if (parent instanceof FetchGroupMetaData)
                {
                    FetchGroupMetaData fgmd = (FetchGroupMetaData)parent;
                    PropertyMetaData propmd = newPropertyObject(fgmd, attrs);
                    fgmd.addMember(propmd);
                    pushStack(propmd);
                }
            }
            else if (localName.equals("datastore-identity"))
View Full Code Here

        }
        else
        {
            if (propertyAccess)
            {
                mmd = new PropertyMetaData(acmd, getAttr(attrs,"name"));
            }
            else
            {
                mmd = new FieldMetaData(acmd, getAttr(attrs,"name"));
            }
View Full Code Here

        else
        {
            // Create new property/field
            if (propertyAccess)
            {
                mmd = new PropertyMetaData(acmd, getAttr(attrs, "name"));
            }
            else
            {
                mmd = new FieldMetaData(acmd, getAttr(attrs, "name"));
            }
View Full Code Here

    protected AbstractMemberMetaData newTransientFieldObject(MetaData md, String name)
    {
        AbstractMemberMetaData mmd = null;
        if (propertyAccess)
        {
            mmd = new PropertyMetaData(md, name);
        }
        else
        {
            mmd = new FieldMetaData(md, name);
        }
View Full Code Here

    protected AbstractMemberMetaData newOverriddenFieldObject(MetaData md, Attributes attrs)
    {
        AbstractMemberMetaData mmd = null;
        if (propertyAccess)
        {
            mmd = new PropertyMetaData(md, "#UNKNOWN." + getAttr(attrs, "name"));
        }
        else
        {
            mmd = new FieldMetaData(md, "#UNKNOWN." + getAttr(attrs, "name"));
        }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.jdo.metadata.FetchGroupMetadata#newPropertyMetadata(java.lang.String)
     */
    public PropertyMetadata newPropertyMetadata(String name)
    {
        PropertyMetaData internalPmd = getInternal().newPropertyMetaData(name);
        PropertyMetadataImpl pmd = new PropertyMetadataImpl(internalPmd);
        pmd.parent = this;
        return pmd;
    }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.jdo.metadata.UniqueMetadata#newPropertyMetadata(java.lang.String)
     */
    public PropertyMetadata newPropertyMetadata(String name)
    {
        PropertyMetaData internalPmd = getInternal().newPropertyMetaData(name);
        PropertyMetadataImpl pmd = new PropertyMetadataImpl(internalPmd);
        pmd.parent = this;
        return pmd;
    }
View Full Code Here

        // Create the field
        AbstractMemberMetaData fmd;
        if (field.isProperty())
        {
            fmd = new PropertyMetaData(cmd, field.getName());
        }
        else
        {
            fmd = new FieldMetaData(cmd, field.getName());
        }
View Full Code Here

                        embeddedValue = (String)annotationValues.get("embeddedValue");

                        if (member.isProperty())
                        {
                            // Property
                            mmd = new PropertyMetaData(cmd, member.getName());
                        }
                        else
                        {
                            // Field
                            mmd = new FieldMetaData(cmd, member.getName());
                        }
                        mmd.setPersistenceModifier(modifier);
                        mmd.setDefaultFetchGroup(dfg);
                        mmd.setPrimaryKey(pk);
                        mmd.setEmbedded(embedded);
                        mmd.setSerialised(serialized);
                        mmd.setDependent(dependent);
                        mmd.setNullValue(org.datanucleus.metadata.NullValue.getNullValue(nullValue));
                        mmd.setMappedBy(mappedBy);
                        mmd.setColumn(column);
                        mmd.setTable(table);
                        mmd.setRecursionDepth(recursionDepth);
                        mmd.setLoadFetchGroup(loadFetchGroup);
                        mmd.setValueStrategy(valueStrategy);
                        mmd.setSequence(sequence);
                        mmd.setFieldTypes(fieldTypeName);

                        // Add any columns defined on the @Persistent
                        Column[] columns = (Column[])annotationValues.get("columns");
                        if (columns != null && columns.length > 0)
                        {
                            for (int j=0;j<columns.length;j++)
                            {
                                mmd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(columns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(mmd, (Extension[])annotationValues.get("extensions"));
                    }
                    else if (annName.equals(JDOAnnotationUtils.PRIMARY_KEY))
                    {
                        primaryKey = true;
                        if (cmd.getIdentityType() == IdentityType.DATASTORE)
                        {
                            // ClassMetaData was created as DATASTORE so change it to APPLICATION
                            cmd.setIdentityType(IdentityType.APPLICATION);
                        }
                    }
                    else if (annName.equals(JDOAnnotationUtils.SERIALIZED))
                    {
                        serialised = true;
                    }
                    else if (annName.equals(JDOAnnotationUtils.NOTPERSISTENT))
                    {
                        nonPersistentField = true;
                    }
                    else if (annName.equals(JDOAnnotationUtils.TRANSACTIONAL))
                    {
                        transactionalField = true;
                    }
                    else if (annName.equals(JDOAnnotationUtils.COLUMNS))
                    {
                        // Multiple column specification
                        Column[] cols = (Column[])annotationValues.get("value");
                        if (cols != null && cols.length > 0)
                        {
                            colmds = new ColumnMetaData[cols.length];
                            for (int j=0;j<cols.length;j++)
                            {
                                colmds[j] = JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(cols[j]);
                                JDOAnnotationUtils.addExtensionsToMetaData(colmds[j], cols[j].extensions());
                            }
                        }
                    }
                    else if (annName.equals(JDOAnnotationUtils.COLUMN))
                    {
                        // Single column specification
                        colmds = new ColumnMetaData[1];
                        colmds[0] = JDOAnnotationUtils.getColumnMetaDataForAnnotations(annotationValues);
                        JDOAnnotationUtils.addExtensionsToMetaData(colmds[0], (Extension[])annotationValues.get("extensions"));
                    }
                    else if (annName.equals(JDOAnnotationUtils.JOIN))
                    {
                        String joinColumn = (String)annotationValues.get("column");
                        String joinOuter = (String)annotationValues.get("outer");
                        String deleteAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("deleteAction"));
                        String pkName = (String)annotationValues.get("primaryKey");
                        String fkName = (String)annotationValues.get("foreignKey");
                        String generateFK = (String)annotationValues.get("generateForeignKey");
                        String indexed = (String)annotationValues.get("indexed");
                        String indexName = (String)annotationValues.get("index");
                        String unique = (String)annotationValues.get("unique");
                        String uniqueName = (String)annotationValues.get("uniqueKey");
                        String generatePK = (String)annotationValues.get("generatePrimaryKey");
                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            unique = "true";
                        }
                        if (!StringUtils.isWhitespace(indexName))
                        {
                            indexed = "true";
                        }
                        Column[] joinColumns = (Column[])annotationValues.get("columns");
                        joinmd = new JoinMetaData();
                        joinmd.setColumnName(joinColumn);
                        joinmd.setOuter(joinOuter);
                        joinmd.setIndexed(IndexedValue.getIndexedValue(indexed));
                        joinmd.setUnique(unique);
                        joinmd.setDeleteAction(deleteAction);

                        if (!StringUtils.isWhitespace(pkName))
                        {
                            PrimaryKeyMetaData pkmd = new PrimaryKeyMetaData();
                            pkmd.setName(pkName);
                            joinmd.setPrimaryKeyMetaData(pkmd);
                        }
                        else if (generatePK != null && generatePK.equalsIgnoreCase("true"))
                        {
                            joinmd.setPrimaryKeyMetaData(new PrimaryKeyMetaData());
                        }

                        if (!StringUtils.isWhitespace(fkName))
                        {
                            ForeignKeyMetaData joinFkmd = joinmd.getForeignKeyMetaData();
                            if (joinFkmd == null)
                            {
                                joinFkmd = new ForeignKeyMetaData();
                                joinFkmd.setName(fkName);
                                joinmd.setForeignKeyMetaData(joinFkmd);
                            }
                            else
                            {
                                joinFkmd.setName(fkName);
                            }
                        }
                        else if (generateFK != null && generateFK.equalsIgnoreCase("true"))
                        {
                            joinmd.setForeignKeyMetaData(new ForeignKeyMetaData());
                        }

                        if (!StringUtils.isWhitespace(indexName))
                        {
                            IndexMetaData joinIdxmd = joinmd.getIndexMetaData();
                            if (joinIdxmd == null)
                            {
                                joinIdxmd = new IndexMetaData();
                                joinmd.setIndexMetaData(joinIdxmd);
                            }
                            joinIdxmd.setName(indexName);
                        }

                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            UniqueMetaData joinUnimd = joinmd.getUniqueMetaData();
                            if (joinUnimd == null)
                            {
                                joinUnimd = new UniqueMetaData();
                                joinmd.setUniqueMetaData(joinUnimd);
                            }
                            joinUnimd.setName(uniqueName);
                        }
                        if (joinColumns != null && joinColumns.length > 0)
                        {
                            for (int j=0;j<joinColumns.length;j++)
                            {
                                joinmd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(joinColumns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(joinmd, (Extension[])annotationValues.get("extensions"));
                    }
                    else if (annName.equals(JDOAnnotationUtils.ELEMENT))
                    {
                        // Element of a Collection/Array
                        elementTypes = (Class[])annotationValues.get("types");
                        embeddedElement = (String)annotationValues.get("embedded");
                        serializedElement = (String)annotationValues.get("serialized");
                        dependentElement = (String)annotationValues.get("dependent");
                        String elementColumn = (String)annotationValues.get("column");
                        String elementDeleteAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("deleteAction"));
                        String elementUpdateAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("updateAction"));
                        String elementMappedBy = (String)annotationValues.get("mappedBy");
                        Column[] elementColumns = (Column[])annotationValues.get("columns");
                        String fkName = (String)annotationValues.get("foreignKey");
                        String generateFK = (String)annotationValues.get("generateForeignKey");
                        String indexed = (String)annotationValues.get("indexed");
                        String indexName = (String)annotationValues.get("index");
                        String unique = (String)annotationValues.get("unique");
                        String uniqueName = (String)annotationValues.get("uniqueKey");
                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            unique = "true";
                        }
                        if (!StringUtils.isWhitespace(indexName))
                        {
                            indexed = "true";
                        }
                        elemmd = new ElementMetaData();
                        elemmd.setColumnName(elementColumn);
                        elemmd.setDeleteAction(elementDeleteAction);
                        elemmd.setUpdateAction(elementUpdateAction);
                        elemmd.setIndexed(IndexedValue.getIndexedValue(indexed));
                        elemmd.setUnique(unique);
                        elemmd.setMappedBy(elementMappedBy);
                        if (!StringUtils.isWhitespace(fkName))
                        {
                            ForeignKeyMetaData elemFkmd = elemmd.getForeignKeyMetaData();
                            if (elemFkmd == null)
                            {
                                elemFkmd = new ForeignKeyMetaData();
                                elemFkmd.setName(fkName);
                                elemmd.setForeignKeyMetaData(elemFkmd);
                            }
                            else
                            {
                                elemFkmd.setName(fkName);
                            }
                        }
                        else if (generateFK != null && generateFK.equalsIgnoreCase("true"))
                        {
                            elemmd.setForeignKeyMetaData(new ForeignKeyMetaData());
                        }

                        if (!StringUtils.isWhitespace(indexName))
                        {
                            IndexMetaData elemIdxmd = elemmd.getIndexMetaData();
                            if (elemIdxmd == null)
                            {
                                elemIdxmd = new IndexMetaData();
                                elemmd.setIndexMetaData(elemIdxmd);
                            }
                            elemIdxmd.setName(indexName);
                        }

                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            UniqueMetaData elemUnimd = elemmd.getUniqueMetaData();
                            if (elemUnimd == null)
                            {
                                elemUnimd = new UniqueMetaData();
                                elemmd.setUniqueMetaData(elemUnimd);
                            }
                            elemUnimd.setName(uniqueName);
                        }
                        if (elementColumns != null && elementColumns.length > 0)
                        {
                            for (int j=0;j<elementColumns.length;j++)
                            {
                                elemmd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(elementColumns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(elemmd, (Extension[])annotationValues.get("extensions"));

                        Embedded[] embeddedMappings = (Embedded[])annotationValues.get("embeddedMapping");
                        if (embeddedMappings != null && embeddedMappings.length > 0)
                        {
                            // Embedded element
                            EmbeddedMetaData embmd = new EmbeddedMetaData();
                            embmd.setOwnerMember(embeddedMappings[0].ownerMember());
                            embmd.setNullIndicatorColumn(embeddedMappings[0].nullIndicatorColumn());
                            embmd.setNullIndicatorValue(embeddedMappings[0].nullIndicatorValue());
                            elemmd.setEmbeddedMetaData(embmd);
                            embeddedElementMembers = embeddedMappings[0].members();
                            // Delay addition of embeddedElementMembers til completion of this loop so we have the element type
                        }
                    }
                    else if (annName.equals(JDOAnnotationUtils.KEY))
                    {
                        // Key of a Map
                        Class[] keyTypes = (Class[])annotationValues.get("types");
                        if (keyTypes != null && keyTypes.length > 0)
                        {
                            // TODO Support more than 1 value
                            keyType = keyTypes[0];
                        }
                        embeddedKey = (String)annotationValues.get("embedded");
                        serializedKey = (String)annotationValues.get("serialized");
                        dependentKey = (String)annotationValues.get("dependent");
                        String keyColumn = (String)annotationValues.get("column");
                        String keyDeleteAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("deleteAction"));
                        String keyUpdateAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("updateAction"));
                        String keyMappedBy = (String)annotationValues.get("mappedBy");
                        Column[] keyColumns = (Column[])annotationValues.get("columns");
                        String fkName = (String)annotationValues.get("foreignKey");
                        String generateFK = (String)annotationValues.get("generateForeignKey");
                        String indexed = (String)annotationValues.get("indexed");
                        String indexName = (String)annotationValues.get("index");
                        String unique = (String)annotationValues.get("unique");
                        String uniqueName = (String)annotationValues.get("uniqueKey");
                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            unique = "true";
                        }
                        if (!StringUtils.isWhitespace(indexName))
                        {
                            indexed = "true";
                        }
                        keymd = new KeyMetaData();
                        keymd.setColumnName(keyColumn);
                        keymd.setDeleteAction(keyDeleteAction);
                        keymd.setUpdateAction(keyUpdateAction);
                        keymd.setIndexed(IndexedValue.getIndexedValue(indexed));
                        keymd.setUnique(unique);
                        keymd.setMappedBy(keyMappedBy);
                        if (!StringUtils.isWhitespace(fkName))
                        {
                            ForeignKeyMetaData keyFkmd = keymd.getForeignKeyMetaData();
                            if (keyFkmd == null)
                            {
                                keyFkmd = new ForeignKeyMetaData();
                                keyFkmd.setName(fkName);
                                keymd.setForeignKeyMetaData(keyFkmd);
                            }
                            else
                            {
                                keyFkmd.setName(fkName);
                            }
                        }
                        else if (generateFK != null && generateFK.equalsIgnoreCase("true"))
                        {
                            keymd.setForeignKeyMetaData(new ForeignKeyMetaData());
                        }

                        if (!StringUtils.isWhitespace(indexName))
                        {
                            IndexMetaData keyIdxmd = keymd.getIndexMetaData();
                            if (keyIdxmd == null)
                            {
                                keyIdxmd = new IndexMetaData();
                                keymd.setIndexMetaData(keyIdxmd);
                            }
                            keyIdxmd.setName(indexName);
                        }

                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            UniqueMetaData keyUnimd = keymd.getUniqueMetaData();
                            if (keyUnimd == null)
                            {
                                keyUnimd = new UniqueMetaData();
                                keymd.setUniqueMetaData(keyUnimd);
                            }
                            keyUnimd.setName(uniqueName);
                        }
                        if (keyColumns != null && keyColumns.length > 0)
                        {
                            for (int j=0;j<keyColumns.length;j++)
                            {
                                keymd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(keyColumns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(keymd, (Extension[])annotationValues.get("extensions"));

                        Embedded[] embeddedMappings = (Embedded[])annotationValues.get("embeddedMapping");
                        if (embeddedMappings != null && embeddedMappings.length > 0)
                        {
                            // Embedded key
                            EmbeddedMetaData embmd = new EmbeddedMetaData();
                            embmd.setOwnerMember(embeddedMappings[0].ownerMember());
                            embmd.setNullIndicatorColumn(embeddedMappings[0].nullIndicatorColumn());
                            embmd.setNullIndicatorValue(embeddedMappings[0].nullIndicatorValue());
                            keymd.setEmbeddedMetaData(embmd);
                            embeddedKeyMembers = embeddedMappings[0].members();
                            // Delay addition of embeddedKeyMembers til completion of this loop so we have the key type
                        }
                    }
                    else if (annName.equals(JDOAnnotationUtils.VALUE))
                    {
                        // Value of a Map
                        Class[] valueTypes = (Class[])annotationValues.get("types");
                        if (valueTypes != null && valueTypes.length > 0)
                        {
                            // TODO Support more than 1 value
                            valueType = valueTypes[0];
                        }
                        embeddedValue = (String)annotationValues.get("embedded");
                        serializedValue = (String)annotationValues.get("serialized");
                        dependentValue = (String)annotationValues.get("dependent");
                        String valueColumn = (String)annotationValues.get("column");
                        String valueDeleteAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("deleteAction"));
                        String valueUpdateAction = JDOAnnotationUtils.getForeignKeyActionString(
                            (ForeignKeyAction)annotationValues.get("updateAction"));
                        String valueMappedBy = (String)annotationValues.get("mappedBy");
                        Column[] valueColumns = (Column[])annotationValues.get("columns");
                        String fkName = (String)annotationValues.get("foreignKey");
                        String generateFK = (String)annotationValues.get("generateForeignKey");
                        String indexed = (String)annotationValues.get("indexed");
                        String indexName = (String)annotationValues.get("index");
                        String unique = (String)annotationValues.get("unique");
                        String uniqueName = (String)annotationValues.get("uniqueKey");
                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            unique = "true";
                        }
                        if (!StringUtils.isWhitespace(indexName))
                        {
                            indexed = "true";
                        }
                        valuemd = new ValueMetaData();
                        valuemd.setColumnName(valueColumn);
                        valuemd.setDeleteAction(valueDeleteAction);
                        valuemd.setUpdateAction(valueUpdateAction);
                        valuemd.setIndexed(IndexedValue.getIndexedValue(indexed));
                        valuemd.setUnique(unique);
                        valuemd.setMappedBy(valueMappedBy);
                        if (!StringUtils.isWhitespace(fkName))
                        {
                            ForeignKeyMetaData valueFkmd = valuemd.getForeignKeyMetaData();
                            if (valueFkmd == null)
                            {
                                valueFkmd = new ForeignKeyMetaData();
                                valueFkmd.setName(fkName);
                                valuemd.setForeignKeyMetaData(valueFkmd);
                            }
                            else
                            {
                                valueFkmd.setName(fkName);
                            }
                        }
                        else if (generateFK != null && generateFK.equalsIgnoreCase("true"))
                        {
                            valuemd.setForeignKeyMetaData(new ForeignKeyMetaData());
                        }

                        if (!StringUtils.isWhitespace(indexName))
                        {
                            IndexMetaData valueIdxmd = valuemd.getIndexMetaData();
                            if (valueIdxmd == null)
                            {
                                valueIdxmd = new IndexMetaData();
                                valuemd.setIndexMetaData(valueIdxmd);
                            }
                            valueIdxmd.setName(indexName);
                        }

                        if (!StringUtils.isWhitespace(uniqueName))
                        {
                            UniqueMetaData valueUnimd = valuemd.getUniqueMetaData();
                            if (valueUnimd == null)
                            {
                                valueUnimd = new UniqueMetaData();
                                valuemd.setUniqueMetaData(valueUnimd);
                            }
                            valueUnimd.setName(uniqueName);
                        }
                        if (valueColumns != null && valueColumns.length > 0)
                        {
                            for (int j=0;j<valueColumns.length;j++)
                            {
                                valuemd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(valueColumns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(valuemd, (Extension[])annotationValues.get("extensions"));

                        Embedded[] embeddedMappings = (Embedded[])annotationValues.get("embeddedMapping");
                        if (embeddedMappings != null && embeddedMappings.length > 0)
                        {
                            // Embedded value
                            EmbeddedMetaData embmd = new EmbeddedMetaData();
                            embmd.setOwnerMember(embeddedMappings[0].ownerMember());
                            embmd.setNullIndicatorColumn(embeddedMappings[0].nullIndicatorColumn());
                            embmd.setNullIndicatorValue(embeddedMappings[0].nullIndicatorValue());
                            valuemd.setEmbeddedMetaData(embmd);
                            embeddedValueMembers = embeddedMappings[0].members();
                            // Delay addition of embeddedValueMembers til completion of this loop so we have the value type
                        }
                    }
                    else if (annName.equals(JDOAnnotationUtils.ORDER))
                    {
                        String orderColumn = (String)annotationValues.get("column");
                        String orderMappedBy = (String)annotationValues.get("mappedBy");
                        Column[] orderColumns = (Column[])annotationValues.get("columns");
                        ordermd = new OrderMetaData();
                        ordermd.setColumnName(orderColumn);
                        ordermd.setMappedBy(orderMappedBy);
                        if (orderColumns != null && orderColumns.length > 0)
                        {
                            for (int j=0;j<orderColumns.length;j++)
                            {
                                ordermd.addColumn(JDOAnnotationUtils.getColumnMetaDataForColumnAnnotation(orderColumns[j]));
                            }
                        }
                        JDOAnnotationUtils.addExtensionsToMetaData(ordermd, (Extension[])annotationValues.get("extensions"));
                    }
                    else if (annName.equals(JDOAnnotationUtils.EMBEDDED))
                    {
                        embeddedOwnerField = (String)annotationValues.get("ownerMember");
                        embeddedNullIndicatorColumn = (String)annotationValues.get("nullIndicatorColumn");
                        embeddedNullIndicatorValue = (String)annotationValues.get("nullIndicatorValue");
                        embeddedMembers = (Persistent[])annotationValues.get("members");
                    }
                    else if (annName.equals(JDOAnnotationUtils.INDEX))
                    {
                        // Index for the field
                        String name = (String)annotationValues.get("name");
                        String table = (String)annotationValues.get("table");
                        String unique = (String)annotationValues.get("unique");
                        String[] members = (String[])annotationValues.get("members");
                        Column[] columns = (Column[])annotationValues.get("columns");

                        idxmd = JDOAnnotationUtils.getIndexMetaData(name, table, unique, members, columns);
                    }
                    else if (annName.equals(JDOAnnotationUtils.UNIQUE))
                    {
                        // Unique for the field
                        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");

                        unimd = JDOAnnotationUtils.getUniqueMetaData(name, table, deferred, members, columns);
                    }
                    else if (annName.equals(JDOAnnotationUtils.FOREIGNKEY))
                    {
                        // ForeignKey for field
                        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");

                        fkmd = JDOAnnotationUtils.getFKMetaData(name, table, unique, deferred, deleteAction, updateAction,
                            members, columns);
                    }
                    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
                    {
                        NucleusLogger.METADATA.error(LOCALISER.msg("044203",
                            member.getName(), annotations[i].getName()));
                    }
                }
            }

            if (mmd == null &&
                (transactionalField || nonPersistentField || primaryKey || colmds != null || serialised ||
                 embeddedOwnerField != null || embeddedNullIndicatorColumn != null || embeddedNullIndicatorValue != null ||
                 embeddedMembers != null ||
                 elemmd != null || keymd != null || valuemd != null || ordermd != null ||
                 idxmd != null || unimd != null || fkmd != null || joinmd != null))
            {
                // @Persistent not supplied but other relevant annotations defined, so add default metadata element
                if (member.isProperty())
                {
                    mmd = new PropertyMetaData(cmd, member.getName());
                }
                else
                {
                    mmd = new FieldMetaData(cmd, member.getName());
                }
View Full Code Here

TOP

Related Classes of org.datanucleus.metadata.PropertyMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.