Package org.eclipse.persistence.oxm.mappings

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


        relationTableMapping.setGetMethodName("getRelationTableQualifiedName");
        relationTableMapping.setSetMethodName("setRelationTableName");
        relationTableMapping.setXPath(getSecondaryNamespaceXPath() + "relation-table/text()");
        descriptor.addMapping(relationTableMapping);

        XMLCompositeCollectionMapping sourceToRelationKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
        sourceToRelationKeyFieldAssociationsMapping.setReferenceClass(Association.class);
        // Handle translation of foreign key associations to hashtables.
        sourceToRelationKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                List sourceFields = ((ManyToManyMapping)object).getSourceKeyFields();
                List relationFields = ((ManyToManyMapping)object).getSourceRelationKeyFields();
                List associations = new ArrayList(sourceFields.size());
                for (int index = 0; index < sourceFields.size(); index++) {
                    associations.add(new Association(relationFields.get(index), sourceFields.get(index)));
                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                ManyToManyMapping mapping = (ManyToManyMapping)object;
                List associations = (List)value;
                mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setSourceRelationKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
                    mapping.getSourceRelationKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        sourceToRelationKeyFieldAssociationsMapping.setAttributeName("sourceToRelationKeyFieldAssociationsMapping");
        sourceToRelationKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "source-relation-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
        descriptor.addMapping(sourceToRelationKeyFieldAssociationsMapping);

        XMLCompositeCollectionMapping targetToRelationKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
        targetToRelationKeyFieldAssociationsMapping.setReferenceClass(Association.class);
        // Handle translation of foreign key associations to hashtables.
        targetToRelationKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                List targetFields = ((ManyToManyMapping)object).getTargetKeyFields();
                List relationFields = ((ManyToManyMapping)object).getTargetRelationKeyFields();
                List associations = new ArrayList(targetFields.size());
                for (int index = 0; index < targetFields.size(); index++) {
                    associations.add(new Association(relationFields.get(index), targetFields.get(index)));
                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                ManyToManyMapping mapping = (ManyToManyMapping)object;
                List associations = (List)value;
                mapping.setTargetKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setTargetRelationKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getTargetKeyFields().add((DatabaseField)association.getValue());
                    mapping.getTargetRelationKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        targetToRelationKeyFieldAssociationsMapping.setAttributeName("targetToRelationKeyFieldAssociations");
        targetToRelationKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-relation-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
        descriptor.addMapping(targetToRelationKeyFieldAssociationsMapping);

        XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
        relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
        relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
View Full Code Here


        structureMapping.setGetMethodName("getStructureName");
        structureMapping.setSetMethodName("setStructureName");
        structureMapping.setXPath(getPrimaryNamespaceXPath() + "structure/text()");
        descriptor.addMapping(structureMapping);

        XMLCompositeCollectionMapping orderedFieldsMapping = new XMLCompositeCollectionMapping();
        orderedFieldsMapping.useCollectionClass(NonSynchronizedVector.class);
        orderedFieldsMapping.setAttributeName("orderedFields");
        orderedFieldsMapping.setXPath(getPrimaryNamespaceXPath() + "field-order/" + getPrimaryNamespaceXPath() + "field");
        orderedFieldsMapping.setReferenceClass(DatabaseField.class);
        descriptor.addMapping(orderedFieldsMapping);

        return descriptor;
    }
View Full Code Here

        XMLDirectMapping4.setGetMethodName("getDefaultAttributeValue");
        XMLDirectMapping4.setSetMethodName("setDefaultAttributeValue");
        XMLDirectMapping4.setXPath(getPrimaryNamespaceXPath() + "default-value/text()");
        descriptor.addMapping(XMLDirectMapping4);

        XMLCompositeCollectionMapping fieldToAttributeValueAssociationsMapping = new XMLCompositeCollectionMapping();
        fieldToAttributeValueAssociationsMapping.setAttributeName("fieldToAttributeValueAssociations");
        fieldToAttributeValueAssociationsMapping.setGetMethodName("getFieldToAttributeValueAssociations");
        fieldToAttributeValueAssociationsMapping.setSetMethodName("setFieldToAttributeValueAssociations");
        fieldToAttributeValueAssociationsMapping.setXPath(getPrimaryNamespaceXPath() + "type-mappings/" + getPrimaryNamespaceXPath() + "type-mapping");
        fieldToAttributeValueAssociationsMapping.setReferenceClass(TypeMapping.class);
        descriptor.addMapping(fieldToAttributeValueAssociationsMapping);

        return descriptor;
    }
View Full Code Here

        XMLDescriptor descriptor = new XMLDescriptor();
        descriptor.setJavaClass(OneToManyMapping.class);

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

        XMLCompositeCollectionMapping sourceToTargetKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
        sourceToTargetKeyFieldAssociationsMapping.setReferenceClass(Association.class);
        // Handle translation of foreign key associations to hashtables.
        sourceToTargetKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                List sourceFields = ((OneToManyMapping)object).getSourceKeyFields();
                List targetFields = ((OneToManyMapping)object).getTargetForeignKeyFields();
                List associations = new ArrayList(sourceFields.size());
                for (int index = 0; index < sourceFields.size(); index++) {
                    associations.add(new Association(targetFields.get(index), sourceFields.get(index)));
                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToManyMapping mapping = (OneToManyMapping)object;
                List associations = (List)value;
                mapping.setSourceKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                mapping.setTargetForeignKeyFields(NonSynchronizedVector.newInstance(associations.size()));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceKeyFields().add((DatabaseField)association.getValue());
                    mapping.getTargetForeignKeyFields().add((DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "target-foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
        descriptor.addMapping(sourceToTargetKeyFieldAssociationsMapping);

        XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
        relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
        relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
View Full Code Here

        XMLDescriptor descriptor = new XMLDescriptor();
        descriptor.setJavaClass(OneToOneMapping.class);

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

        XMLCompositeCollectionMapping sourceToTargetKeyFieldAssociationsMapping = new XMLCompositeCollectionMapping();
        sourceToTargetKeyFieldAssociationsMapping.setReferenceClass(Association.class);
        // Handle translation of foreign key associations to hashtables.
        sourceToTargetKeyFieldAssociationsMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                Map sourceToTargetKeyFields = ((OneToOneMapping)object).getSourceToTargetKeyFields();
                List associations = new ArrayList(sourceToTargetKeyFields.size());
                Iterator iterator = sourceToTargetKeyFields.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry entry = (Map.Entry)iterator.next();
                    associations.add(new Association(entry.getKey(), entry.getValue()));
                }
                return associations;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                OneToOneMapping mapping = (OneToOneMapping)object;
                List associations = (List)value;
                mapping.setSourceToTargetKeyFields(new HashMap(associations.size() + 1));
                mapping.setTargetToSourceKeyFields(new HashMap(associations.size() + 1));
                Iterator iterator = associations.iterator();
                while (iterator.hasNext()) {
                    Association association = (Association)iterator.next();
                    mapping.getSourceToTargetKeyFields().put((DatabaseField)association.getKey(), (DatabaseField)association.getValue());
                    mapping.getTargetToSourceKeyFields().put((DatabaseField)association.getValue(), (DatabaseField)association.getKey());
                }
            }
        });
        sourceToTargetKeyFieldAssociationsMapping.setAttributeName("sourceToTargetKeyFieldAssociations");
        sourceToTargetKeyFieldAssociationsMapping.setXPath(getSecondaryNamespaceXPath() + "foreign-key/" + getSecondaryNamespaceXPath() + "field-reference");
        descriptor.addMapping(sourceToTargetKeyFieldAssociationsMapping);

        XMLCompositeCollectionMapping foreignKeyFieldNamesMapping = new XMLCompositeCollectionMapping();
        foreignKeyFieldNamesMapping.useCollectionClass(NonSynchronizedVector.class);
        foreignKeyFieldNamesMapping.setAttributeName("foreignKeyFields");
        foreignKeyFieldNamesMapping.setGetMethodName("getForeignKeyFields");
        foreignKeyFieldNamesMapping.setSetMethodName("setForeignKeyFields");
        foreignKeyFieldNamesMapping.setXPath(getSecondaryNamespaceXPath() + "foreign-key-fields/" + getSecondaryNamespaceXPath() + "field");
        foreignKeyFieldNamesMapping.setReferenceClass(DatabaseField.class);
        descriptor.addMapping(foreignKeyFieldNamesMapping);

        XMLDirectMapping relationshipPartnerAttributeNameMapping = new XMLDirectMapping();
        relationshipPartnerAttributeNameMapping.setAttributeName("relationshipPartnerAttributeName");
        relationshipPartnerAttributeNameMapping.setGetMethodName("getRelationshipPartnerAttributeName");
View Full Code Here

        nameMapping.setSetMethodName("setName");
        nameMapping.setGetMethodName("getName");
        nameMapping.setXPath(getSecondaryNamespaceXPath() + "name/text()");
        descriptor.addMapping(nameMapping);

        XMLCompositeCollectionMapping descriptorsMapping = new XMLCompositeCollectionMapping();
        descriptorsMapping.useCollectionClass(NonSynchronizedVector.class);
        descriptorsMapping.setAttributeName("descriptors");
        descriptorsMapping.setSetMethodName("setOrderedDescriptors");
        descriptorsMapping.setGetMethodName("getOrderedDescriptors");
        descriptorsMapping.setReferenceClass(ClassDescriptor.class);
        descriptorsMapping.setXPath(getSecondaryNamespaceXPath() + "class-mapping-descriptors/" + getSecondaryNamespaceXPath() + "class-mapping-descriptor");
        descriptor.addMapping(descriptorsMapping);

        XMLCompositeObjectMapping loginMapping = new XMLCompositeObjectMapping();
        loginMapping.setSetMethodName("setDatasourceLogin");
        loginMapping.setGetMethodName("getDatasourceLogin");
View Full Code Here

        descriptor.setDefaultRootElement("query-policy");

        descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
        descriptor.getInheritancePolicy().addClassIndicator(DescriptorQueryManager.class, getPrimaryNamespaceXPath() + "query-policy");

        XMLCompositeCollectionMapping namedQueriesMapping = new XMLCompositeCollectionMapping();
        namedQueriesMapping.setReferenceClass(DatabaseQuery.class);
        namedQueriesMapping.useCollectionClass(Vector.class);
        namedQueriesMapping.setAttributeName("queries");
        namedQueriesMapping.setGetMethodName("getAllQueries");
        namedQueriesMapping.setSetMethodName("setAllQueries");
        namedQueriesMapping.setXPath(getSecondaryNamespaceXPath() + "queries/" + getSecondaryNamespaceXPath() + "query");
        descriptor.addMapping(namedQueriesMapping);

        XMLDirectMapping queryTimeoutMapping = new XMLDirectMapping();
        queryTimeoutMapping.setAttributeName("queryTimeout");
        queryTimeoutMapping.setGetMethodName("getQueryTimeout");
View Full Code Here

    protected ClassDescriptor buildReturningPolicyDescriptor() {
        XMLDescriptor descriptor = new XMLDescriptor();
        descriptor.setJavaClass(ReturningPolicy.class);
        descriptor.setDefaultRootElement("returning-policy");

        XMLCompositeCollectionMapping returningFieldInfoMapping = new XMLCompositeCollectionMapping();
        returningFieldInfoMapping.useCollectionClass(NonSynchronizedVector.class);
        returningFieldInfoMapping.setAttributeName("infos");
        returningFieldInfoMapping.setReferenceClass(ReturningPolicy.Info.class);
        returningFieldInfoMapping.setGetMethodName("getFieldInfos");
        returningFieldInfoMapping.setSetMethodName("setFieldInfos");
        returningFieldInfoMapping.setXPath(getPrimaryNamespaceXPath() + "returning-field-infos/" + getPrimaryNamespaceXPath() + "returning-field-info");
        descriptor.addMapping(returningFieldInfoMapping);

        return descriptor;
    }
View Full Code Here

        });
        indirectionPolicyMapping.setAttributeName("indirectionPolicy");
        indirectionPolicyMapping.setXPath(getPrimaryNamespaceXPath() + "indirection");
        descriptor.addMapping(indirectionPolicyMapping);

        XMLCompositeCollectionMapping fieldTransformationsMapping = new XMLCompositeCollectionMapping();

        // Handle translation of field-method hashtable to field-transformations.
        fieldTransformationsMapping.setAttributeName("fieldTransformations");
        fieldTransformationsMapping.setGetMethodName("getFieldTransformations");
        fieldTransformationsMapping.setSetMethodName("setFieldTransformations");
        fieldTransformationsMapping.setXPath(getPrimaryNamespaceXPath() + "field-transformations/" + getPrimaryNamespaceXPath() + "field-transformation");
        fieldTransformationsMapping.setReferenceClass(FieldTransformation.class);
        descriptor.addMapping(fieldTransformationsMapping);

        return descriptor;
    }
View Full Code Here

        typeFieldMapping.setSetMethodName("setTypeField");
        typeFieldMapping.setReferenceClass(DatabaseField.class);
        typeFieldMapping.setXPath(getPrimaryNamespaceXPath() + "type-field");
        descriptor.addMapping(typeFieldMapping);

        XMLCompositeCollectionMapping foreignKeyFieldsMapping = new XMLCompositeCollectionMapping();
        foreignKeyFieldsMapping.useCollectionClass(NonSynchronizedVector.class);
        foreignKeyFieldsMapping.setAttributeName("foreignKeyFields");
        foreignKeyFieldsMapping.setGetMethodName("getForeignKeyFields");
        foreignKeyFieldsMapping.setSetMethodName("setForeignKeyFields");
        foreignKeyFieldsMapping.setXPath(getPrimaryNamespaceXPath() + "foreign-key-fields/" + getPrimaryNamespaceXPath() + "field");
        foreignKeyFieldsMapping.setReferenceClass(DatabaseField.class);
        descriptor.addMapping(foreignKeyFieldsMapping);

        XMLCompositeCollectionMapping sourceFieldToTargetQueryKeyMapping = new XMLCompositeCollectionMapping();
        sourceFieldToTargetQueryKeyMapping.setAttributeName("sourceToTargetQueryKeyNames");
        sourceFieldToTargetQueryKeyMapping.setXPath(getPrimaryNamespaceXPath() + "foreign-key-to-query-key/" + getPrimaryNamespaceXPath() + "query-key-reference");
        sourceFieldToTargetQueryKeyMapping.setGetMethodName("getSourceToTargetQueryKeyFieldAssociations");
        sourceFieldToTargetQueryKeyMapping.setSetMethodName("setSourceToTargetQueryKeyFieldAssociations");
        // Handle translation of query key associations string to field.
        sourceFieldToTargetQueryKeyMapping.setAttributeAccessor(new AttributeAccessor() {
            public Object getAttributeValueFromObject(Object object) {
                VariableOneToOneMapping mapping = (VariableOneToOneMapping)object;
                Vector associations = mapping.getSourceToTargetQueryKeyFieldAssociations();
                Vector queryKeyReferences = new Vector(associations.size());
                for (int index = 0; index < associations.size(); index++) {
                    Association association = (Association)associations.get(index);
                    QueryKeyReference reference = new QueryKeyReference();
                    reference.setKey(new DatabaseField((String)association.getKey()));
                    reference.setValue(association.getValue());
                    queryKeyReferences.add(reference);
                }
                return queryKeyReferences;
            }

            public void setAttributeValueInObject(Object object, Object value) {
                VariableOneToOneMapping mapping = (VariableOneToOneMapping)object;
                Vector associations = (Vector)value;
                for (int index = 0; index < associations.size(); index++) {
                    Association association = (Association)associations.get(index);
                    association.setKey(((DatabaseField)association.getKey()).getQualifiedName());
                }
                mapping.setSourceToTargetQueryKeyFieldAssociations(associations);
            }
        });
        sourceFieldToTargetQueryKeyMapping.setReferenceClass(QueryKeyReference.class);
        descriptor.addMapping(sourceFieldToTargetQueryKeyMapping);

        XMLCompositeCollectionMapping classIndicatorsMapping = new XMLCompositeCollectionMapping();
        classIndicatorsMapping.setAttributeName("classIndicatorAssociations");
        classIndicatorsMapping.setGetMethodName("getClassIndicatorAssociations");
        classIndicatorsMapping.setSetMethodName("setClassIndicatorAssociations");
        classIndicatorsMapping.setXPath(getPrimaryNamespaceXPath() + "class-indicator-mappings/" + getPrimaryNamespaceXPath() + "class-indicator-mapping");
        classIndicatorsMapping.setReferenceClass(TypedAssociation.class);
        descriptor.addMapping(classIndicatorsMapping);

        return descriptor;
    }
View Full Code Here

TOP

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

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.