Examples of FieldMetaData


Examples of org.apache.openjpa.meta.FieldMetaData

        return true;
    }

    public boolean assignField(OpenJPAStateManager sm, int field,
        boolean preFlush) {
        FieldMetaData fmd = sm.getMetaData().getField(field);
        Object val = ImplHelper.generateFieldValue(_ctx, fmd);
        if (val == null)
            return false;
        sm.store(field, val);
        return true;
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

     */
    private void updateInMemory(Object ob, Object[] params) {
        for (Iterator it = getUpdates().entrySet().iterator();
            it.hasNext();) {
            Map.Entry e = (Map.Entry) it.next();
            FieldMetaData fmd = (FieldMetaData) e.getKey();

            Object val;
            Object value = e.getValue();
            if (value instanceof Val) {
                val = ((Val) value).
                    evaluate(ob, null, getStoreContext(), params);
            } else if (value instanceof Literal) {
                val = ((Literal) value).getValue();
            } else if (value instanceof Constant) {
                val = ((Constant) value).getValue(params);
            } else {
                throw new UserException(_loc.get("only-update-primitives"));
            }

            OpenJPAStateManager sm = _broker.getStateManager(ob);
            int i = fmd.getIndex();
            PersistenceCapable into = ImplHelper.toPersistenceCapable(ob,
                _broker.getConfiguration());

            // set the actual field in the instance
            int set = OpenJPAStateManager.SET_USER;
            switch (fmd.getDeclaredTypeCode()) {
                case JavaTypes.BOOLEAN:
                    sm.settingBooleanField(into, i, sm.fetchBooleanField(i),
                        val == null ? false : ((Boolean) val).booleanValue(),
                        set);
                    break;
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

    protected void evalSetClause(QueryExpressions exps) {
        // handle SET field = value
        JPQLNode[] nodes = root().findChildrenByID(JJTUPDATEITEM);
        for (int i = 0; nodes != null && i < nodes.length; i++) {
            FieldMetaData field = getPath(firstChild(nodes[i])).last();
            Value val = getValue(onlyChild(lastChild(nodes[i])));
            exps.putUpdate(field, val);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

        return addJoin(path, alias, inner, exp);
    }

    private Expression addJoin(Path path, JPQLNode aliasNode, boolean inner,
        Expression exp) {
        FieldMetaData fmd = path.last();

        if (fmd == null)
            throw parseException(EX_USER, "path-no-meta",
                new Object[]{ path, null }, null);

        String alias = aliasNode != null ? aliasNode.text : nextAlias();

        Value var = getVariable(alias, true);
        var.setMetaData(getFieldType(fmd));

        Expression join = null;

        // if the variable is already bound, get the var's value and
        // do a regular contains with that
        boolean bound = isBound(var);
        if (bound) {
            var = getValue(aliasNode, VAR_PATH);
        } else {
            bind(var);
            join = and(join, factory.bindVariable(var, path));
        }

        if (!fmd.isTypePC()) // multi-valued relation
        {
            if (bound)
                join = and(join, factory.contains(path, var));

            setImplicitContainsTypes(path, var, CONTAINS_TYPE_ELEMENT);
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

        // we only check for parameter-to-path comparisons
        if (param == null || path == null || parameterTypes == null)
            return;

        FieldMetaData fmd = path.last();
        if (fmd == null)
            return;

        Class type = path.isXPath() ? path.getType() : fmd.getType();
        if (type == null)
            return;

        String paramName = param.getParameterName();
        if (paramName == null)
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

    /**
     * Serialize a single column.
     */
    private void serializeColumn(Column col, ColType type, String secondary,
        boolean unique, AnnotationBuilder ab, Object meta) {
        FieldMetaData fmd = meta instanceof FieldMetaData ?
            (FieldMetaData) meta : null;
        AnnotationBuilder abCol = newAnnotationBuilder(
            type.getColumnAnnotationType());
        if (col.getName() != null && (null == fmd ||
            !col.getName().equalsIgnoreCase(fmd.getName())))
            abCol.add("name", col.getName());
        if (col.getTypeName() != null)
            abCol.add("columnDefinition", col.getTypeName());
        if (col.getTarget() != null
            && (type == ColType.JOIN || type == ColType.INVERSE
View Full Code Here

Examples of org.apache.openjpa.meta.FieldMetaData

            return _cast;
        Action act = lastFieldAction();
        if (act != null && act.op == Action.GET_XPATH)
            return ((XMLMetaData) act.data).getType();
       
        FieldMetaData fld = (act == null) ? null : (FieldMetaData) act.data;
        boolean key = act != null && act.op == Action.GET_KEY;
        if (fld != null) {
            switch (fld.getDeclaredTypeCode()) {
                case JavaTypes.ARRAY:
                    if (fld.getDeclaredType() == byte[].class
                        || fld.getDeclaredType() == Byte[].class
                        || fld.getDeclaredType() == char[].class
                        || fld.getDeclaredType() == Character[].class)
                        return fld.getDeclaredType();
                    return fld.getElement().getDeclaredType();
                case JavaTypes.MAP:
                    if (key)
                        return fld.getKey().getDeclaredType();
                    return fld.getElement().getDeclaredType();
                case JavaTypes.COLLECTION:
                    return fld.getElement().getDeclaredType();
                default:
                    return fld.getDeclaredType();
            }
        }
        if (_class != null)
            return _class.getDescribedType();
        return Object.class;
View Full Code Here

Examples of org.broadleafcommerce.openadmin.dto.FieldMetadata

                String propertyName = override.name();
                Map<String, FieldMetadata> loopMap = new HashMap<String, FieldMetadata>();
                loopMap.putAll(metadata);
                for (Map.Entry<String, FieldMetadata> entry : loopMap.entrySet()) {
                    if (entry.getKey().startsWith(propertyName) || StringUtils.isEmpty(propertyName)) {
                        FieldMetadata targetMetadata = entry.getValue();
                        if (targetMetadata instanceof AdornedTargetCollectionMetadata) {
                            AdornedTargetCollectionMetadata serverMetadata = (AdornedTargetCollectionMetadata) targetMetadata;
                            if (serverMetadata.getTargetClass() != null) {
                                try {
                                    Class<?> targetClass = Class.forName(serverMetadata.getTargetClass());
View Full Code Here

Examples of org.codehaus.aspectwerkz.metadata.FieldMetaData

            Expression root = space.createExpression("pc1 || pc2");
            Expression rootAnonymous = space.createExpression("set(* test.ExpressionTest.m_name) || pc2");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(
                    ExpressionTest.class.getDeclaredField("m_name")
            );
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(
                    ExpressionTest.class.getDeclaredField("m_type")
            );

            assertTrue(root.match(classMetaData1, PointcutType.SET));
            assertTrue(rootAnonymous.match(classMetaData1, PointcutType.SET));
View Full Code Here

Examples of org.datanucleus.metadata.FieldMetaData

                                overriddenFields = new HashSet<AbstractMemberMetaData>();
                            }

                            for (int j=0;j<overrides.length;j++)
                            {
                                AbstractMemberMetaData fmd = new FieldMetaData(cmd,
                                    "#UNKNOWN." + overrides[j].name());
                                fmd.setPersistenceModifier(FieldPersistenceModifier.PERSISTENT.toString());
                                Column col = overrides[j].column();
                                // TODO Make inferrals about jdbctype, length etc if the field is 1 char etc
                                ColumnMetaData colmd = new ColumnMetaData();
                                colmd.setName(col.name());
                                colmd.setLength(col.length());
                                colmd.setScale(col.scale());
                                colmd.setAllowsNull(col.nullable());
                                colmd.setInsertable(col.insertable());
                                colmd.setUpdateable(col.updatable());
                                colmd.setUnique(col.unique());
                                fmd.addColumn(colmd);
                                overriddenFields.add(fmd);
                            }
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.ATTRIBUTE_OVERRIDE))
                    {
                        if (overriddenFields == null)
                        {
                            overriddenFields = new HashSet<AbstractMemberMetaData>();
                        }

                        AbstractMemberMetaData fmd = new FieldMetaData(cmd,
                            "#UNKNOWN." + (String)annotationValues.get("name"));
                        Column col = (Column)annotationValues.get("column");
                        // TODO Make inferrals about jdbctype, length etc if the field is 1 char etc
                        ColumnMetaData colmd = new ColumnMetaData();
                        colmd.setName(col.name());
                        colmd.setLength(col.length());
                        colmd.setScale(col.scale());
                        colmd.setAllowsNull(col.nullable());
                        colmd.setInsertable(col.insertable());
                        colmd.setUpdateable(col.updatable());
                        colmd.setUnique(col.unique());
                        fmd.addColumn(colmd);
                        overriddenFields.add(fmd);
                    }
                    else if (annName.equals(JPAAnnotationUtils.ASSOCIATION_OVERRIDES))
                    {
                        AssociationOverride[] overrides = (AssociationOverride[])annotationValues.get("value");
                        if (overrides != null)
                        {
                            if (overriddenFields == null)
                            {
                                overriddenFields = new HashSet<AbstractMemberMetaData>();
                            }

                            for (int j=0;j<overrides.length;j++)
                            {
                                AbstractMemberMetaData fmd = new FieldMetaData(cmd,
                                    "#UNKNOWN." + overrides[j].name());
                                JoinColumn[] cols = overrides[j].joinColumns();
                                for (int k=0;k<cols.length;k++)
                                {
                                    ColumnMetaData colmd = new ColumnMetaData();
                                    colmd.setName(cols[k].name());
                                    colmd.setTarget(cols[k].referencedColumnName());
                                    colmd.setAllowsNull(cols[k].nullable());
                                    colmd.setInsertable(cols[k].insertable());
                                    colmd.setUpdateable(cols[k].updatable());
                                    colmd.setUnique(cols[k].unique());
                                    fmd.addColumn(colmd);
                                }
                                overriddenFields.add(fmd);
                            }
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.ASSOCIATION_OVERRIDE))
                    {
                        if (overriddenFields == null)
                        {
                            overriddenFields = new HashSet<AbstractMemberMetaData>();
                        }

                        AbstractMemberMetaData fmd = new FieldMetaData(cmd,
                            "#UNKNOWN." + (String)annotationValues.get("name"));
                        JoinColumn[] cols = (JoinColumn[])annotationValues.get("joinColumns");
                        for (int k=0;k<cols.length;k++)
                        {
                            ColumnMetaData colmd = new ColumnMetaData();
                            colmd.setName(cols[k].name());
                            colmd.setTarget(cols[k].referencedColumnName());
                            colmd.setAllowsNull(cols[k].nullable());
                            colmd.setInsertable(cols[k].insertable());
                            colmd.setUpdateable(cols[k].updatable());
                            colmd.setUnique(cols[k].unique());
                            fmd.addColumn(colmd);
                        }
                        overriddenFields.add(fmd);
                    }
                    else if (annName.equals(JPAAnnotationUtils.NAMED_QUERIES))
                    {
                        NamedQuery[] queries = (NamedQuery[])annotationValues.get("value");
                        if (namedQueries == null)
                        {
                            namedQueries = new HashSet<QueryMetaData>();
                        }
                        for (int j=0;j<queries.length;j++)
                        {
                            QueryMetaData qmd = new QueryMetaData(queries[j].name());
                            qmd.setLanguage(QueryLanguage.JPQL.toString());
                            qmd.setUnmodifiable(true);
                            qmd.setQuery(queries[j].query());
                            namedQueries.add(qmd);
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.NAMED_QUERY))
                    {
                        if (namedQueries == null)
                        {
                            namedQueries = new HashSet<QueryMetaData>();
                        }
                        QueryMetaData qmd = new QueryMetaData((String)annotationValues.get("name"));
                        qmd.setLanguage(QueryLanguage.JPQL.toString());
                        qmd.setUnmodifiable(true);
                        qmd.setQuery((String)annotationValues.get("query"));
                        namedQueries.add(qmd);
                    }
                    else if (annName.equals(JPAAnnotationUtils.NAMED_NATIVE_QUERIES))
                    {
                        NamedNativeQuery[] queries = (NamedNativeQuery[])annotationValues.get("value");
                        if (namedQueries == null)
                        {
                            namedQueries = new HashSet<QueryMetaData>();
                        }
                        for (int j=0;j<queries.length;j++)
                        {
                            String resultClassName = null;
                            if (queries[j].resultClass() != null && queries[j].resultClass() != void.class)
                            {
                                resultClassName = queries[j].resultClass().getName();
                            }
                            String resultMappingName = null;
                            if (queries[j].resultSetMapping() != null)
                            {
                                resultMappingName = queries[j].resultSetMapping();
                            }
                            QueryMetaData qmd = new QueryMetaData(queries[j].name());
                            qmd.setLanguage(QueryLanguage.SQL.toString());
                            qmd.setUnmodifiable(true);
                            qmd.setResultClass(resultClassName);
                            qmd.setResultMetaDataName(resultMappingName);
                            qmd.setQuery(queries[j].query());
                            namedQueries.add(qmd);
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.NAMED_NATIVE_QUERY))
                    {
                        if (namedQueries == null)
                        {
                            namedQueries = new HashSet<QueryMetaData>();
                        }

                        Class resultClass = (Class)annotationValues.get("resultClass");
                        String resultClassName = null;
                        if (resultClass != null && resultClass != void.class)
                        {
                            resultClassName = resultClass.getName();
                        }
                        String resultMappingName = (String)annotationValues.get("resultSetMapping");
                        if (StringUtils.isWhitespace(resultMappingName))
                        {
                            resultMappingName = null;
                        }
                        QueryMetaData qmd = new QueryMetaData((String)annotationValues.get("name"));
                        qmd.setLanguage(QueryLanguage.SQL.toString());
                        qmd.setUnmodifiable(true);
                        qmd.setResultClass(resultClassName);
                        qmd.setResultMetaDataName(resultMappingName);
                        qmd.setQuery((String)annotationValues.get("query"));
                        namedQueries.add(qmd);
                    }
                    else if (annName.equals(JPAAnnotationUtils.SQL_RESULTSET_MAPPINGS))
                    {
                        SqlResultSetMapping[] mappings = (SqlResultSetMapping[])annotationValues.get("value");
                        if (resultMappings == null)
                        {
                            resultMappings = new ArrayList<QueryResultMetaData>();
                        }

                        for (int j=0;j<mappings.length;j++)
                        {
                            QueryResultMetaData qrmd = new QueryResultMetaData(mappings[j].name());
                            EntityResult[] entityResults = (EntityResult[])mappings[j].entities();
                            if (entityResults != null)
                            {
                                for (int k=0;k<entityResults.length;k++)
                                {
                                    String entityClassName = entityResults[k].entityClass().getName();
                                    qrmd.addPersistentTypeMapping(entityClassName, null,
                                        entityResults[k].discriminatorColumn());
                                    FieldResult[] fields = entityResults[k].fields();
                                    if (fields != null)
                                    {
                                        for (int l=0;l<fields.length;l++)
                                        {
                                            qrmd.addMappingForPersistentTypeMapping(entityClassName, fields[l].name(), fields[l].column());
                                        }
                                    }
                                }
                            }
                            ColumnResult[] colResults = (ColumnResult[])mappings[j].columns();
                            if (colResults != null)
                            {
                                for (int k=0;k<colResults.length;k++)
                                {
                                    qrmd.addScalarColumn(colResults[k].name());
                                }
                            }

                            resultMappings.add(qrmd);
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.SQL_RESULTSET_MAPPING))
                    {
                        if (resultMappings == null)
                        {
                            resultMappings = new ArrayList<QueryResultMetaData>();
                        }

                        QueryResultMetaData qrmd = new QueryResultMetaData((String)annotationValues.get("name"));
                        EntityResult[] entityResults = (EntityResult[])annotationValues.get("entities");
                        if (entityResults != null)
                        {
                            for (int j=0;j<entityResults.length;j++)
                            {
                                String entityClassName = entityResults[j].entityClass().getName();
                                qrmd.addPersistentTypeMapping(entityClassName, null,
                                    entityResults[j].discriminatorColumn());
                                FieldResult[] fields = entityResults[j].fields();
                                if (fields != null)
                                {
                                    for (int k=0;k<fields.length;k++)
                                    {
                                        qrmd.addMappingForPersistentTypeMapping(entityClassName, fields[k].name(), fields[k].column());
                                    }
                                }
                            }
                        }
                        ColumnResult[] colResults = (ColumnResult[])annotationValues.get("columns");
                        if (colResults != null)
                        {
                            for (int j=0;j<colResults.length;j++)
                            {
                                qrmd.addScalarColumn(colResults[j].name());
                            }
                        }
                        resultMappings.add(qrmd);
                    }
                    else if (annName.equals(JPAAnnotationUtils.SECONDARY_TABLES))
                    {
                        // processed below in newJoinMetaData
                    }
                    else if (annName.equals(JPAAnnotationUtils.SECONDARY_TABLE))
                    {
                        // processed below in newJoinMetaData
                    }
                    else if (annName.equals(JPAAnnotationUtils.FETCHPLANS))
                    {
                        if (fetchPlans != null)
                        {
                            NucleusLogger.METADATA.warn(LOCALISER.msg("044207", cmd.getFullClassName()));
                        }
                        FetchPlan[] plans = (FetchPlan[])annotationValues.get("value");
                        fetchPlans = new FetchPlanMetaData[plans.length];
                        for (int j=0;j<plans.length;j++)
                        {
                            fetchPlans[j] = new FetchPlanMetaData(plans[j].name());
                            fetchPlans[j].setMaxFetchDepth(plans[j].maxFetchDepth());
                            fetchPlans[j].setFetchSize(plans[j].fetchSize());
                            int numGroups = plans[j].fetchGroups().length;
                            for (int k=0;k<numGroups;k++)
                            {
                                FetchGroupMetaData fgmd = new FetchGroupMetaData(plans[j].fetchGroups()[k]);
                                fetchPlans[j].addFetchGroup(fgmd);
                            }
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.FETCHPLAN))
                    {
                        if (fetchPlans != null)
                        {
                            NucleusLogger.METADATA.warn(LOCALISER.msg("044207", cmd.getFullClassName()));
                        }
                        fetchPlans = new FetchPlanMetaData[1];
                        int maxFetchDepth = ((Integer)annotationValues.get("maxFetchDepth")).intValue();
                        int fetchSize = ((Integer)annotationValues.get("fetchSize")).intValue();
                        fetchPlans[0] = new FetchPlanMetaData((String)annotationValues.get("name"));
                        fetchPlans[0].setMaxFetchDepth(maxFetchDepth);
                        fetchPlans[0].setFetchSize(fetchSize);
                    }
                    else if (annName.equals(JPAAnnotationUtils.FETCHGROUPS))
                    {
                        if (fetchGroups != null)
                        {
                            NucleusLogger.METADATA.warn(LOCALISER.msg("044208", cmd.getFullClassName()));
                        }
                        FetchGroup[] groups = (FetchGroup[])annotationValues.get("value");
                        fetchGroups = new FetchGroupMetaData[groups.length];
                        for (int j=0;j<groups.length;j++)
                        {
                            fetchGroups[j] = new FetchGroupMetaData(groups[j].name());
                            fetchGroups[j].setPostLoad(groups[j].postLoad());
                            int numFields = groups[j].members().length;
                            for (int k=0;k<numFields;k++)
                            {
                                FieldMetaData fmd = new FieldMetaData(fetchGroups[j],
                                    groups[j].members()[k].value());
                                fmd.setRecursionDepth(groups[j].members()[k].recursionDepth());
                                fetchGroups[j].addMember(fmd);
                            }
                            int numGroups = groups[j].fetchGroups().length;
                            for (int k=0;k<numGroups;k++)
                            {
                                FetchGroupMetaData subgrp = new FetchGroupMetaData(groups[j].fetchGroups()[k]);
                                fetchGroups[j].addFetchGroup(subgrp);
                            }
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.FETCHGROUP))
                    {
                        if (fetchGroups != null)
                        {
                            NucleusLogger.METADATA.warn(LOCALISER.msg("044208", cmd.getFullClassName()));
                        }
                        fetchGroups = new FetchGroupMetaData[1];
                        fetchGroups[0] = new FetchGroupMetaData((String)annotationValues.get("name"));
                        fetchGroups[0].setPostLoad((String)annotationValues.get("postLoad"));
                        FetchMember[] fields = (FetchMember[])annotationValues.get("members");
                        if (fields != null)
                        {
                            for (int j=0;j<fields.length;j++)
                            {
                                FieldMetaData fmd = new FieldMetaData(fetchGroups[0],
                                    fields[j].value());
                                fmd.setRecursionDepth(fields[j].recursionDepth());
                                fetchGroups[0].addMember(fmd);
                            }
                        }
                    }
                    else if (annName.equals(JPAAnnotationUtils.EXTENSION))
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.