diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java | 208 |
1 files changed, 0 insertions, 208 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java deleted file mode 100644 index 1145a8c2ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.jpa1.context.java; - -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AssociationOverride; -import org.eclipse.jpt.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaBaseEmbeddedMapping; -import org.eclipse.jpt.core.jpa2.JpaFactory2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaEmbeddedMapping2_0; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - - -public class GenericJavaEmbeddedMapping - extends AbstractJavaBaseEmbeddedMapping<EmbeddedAnnotation> - implements JavaEmbeddedMapping2_0 -{ - protected final JavaAssociationOverrideContainer associationOverrideContainer; - - public GenericJavaEmbeddedMapping(JavaPersistentAttribute parent) { - super(parent); - this.associationOverrideContainer = ((JpaFactory2_0) this.getJpaFactory()).buildJavaAssociationOverrideContainer(this, new AssociationOverrideContainerOwner()); - } - - @Override - protected void initialize() { - super.initialize(); - this.associationOverrideContainer.initialize(this.getResourcePersistentAttribute()); - } - - @Override - protected void update() { - super.update(); - this.associationOverrideContainer.update(this.getResourcePersistentAttribute()); - } - - @Override - public void postUpdate() { - super.postUpdate(); - this.associationOverrideContainer.postUpdate(); - } - - //****************** JavaAttributeMapping implementation ******************* - - public String getKey() { - return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; - } - - public String getAnnotationName() { - return EmbeddedAnnotation.ANNOTATION_NAME; - } - - //only putting this in EmbeddedMapping since relationship mappings - //defined within an embedded id class are not supported by the 2.0 spec. - @Override - public Iterator<String> allMappingNames() { - if (getJpaPlatformVersion().isCompatibleWithJpaVersion(JptCorePlugin.JPA_FACET_VERSION_2_0)) { - return new CompositeIterator<String>( - getName(), - embeddableAttributeMappingNames() - ); - } - return super.allMappingNames(); - } - - protected Iterator<String> embeddableAttributeMappingNames() { - return new TransformationIterator<String, String>( - new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings()) { - @Override - protected Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - } - ) - ) { - @Override - protected String transform(String next) { - return getName() + '.' + next; - } - }; - } - - @Override - public AttributeMapping resolveAttributeMapping(String name) { - AttributeMapping resolvedMapping = super.resolveAttributeMapping(name); - if (resolvedMapping != null) { - return resolvedMapping; - } - if (getJpaPlatformVersion().isCompatibleWithJpaVersion(JptCorePlugin.JPA_FACET_VERSION_2_0)) { - int dotIndex = name.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(name.substring(0, dotIndex))) { - for (AttributeMapping attributeMapping : CollectionTools.iterable(embeddableAttributeMappings())) { - resolvedMapping = attributeMapping.resolveAttributeMapping(name.substring(dotIndex + 1)); - if (resolvedMapping != null) { - return resolvedMapping; - } - } - } - } - } - return null; - } - - @Override - public RelationshipReference resolveRelationshipReference(String attributeName) { - if (getJpaPlatformVersion().isCompatibleWithJpaVersion(JptCorePlugin.JPA_FACET_VERSION_2_0)) { - int dotIndex = attributeName.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(attributeName.substring(0, dotIndex))) { - attributeName = attributeName.substring(dotIndex + 1); - AssociationOverride override = getAssociationOverrideContainer().getAssociationOverrideNamed(attributeName); - if (override != null && !override.isVirtual()) { - return override.getRelationshipReference(); - } - if (this.getEmbeddable() == null) { - return null; - } - return this.getEmbeddable().resolveRelationshipReference(attributeName); - } - } - } - return null; - } - - //****************** AbstractJavaAttributeMapping implementation ******************* - @Override - protected void addSupportingAnnotationNamesTo(Vector<String> names) { - super.addSupportingAnnotationNamesTo(names); - if (this.getJpaPlatformVersion().isCompatibleWithJpaVersion(JptCorePlugin.JPA_FACET_VERSION_2_0)) { - names.add(JPA.ASSOCIATION_OVERRIDE); - names.add(JPA.ASSOCIATION_OVERRIDES); - } - } - - - //****************** association overrides - 2.0 supports this ******************* - - public JavaAssociationOverrideContainer getAssociationOverrideContainer() { - return this.associationOverrideContainer; - } - - - @Override - public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - - result = getAssociationOverrideContainer().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - return null; - } - - // ********** association override container owner ********** - - class AssociationOverrideContainerOwner implements AssociationOverrideContainer.Owner { - - public TypeMapping getOverridableTypeMapping() { - return GenericJavaEmbeddedMapping.this.getOverridableTypeMapping(); - } - - public TypeMapping getTypeMapping() { - return GenericJavaEmbeddedMapping.this.getTypeMapping(); - } - - public RelationshipReference resolveRelationshipReference(String associationOverrideName) { - TypeMapping overridableTypeMapping = getOverridableTypeMapping(); - RelationshipReference relationshipReference = null; - if (overridableTypeMapping != null) { - for (TypeMapping typeMapping : CollectionTools.iterable(overridableTypeMapping.inheritanceHierarchy())) { - relationshipReference = typeMapping.resolveRelationshipReference(associationOverrideName); - if (relationshipReference != null) { - return relationshipReference; - } - } - } - return relationshipReference; - } - } - -} |