Package org.eclipse.persistence.oxm.mappings

Examples of org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping


   
    /**
     * INTERNAL:
     */
    protected XMLCompositeObjectMapping getSequenceGeneratorMapping() {
        XMLCompositeObjectMapping sequenceGeneratorMapping = new XMLCompositeObjectMapping();
        sequenceGeneratorMapping.setAttributeName("m_sequenceGenerator");
        sequenceGeneratorMapping.setGetMethodName("getSequenceGenerator");
        sequenceGeneratorMapping.setSetMethodName("setSequenceGenerator");
        sequenceGeneratorMapping.setReferenceClass(SequenceGeneratorMetadata.class);
        sequenceGeneratorMapping.setXPath("orm:sequence-generator");
        return sequenceGeneratorMapping;
    }
View Full Code Here


   
    /**
     * INTERNAL:
     */
    protected XMLCompositeObjectMapping getTableGeneratorMapping() {
        XMLCompositeObjectMapping tableGeneratorMapping = new XMLCompositeObjectMapping();
        tableGeneratorMapping.setAttributeName("m_tableGenerator");
        tableGeneratorMapping.setGetMethodName("getTableGenerator");
        tableGeneratorMapping.setSetMethodName("setTableGenerator");
        tableGeneratorMapping.setReferenceClass(TableGeneratorMetadata.class);
        tableGeneratorMapping.setXPath("orm:table-generator");
        return tableGeneratorMapping;
    }
View Full Code Here

   
    /**
     * INTERNAL:
     */
    protected XMLCompositeObjectMapping getValueColumnMapping() {
        XMLCompositeObjectMapping valueColumnMapping = new XMLCompositeObjectMapping();
        valueColumnMapping.setAttributeName("m_valueColumn");
        valueColumnMapping.setGetMethodName("getValueColumn");
        valueColumnMapping.setSetMethodName("setValueColumn");
        valueColumnMapping.setReferenceClass(ColumnMetadata.class);
        valueColumnMapping.setXPath("orm:value-column");
        return valueColumnMapping;
    }
View Full Code Here

            ListWrapper listWrapper = (ListWrapper) getDeclaredProperty(propertyIndex);
            listWrapper.setCurrentElements((List) newValue);
        } else {
            // OLD VALUE
            if (mapping.isAbstractCompositeObjectMapping()) {
                XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
                if (oldValue != null && compositeMapping.getContainerAccessor() != null) {
                    compositeMapping.getContainerAccessor().setAttributeValueInObject(oldValue, null);
                }
            }

            // NEW VALUE
            newValue = jaxbHelperContext.unwrap((DataObject) value);
            mapping.getAttributeAccessor().setAttributeValueInObject(entity, newValue);
            if (mapping.isAbstractCompositeObjectMapping()) {
                XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
                if (value != null && compositeMapping.getContainerAccessor() != null) {
                    compositeMapping.getContainerAccessor().setAttributeValueInObject(newValue, entity);
                }
            }
        }

    }
View Full Code Here

            mapping.getAttributeAccessor().setAttributeValueInObject(entity, container);
        } else {
            // OLD VALUE
            Object oldValue = mapping.getAttributeAccessor().getAttributeValueFromObject(entity);
            if (mapping.isAbstractCompositeObjectMapping()) {
                XMLCompositeObjectMapping compositeMapping = (XMLCompositeObjectMapping) mapping;
                if (compositeMapping.getContainerAccessor() != null) {
                    if (oldValue != null) {
                        compositeMapping.getContainerAccessor().setAttributeValueInObject(oldValue, null);
                    }
                }
            }

            // NEW VALUE
View Full Code Here

        parameters.setAttributeName("parameters");
        parameters.setReferenceClass(Parameter.class);
        parameters.setXPath("parameter");
        descriptor.addMapping(parameters);

        XMLCompositeObjectMapping resultMapping = new XMLCompositeObjectMapping();
        resultMapping.setAttributeName("result");
        resultMapping.setReferenceClass(Result.class);
        resultMapping.setXPath( "result");
        descriptor.addMapping(resultMapping);

        XMLChoiceObjectMapping queryHandlerMapping = new XMLChoiceObjectMapping();
        queryHandlerMapping.setAttributeName("queryHandler");
        queryHandlerMapping.addChoiceElement("jpql", JPQLQueryHandler.class);
View Full Code Here

        QNameTransformer qNameTransformer = new QNameTransformer("type/text()");
        type.addFieldTransformer("type/text()", qNameTransformer);
        type.setAttributeTransformer(qNameTransformer);
        descriptor.addMapping(type);

        XMLCompositeObjectMapping attachment = new XMLCompositeObjectMapping();
        attachment.setAttributeName("attachment");
        attachment.setXPath("attachment");
        attachment.setReferenceClass(Attachment.class);
        descriptor.addMapping(attachment);

        XMLCompositeObjectMapping sxf = new XMLCompositeObjectMapping();
        sxf.setAttributeName("simpleXMLFormat");
        sxf.setXPath("simple-xml-format");
        sxf.setReferenceClass(SimpleXMLFormat.class);
        descriptor.addMapping(sxf);

        XMLDirectMapping isCollection = new XMLDirectMapping();
        isCollection.setAttributeAccessor(new AttributeAccessor() {
            @Override
View Full Code Here

        descriptor.setJavaClass(ParameterExpression.class);
        descriptor.setDefaultRootElement("parameter-expression");

        descriptor.getInheritancePolicy().setParentClass(Expression.class);

        XMLCompositeObjectMapping parameterMapping = new XMLCompositeObjectMapping();
        parameterMapping.setAttributeName("field");
        parameterMapping.setReferenceClass(DatabaseField.class);
        parameterMapping.setXPath(getPrimaryNamespaceXPath() + "parameter");
        descriptor.addMapping(parameterMapping);

        XMLCompositeObjectMapping baseMapping = new XMLCompositeObjectMapping();
        baseMapping.setAttributeName("baseExpression");
        baseMapping.setReferenceClass(Expression.class);
        baseMapping.setXPath(getPrimaryNamespaceXPath() + "base");
        descriptor.addMapping(baseMapping);

        return descriptor;
    }
View Full Code Here

        descriptor.setJavaClass(FieldExpression.class);
        descriptor.setDefaultRootElement("field-expression");

        descriptor.getInheritancePolicy().setParentClass(Expression.class);

        XMLCompositeObjectMapping parameterMapping = new XMLCompositeObjectMapping();
        parameterMapping.setAttributeName("field");
        parameterMapping.setReferenceClass(DatabaseField.class);
        parameterMapping.setXPath(getPrimaryNamespaceXPath() + "field");
        descriptor.addMapping(parameterMapping);

        XMLCompositeObjectMapping baseMapping = new XMLCompositeObjectMapping();
        baseMapping.setAttributeName("baseExpression");
        baseMapping.setReferenceClass(Expression.class);
        baseMapping.setXPath(getPrimaryNamespaceXPath() + "base");
        descriptor.addMapping(baseMapping);

        return descriptor;
    }
View Full Code Here

        nameMapping.setGetMethodName("getName");
        nameMapping.setSetMethodName("setName");
        nameMapping.setXPath("@name");
        descriptor.addMapping(nameMapping);

        XMLCompositeObjectMapping expressionMapping = new XMLCompositeObjectMapping();
        expressionMapping.setAttributeName("selectionCriteria");
        expressionMapping.setGetMethodName("getSelectionCriteria");
        expressionMapping.setSetMethodName("setSelectionCriteria");
        expressionMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                return ((DatabaseQuery)object).getSelectionCriteria();
            }

            public void setAttributeValueInObject(Object object, Object value) {
                if (!(object instanceof ObjectLevelReadQuery)) {
                    return;
                }
                ObjectLevelReadQuery query = (ObjectLevelReadQuery)object;
                Expression expression = (Expression)value;
                if (expression != null) {
                    expression = expression.rebuildOn(query.getExpressionBuilder());
                }
                query.setSelectionCriteria(expression);
            }
        });
        expressionMapping.setReferenceClass(Expression.class);
        expressionMapping.setXPath(getSecondaryNamespaceXPath() + "criteria");
        descriptor.addMapping(expressionMapping);

        XMLCompositeCollectionMapping argumentsMapping = new XMLCompositeCollectionMapping();

        // Handle translation of argument lists to query-arguments.
        argumentsMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                DatabaseQuery query = (DatabaseQuery)object;
                Vector arguments = query.getArguments();
                Vector types = query.getArgumentTypeNames();
                Vector values = query.getArgumentValues();
                Vector queryArguments = new Vector(arguments.size());
                for (int index = 0; index < arguments.size(); index++) {
                    QueryArgument queryArgument = new QueryArgument();
                    queryArgument.setKey(arguments.get(index));
                    if (!types.isEmpty()) {
                        queryArgument.setTypeName((String)types.get(index));
                    }
                    if (!values.isEmpty()) {
                        queryArgument.setValue(values.get(index));
                    }
                    queryArguments.add(queryArgument);
                }
                return queryArguments;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                DatabaseQuery query = (DatabaseQuery)object;
                Vector queryArguments = (Vector)value;
                Vector arguments = NonSynchronizedVector.newInstance(queryArguments.size());
                Vector types = NonSynchronizedVector.newInstance(queryArguments.size());
                Vector values = NonSynchronizedVector.newInstance(queryArguments.size());
                for (int index = 0; index < queryArguments.size(); index++) {
                    QueryArgument queryArgument = (QueryArgument)queryArguments.get(index);
                    arguments.add(queryArgument.getKey());
                    if (queryArgument.getValue() != null) {
                        values.add(queryArgument.getValue());
                    }
                    if (queryArgument.getType() != null) {
                        types.add(queryArgument.getType());
                    }
                }
                query.setArguments(arguments);
                if (!types.isEmpty()) {
                    query.setArgumentTypes(types);
                }
                if (!values.isEmpty()) {
                    query.setArgumentValues(values);
                }
            }
        });
        argumentsMapping.setAttributeName("argumentsMapping");
        argumentsMapping.setXPath(getSecondaryNamespaceXPath() + "arguments/" + getSecondaryNamespaceXPath() + "argument");
        argumentsMapping.setReferenceClass(QueryArgument.class);
        descriptor.addMapping(argumentsMapping);

        XMLDirectMapping shouldMaintainCacheMapping = new XMLDirectMapping();
        shouldMaintainCacheMapping.setAttributeName("shouldMaintainCache");
        shouldMaintainCacheMapping.setGetMethodName("shouldMaintainCache");
        shouldMaintainCacheMapping.setSetMethodName("setShouldMaintainCache");
        shouldMaintainCacheMapping.setXPath(getPrimaryNamespaceXPath() + "maintain-cache/text()");
        shouldMaintainCacheMapping.setNullValue(Boolean.TRUE);
        descriptor.addMapping(shouldMaintainCacheMapping);

        XMLDirectMapping shouldBindAllParametersMapping = new XMLDirectMapping();
        shouldBindAllParametersMapping.setAttributeName("shouldBindAllParameters");
        shouldBindAllParametersMapping.setXPath(getPrimaryNamespaceXPath() + "bind-all-parameters/text()");
        descriptor.addMapping(shouldBindAllParametersMapping);

        XMLDirectMapping shouldCacheStatementMapping = new XMLDirectMapping();
        shouldCacheStatementMapping.setAttributeName("shouldCacheStatement");
        shouldCacheStatementMapping.setXPath(getPrimaryNamespaceXPath() + "cache-statement/text()");
        descriptor.addMapping(shouldCacheStatementMapping);

        XMLDirectMapping queryTimeoutMapping = new XMLDirectMapping();
        queryTimeoutMapping.setAttributeName("queryTimeout");
        queryTimeoutMapping.setGetMethodName("getQueryTimeout");
        queryTimeoutMapping.setSetMethodName("setQueryTimeout");
        queryTimeoutMapping.setXPath(getPrimaryNamespaceXPath() + "timeout/text()");
        queryTimeoutMapping.setNullValue(new Integer(DescriptorQueryManager.DefaultTimeout));
        descriptor.addMapping(queryTimeoutMapping);

        // feaure 2297
        XMLDirectMapping shouldPrepareMapping = new XMLDirectMapping();
        shouldPrepareMapping.setAttributeName("shouldPrepare");
        shouldPrepareMapping.setGetMethodName("shouldPrepare");
        shouldPrepareMapping.setSetMethodName("setShouldPrepare");
        shouldPrepareMapping.setXPath(getPrimaryNamespaceXPath() + "prepare/text()");
        shouldPrepareMapping.setNullValue(Boolean.TRUE);
        descriptor.addMapping(shouldPrepareMapping);

        XMLCompositeObjectMapping callMapping = new XMLCompositeObjectMapping();
        callMapping.setAttributeName("call");
        callMapping.setGetMethodName("getDatasourceCall");
        callMapping.setSetMethodName("setDatasourceCall");
        callMapping.setReferenceClass(Call.class);
        callMapping.setXPath(getPrimaryNamespaceXPath() + "call");
        descriptor.addMapping(callMapping);

        XMLCompositeObjectMapping redirectorMapping = new XMLCompositeObjectMapping();
        redirectorMapping.setAttributeName("redirector");
        redirectorMapping.setGetMethodName("getRedirector");
        redirectorMapping.setSetMethodName("setRedirector");
        redirectorMapping.setReferenceClass(MethodBaseQueryRedirector.class);
        redirectorMapping.setXPath(getPrimaryNamespaceXPath() + "query-redirector");
        descriptor.addMapping(redirectorMapping);

        return descriptor;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping

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.