Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java171
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java293
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java310
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java304
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java293
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java1776
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java209
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java458
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java325
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java177
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java158
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java130
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java814
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java226
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java219
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java255
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java179
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java699
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java679
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java198
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java348
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java524
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java274
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java203
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java203
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java250
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java114
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java166
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java230
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java360
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java64
75 files changed, 0 insertions, 13333 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java
deleted file mode 100644
index 50b0229ea6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaAssociationOverrideRelationshipReference extends AbstractJavaJpaContextNode
- implements JavaAssociationOverrideRelationshipReference
-{
-
- // cache the strategy for property change notification
- protected JoiningStrategy cachedPredominantJoiningStrategy;
-
- protected final JavaJoinColumnInAssociationOverrideJoiningStrategy joinColumnJoiningStrategy;
-
- protected AbstractJavaAssociationOverrideRelationshipReference(JavaAssociationOverride parent) {
- super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected JavaJoinColumnInAssociationOverrideJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnInAssociationOverrideJoiningStrategy(this);
- }
-
- @Override
- public JavaAssociationOverride getParent() {
- return (JavaAssociationOverride) super.getParent();
- }
-
- public JavaAssociationOverride getAssociationOverride() {
- return getParent();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public TypeMapping getTypeMapping() {
- return getAssociationOverride().getOwner().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
- // **************** RelationshipMapping implementation *******************************
-
- public boolean isParentVirtual() {
- return getAssociationOverride().isVirtual();
- }
-
- // **************** predominant joining strategy ***************************
-
- public JoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy(JoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
- public void initialize(AssociationOverrideAnnotation associationOverride) {
- initializeJoiningStrategies(associationOverride);
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected void initializeJoiningStrategies(AssociationOverrideAnnotation associationOverride) {
- this.joinColumnJoiningStrategy.initialize(associationOverride);
- }
-
- public void update(AssociationOverrideAnnotation associationOverride) {
- updateJoiningStrategies(associationOverride);
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void updateJoiningStrategies(AssociationOverrideAnnotation associationOverride) {
- this.joinColumnJoiningStrategy.update(associationOverride);
- }
-
- protected abstract JoiningStrategy calculatePredominantJoiningStrategy();
-
- @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 = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getAssociationOverride().getValidationTextRange(astRoot);
- }
-
- // **************** join columns *******************************************
-
-
- public JavaJoinColumnInAssociationOverrideJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverride().getOwner().getRelationshipMapping(getAssociationOverride().getName());
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return getRelationshipMapping().isOwnedBy(mapping);
- }
-
- public boolean isRelationshipOwner() {
- return getRelationshipMapping().isRelationshipOwner();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
deleted file mode 100644
index fe0ab53a8c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.ColumnMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.SimpleMetamodelField;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java attribute mapping
- */
-public abstract class AbstractJavaAttributeMapping<T extends Annotation>
- extends AbstractJavaJpaContextNode
- implements JavaAttributeMapping, AttributeMapping2_0
-{
- protected T mappingAnnotation;
-
- protected Vector<String> supportingAnnotationNames;
-
-
- protected AbstractJavaAttributeMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @SuppressWarnings("unchecked")
- public void initialize(Annotation annotation) {
- this.mappingAnnotation = (T) annotation;
- this.initialize();
- }
-
- protected void initialize() {
- // do nothing by default
- }
-
- @SuppressWarnings("unchecked")
- public void update(Annotation annotation) {
- this.mappingAnnotation = (T) annotation;
- this.update();
- }
-
- protected void update() {
- // do nothing by default
- }
-
- @Override
- public JavaPersistentAttribute getParent() {
- return (JavaPersistentAttribute) super.getParent();
- }
-
- public JavaPersistentAttribute getPersistentAttribute() {
- return this.getParent();
- }
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.getParent().getResourcePersistentAttribute();
- }
-
- public T getMappingAnnotation() {
- return this.mappingAnnotation;
- }
-
- /**
- * the persistent attribute can tell whether there is a "specified" mapping
- * or a "default" one
- */
- public boolean isDefault() {
- return this.getPersistentAttribute().mappingIsDefault(this);
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return this.getTypeMapping().shouldValidateAgainstDatabase();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getPersistentAttribute().getOwningTypeMapping();
- }
-
- public String getName() {
- return this.getPersistentAttribute().getName();
- }
-
- public Table getDbTable(String tableName) {
- return this.getTypeMapping().getDbTable(tableName);
- }
-
- public String getPrimaryKeyColumnName() {
- return null;
- }
-
- public boolean isOverridableAttributeMapping() {
- return false;
- }
-
- public boolean isOverridableAssociationMapping() {
- return false;
- }
-
- public boolean isRelationshipOwner() {
- return false;
- }
-
- public boolean isOwnedBy(AttributeMapping mapping) {
- return false;
- }
-
- public Iterator<String> allMappingNames() {
- return new SingleElementIterator<String>(getName());
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- if (getName().equals(name)) {
- return this;
- }
- return null;
- }
-
- public Iterator<String> allOverrideableAttributeMappingNames() {
- if (isOverridableAttributeMapping()) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Iterator<String> allOverrideableAssociationMappingNames() {
- if (isOverridableAssociationMapping()) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- ColumnMapping columnMapping = this.resolveColumnMapping(attributeName);
- return columnMapping == null ? null : columnMapping.getColumn();
- }
-
- protected ColumnMapping resolveColumnMapping(String name) {
- AttributeMapping attributeMapping = resolveAttributeMapping(name);
- if (attributeMapping != null && attributeMapping.isOverridableAttributeMapping()) {
- return (ColumnMapping) attributeMapping;
- }
- return null;
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- RelationshipMapping relationshipMapping = this.resolveRelationshipMapping(attributeName);
- return relationshipMapping == null ? null : relationshipMapping.getRelationshipReference();
- }
-
- protected RelationshipMapping resolveRelationshipMapping(String name) {
- AttributeMapping attributeMapping = resolveAttributeMapping(name);
- if (attributeMapping != null && attributeMapping.isOverridableAssociationMapping()) {
- return (RelationshipMapping) attributeMapping;
- }
- return null;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** supporting annotation names **********
-
- public Iterable<String> getSupportingAnnotationNames() {
- if (this.supportingAnnotationNames == null) {
- this.supportingAnnotationNames = this.buildSupportingAnnotationNames();
- }
- return this.supportingAnnotationNames;
- }
-
- protected Vector<String> buildSupportingAnnotationNames() {
- Vector<String> names = new Vector<String>();
- this.addSupportingAnnotationNamesTo(names);
- return names;
- }
-
- protected void addSupportingAnnotationNamesTo(@SuppressWarnings("unused") Vector<String> names) {
- // the default is none
- }
-
-
- // ********** metamodel **********
-
- public MetamodelField getMetamodelField() {
- return new SimpleMetamodelField(
- this.getMetamodelFieldModifiers(),
- this.getMetamodelFieldTypeName(),
- this.getMetamodelFieldTypeArgumentNames(),
- this.getMetamodelFieldName()
- );
- }
-
- protected Iterable<String> getMetamodelFieldModifiers() {
- return STANDARD_METAMODEL_FIELD_MODIFIERS;
- }
-
- /**
- * most mappings are "singular"
- */
- protected String getMetamodelFieldTypeName() {
- return JPA2_0.SINGULAR_ATTRIBUTE;
- }
-
- protected final Iterable<String> getMetamodelFieldTypeArgumentNames() {
- ArrayList<String> typeArgumentNames = new ArrayList<String>(3);
- typeArgumentNames.add(this.getTypeMapping().getPersistentType().getName());
- this.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- return typeArgumentNames;
- }
-
- /**
- * by default, we add only the mapping's attribute type name;
- * but collection relationship mappings will also need to add the key type
- * name if the "collection" is of type java.util.Map
- */
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- typeArgumentNames.add(this.getMetamodelTypeName());
- }
-
- public String getMetamodelTypeName() {
- return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelTypeName();
- }
-
- protected String getMetamodelFieldName() {
- return this.getName();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateMappingType(messages, astRoot);
- }
-
- protected void validateMappingType(List<IMessage> messages, CompilationUnit astRoot) {
- if ( ! this.getTypeMapping().attributeMappingKeyAllowed(this.getKey())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getMappingAnnotationTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- protected TextRange getMappingAnnotationTextRange(CompilationUnit astRoot) {
- return (this.mappingAnnotation == null) ? null : this.mappingAnnotation.getTextRange(astRoot);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java
deleted file mode 100644
index 46bbad8953..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-
-public abstract class AbstractJavaAttributeMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- protected AbstractJavaAttributeMappingDefinition() {
- super();
- }
-
-
- /**
- * Default implementation. Override if the mapping definition applies in the annotationless case.
- */
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return false;
- }
-
- /**
- * Default implementation. Override if the mapping definition needs to do more analysis.
- */
- public boolean testSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(getAnnotationName())
- != null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
deleted file mode 100644
index cae35d5535..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> extends AbstractJavaNamedColumn<T>
- implements JavaBaseColumn
-{
-
- protected String specifiedTable;
-
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
-
- protected Boolean specifiedNullable;
-
- protected Boolean specifiedInsertable;
-
- protected Boolean specifiedUpdatable;
-
- protected AbstractJavaBaseColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner) {
- super(parent, owner);
- }
-
- @Override
- protected void initialize(T column) {
- super.initialize(column);
- this.defaultTable = this.buildDefaultTableName();
- this.specifiedTable = this.getResourceTable();
- this.specifiedUnique = this.getResourceUnique();
- this.specifiedNullable = this.getResourceNullable();
- this.specifiedInsertable = this.getResourceInsertable();
- this.specifiedUpdatable = this.getResourceUpdatable();
- }
-
- @Override
- protected void update(T column) {
- super.update(column);
- this.setDefaultTable(this.buildDefaultTableName());
- this.setSpecifiedTable_(this.getResourceTable());
- this.setSpecifiedUnique_(this.getResourceUnique());
- this.setSpecifiedNullable_(this.getResourceNullable());
- this.setSpecifiedInsertable_(this.getResourceInsertable());
- this.setSpecifiedUpdatable_(this.getResourceUpdatable());
- }
-
- @Override
- public JavaBaseColumn.Owner getOwner() {
- return (JavaBaseColumn.Owner) super.getOwner();
- }
-
- //************** BaseColumn implementation *******************
-
- //************** table *******************
-
- @Override
- public String getTable() {
- return (this.getSpecifiedTable() == null) ? getDefaultTable() : this.getSpecifiedTable();
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- public void setSpecifiedTable(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- getResourceColumn().setTable(newSpecifiedTable);
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedTable_(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String newDefaultTable) {
- String oldDefaultTable = this.defaultTable;
- this.defaultTable = newDefaultTable;
- firePropertyChanged(BaseColumn.DEFAULT_TABLE_PROPERTY, oldDefaultTable, newDefaultTable);
- }
-
- protected String getResourceTable() {
- return getResourceColumn().getTable();
- }
-
- public boolean tableNameIsInvalid() {
- return getOwner().tableNameIsInvalid(getTable());
- }
-
- //************** unique *******************
-
- public boolean isUnique() {
- return (this.getSpecifiedUnique() == null) ? this.isDefaultUnique() : this.getSpecifiedUnique().booleanValue();
- }
-
- public boolean isDefaultUnique() {
- return BaseColumn.DEFAULT_UNIQUE;
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- public void setSpecifiedUnique(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- this.getResourceColumn().setUnique(newSpecifiedUnique);
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedUnique_(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- protected Boolean getResourceUnique() {
- return getResourceColumn().getUnique();
- }
-
- //************** nullable *******************
-
- public boolean isNullable() {
- return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue();
- }
-
- public boolean isDefaultNullable() {
- return BaseColumn.DEFAULT_NULLABLE;
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- public void setSpecifiedNullable(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- this.getResourceColumn().setNullable(newSpecifiedNullable);
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- protected Boolean getResourceNullable() {
- return getResourceColumn().getNullable();
- }
-
- //************** insertable *******************
-
- public boolean isInsertable() {
- return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue();
- }
-
- public boolean isDefaultInsertable() {
- return BaseColumn.DEFAULT_INSERTABLE;
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- this.getResourceColumn().setInsertable(newSpecifiedInsertable);
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- protected Boolean getResourceInsertable() {
- return getResourceColumn().getInsertable();
- }
-
- //************** updatable *******************
-
- public boolean isUpdatable() {
- return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue();
- }
-
- public boolean isDefaultUpdatable() {
- return BaseColumn.DEFAULT_UPDATABLE;
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- this.getResourceColumn().setUpdatable(newSpecifiedUpdatable);
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- protected Boolean getResourceUpdatable() {
- return getResourceColumn().getUpdatable();
- }
-
- public TextRange getTableTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceColumn().getTableTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- public boolean tableTouches(int pos, CompilationUnit astRoot) {
- return getResourceColumn().tableTouches(pos, astRoot);
- }
-
- public Iterator<String> candidateTableNames() {
- return getOwner().candidateTableNames();
- }
-
- private Iterator<String> candidateTableNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateTableNames(), filter);
- }
-
- private Iterator<String> javaCandidateTableNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateTableNames(filter));
- }
-
- @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;
- }
- if (this.tableTouches(pos, astRoot)) {
- return this.javaCandidateTableNames(filter);
- }
- return null;
- }
-
- protected String buildDefaultTableName() {
- return this.getOwner().getDefaultTableName();
- }
-
- @Override
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaBaseColumnTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
deleted file mode 100644
index 28217ee14f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseEmbeddedMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaBaseEmbeddedMapping<T extends Annotation>
- extends AbstractJavaAttributeMapping<T>
- implements JavaBaseEmbeddedMapping
-{
- protected final JavaAttributeOverrideContainer attributeOverrideContainer;
-
- private Embeddable targetEmbeddable;
-
-
- protected AbstractJavaBaseEmbeddedMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.attributeOverrideContainer =
- this.getJpaFactory().buildJavaAttributeOverrideContainer(
- this,
- buildAttributeOverrideContainerOwner());
- }
-
-
- protected JavaAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() {
- return new AttributeOverrideContainerOwner();
- }
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return this.targetEmbeddable;
- }
-
-
- //****************** JavaAttributeMapping implementation *******************
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.ATTRIBUTE_OVERRIDE);
- names.add(JPA.ATTRIBUTE_OVERRIDES);
- }
-
- public Embeddable getTargetEmbeddable() {
- return this.targetEmbeddable;
- }
-
- protected void setTargetEmbeddable_(Embeddable newTargetEmbeddable) {
- Embeddable oldTargetEmbeddable = this.targetEmbeddable;
- this.targetEmbeddable = newTargetEmbeddable;
- firePropertyChanged(TARGET_EMBEDDABLE_PROPERTY, oldTargetEmbeddable, newTargetEmbeddable);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.attributeOverrideContainer.initialize(this.getResourcePersistentAttribute());
- this.targetEmbeddable = this.getPersistentAttribute().getEmbeddable();
- }
-
- @Override
- protected void update() {
- super.update();
- setTargetEmbeddable_(this.getPersistentAttribute().getEmbeddable());
- this.attributeOverrideContainer.update(this.getResourcePersistentAttribute());
- }
-
- protected Iterator<AttributeMapping> embeddableAttributeMappings() {
- Embeddable targetEmbeddable = getTargetEmbeddable();
- if (targetEmbeddable != null && targetEmbeddable != getPersistentAttribute().getOwningTypeMapping()) {
- return targetEmbeddable.attributeMappings();
- }
- return EmptyIterator.instance();
- }
-
- @Override
- public Iterator<String> allOverrideableAttributeMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAttributeMappingNames() :
- super.allOverrideableAttributeMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAttributeMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- }
- );
- }
-
- @Override
- public Iterator<String> allOverrideableAssociationMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAssociationMappingNames() :
- super.allOverrideableAssociationMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAssociationMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- }
- );
- }
-
- protected Iterator<String> embeddableOverrideableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<String, String>(
- new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer)))
- {
- @Override
- protected String transform(String next) {
- return getName() + '.' + next;
- }
- };
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- if (this.isJpa2_0Compatible()) {
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- if (getName().equals(attributeName.substring(0, dotIndex))) {
- attributeName = attributeName.substring(dotIndex + 1);
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- if (this.getTargetEmbeddable() == null) {
- return null;
- }
- return this.getTargetEmbeddable().resolveOverriddenColumn(attributeName);
- }
- }
- }
- return null;
- }
-
- @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 = getAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- //******** Validation ******************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- if (validateTargetEmbeddable(messages, reporter, astRoot)) {
- validateOverrides(messages, reporter, astRoot);
- }
- }
-
- protected boolean validateTargetEmbeddable(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (getTargetEmbeddable() == null) {
- String targetEmbeddableTypeName = getPersistentAttribute().getTypeName();
- // if the type isn't resolveable, there'll already be a java error
- if (targetEmbeddableTypeName != null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_NOT_AN_EMBEDDABLE,
- new String[] {targetEmbeddableTypeName},
- this,
- this.getValidationTextRange(astRoot)));
- }
- return false;
- }
- return true;
- }
-
- protected void validateOverrides(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- getAttributeOverrideContainer().validate(messages, reporter, astRoot);
- }
-
- //********** AttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator<String> allOverridableAttributeNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAttributeNames();
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaBaseEmbeddedMapping.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java
deleted file mode 100644
index 3e27e83e3a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Fetchable;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.LobAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaBasicMapping
- extends AbstractJavaAttributeMapping<BasicAnnotation>
- implements JavaBasicMapping
-{
- protected FetchType specifiedFetch;
-
- protected Boolean specifiedOptional;
-
- protected final JavaColumn column;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
- protected AbstractJavaBasicMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = getJpaFactory().buildJavaColumn(this, this);
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.converter = this.buildConverter(this.getResourceConverterType());
- this.specifiedFetch = this.getResourceFetch();
- this.specifiedOptional = this.getResourceOptional();
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- //************** AttributeMapping implementation ***************
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- //************** JavaAttributeMapping implementation ***************
- public String getAnnotationName() {
- return BasicAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.LOB);
- names.add(JPA.TEMPORAL);
- names.add(JPA.ENUMERATED);
- }
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- //************** BasicMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public FetchType getFetch() {
- return (this.getSpecifiedFetch() == null) ? this.getDefaultFetch() : this.getSpecifiedFetch();
- }
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(newSpecifiedFetch));
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedFetch_(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- public boolean isOptional() {
- return (this.getSpecifiedOptional() == null) ? this.isDefaultOptional() : this.getSpecifiedOptional().booleanValue();
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- this.mappingAnnotation.setOptional(newSpecifiedOptional);
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- protected void setSpecifiedOptional_(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- this.setSpecifiedFetch_(this.getResourceFetch());
- this.setSpecifiedOptional_(this.getResourceOptional());
- }
-
- protected FetchType getResourceFetch() {
- return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch());
- }
-
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.ENUMERATED_CONVERTER)) {
- return getJpaFactory().buildJavaEnumeratedConverter(this, this.getResourcePersistentAttribute());
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- if (this.valuesAreEqual(converterType, Converter.LOB_CONVERTER)) {
- return getJpaFactory().buildJavaLobConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME) != null) {
- return Converter.ENUMERATED_CONVERTER;
- }
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- if (this.getResourcePersistentAttribute().getAnnotation(LobAnnotation.ANNOTATION_NAME) != null) {
- return Converter.LOB_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- @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 = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.getColumn().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java
deleted file mode 100644
index 0bcff08ea6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java
+++ /dev/null
@@ -1,51 +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.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-
-
-public abstract class AbstractJavaEmbeddable
- extends AbstractJavaTypeMapping
- implements JavaEmbeddable
-{
- protected AbstractJavaEmbeddable(JavaPersistentType parent) {
- super(parent);
- }
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddableAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public boolean isMapped() {
- return true;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
deleted file mode 100644
index e5cdff300d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
+++ /dev/null
@@ -1,1776 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaPlatformVariation.Supported;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AssociationOverride;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaDiscriminatorColumn;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaQueryContainer;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.java.JavaTable;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.SecondaryTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.TableValidator;
-import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0;
-import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaEntity
- extends AbstractJavaTypeMapping
- implements JavaEntity, JavaCacheableHolder2_0
-{
- protected String specifiedName;
-
- protected String defaultName;
-
- protected final JavaIdClassReference idClassReference;
-
- protected final JavaTable table;
-
- protected boolean specifiedTableIsAllowed;
-
- protected boolean tableIsUndefined;
-
- protected final List<JavaSecondaryTable> specifiedSecondaryTables;
-
- protected final List<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns;
-
- protected JavaPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn;
-
- protected InheritanceType specifiedInheritanceStrategy;
-
- protected InheritanceType defaultInheritanceStrategy;
-
- protected String defaultDiscriminatorValue;
-
- protected String specifiedDiscriminatorValue;
-
- protected boolean specifiedDiscriminatorValueIsAllowed;
-
- protected boolean discriminatorValueIsUndefined;
-
- protected final JavaDiscriminatorColumn discriminatorColumn;
-
- protected boolean specifiedDiscriminatorColumnIsAllowed;
-
- protected boolean discriminatorColumnIsUndefined;
-
- protected final JavaAttributeOverrideContainer attributeOverrideContainer;
-
- protected final JavaAssociationOverrideContainer associationOverrideContainer;
-
- protected final JavaQueryContainer queryContainer;
-
- protected final JavaGeneratorContainer generatorContainer;
-
- protected Entity rootEntity;
-
-
- protected AbstractJavaEntity(JavaPersistentType parent) {
- super(parent);
- this.idClassReference = buildIdClassReference();
- this.table = this.getJpaFactory().buildJavaTable(this, new TableOwner());
- this.discriminatorColumn = buildJavaDiscriminatorColumn();
- this.specifiedSecondaryTables = new ArrayList<JavaSecondaryTable>();
- this.specifiedPrimaryKeyJoinColumns = new ArrayList<JavaPrimaryKeyJoinColumn>();
- this.attributeOverrideContainer =
- getJpaFactory().buildJavaAttributeOverrideContainer(this, new AttributeOverrideContainerOwner());
- this.associationOverrideContainer =
- getJpaFactory().buildJavaAssociationOverrideContainer(this, new AssociationOverrideContainerOwner());
- this.queryContainer = getJpaFactory().buildJavaQueryContainer(this);
- this.generatorContainer = getJpaFactory().buildJavaGeneratorContainer(this);
- }
-
- protected JavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- protected JavaBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected JavaDiscriminatorColumn buildJavaDiscriminatorColumn() {
- return this.getJpaFactory().buildJavaDiscriminatorColumn(this, buildDiscriminatorColumnOwner());
- }
-
- protected JavaDiscriminatorColumn.Owner buildDiscriminatorColumnOwner() {
- return new JavaDiscriminatorColumn.Owner(){
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public String getDefaultColumnName() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getName()
- :
- discriminatorColumnIsUndefined()?
- null
- :
- DiscriminatorColumn.DEFAULT_NAME;
- }
-
- public int getDefaultLength() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getLength()
- :
- discriminatorColumnIsUndefined()?
- 0//TODO think i want to return null here
- :
- DiscriminatorColumn.DEFAULT_LENGTH;
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getDiscriminatorType()
- :
- discriminatorColumnIsUndefined()?
- null
- :
- DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE;
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new DiscriminatorColumnValidator(column, textRangeResolver);
- }
- };
- }
-
- @Override
- public void initialize(JavaResourcePersistentType resourcePersistentType) {
- super.initialize(resourcePersistentType);
-
- this.specifiedName = this.getResourceName();
- this.defaultName = this.getResourceDefaultName();
- this.idClassReference.initialize();
- this.rootEntity = calculateRootEntity();
- this.defaultInheritanceStrategy = this.buildDefaultInheritanceStrategy();
- this.specifiedInheritanceStrategy = this.getResourceInheritanceStrategy(getResourceInheritance());
- this.specifiedDiscriminatorValueIsAllowed = this.buildSpecifiedDiscriminatorValueIsAllowed();
- this.discriminatorValueIsUndefined = this.buildDiscriminatorValueIsUndefined();
- this.specifiedDiscriminatorValue = this.getResourceDiscriminatorValue().getValue();
- this.defaultDiscriminatorValue = this.buildDefaultDiscriminatorValue();
- this.specifiedDiscriminatorColumnIsAllowed = this.buildSpecifiedDiscriminatorColumnIsAllowed();
- this.discriminatorColumnIsUndefined = this.buildDiscriminatorColumnIsUndefined();
- this.discriminatorColumn.initialize(this.getResourceDiscriminatorColumn());
- this.specifiedTableIsAllowed = this.buildSpecifiedTableIsAllowed();
- this.tableIsUndefined = this.buildTableIsUndefined();
- this.table.initialize(resourcePersistentType);
- this.initializeSecondaryTables();
- this.generatorContainer.initialize(resourcePersistentType);
- this.queryContainer.initialize(resourcePersistentType);
- this.initializePrimaryKeyJoinColumns();
- this.initializeDefaultPrimaryKeyJoinColumn();
- this.attributeOverrideContainer.initialize(resourcePersistentType);
- this.associationOverrideContainer.initialize(resourcePersistentType);
- }
-
- protected void initializeSecondaryTables() {
- for (Iterator<NestableAnnotation> stream =
- this.javaResourcePersistentType.annotations(
- SecondaryTableAnnotation.ANNOTATION_NAME,
- SecondaryTablesAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.specifiedSecondaryTables.add(
- buildSecondaryTable((SecondaryTableAnnotation) stream.next()));
- }
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- for (Iterator<NestableAnnotation> stream =
- this.javaResourcePersistentType.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.specifiedPrimaryKeyJoinColumns.add(
- buildPrimaryKeyJoinColumn((PrimaryKeyJoinColumnAnnotation) stream.next()));
- }
- }
-
- protected boolean shouldBuildDefaultPrimaryKeyJoinColumn() {
- return !containsSpecifiedPrimaryKeyJoinColumns();
- }
-
- protected void initializeDefaultPrimaryKeyJoinColumn() {
- if (!shouldBuildDefaultPrimaryKeyJoinColumn()) {
- return;
- }
- this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
-
- //query for the inheritance resource every time on setters.
- //call one setter and the inheritanceResource could change.
- //You could call more than one setter before this object has received any notification
- //from the java resource model
- protected InheritanceAnnotation getResourceInheritance() {
- return (InheritanceAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
- }
-
- protected DiscriminatorValueAnnotation getResourceDiscriminatorValue() {
- return (DiscriminatorValueAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
- }
-
- protected DiscriminatorColumnAnnotation getResourceDiscriminatorColumn() {
- return (DiscriminatorColumnAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected EntityAnnotation getResourceMappingAnnotation() {
- return (EntityAnnotation) super.getResourceMappingAnnotation();
- }
-
- // **************** AttributeOverrideContainer.Owner impl *****************
-
- public TypeMapping getTypeMapping() {
- return this;
- }
-
- public TypeMapping getOverridableTypeMapping() {
- PersistentType superPersistentType = getPersistentType().getSuperPersistentType();
- return superPersistentType == null ? null : superPersistentType.getMapping();
- }
-
-
- // **************** TypeMapping implementation ****************************
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- @Override
- public String getPrimaryTableName() {
- return this.getTable().getName();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getPrimaryDbTable() {
- return getTable().getDbTable();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- // matching database objects and identifiers is database platform-specific
- return this.getDataSource().selectDatabaseObjectForIdentifier(this.getAssociatedDbTablesIncludingInherited(), tableName);
- }
-
- protected Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited() {
- return new FilteringIterable<org.eclipse.jpt.db.Table>(this.getAssociatedDbTablesIncludingInherited_()) {
- @Override
- protected boolean accept(org.eclipse.jpt.db.Table t) {
- return t != null;
- }
- };
- }
-
- protected Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited_() {
- return new TransformationIterable<Table, org.eclipse.jpt.db.Table>(this.getAssociatedTablesIncludingInherited()) {
- @Override
- protected org.eclipse.jpt.db.Table transform(Table t) {
- return t.getDbTable();
- }
- };
- }
-
- @Override
- public Schema getDbSchema() {
- return getTable().getDbSchema();
- }
-
-
- //****************** JavaTypeMapping implementation *******************
-
- public String getAnnotationName() {
- return EntityAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
- protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JPA.TABLE,
- JPA.SECONDARY_TABLE,
- JPA.SECONDARY_TABLES,
- JPA.PRIMARY_KEY_JOIN_COLUMN,
- JPA.PRIMARY_KEY_JOIN_COLUMNS,
- JPA.ID_CLASS,
- JPA.INHERITANCE,
- JPA.DISCRIMINATOR_VALUE,
- JPA.DISCRIMINATOR_COLUMN,
- JPA.SEQUENCE_GENERATOR,
- JPA.TABLE_GENERATOR,
- JPA.NAMED_QUERY,
- JPA.NAMED_QUERIES,
- JPA.NAMED_NATIVE_QUERY,
- JPA.NAMED_NATIVE_QUERIES,
- JPA.SQL_RESULT_SET_MAPPING,
- JPA.EXCLUDE_DEFAULT_LISTENERS,
- JPA.EXCLUDE_SUPERCLASS_LISTENERS,
- JPA.ENTITY_LISTENERS,
- JPA.PRE_PERSIST,
- JPA.POST_PERSIST,
- JPA.PRE_REMOVE,
- JPA.POST_REMOVE,
- JPA.PRE_UPDATE,
- JPA.POST_UPDATE,
- JPA.POST_LOAD,
- JPA.ATTRIBUTE_OVERRIDE,
- JPA.ATTRIBUTE_OVERRIDES,
- JPA.ASSOCIATION_OVERRIDE,
- JPA.ASSOCIATION_OVERRIDES
- };
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
-
- // **************** name **************************************************
-
- @Override
- public String getName() {
- return (this.getSpecifiedName() == null) ? this.getDefaultName() : this.getSpecifiedName();
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- this.getResourceMappingAnnotation().setName(newSpecifiedName);
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected/*private-protected*/ void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
-
- // **************** id class **********************************************
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
-
- // **************** table *************************************************
-
- public JavaTable getTable() {
- return this.table;
- }
-
- public ListIterator<JavaSecondaryTable> specifiedSecondaryTables() {
- return new CloneListIterator<JavaSecondaryTable>(this.specifiedSecondaryTables);
- }
-
- public int specifiedSecondaryTablesSize() {
- return this.specifiedSecondaryTables.size();
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable(int index) {
- JavaSecondaryTable secondaryTable = getJpaFactory().buildJavaSecondaryTable(this, new SecondaryTableOwner());
- this.specifiedSecondaryTables.add(index, secondaryTable);
- SecondaryTableAnnotation secondaryTableResource =
- (SecondaryTableAnnotation) this.javaResourcePersistentType.
- addAnnotation(
- index, SecondaryTableAnnotation.ANNOTATION_NAME,
- SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTable.initialize(secondaryTableResource);
- fireItemAdded(SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable);
- return secondaryTable;
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable() {
- return this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size());
- }
-
- protected void addSpecifiedSecondaryTable(int index, JavaSecondaryTable secondaryTable) {
- addItemToList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected void addSpecifiedSecondaryTable(JavaSecondaryTable secondaryTable) {
- this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size(), secondaryTable);
- }
-
- public void removeSpecifiedSecondaryTable(SecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- public void removeSpecifiedSecondaryTable(int index) {
- JavaSecondaryTable removedSecondaryTable = this.specifiedSecondaryTables.remove(index);
- this.javaResourcePersistentType.removeAnnotation(
- index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(SPECIFIED_SECONDARY_TABLES_LIST, index, removedSecondaryTable);
- }
-
- protected void removeSpecifiedSecondaryTable_(JavaSecondaryTable secondaryTable) {
- removeItemFromList(secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedSecondaryTables, targetIndex, sourceIndex);
- this.javaResourcePersistentType.moveAnnotation(
- targetIndex, sourceIndex, SecondaryTablesAnnotation.ANNOTATION_NAME);
- fireItemMoved(SPECIFIED_SECONDARY_TABLES_LIST, targetIndex, sourceIndex);
- }
-
- public ListIterator<JavaSecondaryTable> secondaryTables() {
- return specifiedSecondaryTables();
- }
-
- public int secondaryTablesSize() {
- return specifiedSecondaryTablesSize();
- }
-
- public InheritanceType getInheritanceStrategy() {
- return (this.getSpecifiedInheritanceStrategy() == null) ? this.getDefaultInheritanceStrategy() : this.getSpecifiedInheritanceStrategy();
- }
-
- public InheritanceType getDefaultInheritanceStrategy() {
- return this.defaultInheritanceStrategy;
- }
-
- protected void setDefaultInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.defaultInheritanceStrategy;
- this.defaultInheritanceStrategy = newInheritanceType;
- firePropertyChanged(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- public InheritanceType getSpecifiedInheritanceStrategy() {
- return this.specifiedInheritanceStrategy;
- }
-
- public void setSpecifiedInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- getResourceInheritance().setStrategy(InheritanceType.toJavaResourceModel(newInheritanceType));
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedInheritanceStrategy_(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- public JavaDiscriminatorColumn getDiscriminatorColumn() {
- return this.discriminatorColumn;
- }
-
- public String getDefaultDiscriminatorValue() {
- return this.defaultDiscriminatorValue;
- }
-
- protected void setDefaultDiscriminatorValue(String newDefaultDiscriminatorValue) {
- String oldDefaultDiscriminatorValue = this.defaultDiscriminatorValue;
- this.defaultDiscriminatorValue = newDefaultDiscriminatorValue;
- firePropertyChanged(DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, oldDefaultDiscriminatorValue, newDefaultDiscriminatorValue);
- }
-
- public String getSpecifiedDiscriminatorValue() {
- return this.specifiedDiscriminatorValue;
- }
-
- public void setSpecifiedDiscriminatorValue(String newSpecifiedDiscriminatorValue) {
- String oldSpecifiedDiscriminatorValue = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = newSpecifiedDiscriminatorValue;
- getResourceDiscriminatorValue().setValue(newSpecifiedDiscriminatorValue);
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, oldSpecifiedDiscriminatorValue, newSpecifiedDiscriminatorValue);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedDiscriminatorValue_(String newSpecifiedDiscriminatorValue) {
- String oldSpecifiedDiscriminatorValue = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = newSpecifiedDiscriminatorValue;
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, oldSpecifiedDiscriminatorValue, newSpecifiedDiscriminatorValue);
- }
-
- public String getDiscriminatorValue() {
- return (this.getSpecifiedDiscriminatorValue() == null) ? getDefaultDiscriminatorValue() : this.getSpecifiedDiscriminatorValue();
- }
-
- public boolean specifiedDiscriminatorValueIsAllowed() {
- return this.specifiedDiscriminatorValueIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorValueIsAllowed(boolean specifiedDiscriminatorValueIsAllowed) {
- boolean old = this.specifiedDiscriminatorValueIsAllowed;
- this.specifiedDiscriminatorValueIsAllowed = specifiedDiscriminatorValueIsAllowed;
- firePropertyChanged(Entity.SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorValueIsAllowed);
- }
-
- public boolean discriminatorValueIsUndefined() {
- return this.discriminatorValueIsUndefined;
- }
-
- protected void setDiscriminatorValueIsUndefined(boolean discriminatorValueIsUndefined) {
- boolean old = this.discriminatorValueIsUndefined;
- this.discriminatorValueIsUndefined = discriminatorValueIsUndefined;
- firePropertyChanged(DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, discriminatorValueIsUndefined);
- }
-
- public boolean specifiedDiscriminatorColumnIsAllowed() {
- return this.specifiedDiscriminatorColumnIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean specifiedDiscriminatorColumnIsAllowed) {
- boolean old = this.specifiedDiscriminatorColumnIsAllowed;
- this.specifiedDiscriminatorColumnIsAllowed = specifiedDiscriminatorColumnIsAllowed;
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorColumnIsAllowed);
- }
-
- public boolean discriminatorColumnIsUndefined() {
- return this.discriminatorColumnIsUndefined;
- }
-
- protected void setDiscriminatorColumnIsUndefined(boolean discriminatorColumnIsUndefined) {
- boolean old = this.discriminatorColumnIsUndefined;
- this.discriminatorColumnIsUndefined = discriminatorColumnIsUndefined;
- firePropertyChanged(DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, discriminatorColumnIsUndefined);
- }
-
- public boolean specifiedTableIsAllowed() {
- return this.specifiedTableIsAllowed;
- }
-
- protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) {
- boolean old = this.specifiedTableIsAllowed;
- this.specifiedTableIsAllowed = specifiedTableIsAllowed;
- firePropertyChanged(SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed);
- }
-
- public boolean tableIsUndefined() {
- return this.tableIsUndefined;
- }
-
- protected void setTableIsUndefined(boolean tableIsUndefined) {
- boolean old = this.tableIsUndefined;
- this.tableIsUndefined = tableIsUndefined;
- firePropertyChanged(TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined);
- }
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumns() : this.defaultPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.defaultPrimaryKeyJoinColumnsSize();
- }
-
- public ListIterator<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return new CloneListIterator<JavaPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- public boolean containsSpecifiedPrimaryKeyJoinColumns() {
- return !this.specifiedPrimaryKeyJoinColumns.isEmpty();
- }
-
- public JavaPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() {
- return this.defaultPrimaryKeyJoinColumn;
- }
-
- protected void setDefaultPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn newPkJoinColumn) {
- JavaPrimaryKeyJoinColumn oldPkJoinColumn = this.defaultPrimaryKeyJoinColumn;
- this.defaultPrimaryKeyJoinColumn = newPkJoinColumn;
- firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldPkJoinColumn, newPkJoinColumn);
- }
-
- protected ListIterator<JavaPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() {
- if (this.defaultPrimaryKeyJoinColumn != null) {
- return new SingleElementListIterator<JavaPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn);
- }
- return EmptyListIterator.instance();
- }
-
- protected int defaultPrimaryKeyJoinColumnsSize() {
- return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1;
- }
-
- public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn oldDefaultPkJoinColumn = this.getDefaultPrimaryKeyJoinColumn();
- if (oldDefaultPkJoinColumn != null) {
- //null the default join column now if one already exists.
- //if one does not exist, there is already a specified join column.
- //Remove it now so that it doesn't get removed during an update and
- //cause change notifications to be sent to the UI in the wrong order
- this.defaultPrimaryKeyJoinColumn = null;
- }
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, buildPrimaryKeyJoinColumnOwner());
- this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnResource =
- (PrimaryKeyJoinColumnAnnotation) this.javaResourcePersistentType.
- addAnnotation(
- index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- primaryKeyJoinColumn.initialize(pkJoinColumnResource);
- this.fireItemAdded(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn);
- if (oldDefaultPkJoinColumn != null) {
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null);
- }
- return primaryKeyJoinColumn;
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.addSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.size(), primaryKeyJoinColumn);
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn) {
- removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn removedPrimaryKeyJoinColumn = this.specifiedPrimaryKeyJoinColumns.remove(index);
- if (!containsSpecifiedPrimaryKeyJoinColumns()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
- this.javaResourcePersistentType.removeAnnotation(
- index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- fireItemRemoved(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn);
- if (this.defaultPrimaryKeyJoinColumn != null) {
- //fire change notification if a defaultJoinColumn was created above
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, null, this.defaultPrimaryKeyJoinColumn);
- }
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- removeItemFromList(primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.javaResourcePersistentType.moveAnnotation(
- targetIndex, sourceIndex, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- public JavaAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.associationOverrideContainer;
- }
-
- public JavaQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- public Entity getParentEntity() {
- for (Iterator<PersistentType> stream = getPersistentType().ancestors(); stream.hasNext();) {
- TypeMapping typeMapping = stream.next().getMapping();
- if (typeMapping instanceof Entity) {
- return (Entity) typeMapping;
- }
- }
- return null;
- }
-
- public Entity getRootEntity() {
- return this.rootEntity;
- }
-
- public boolean isRoot() {
- return this == this.getRootEntity();
- }
-
- /**
- * Return whether the entity is a descendant in (as opposed to the root of)
- * an inheritance hierarchy.
- */
- protected boolean isDescendant() {
- return ! this.isRoot();
- }
-
- /**
- * Table name defaults to the entity name.
- * If the entity is part of a single table inheritance hierarchy, table
- * name defaults to the root entity's table name.
- * If the entity is abstract and part of a table per class
- * inheritance hierarchy, the table name defaults to null, no table applies
- */
- public String getDefaultTableName() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getName()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getName();
- }
-
- public String getDefaultSchema() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getSchema()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultSchema();
- }
-
- public String getDefaultCatalog() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getCatalog()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultCatalog();
- }
-
- /**
- * Return whether the entity is a descendant of the root entity
- * of a "single table" inheritance hierarchy.
- */
- protected boolean isSingleTableDescendant() {
- return (this.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE)
- && this.isDescendant();
- }
-
- /**
- * Return whether the entity is the top of an inheritance hierarchy
- * and has no descendants and no specified inheritance strategy has been defined.
- */
- protected boolean isRootNoDescendantsNoStrategyDefined() {
- return isRoot() && !getPersistenceUnit().entityIsRootWithSubEntities(this.getName()) && getSpecifiedInheritanceStrategy() == null;
- }
-
- /**
- * Return whether the entity is abstract and is a part of a
- * "table per class" inheritance hierarchy.
- */
- protected boolean isAbstractTablePerClass() {
- return isAbstract() && isTablePerClass();
- }
-
- /**
- * Return whether the entity is a part of a "table per class"
- * inheritance hierarchy.
- */
- protected boolean isTablePerClass() {
- return (this.getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS);
- }
-
- /**
- * Return whether the entity is a part of a "table per class"
- * inheritance hierarchy.
- */
- protected boolean isTablePerClassDescendant() {
- return isTablePerClass() && isDescendant();
- }
-
- /**
- * Return whether the type is abstract.
- */
- protected boolean isAbstract() {
- return this.javaResourcePersistentType.isAbstract();
- }
-
- /**
- * Return whether the type is final.
- */
- protected boolean isFinal() {
- return this.javaResourcePersistentType.isFinal();
- }
-
- /**
- * Return whether the type is a top-level type.
- */
- protected boolean isMember() {
- return this.javaResourcePersistentType.isMemberType();
- }
-
- /**
- * Return whether the type is static.
- */
- protected boolean isStatic() {
- return this.javaResourcePersistentType.isStatic();
- }
-
- public String getPrimaryKeyColumnName() {
- return getPrimaryKeyColumnName(this);
- }
-
- /**
- * Convenience implementation that is shared with ORM.
- */
- public static String getPrimaryKeyColumnName(Entity entity) {
- String pkColumnName = null;
- for (Iterator<PersistentAttribute> stream = entity.getPersistentType().allAttributes(); stream.hasNext(); ) {
- PersistentAttribute attribute = stream.next();
- String current = attribute.getPrimaryKeyColumnName();
- if (current != null) {
- // 229423 - if the attribute is a primary key, but it has an attribute override,
- // use the override column instead
- AttributeOverride attributeOverride = entity.getAttributeOverrideContainer().getAttributeOverrideNamed(attribute.getName());
- if (attributeOverride != null) {
- current = attributeOverride.getColumn().getName();
- }
- }
- if (pkColumnName == null) {
- pkColumnName = current;
- }
- else if (current != null) {
- // if we encounter a composite primary key, return null
- return null;
- }
- }
- // if we encounter only a single primary key column name, return it
- return pkColumnName;
- }
-
- public PersistentAttribute getIdAttribute() {
- Iterable<AttributeMapping> idAttributeMappings = getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- if (CollectionTools.size(idAttributeMappings) != 1) {
- return null;
- }
- return idAttributeMappings.iterator().next().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- if (tableIsUndefined()) {
- return false;
- }
- return ! CollectionTools.contains(this.associatedTableNamesIncludingInherited(), tableName);
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return super.shouldValidateAgainstDatabase() && ! isAbstractTablePerClass();
- }
-
- @Override
- public Iterator<Table> associatedTables() {
- return new CompositeIterator<Table>(this.getTable(), this.secondaryTables());
- }
-
- @Override
- public Iterator<Table> associatedTablesIncludingInherited() {
- return this.getAssociatedTablesIncludingInherited().iterator();
- }
-
- protected Iterable<Table> getAssociatedTablesIncludingInherited() {
- return new CompositeIterable<Table>(new TransformationIterable<TypeMapping, Iterable<Table>>(this.getInheritanceHierarchy()) {
- @Override
- protected Iterable<Table> transform(TypeMapping mapping) {
- return new FilteringIterable<Table>(CollectionTools.iterable(mapping.associatedTables())) {
- @Override
- protected boolean accept(Table o) {
- return true;
- //TODO
- //filtering these out so as to avoid the duplicate table, root and children share the same table
- //return !(o instanceof SingleTableInheritanceChildTableImpl);
- }
- };
- }
- });
- }
-
- @Override
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return this.nonNullTableNames(this.associatedTablesIncludingInherited());
- }
-
- protected Iterator<String> nonNullTableNames(Iterator<Table> tables) {
- return new FilteringIterator<String>(this.tableNames(tables)) {
- @Override
- protected boolean accept(String o) {
- return o != null;
- }
- };
- }
-
- protected Iterator<String> tableNames(Iterator<Table> tables) {
- return new TransformationIterator<Table, String>(tables) {
- @Override
- protected String transform(Table t) {
- return t.getName();
- }
- };
- }
-
- /**
- * Return an iterator of Entities, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- protected Iterator<TypeMapping> ancestors() {
- return new TransformationIterator<PersistentType, TypeMapping>(getPersistentType().ancestors()) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- @Override
- public Iterator<String> overridableAttributeNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAttributeNames();
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- return super.resolveOverriddenColumn(attributeName);
- }
-
- @Override
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- AssociationOverride override = getAssociationOverrideContainer().getAssociationOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getRelationshipReference();
- }
- return super.resolveRelationshipReference(attributeName);
- }
-
- @Override
- public Iterator<String> overridableAssociationNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAssociationNames();
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.allAttributeMappings())) {
- AttributeMapping resolvedMapping = attributeMapping.resolveAttributeMapping(name);
- if (resolvedMapping != null) {
- return resolvedMapping;
- }
- }
- return null;
- }
-
- @Override
- public void update(JavaResourcePersistentType resourcePersistentType) {
- super.update(resourcePersistentType);
- setSpecifiedName_(getResourceName());
- setDefaultName(getResourceDefaultName());
- this.idClassReference.update();
- updateRootEntity();
- updateInheritance(getResourceInheritance());
- updateDiscriminatorColumn();
- updateDiscriminatorValue(getResourceDiscriminatorValue());
- setSpecifiedTableIsAllowed(buildSpecifiedTableIsAllowed());
- setTableIsUndefined(buildTableIsUndefined());
- updateTable();
- updateSecondaryTables();
- this.generatorContainer.update(resourcePersistentType);
- this.queryContainer.update(resourcePersistentType);
- updateSpecifiedPrimaryKeyJoinColumns();
- updateDefaultPrimaryKeyJoinColumn();
- this.attributeOverrideContainer.update(resourcePersistentType);
- this.associationOverrideContainer.update(resourcePersistentType);
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- postUpdateDiscriminatorColumn();
- postUpdateDiscriminatorValue();
- this.associationOverrideContainer.postUpdate();
- }
-
- protected String getResourceName() {
- return this.getResourceMappingAnnotation().getName();
- }
-
- protected String getResourceDefaultName() {
- return this.javaResourcePersistentType.getName();
- }
-
- protected void updateTable() {
- getTable().update(this.javaResourcePersistentType);
- }
-
- protected void updateInheritance(InheritanceAnnotation inheritanceResource) {
- this.setSpecifiedInheritanceStrategy_(this.getResourceInheritanceStrategy(inheritanceResource));
- this.setDefaultInheritanceStrategy(this.buildDefaultInheritanceStrategy());
- }
-
- protected InheritanceType getResourceInheritanceStrategy(InheritanceAnnotation inheritanceResource) {
- return InheritanceType.fromJavaResourceModel(inheritanceResource.getStrategy());
- }
-
- protected InheritanceType buildDefaultInheritanceStrategy() {
- return this.isRoot() ? InheritanceType.SINGLE_TABLE : this.getRootEntity().getInheritanceStrategy();
- }
-
- protected void updateRootEntity() {
- //I am making an assumption here that we don't need property change notification for rootEntity, this might be wrong
- this.rootEntity = calculateRootEntity();
- if (this.rootEntity != this) {
- this.rootEntity.addSubEntity(this);
- }
- }
-
- protected Entity calculateRootEntity() {
- Entity root = this;
- for (Iterator<TypeMapping> stream = inheritanceHierarchy(); stream.hasNext();) {
- TypeMapping typeMapping = stream.next();
- if (typeMapping instanceof Entity) {
- root = (Entity) typeMapping;
- }
- }
- return root;
- }
-
- public void addSubEntity(Entity subEntity) {
- getPersistenceUnit().addRootEntityWithSubEntities(getName());
- }
-
- protected void updateDiscriminatorColumn() {
- this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- getDiscriminatorColumn().update(this.getResourceDiscriminatorColumn());
- }
-
- protected void postUpdateDiscriminatorColumn() {
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- this.getDiscriminatorColumn().postUpdate();
- }
-
- protected void updateDiscriminatorValue(DiscriminatorValueAnnotation discriminatorValueResource) {
- this.setSpecifiedDiscriminatorValueIsAllowed(this.buildSpecifiedDiscriminatorValueIsAllowed());
- this.setSpecifiedDiscriminatorValue_(discriminatorValueResource.getValue());
- }
-
- protected void postUpdateDiscriminatorValue() {
- this.setDiscriminatorValueIsUndefined(this.buildDiscriminatorValueIsUndefined());
- this.setDefaultDiscriminatorValue(this.buildDefaultDiscriminatorValue());
- }
-
- /**
- * From the Spec:
- * If the DiscriminatorValue annotation is not specified, a
- * provider-specific function to generate a value representing
- * the entity type is used for the value of the discriminator
- * column. If the DiscriminatorType is STRING, the discriminator
- * value default is the entity name.
- *
- * TODO extension point for provider-specific function?
- */
- protected String buildDefaultDiscriminatorValue() {
- if (discriminatorValueIsUndefined()) {
- return null;
- }
- if (this.getDiscriminatorType() != DiscriminatorType.STRING) {
- return null;
- }
- return this.getName();
- }
-
- protected DiscriminatorType getDiscriminatorType() {
- return this.getDiscriminatorColumn().getDiscriminatorType();
- }
-
- protected boolean buildSpecifiedDiscriminatorValueIsAllowed() {
- return !isTablePerClass() && !isAbstract();
- }
-
- protected boolean buildDiscriminatorValueIsUndefined() {
- return isTablePerClass() || isAbstract() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedDiscriminatorColumnIsAllowed() {
- return !isTablePerClass() && isRoot();
- }
-
- protected boolean buildDiscriminatorColumnIsUndefined() {
- return isTablePerClass() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedTableIsAllowed() {
- return !isAbstractTablePerClass() && !isSingleTableDescendant();
- }
-
- protected boolean buildTableIsUndefined() {
- return isAbstractTablePerClass();
- }
-
- protected void updateSecondaryTables() {
- ListIterator<JavaSecondaryTable> secondaryTables = specifiedSecondaryTables();
- Iterator<NestableAnnotation> resourceSecondaryTables =
- this.javaResourcePersistentType.annotations(
- SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
-
- while (secondaryTables.hasNext()) {
- JavaSecondaryTable secondaryTable = secondaryTables.next();
- if (resourceSecondaryTables.hasNext()) {
- secondaryTable.update((SecondaryTableAnnotation) resourceSecondaryTables.next());
- }
- else {
- removeSpecifiedSecondaryTable_(secondaryTable);
- }
- }
-
- while (resourceSecondaryTables.hasNext()) {
- addSpecifiedSecondaryTable(buildSecondaryTable((SecondaryTableAnnotation) resourceSecondaryTables.next()));
- }
- }
-
- protected JavaSecondaryTable buildSecondaryTable(SecondaryTableAnnotation secondaryTableResource) {
- JavaSecondaryTable secondaryTable = getJpaFactory().buildJavaSecondaryTable(this, new SecondaryTableOwner());
- secondaryTable.initialize(secondaryTableResource);
- return secondaryTable;
- }
-
- protected void updateSpecifiedPrimaryKeyJoinColumns() {
- ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = specifiedPrimaryKeyJoinColumns();
- Iterator<NestableAnnotation> resourcePrimaryKeyJoinColumns =
- this.javaResourcePersistentType.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (primaryKeyJoinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = primaryKeyJoinColumns.next();
- if (resourcePrimaryKeyJoinColumns.hasNext()) {
- primaryKeyJoinColumn.update((PrimaryKeyJoinColumnAnnotation) resourcePrimaryKeyJoinColumns.next());
- }
- else {
- removeSpecifiedPrimaryKeyJoinColumn_(primaryKeyJoinColumn);
- }
- }
-
- while (resourcePrimaryKeyJoinColumns.hasNext()) {
- addSpecifiedPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn((PrimaryKeyJoinColumnAnnotation) resourcePrimaryKeyJoinColumns.next()));
- }
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(PrimaryKeyJoinColumnAnnotation primaryKeyJoinColumnResource) {
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, buildPrimaryKeyJoinColumnOwner());
- primaryKeyJoinColumn.initialize(primaryKeyJoinColumnResource);
- return primaryKeyJoinColumn;
- }
-
- protected void updateDefaultPrimaryKeyJoinColumn() {
- if (!shouldBuildDefaultPrimaryKeyJoinColumn()) {
- setDefaultPrimaryKeyJoinColumn(null);
- return;
- }
- if (getDefaultPrimaryKeyJoinColumn() == null) {
- this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType)));
- }
- else {
- this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
- }
-
-
- //******************** Code Completion *************************
-
- @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 = this.getTable().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaSecondaryTable sTable : CollectionTools.iterable(this.secondaryTables())) {
- result = sTable.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- for (JavaPrimaryKeyJoinColumn column : CollectionTools.iterable(this.primaryKeyJoinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- result = this.getAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getAssociationOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getDiscriminatorColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getGeneratorContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- //********** Validation ********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- validatePrimaryKey(messages, reporter, astRoot);
- validateTable(messages, reporter, astRoot);
- for (Iterator<JavaSecondaryTable> stream = this.specifiedSecondaryTables(); stream.hasNext();) {
- stream.next().validate(messages, reporter, astRoot);
- }
- validateInheritance(messages, reporter, astRoot);
- for (Iterator<JavaPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- getGeneratorContainer().validate(messages, reporter, astRoot);
- getQueryContainer().validate(messages, reporter, astRoot);
- getAttributeOverrideContainer().validate(messages, reporter, astRoot);
- getAssociationOverrideContainer().validate(messages, reporter, astRoot);
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericEntityPrimaryKeyValidator(this, buildTextRangeResolver(astRoot));
- }
-
- @Override
- protected EntityTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaEntityTextRangeResolver(this, astRoot);
- }
-
- protected void validateTable(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (isAbstractTablePerClass()) {
- if (this.table.isResourceSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- if (isSingleTableDescendant()) {
- if (this.table.isResourceSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- this.table.validate(messages, reporter, astRoot);
- }
-
- protected void validateInheritance(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- validateInheritanceStrategy(messages, astRoot);
- validateDiscriminatorColumn(messages, reporter, astRoot);
- validateDiscriminatorValue(messages, astRoot);
- }
-
- protected void validateDiscriminatorColumn(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (specifiedDiscriminatorColumnIsAllowed() && !discriminatorColumnIsUndefined()) {
- getDiscriminatorColumn().validate(messages, reporter, astRoot);
- }
- else if (getDiscriminatorColumn().isResourceSpecified()) {
- if (!isRoot()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange(astRoot)
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected void validateDiscriminatorValue(List<IMessage> messages, CompilationUnit astRoot) {
- if (discriminatorValueIsUndefined() && getSpecifiedDiscriminatorValue() != null) {
- if (isAbstract()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange(astRoot)
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected void validateInheritanceStrategy(List<IMessage> messages, CompilationUnit astRoot) {
- Supported tablePerConcreteClassInheritanceIsSupported = getJpaPlatformVariation().getTablePerConcreteClassInheritanceIsSupported();
- if (tablePerConcreteClassInheritanceIsSupported == Supported.YES) {
- return;
- }
- if ((getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS) && isRoot()) {
- if (tablePerConcreteClassInheritanceIsSupported == Supported.NO) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange(astRoot)
- )
- );
- }
- else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected TextRange getDiscriminatorValueTextRange(CompilationUnit astRoot) {
- return getResourceDiscriminatorValue().getTextRange(astRoot);
- }
-
- protected TextRange getDiscriminatorColumnTextRange(CompilationUnit astRoot) {
- return getDiscriminatorColumn().getValidationTextRange(astRoot);
- }
-
- protected TextRange getInheritanceStrategyTextRange(CompilationUnit astRoot) {
- return getResourceInheritance().getStrategyTextRange(astRoot);
- }
-
-
- protected class TableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new TableValidator(table, textRangeResolver);
- }
- }
-
- protected class SecondaryTableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new SecondaryTableValidator((SecondaryTable) table, textRangeResolver);
- }
- }
-
- // ********** association override container owner **********
-
- protected class AssociationOverrideContainerOwner
- implements JavaAssociationOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAssociationNames();
- }
-
- public RelationshipReference resolveRelationshipReference(String associationOverrideName) {
- return MappingTools.resolveRelationshipReference(getOverridableTypeMapping(), associationOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractJavaEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) owner, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideInverseJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinTableValidator(override, (JoinTable) table, textRangeResolver);
- }
- }
-
- //********** AttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator allOverridableAttributeNames_(TypeMapping typeMapping) {
- final Collection mappedByRelationshipAttributes = CollectionTools.collection(
- new TransformationIterator<SingleRelationshipMapping2_0, String>(getMapsIdRelationships()) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 next) {
- return next.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- });
- return new FilteringIterator<String>(typeMapping.allOverridableAttributeNames()) {
- @Override
- protected boolean accept(String o) {
- if (mappedByRelationshipAttributes.isEmpty()) {
- return true;
- }
- // overrideable names are (usually?) qualified with a container mapping,
- // which may also be the one mapped by a relationship
- String qualifier =
- (o.indexOf('.') > 0) ?
- o.substring(0, o.indexOf('.'))
- : o;
- return ! mappedByRelationshipAttributes.contains(qualifier);
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractJavaEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-
-
- // ********** pk join column owner **********
-
- protected class PrimaryKeyJoinColumnOwner implements JavaBaseJoinColumn.Owner
- {
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public org.eclipse.jpt.db.Table getReferencedColumnDbTable() {
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? null : parentEntity.getPrimaryDbTable();
- }
-
- public int joinColumnsSize() {
- return AbstractJavaEntity.this.primaryKeyJoinColumnsSize();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractJavaEntity.this.defaultPrimaryKeyJoinColumn == joinColumn;
- }
-
- public String getDefaultColumnName() {
- if (joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java
deleted file mode 100644
index 1b7acb4051..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java
+++ /dev/null
@@ -1,209 +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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.java.JavaGenerator;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- *
- */
-public abstract class AbstractJavaGenerator
- extends AbstractJavaJpaContextNode
- implements JavaGenerator
-{
- protected String name;
-
- protected Integer specifiedInitialValue;
-
- protected Integer specifiedAllocationSize;
-
- protected GeneratorAnnotation resourceGenerator;
-
-
- protected AbstractJavaGenerator(JavaJpaContextNode parent) {
- super(parent);
- }
-
- protected GeneratorAnnotation getResourceGenerator() {
- return this.resourceGenerator;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.resourceGenerator.setName(name);
- this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
- }
-
-
- // ********** initial value **********
-
- public int getInitialValue() {
- return (this.specifiedInitialValue != null) ? this.specifiedInitialValue.intValue() : this.getDefaultInitialValue();
- }
-
- public Integer getSpecifiedInitialValue() {
- return this.specifiedInitialValue;
- }
-
- public void setSpecifiedInitialValue(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.resourceGenerator.setInitialValue(specifiedInitialValue);
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
- protected void setSpecifiedInitialValue_(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
-
- // ********** allocation size **********
-
- public int getAllocationSize() {
- return (this.specifiedAllocationSize != null) ? this.specifiedAllocationSize.intValue() : this.getDefaultAllocationSize();
- }
-
- public Integer getSpecifiedAllocationSize() {
- return this.specifiedAllocationSize;
- }
-
- public void setSpecifiedAllocationSize(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.resourceGenerator.setAllocationSize(specifiedAllocationSize);
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- protected void setSpecifiedAllocationSize_(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- public int getDefaultAllocationSize() {
- return Generator.DEFAULT_ALLOCATION_SIZE;
- }
-
-
- // ********** text ranges **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
- public TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourceGenerator.getTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.resourceGenerator.getNameTextRange(astRoot);
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(GeneratorAnnotation generatorAnnotation) {
- this.resourceGenerator = generatorAnnotation;
- this.name = generatorAnnotation.getName();
- this.specifiedInitialValue = generatorAnnotation.getInitialValue();
- this.specifiedAllocationSize = generatorAnnotation.getAllocationSize();
- }
-
- protected void update(GeneratorAnnotation generatorAnnotation) {
- this.resourceGenerator = generatorAnnotation;
- this.setName_(generatorAnnotation.getName());
- this.setSpecifiedInitialValue_(generatorAnnotation.getInitialValue());
- this.setSpecifiedAllocationSize_(generatorAnnotation.getAllocationSize());
- getPersistenceUnit().addGenerator(this);
- }
-
-
- // ********** database stuff **********
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- protected abstract String getSchema();
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- protected abstract String getCatalog();
-
-
- // ********** misc **********
-
- public boolean isVirtual() {
- return false;
- }
-
- public boolean overrides(Generator generator) {
- // java is at the base of the tree
- return false;
- }
-
- public boolean duplicates(Generator other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
deleted file mode 100644
index a89c3dcd82..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaGeneratedValue;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.IdMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaIdMapping
- extends AbstractJavaAttributeMapping<IdAnnotation>
- implements JavaIdMapping, IdMapping2_0
-{
- protected final JavaColumn column;
-
- /* 2.0 feature - a relationship may map this id */
- protected boolean mappedByRelationship;
-
- protected JavaGeneratedValue generatedValue;
-
- protected final JavaGeneratorContainer generatorContainer;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
-
- protected AbstractJavaIdMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = this.getJpaFactory().buildJavaColumn(this, this);
- this.generatorContainer = this.buildGeneratorContainer();
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
-
- @Override
- protected void initialize() {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.mappedByRelationship = calculateMappedByRelationship();
- this.generatorContainer.initialize(this.getResourcePersistentAttribute());
- this.initializeGeneratedValue();
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- protected void initializeGeneratedValue() {
- GeneratedValueAnnotation resourceGeneratedValue = this.getResourceGeneratedValue();
- if (resourceGeneratedValue != null) {
- this.generatedValue = this.buildGeneratedValue(resourceGeneratedValue);
- }
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) this.getResourcePersistentAttribute().
- getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- protected boolean isColumnSpecified() {
- return getResourcePersistentAttribute().getAnnotation(ColumnAnnotation.ANNOTATION_NAME) != null;
- }
-
- private JavaGeneratorContainer buildGeneratorContainer() {
- return this.getJpaFactory().buildJavaGeneratorContainer(this);
- }
-
-
- //************** JavaAttributeMapping implementation ***************
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.GENERATED_VALUE);
- names.add(JPA.TEMPORAL);
- names.add(JPA.TABLE_GENERATOR);
- names.add(JPA.SEQUENCE_GENERATOR);
- }
-
-
- //************** NamedColumn.Owner implementation ***************
-
- public String getDefaultColumnName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getName();
- }
-
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
-
- //************** IdMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public JavaGeneratedValue addGeneratedValue() {
- if (getGeneratedValue() != null) {
- throw new IllegalStateException("gemeratedValue already exists"); //$NON-NLS-1$
- }
- this.generatedValue = getJpaFactory().buildJavaGeneratedValue(this);
- GeneratedValueAnnotation generatedValueResource =
- (GeneratedValueAnnotation) getResourcePersistentAttribute().
- addAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- this.generatedValue.initialize(generatedValueResource);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, null, this.generatedValue);
- return this.generatedValue;
- }
-
- public void removeGeneratedValue() {
- if (getGeneratedValue() == null) {
- throw new IllegalStateException("gemeratedValue does not exist, cannot be removed"); //$NON-NLS-1$
- }
- JavaGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = null;
- getResourcePersistentAttribute().removeAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, null);
- }
-
- public JavaGeneratedValue getGeneratedValue() {
- return this.generatedValue;
- }
-
- protected void setGeneratedValue(JavaGeneratedValue newGeneratedValue) {
- JavaGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = newGeneratedValue;
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, newGeneratedValue);
- }
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- setMappedByRelationship(calculateMappedByRelationship());
- this.generatorContainer.update(this.getResourcePersistentAttribute());
- this.updateGeneratedValue();
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- }
-
- protected void updateGeneratedValue() {
- GeneratedValueAnnotation resourceGeneratedValue = getResourceGeneratedValue();
- if (resourceGeneratedValue == null) {
- if (getGeneratedValue() != null) {
- setGeneratedValue(null);
- }
- }
- else {
- if (getGeneratedValue() == null) {
- setGeneratedValue(buildGeneratedValue(resourceGeneratedValue));
- }
- else {
- getGeneratedValue().update(resourceGeneratedValue);
- }
- }
- }
-
- protected JavaGeneratedValue buildGeneratedValue(GeneratedValueAnnotation resourceGeneratedValue) {
- JavaGeneratedValue gv = getJpaFactory().buildJavaGeneratedValue(this);
- gv.initialize(resourceGeneratedValue);
- return gv;
- }
-
- protected TableGeneratorAnnotation getResourceTableGenerator() {
- return (TableGeneratorAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected SequenceGeneratorAnnotation getResourceSequenceGenerator() {
- return (SequenceGeneratorAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected GeneratedValueAnnotation getResourceGeneratedValue() {
- return (GeneratedValueAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
-
- // **************** IdMapping2_0 impl *************************************
-
- public boolean isMappedByRelationship() {
- return this.mappedByRelationship;
- }
-
- protected void setMappedByRelationship(boolean newValue) {
- boolean oldValue = this.mappedByRelationship;
- this.mappedByRelationship = newValue;
- firePropertyChanged(MAPPED_BY_RELATIONSHIP_PROPERTY, oldValue, newValue);
- }
-
- protected boolean calculateMappedByRelationship() {
- for (SingleRelationshipMapping2_0 each : getMapsIdRelationships()) {
- if (getName().equals(each.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue())) {
- return true;
- }
- }
- return false;
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
-
- // ********** code assist **********
-
- @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 = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.generatorTouches(pos, astRoot)) {
- result = this.persistenceGeneratorNames(filter);
- if (result != null) {
- return result;
- }
- }
- result = this.getGeneratorContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** code assist: generator
-
- protected boolean generatorTouches(int pos, CompilationUnit astRoot) {
- if (getResourceGeneratedValue() != null) {
- return this.getResourceGeneratedValue().generatorTouches(pos, astRoot);
- }
- return false;
- }
-
- protected Iterator<String> persistenceGeneratorNames() {
- if(this.getPersistenceUnit().generatorsSize() == 0) {
- return EmptyIterator.<String> instance();
- }
- return CollectionTools.iterator(this.getPersistenceUnit().uniqueGeneratorNames());
- }
-
- private Iterator<String> generatorNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.persistenceGeneratorNames(), filter);
- }
-
- protected Iterator<String> persistenceGeneratorNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.generatorNames(filter));
- }
-
-
- // *************************************************************************
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.getColumn().getName();
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
-
- //*********** Validation ************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- // [JPA 2.0] if the column is specified, or if the id is not mapped by a relationship,
- // then the column is validated.
- // (In JPA 1.0, the column will always be validated, since the id is never mapped by a
- // relationship)
- if (isColumnSpecified() || ! isMappedByRelationship()) {
- this.getColumn().validate(messages, reporter, astRoot);
- }
-
- // [JPA 2.0] if the column is specified and the id is mapped by a relationship,
- // then that is an error
- // (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship)
- if (isColumnSpecified() && isMappedByRelationship()) {
- messages.add(
- buildMessage(
- JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
- new String[] {},
- getColumn().getValidationTextRange(astRoot)));
- }
-
- if (this.getGeneratedValue() != null) {
- this.getGeneratedValue().validate(messages, reporter, astRoot);
- }
- this.getGeneratorContainer().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- /* TODO - move to AbstractOrmAttributeMapping? */
- protected IMessage buildMessage(String msgID, String[] params, TextRange textRange) {
- PersistentAttribute attribute = getPersistentAttribute();
- String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
-
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(params, 0, attributeDesc),
- this,
- textRange);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java
deleted file mode 100644
index 06fce4be77..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-
-public abstract class AbstractJavaIdMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- protected AbstractJavaIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaIdMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java
deleted file mode 100644
index 0e1e64b65f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-public abstract class AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy
- extends AbstractJavaJoinColumnJoiningStrategy
-{
-
- protected AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy(JavaJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- @Override
- public JavaJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return (JavaJoinColumnEnabledRelationshipReference) super.getRelationshipReference();
- }
-
- @Override
- public JavaRelationshipMapping getRelationshipMapping() {
- return getRelationshipReference().getRelationshipMapping();
- }
-
- protected abstract Entity getRelationshipTargetEntity();
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- public boolean isOverridableAssociation() {
- return true;
- }
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute().getResourcePersistentAttribute();
- }
-
- @Override
- protected Iterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return new TransformationIterator<NestableAnnotation, JoinColumnAnnotation>(
- this.getResourcePersistentAttribute().annotations(
- JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)) {
- @Override
- protected JoinColumnAnnotation transform(NestableAnnotation next) {
- return (JoinColumnAnnotation) next;
- }
- };
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation(int index) {
- return (JoinColumnAnnotation) this.getResourcePersistentAttribute().
- addAnnotation(
- index,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void removeAnnotation(int index) {
- this.getResourcePersistentAttribute().
- removeAnnotation(
- index,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.getResourcePersistentAttribute().
- moveAnnotation(
- targetIndex,
- sourceIndex,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator((JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java
deleted file mode 100644
index cdc459610b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinColumnJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinColumnJoiningStrategy
-{
- protected JavaJoinColumn defaultJoinColumn;
-
- protected final Vector<JavaJoinColumn> specifiedJoinColumns = new Vector<JavaJoinColumn>();
- protected final JavaJoinColumn.Owner joinColumnOwner;
-
-
- protected AbstractJavaJoinColumnJoiningStrategy(JoinColumnEnabledRelationshipReference parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
- protected abstract JavaJoinColumn.Owner buildJoinColumnOwner();
-
- public void initializeFrom(JoinColumnJoiningStrategy oldStrategy) {
- for (JoinColumn joinColumn : CollectionTools.iterable(oldStrategy.joinColumns())) {
- JoinColumn newJoinColumn = this.addSpecifiedJoinColumn(this.specifiedJoinColumnsSize());
- newJoinColumn.setSpecifiedName(joinColumn.getName());
- newJoinColumn.setSpecifiedReferencedColumnName(joinColumn.getReferencedColumnName());
- }
- }
-
- @Override
- public JoinColumnEnabledRelationshipReference getParent() {
- return (JoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public JoinColumnEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : typeMapping.getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : typeMapping.getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? false : typeMapping.tableNameIsInvalid(tableName);
- }
-
- protected Iterator<String> candidateTableNames() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? EmptyIterator.<String> instance() : typeMapping.associatedTableNamesIncludingInherited();
- }
-
- public void addStrategy() {
- if (specifiedJoinColumnsSize() == 0) {
- addSpecifiedJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (JoinColumn each : CollectionTools.iterable(specifiedJoinColumns())) {
- removeSpecifiedJoinColumn(each);
- }
- }
-
- public Table getReferencedColumnDbTable() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- // **************** join columns *******************************************
-
- public ListIterator<JavaJoinColumn> joinColumns() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumns() : this.defaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumnsSize() : this.defaultJoinColumnsSize();
- }
-
-
- // **************** default join column ************************************
-
- public JavaJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(JavaJoinColumn column) {
- JavaJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = column;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, column);
- }
-
- protected ListIterator<JavaJoinColumn> defaultJoinColumns() {
- if (this.defaultJoinColumn != null) {
- return new SingleElementListIterator<JavaJoinColumn>(this.defaultJoinColumn);
- }
- return EmptyListIterator.instance();
- }
-
- protected int defaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
-
- // **************** specified join columns *********************************
-
- public ListIterator<JavaJoinColumn> specifiedJoinColumns() {
- return new CloneListIterator<JavaJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return ! this.specifiedJoinColumns.isEmpty();
- }
-
- public JavaJoinColumn addSpecifiedJoinColumn(int index) {
- // Clear out the default now so it doesn't get removed during an update and
- // cause change notifications to be sent to the UI in the wrong order.
- JavaJoinColumn oldDefault = this.defaultJoinColumn;
- this.defaultJoinColumn = null;
-
- JavaJoinColumn joinColumn = this.getJpaFactory().buildJavaJoinColumn(this, this.joinColumnOwner);
- this.specifiedJoinColumns.add(index, joinColumn);
- JoinColumnAnnotation joinColumnAnnotation = this.addAnnotation(index);
- joinColumn.initialize(joinColumnAnnotation);
- this.fireItemAdded(SPECIFIED_JOIN_COLUMNS_LIST, index, joinColumn);
-
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, oldDefault, null);
- return joinColumn;
- }
-
- protected void addSpecifiedJoinColumn(int index, JavaJoinColumn joinColumn) {
- addItemToList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedJoinColumn(JavaJoinColumn joinColumn) {
- addSpecifiedJoinColumn(this.specifiedJoinColumns.size(), joinColumn);
- }
-
- public void removeSpecifiedJoinColumn(JoinColumn joinColumn) {
- removeSpecifiedJoinColumn(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- public void removeSpecifiedJoinColumn(int index) {
- JavaJoinColumn removedJoinColumn = this.specifiedJoinColumns.remove(index);
- if (this.specifiedJoinColumns.isEmpty()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- this.defaultJoinColumn = buildJoinColumn(buildNullJoinColumnAnnotation());
- }
- removeAnnotation(index);
- fireItemRemoved(SPECIFIED_JOIN_COLUMNS_LIST, index, removedJoinColumn);
- if (this.defaultJoinColumn != null) {
- //fire change notification if a defaultJoinColumn was created above
- firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, null, this.defaultJoinColumn);
- }
- }
-
- protected void removeSpecifiedJoinColumn_(JavaJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedJoinColumns, targetIndex, sourceIndex);
- moveAnnotation(targetIndex, sourceIndex);
- fireItemMoved(SPECIFIED_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- protected abstract JoinColumnAnnotation addAnnotation(int index);
-
- protected abstract void removeAnnotation(int index);
-
- protected abstract void moveAnnotation(int targetIndex, int sourceIndex);
-
- protected abstract Iterator<JoinColumnAnnotation> joinColumnAnnotations();
-
- protected abstract JoinColumnAnnotation buildNullJoinColumnAnnotation();
-
-
- // **************** resource => context ************************************
-
- public void initialize() {
- initializeSpecifiedJoinColumns();
- initializeDefaultJoinColumn();
- }
-
- protected void initializeSpecifiedJoinColumns() {
- Iterator<JoinColumnAnnotation> annotations = joinColumnAnnotations();
- while (annotations.hasNext()) {
- this.specifiedJoinColumns.add(buildJoinColumn(annotations.next()));
- }
- }
-
- public void initializeDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- this.defaultJoinColumn =
- buildJoinColumn(buildNullJoinColumnAnnotation());
- }
- }
-
- public void update() {
- updateSpecifiedJoinColumns();
- updateDefaultJoinColumn();
- }
-
- protected void updateSpecifiedJoinColumns() {
- ListIterator<JavaJoinColumn> joinColumns = specifiedJoinColumns();
- Iterator<JoinColumnAnnotation> resourceJoinColumns = joinColumnAnnotations();
-
- while (joinColumns.hasNext()) {
- JavaJoinColumn joinColumn = joinColumns.next();
- if (resourceJoinColumns.hasNext()) {
- joinColumn.update(resourceJoinColumns.next());
- }
- else {
- removeSpecifiedJoinColumn_(joinColumn);
- }
- }
-
- while (resourceJoinColumns.hasNext()) {
- addSpecifiedJoinColumn(buildJoinColumn(resourceJoinColumns.next()));
- }
- }
-
- protected void updateDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- JoinColumnAnnotation nullAnnotation = buildNullJoinColumnAnnotation();
- if (this.defaultJoinColumn == null) {
- setDefaultJoinColumn(this.buildJoinColumn(nullAnnotation));
- }
- this.defaultJoinColumn.update(nullAnnotation);
- }
- else {
- if (this.defaultJoinColumn != null) {
- setDefaultJoinColumn(null);
- }
- }
- }
-
- protected boolean mayHaveDefaultJoinColumn() {
- return getRelationshipReference().mayHaveDefaultJoinColumn()
- && ! hasSpecifiedJoinColumns();
- }
-
- protected JavaJoinColumn buildJoinColumn(JoinColumnAnnotation joinColumnResource) {
- JavaJoinColumn joinColumn = getJpaFactory().buildJavaJoinColumn(this, this.joinColumnOwner);
- joinColumn.initialize(joinColumnResource);
- return joinColumn;
- }
-
-
- // **************** Java completion proposals ******************************
-
- @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;
- }
- for (JavaJoinColumn column : CollectionTools.iterable(this.joinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- for (Iterator<JavaJoinColumn> stream = this.joinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java
deleted file mode 100644
index 578936693b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.JoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinTableJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinTableJoiningStrategy, Table.Owner
-{
- protected JavaJoinTable joinTable;
-
-
- protected AbstractJavaJoinTableJoiningStrategy(JoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
-
- @Override
- public JoinTableEnabledRelationshipReference getParent() {
- return (JoinTableEnabledRelationshipReference) super.getParent();
- }
-
- public JoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- return getJoinTable().getName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return getJoinTable().getDbTable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getTableName(), tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE;
- }
-
- public String getJoinTableDefaultName() {
- return MappingTools.buildJoinTableDefaultName(this.getRelationshipReference());
- }
-
- public void addStrategy() {
- if (this.joinTable == null) {
- this.joinTable = this.buildJavaJoinTable();
- addAnnotation();
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, null, this.joinTable);
- }
- }
-
- public void removeStrategy() {
- if (this.joinTable != null) {
- JavaJoinTable oldJoinTable = this.joinTable;
- this.joinTable = null;
- removeAnnotation();
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, null);
- }
- }
-
- public void initializeFrom(JoinTableJoiningStrategy oldStrategy) {
- JoinTable oldJoinTable = oldStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.getJoinTable().setSpecifiedCatalog(oldJoinTable.getSpecifiedCatalog());
- this.getJoinTable().setSpecifiedSchema(oldJoinTable.getSpecifiedSchema());
- this.getJoinTable().setSpecifiedName(oldJoinTable.getSpecifiedName());
- }
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTable getJoinTable() {
- return this.joinTable;
- }
-
- protected void setJoinTable_(JavaJoinTable newJoinTable) {
- JavaJoinTable oldJoinTable = this.joinTable;
- this.joinTable = newJoinTable;
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, newJoinTable);
- }
-
- protected abstract JoinTableAnnotation addAnnotation();
-
- protected abstract void removeAnnotation();
-
- protected boolean mayHaveJoinTable() {
- return getAnnotation().isSpecified()
- || getRelationshipReference().mayHaveDefaultJoinTable();
- }
-
-
- // **************** resource => context ************************************
-
- public void initialize() {
- JoinTableAnnotation annotation = getAnnotation();
- if (mayHaveJoinTable()) {
- this.joinTable = this.buildJavaJoinTable();
- this.joinTable.initialize(annotation);
- }
- }
-
- public void update() {
- JoinTableAnnotation annotation = getAnnotation();
- if (mayHaveJoinTable()) {
- if (this.joinTable == null) {
- setJoinTable_(this.buildJavaJoinTable());
- }
- this.joinTable.update(annotation);
- }
- else {
- if (this.joinTable != null) {
- // no annotation, so no clean up
- setJoinTable_(null);
- }
- }
- }
-
- protected JavaJoinTable buildJavaJoinTable() {
- return getJpaFactory().buildJavaJoinTable(this, this);
- }
-
-
- // **************** Java completion proposals ******************************
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null && this.joinTable != null) {
- result = this.joinTable.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- if (this.joinTable != null) {
- this.joinTable.validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java
deleted file mode 100644
index 8a55d4a316..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java
+++ /dev/null
@@ -1,74 +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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.AbstractJpaContextNode;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJpaContextNode
- extends AbstractJpaContextNode
- implements JavaJpaContextNode
-{
- // ********** constructor **********
-
- protected AbstractJavaJpaContextNode(JpaContextNode parent) {
- super(parent);
- }
-
- @Override
- public JpaResourceType getResourceType() {
- return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
- }
-
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- if (this.connectionProfileIsActive()) {
- Iterator<String> result = this.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * This method is called if the database is connected, allowing us to
- * get candidates from the various database tables etc.
- * This method should NOT be cascaded to "child" objects; it should
- * only return candidates for the current object. The cascading is
- * handled by #javaCompletionProposals(int, Filter, CompilationUnit).
- */
- @SuppressWarnings("unused")
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- return null;
- }
-
- // ********** validation **********
-
- /**
- * All subclass implementations {@link #validate(List, CompilationUnit))}
- * should be preceded by a "super" call to this method
- */
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java
deleted file mode 100644
index 87f4be9190..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToManyMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.ManyToMany2_0Annotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-
-
-public abstract class AbstractJavaManyToManyMapping
- extends AbstractJavaMultiRelationshipMapping<ManyToMany2_0Annotation>
- implements JavaManyToManyMapping2_0
-{
- protected AbstractJavaManyToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @Override
- protected JavaRelationshipReference buildRelationshipReference() {
- return new GenericJavaManyToManyRelationshipReference(this);
- }
-
- public String getAnnotationName() {
- return ManyToManyAnnotation.ANNOTATION_NAME;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- public JavaManyToManyRelationshipReference getRelationshipReference() {
- return (JavaManyToManyRelationshipReference) super.getRelationshipReference();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java
deleted file mode 100644
index 38b7e7d227..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.ManyToOne2_0Annotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-
-
-public abstract class AbstractJavaManyToOneMapping
- extends AbstractJavaSingleRelationshipMapping<ManyToOne2_0Annotation>
- implements JavaManyToOneMapping2_0
-{
- protected AbstractJavaManyToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- public String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- public JavaManyToOneRelationshipReference2_0 getRelationshipReference() {
- return (JavaManyToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-
- @Override
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- @Override
- protected void setResourceOptional(Boolean newOptional) {
- this.mappingAnnotation.setOptional(newOptional);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java
deleted file mode 100644
index 314634870b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaManyToOneRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaManyToOneRelationshipReference2_0
-{
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- protected AbstractJavaManyToOneRelationshipReference(JavaManyToOneMapping parent) {
- super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnJoiningStrategy(this);
- }
-
- protected abstract JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- @Override
- public JavaManyToOneMapping getRelationshipMapping() {
- return (JavaManyToOneMapping) getParent();
- }
-
- public boolean isRelationshipOwner() {
- return true;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return false;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- // join columns are default (and only, so far) strategy, so no need
- // to add to resource model
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.joinTableJoiningStrategy.initialize();
- // initialize join column strategy last, as the existence of a default
- // join column is dependent on the other mechanisms (join table) not
- // being specified
- this.joinColumnJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.joinTableJoiningStrategy.update();
- // update join column strategy last, as the existence of a default join
- // column is dependent on the other mechanisms (join table) not being
- // specified
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java
deleted file mode 100644
index 7cc51ed495..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericMappedSuperclassPrimaryKeyValidator;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaMappedSuperclass extends AbstractJavaTypeMapping
- implements JavaMappedSuperclass
-{
- protected final JavaIdClassReference idClassReference;
-
-
- protected AbstractJavaMappedSuperclass(JavaPersistentType parent) {
- super(parent);
- this.idClassReference = buildIdClassReference();
- }
-
-
- protected GenericJavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return MappedSuperclassAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JPA.ID_CLASS,
- JPA.EXCLUDE_DEFAULT_LISTENERS,
- JPA.EXCLUDE_SUPERCLASS_LISTENERS,
- JPA.ENTITY_LISTENERS,
- JPA.PRE_PERSIST,
- JPA.POST_PERSIST,
- JPA.PRE_REMOVE,
- JPA.POST_REMOVE,
- JPA.PRE_UPDATE,
- JPA.POST_UPDATE,
- JPA.POST_LOAD
- };
-
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- @Override
- public void initialize(JavaResourcePersistentType persistentTypeResource) {
- super.initialize(persistentTypeResource);
- this.idClassReference.initialize();
- }
-
- @Override
- public void update(JavaResourcePersistentType persistentTypeResource) {
- super.update(persistentTypeResource);
- this.idClassReference.update();
- }
-
-
- // **************** validation ********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- validatePrimaryKey(messages, reporter, astRoot);
- }
-
- protected void validatePrimaryKey(
- List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
-
- buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericMappedSuperclassPrimaryKeyValidator(this, buildTextRangeResolver(astRoot));
- // TODO - JPA 2.0 validation
- }
-
- @Override
- protected PrimaryKeyTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaMappedSuperclassTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
deleted file mode 100644
index f2d5428ab7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ /dev/null
@@ -1,814 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Orderable;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaMultiRelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaOrderable;
-import org.eclipse.jpt.core.context.java.JavaOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoiningStrategyTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyColumnValidator;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaMapKeyColumn2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java multi-relationship (m:m, 1:m) mapping
- */
-public abstract class AbstractJavaMultiRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaRelationshipMapping<T>
- implements JavaMultiRelationshipMapping, JavaCollectionMapping2_0
-{
- protected final JavaOrderable orderable;
-
- protected Embeddable resolvedTargetEmbeddable;
-
- protected Type valueType;
- protected Type keyType;
-
- protected String specifiedMapKey;
- protected boolean noMapKey = false;
- protected boolean pkMapKey = false;
- protected boolean customMapKey = false;
-
- protected String specifiedMapKeyClass;
- protected String defaultMapKeyClass;
- protected String fullyQualifiedMapKeyClass;
- protected PersistentType resolvedMapKeyType;
- protected Embeddable resolvedMapKeyEmbeddable;
- protected Entity resolvedMapKeyEntity;
-
- protected final JavaColumn mapKeyColumn;
-
- protected final JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer;
-
- protected AbstractJavaMultiRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orderable = this.buildOrderable();
- this.mapKeyColumn = this.buildMapKeyColumn();
- this.mapKeyAttributeOverrideContainer = this.getJpaFactory().buildJavaAttributeOverrideContainer(this, new MapKeyAttributeOverrideContainerOwner());
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orderable.initialize();
- this.resolvedTargetType = this.resolveTargetType();
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.initializeValueType();
- this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
- this.specifiedMapKeyClass = this.getResourceMapKeyClass();
- this.fullyQualifiedMapKeyClass = this.buildFullyQualifiedMapKeyClass();
- this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead?
- this.resolvedMapKeyEmbeddable = this.resolveMapKeyEmbeddable();
- this.resolvedMapKeyEntity = this.resolveMapKeyEntity();
- this.initializeKeyType();
- this.initializeMapKey();
- this.initializeMapKeyColumn();
- this.mapKeyAttributeOverrideContainer.initialize(getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orderable.update();
- this.resolvedTargetType = this.resolveTargetType();//no need for change notification, use resolved target embeddable change notification instead?
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.updateValueType();
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
- this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
- this.setFullyQualifiedMapKeyClass(this.buildFullyQualifiedMapKeyClass());
- this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead?
- this.setResolvedMapKeyEmbeddable(this.resolveMapKeyEmbeddable());
- this.setResolvedMapKeyEntity(this.resolveMapKeyEntity());
- this.updateKeyType();
- this.updateMapKey();
- this.updateMapKeyColumn();
- this.mapKeyAttributeOverrideContainer.update(getResourcePersistentAttribute());
- }
-
- // ********** AbstractJavaAttributeMapping implementation **********
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_TABLE);
- names.add(JPA.MAP_KEY);
- names.add(JPA.ORDER_BY);
- if (this.isJpa2_0Compatible()) {
- names.add(JPA.ATTRIBUTE_OVERRIDE);
- names.add(JPA.ATTRIBUTE_OVERRIDES);
- names.add(JPA2_0.MAP_KEY_CLASS);
- names.add(JPA2_0.MAP_KEY_COLUMN);
- names.add(JPA2_0.MAP_KEY_ENUMERATED);
- names.add(JPA2_0.MAP_KEY_JOIN_COLUMN);
- names.add(JPA2_0.MAP_KEY_JOIN_COLUMNS);
- names.add(JPA2_0.MAP_KEY_TEMPORAL);
- names.add(JPA2_0.ORDER_COLUMN);
- }
- }
-
- // ********** AbstractJavaRelationshipMapping implementation **********
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
-
- // ********** ordering **********
-
- protected JavaOrderable buildOrderable() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory().buildJavaOrderable(this, this.buildOrderableOwner()) :
- this.getJpaFactory().buildJavaOrderable(this, new Orderable.Owner() {/*nothing*/});
- }
-
- public JavaOrderable getOrderable() {
- return this.orderable;
- }
-
- protected Orderable2_0.Owner buildOrderableOwner() {
- return new Orderable2_0.Owner() {
- public String getTableName() {
- return getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
- public Table getDbTable(String tableName) {
- return getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
- };
- }
-
- // ********** Fetchable implementation **********
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- // ********** CollectionMapping implementation **********
-
- protected Embeddable resolveTargetEmbeddable() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- public Type getValueType() {
- return this.valueType;
- }
-
- protected void setValueType(Type newValueType) {
- Type old = this.valueType;
- this.valueType = newValueType;
- firePropertyChanged(VALUE_TYPE_PROPERTY, old, newValueType);
- }
-
- protected void initializeValueType() {
- this.valueType = this.buildValueType();
- }
-
- protected void updateValueType() {
- this.setValueType(this.buildValueType());
- }
-
- protected Type buildValueType() {
- if (this.getResolvedTargetEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (this.resolvedTargetEmbeddable != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- else if (getTargetEntity() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- public Type getKeyType() {
- return this.keyType;
- }
-
- protected void setKeyType(Type newKeyType) {
- Type old = this.keyType;
- this.keyType = newKeyType;
- firePropertyChanged(KEY_TYPE_PROPERTY, old, newKeyType);
- }
-
- protected void initializeKeyType() {
- this.keyType = this.buildKeyType();
- }
-
- protected void updateKeyType() {
- this.setKeyType(this.buildKeyType());
- }
-
- protected Type buildKeyType() {
- if (getResolvedMapKeyEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (getResolvedMapKeyEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (getMapKeyClass() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- public Embeddable getResolvedMapKeyEmbeddable() {
- return this.resolvedMapKeyEmbeddable;
- }
-
- protected void setResolvedMapKeyEmbeddable(Embeddable embeddable) {
- Embeddable old = this.resolvedMapKeyEmbeddable;
- this.resolvedMapKeyEmbeddable = embeddable;
- this.firePropertyChanged(RESOLVED_MAP_KEY_EMBEDDABLE_PROPERTY, old, embeddable);
- }
-
- public Entity getResolvedMapKeyEntity() {
- return this.resolvedMapKeyEntity;
- }
-
- protected void setResolvedMapKeyEntity(Entity entity) {
- Entity old = this.resolvedMapKeyEntity;
- this.resolvedMapKeyEntity = entity;
- this.firePropertyChanged(RESOLVED_MAP_KEY_ENTITY_PROPERTY, old, entity);
- }
-
- public PersistentType getResolvedMapKeyType() {
- return getResolvedMapKeyEmbeddable() == null ? null : getResolvedMapKeyEmbeddable().getPersistentType();
- }
-
- protected PersistentType resolveMapKeyType() {
- return (this.fullyQualifiedMapKeyClass == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedMapKeyClass);
- }
-
- protected Embeddable resolveMapKeyEmbeddable() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- protected Entity resolveMapKeyEntity() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- // ********** map key **********
-
- public String getMapKey() {
- if (this.noMapKey) {
- return null;
- }
- if (this.pkMapKey) {
- return this.getTargetEntityIdAttributeName();
- }
- if (this.customMapKey) {
- return this.specifiedMapKey;
- }
- throw new IllegalStateException("unknown map key"); //$NON-NLS-1$
- }
-
- public String getSpecifiedMapKey() {
- return this.specifiedMapKey;
- }
-
- public void setSpecifiedMapKey(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKey == null) {
- if (mapKeyAnnotation != null) {
- this.removeMapKeyAnnotation();
- }
- } else {
- if (mapKeyAnnotation == null) {
- mapKeyAnnotation = this.addMapKeyAnnotation();
- }
- mapKeyAnnotation.setName(mapKey);
- }
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void setSpecifiedMapKey_(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void initializeMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKeyAnnotation == null) {
- this.noMapKey = true;
- } else {
- this.specifiedMapKey = mapKeyAnnotation.getName();
- if (this.specifiedMapKey == null) {
- this.pkMapKey = true;
- } else {
- this.customMapKey = true;
- }
- }
- }
-
- protected void updateMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKeyAnnotation == null) {
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(true);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(false);
- } else {
- String mk = mapKeyAnnotation.getName();
- this.setSpecifiedMapKey_(mk);
- this.setNoMapKey_(false);
- this.setPkMapKey_(mk == null);
- this.setCustomMapKey_(mk != null);
- }
- }
-
- protected MapKeyAnnotation getMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected MapKeyAnnotation addMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) && mapKeyAnnotation.nameTouches(pos, astRoot);
- }
-
-
- // ********** no map key **********
-
- public boolean isNoMapKey() {
- return this.noMapKey;
- }
-
- public void setNoMapKey(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- if (noMapKey) {
- if (this.getMapKeyAnnotation() != null) {
- this.removeMapKeyAnnotation();
- }
- } else {
- // the 'noMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setNoMapKey_(boolean)
- }
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
- protected void setNoMapKey_(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
-
- // ********** pk map key **********
-
- public boolean isPkMapKey() {
- return this.pkMapKey;
- }
-
- public void setPkMapKey(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (pkMapKey) {
- if (mapKeyAnnotation == null) {
- this.addMapKeyAnnotation();
- } else {
- mapKeyAnnotation.setName(null);
- }
- } else {
- // the 'pkMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setPkMapKey_(boolean)
- }
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
- protected void setPkMapKey_(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
-
- // ********** custom map key **********
-
- public boolean isCustomMapKey() {
- return this.customMapKey;
- }
-
- public void setCustomMapKey(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- if (customMapKey) {
- this.setSpecifiedMapKey(""); //$NON-NLS-1$
- } else {
- // the 'customMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setCustomMapKey_(boolean)
- }
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
- protected void setCustomMapKey_(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
-
- // *************** map key class *************
-
- public String getMapKeyClass() {
- return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
- }
-
- public String getSpecifiedMapKeyClass() {
- return this.specifiedMapKeyClass;
- }
-
- public void setSpecifiedMapKeyClass(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- MapKeyClass2_0Annotation mapKeyClassAnnotation = this.getMapKeyClassAnnotation();
- if (mapKeyClass == null) {
- if (mapKeyClassAnnotation != null) {
- this.removeMapKeyClassAnnotation();
- }
- } else {
- if (mapKeyClassAnnotation == null) {
- mapKeyClassAnnotation = this.addMapKeyClassAnnotation();
- }
- mapKeyClassAnnotation.setValue(mapKeyClass);
- }
-
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String getResourceMapKeyClass() {
- MapKeyClass2_0Annotation annotation = getMapKeyClassAnnotation();
- return annotation == null ? null : annotation.getValue();
- }
-
- public String getDefaultMapKeyClass() {
- return this.defaultMapKeyClass;
- }
-
- protected void setDefaultMapKeyClass(String mapKeyClass) {
- String old = this.defaultMapKeyClass;
- this.defaultMapKeyClass = mapKeyClass;
- this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String buildDefaultMapKeyClass() {
- return this.getPersistentAttribute().getMultiReferenceMapKeyTypeName();
- }
-
- public String getFullyQualifiedMapKeyClass() {
- return this.fullyQualifiedMapKeyClass;
- }
-
- protected void setFullyQualifiedMapKeyClass(String mapKeyClass) {
- String old = this.fullyQualifiedMapKeyClass;
- this.fullyQualifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(FULLY_QUALIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String buildFullyQualifiedMapKeyClass() {
- return (this.specifiedMapKeyClass == null) ?
- this.defaultMapKeyClass :
- this.getMapKeyClassAnnotation().getFullyQualifiedClassName();
- }
-
- public char getMapKeyClassEnclosingTypeSeparator() {
- return '.';
- }
-
- protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() {
- return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- protected MapKeyClass2_0Annotation addMapKeyClassAnnotation() {
- return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyClassAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- // ********** map key column - JPA 2.0 **********
-
- protected JavaColumn buildMapKeyColumn() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaMapKeyColumn(this, this.buildMapKeyColumnOwner()) :
- new NullJavaMapKeyColumn2_0(this);
- }
-
- public JavaColumn getMapKeyColumn() {
- return this.mapKeyColumn;
- }
-
- protected void initializeMapKeyColumn() {
- this.mapKeyColumn.initialize(getMapKeyColumnAnnotation());
- }
-
- protected void updateMapKeyColumn() {
- getMapKeyColumn().update(getMapKeyColumnAnnotation());
- }
-
- public MapKeyColumn2_0Annotation getMapKeyColumnAnnotation() {
- if (!isJpa2_0Compatible()) {
- return null;
- }
- return (MapKeyColumn2_0Annotation) this.getResourcePersistentAttribute().getNonNullAnnotation(MapKeyColumn2_0Annotation.ANNOTATION_NAME);
- }
-
- protected JavaBaseColumn.Owner buildMapKeyColumnOwner() {
- return new MapKeyColumnOwner();
- }
-
- public JavaAttributeOverrideContainer getMapKeyAttributeOverrideContainer() {
- return this.mapKeyAttributeOverrideContainer;
- }
-
- // ********** Java completion proposals **********
-
- @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 = this.getOrderable().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.mapKeyNameTouches(pos, astRoot)) {
- return this.javaCandidateMapKeyNames(filter);
- }
- result = this.getMapKeyColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getMapKeyAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- protected Iterator<String> javaCandidateMapKeyNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateMapKeyNames(filter));
- }
-
- protected Iterator<String> candidateMapKeyNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateMapKeyNames(), filter);
- }
-
- public Iterator<String> candidateMapKeyNames() {
- return this.allTargetEntityAttributeNames();
- }
-
-
- // ********** metamodel **********
-
- @Override
- protected String getMetamodelFieldTypeName() {
- return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldTypeName();
- }
-
- @Override
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- this.addMetamodelFieldMapKeyTypeArgumentNameTo(typeArgumentNames);
- super.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- }
-
- protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
- String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
- if (keyTypeName != null) {
- typeArgumentNames.add(keyTypeName);
- }
- }
-
- public String getMetamodelFieldMapKeyTypeName() {
- return MappingTools.getMetamodelFieldMapKeyTypeName(this);
- }
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.orderable.validate(messages, reporter, astRoot);
- this.validateMapKey(messages, reporter, astRoot);
- }
-
- protected void validateMapKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (getMapKeyAnnotation() != null) {//If MapKey annotation specified, no other MapKey* annotations can be specified, don't validate them
- //TODO validate that the map key refers to an existing attribute
- return;
- }
- if (getKeyType() == Type.BASIC_TYPE) {
- this.getMapKeyColumn().validate(messages, reporter, astRoot);
- //validate map key converter
- }
- else if (getKeyType() == Type.ENTITY_TYPE) {
- //validate map key join columns
- }
- else if (getKeyType() == Type.EMBEDDABLE_TYPE) {
- getMapKeyAttributeOverrideContainer().validate(messages, reporter, astRoot);
- //validate map key association overrides - for eclipselink
- }
- }
-
-
- protected class MapKeyColumnOwner implements JavaBaseColumn.Owner {
- public TypeMapping getTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getTypeMapping();
- }
-
- protected JoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public String getDefaultColumnName() {
- return AbstractJavaMultiRelationshipMapping.this.getName() + "_KEY"; //$NON-NLS-1$
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaMultiRelationshipMapping.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new MapKeyColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
- }
-
- protected abstract class OverrideContainerOwner implements JavaOverrideContainer.Owner {
- public TypeMapping getTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getTypeMapping();
- }
-
- protected JoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- /**
- * If there is a specified table name it needs to be the same
- * the default table name. the table is always the collection table
- */
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getDefaultTableName(), tableName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaMultiRelationshipMapping.this.getValidationTextRange(astRoot);
- }
- }
-
- protected class MapKeyAttributeOverrideContainerOwner
- extends OverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getResolvedMapKeyEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAttributeNames();
- }
-
- public String getPossiblePrefix() {
- return "key."; //$NON-NLS-1$
- }
-
- public String getWritePrefix() {
- return this.getPossiblePrefix();
- }
-
- //since only the key can be an embeddable on a 1-m or m-m, all overrides are relevant
- public boolean isRelevant(String overrideName) {
- return true;
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
deleted file mode 100644
index 82e5419297..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaNamedColumn
-{
-
- protected Owner owner;
-
- protected String specifiedName;
-
- protected String defaultName;
-
- protected String columnDefinition;
-
- protected T resourceColumn;
-
- protected AbstractJavaNamedColumn(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- // ******************* initialization from java resource model ********************
-
- protected void initialize(T column) {
- this.resourceColumn = column;
- this.specifiedName = column.getName();
- this.defaultName = this.buildDefaultName();
- this.columnDefinition = column.getColumnDefinition();
- }
-
- protected void update(T column) {
- this.resourceColumn = column;
- this.setSpecifiedName_(column.getName());
- this.setDefaultName(this.buildDefaultName());
- this.setColumnDefinition_(column.getColumnDefinition());
- }
-
- protected T getResourceColumn() {
- return this.resourceColumn;
- }
-
-
- //************** NamedColumn implementation *****************
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- getResourceColumn().setName(newSpecifiedName);
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(NamedColumn.DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
- /**
- * Return the default column name.
- */
- protected String buildDefaultName() {
- return this.getOwner().getDefaultColumnName();
- }
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- getResourceColumn().setColumnDefinition(newColumnDefinition);
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setColumnDefinition_(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceColumn().getNameTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getResourceColumn().nameTouches(pos, astRoot);
- }
-
- public Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(this.getName());
- }
-
- public Table getDbTable() {
- return getOwner().getDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden
- * in AbstractJavaBaseColumn where a table can be defined.
- */
- public String getTable() {
- return this.getOwner().getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return this.getDbColumn() != null;
- }
-
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.getJavaCandidateNames(filter).iterator();
- }
- return null;
- }
-
- private Iterable<String> getJavaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames(filter));
- }
-
- private Iterable<String> getCandidateNames(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateNames(), filter);
- }
-
- private Iterable<String> getCandidateNames() {
- Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ****************** validation ****************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = getResourceColumn().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildColumnValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildColumnValidator(CompilationUnit astRoot) {
- return this.getOwner().buildColumnValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaNamedColumnTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java
deleted file mode 100644
index 44b80160c2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Vector;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-
-
-public abstract class AbstractJavaOneToManyMapping<T extends OneToMany2_0Annotation>
- extends AbstractJavaMultiRelationshipMapping<T>
- implements JavaOneToManyMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
- protected AbstractJavaOneToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
-
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
- // ********** initialize/update **********
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orphanRemoval.initialize(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orphanRemoval.update(this.getResourcePersistentAttribute());
- }
-
-
- public String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_COLUMN);
- names.add(JPA.JOIN_COLUMNS);
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- // ********** JavaOneToManyMapping implementation **********
-
- @Override
- public JavaOneToManyRelationshipReference2_0 getRelationshipReference() {
- return (JavaOneToManyRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** JavaOrphanRemovalHolder2_0 implementation **********
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java
deleted file mode 100644
index a0f4029318..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaOneToManyRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaOneToManyRelationshipReference2_0
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
-
- protected AbstractJavaOneToManyRelationshipReference(JavaOneToManyMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericJavaJoinTableJoiningStrategy(this);
- }
-
- protected abstract JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy();
-
- @Override
- public JavaOneToManyMapping getRelationshipMapping() {
- return (JavaOneToManyMapping) getParent();
- }
-
- public OneToManyAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public boolean isTargetForeignKeyRelationship() {
- return getJoinColumnJoiningStrategy().isTargetForeignKeyRelationship();
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public final void setMappedByJoiningStrategy() {
- setMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetMappedByJoiningStrategy() {
- unsetMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.removeStrategy();
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return this.getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- setJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setJoinTableJoiningStrategy_() {
- // join table is default, so no need to add annotation
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null
- && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.joinColumnJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.joinColumnJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java
deleted file mode 100644
index 71e4a42087..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Vector;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.OneToOne2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-
-
-public abstract class AbstractJavaOneToOneMapping
- extends AbstractJavaSingleRelationshipMapping<OneToOne2_0Annotation>
- implements JavaOneToOneMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
- // ********** constructor **********
- protected AbstractJavaOneToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
- // ********** initialize/update **********
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orphanRemoval.initialize(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orphanRemoval.update(this.getResourcePersistentAttribute());
- }
-
- public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.PRIMARY_KEY_JOIN_COLUMN);
- names.add(JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- @Override
- protected void setResourceOptional(Boolean newOptional) {
- this.mappingAnnotation.setOptional(newOptional);
- }
-
- // ********** JavaOneToOneMapping implementation **********
-
- @Override
- public JavaOneToOneRelationshipReference2_0 getRelationshipReference() {
- return (JavaOneToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** JavaOrphanRemovalHolder2_0 implementation **********
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java
deleted file mode 100644
index 971f184022..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaOneToOneRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaOneToOneRelationshipReference2_0
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected final JavaPrimaryKeyJoinColumnJoiningStrategy primaryKeyJoinColumnJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected AbstractJavaOneToOneRelationshipReference(JavaOneToOneMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- this.primaryKeyJoinColumnJoiningStrategy = buildPrimaryKeyJoinColumnJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnJoiningStrategy(this);
- }
-
- protected JavaPrimaryKeyJoinColumnJoiningStrategy buildPrimaryKeyJoinColumnJoiningStrategy() {
- return new GenericJavaPrimaryKeyJoinColumnJoiningStrategy(this);
- }
-
- protected abstract JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- @Override
- public JavaOneToOneMapping getRelationshipMapping() {
- return (JavaOneToOneMapping) getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.primaryKeyJoinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- // join columns are default, so no need to add annotations
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null
- && this.getPrimaryKeyJoinColumnJoiningStrategy().primaryKeyJoinColumnsSize() == 0
- && this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
-
- // **************** primary key join columns *******************************
-
- public JavaPrimaryKeyJoinColumnJoiningStrategy getPrimaryKeyJoinColumnJoiningStrategy() {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public boolean usesPrimaryKeyJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public void setPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultPrimaryKeyJoinColumn() {
- return false;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.primaryKeyJoinColumnJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
-
- // initialize join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.primaryKeyJoinColumnJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
-
- // update join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.primaryKeyJoinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java
deleted file mode 100644
index bbbac99f19..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaOverride;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.OverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaOverride
- extends AbstractJavaJpaContextNode
- implements JavaOverride
-{
-
- protected String name;
-
- protected final Owner owner;
-
- protected OverrideAnnotation overrideAnnotation;
-
- public AbstractJavaOverride(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- protected void initialize(OverrideAnnotation overrideAnnotation) {
- this.overrideAnnotation = overrideAnnotation;
- this.initializeName();
- }
-
- protected void update(OverrideAnnotation overrideResource) {
- this.overrideAnnotation = overrideResource;
- this.updateName();
- }
-
- public OverrideAnnotation getOverrideAnnotation() {
- return this.overrideAnnotation;
- }
-
- // ********************* name ****************
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String prefix = getOwner().getPossiblePrefix();
- String unprefixedName = newName;
- if (newName != null && prefix != null && newName.startsWith(prefix)) {
- unprefixedName = newName.substring(newName.indexOf('.') + 1);
- }
- String oldName = this.name;
- this.name = unprefixedName; //set the name without the prefix in the context model
- this.overrideAnnotation.setName(newName); // set the name with the prefix in the resource model
- firePropertyChanged(NAME_PROPERTY, oldName, unprefixedName);
- }
-
- protected void setName_(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- protected void initializeName() {
- String name = this.getResourceName();
- String prefix = getOwner().getPossiblePrefix();
- if (name != null && prefix != null && name.startsWith(prefix)) {
- name = name.substring(name.indexOf('.') + 1);
- }
- this.name = name;
- }
-
- protected void updateName() {
- String name = this.getResourceName();
- String prefix = getOwner().getPossiblePrefix();
- if (name != null && prefix != null && name.startsWith(prefix)) {
- name = name.substring(name.indexOf('.') + 1);
- }
- this.setName_(name);
- }
-
- protected String getResourceName() {
- return this.overrideAnnotation.getName();
- }
-
- public boolean isVirtual() {
- return getOwner().isVirtual(this);
- }
-
- public BaseOverride setVirtual(boolean virtual) {
- return getOwner().setVirtual(virtual, this);
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- protected abstract Iterator<String> candidateNames();
-
- private Iterator<String> candidateNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateNames(), filter);
- }
-
- private Iterator<String> javaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateNames(filter));
- }
-
- @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;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.javaCandidateNames(filter);
- }
- return null;
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.overrideAnnotation.nameTouches(pos, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.overrideAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.overrideAnnotation.getNameTextRange(astRoot);
- return (textRange != null) ? textRange : this.getValidationTextRange(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(getName());
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildValidator(CompilationUnit astRoot) {
- return this.getOwner().buildValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected OverrideTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaOverrideTextRangeResolver(this, astRoot);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
deleted file mode 100644
index c222107a15..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.CollectionMapping;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.ClassName;
-import org.eclipse.jpt.utility.internal.ReflectionTools;
-import org.eclipse.jpt.utility.internal.Tools;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * common state/behavior between Generic and EclipseLink persistent attributes
- */
-public abstract class AbstractJavaPersistentAttribute
- extends AbstractJavaJpaContextNode
- implements JavaPersistentAttribute2_0
-{
- protected String name;
-
- protected JavaAttributeMapping defaultMapping;
-
- protected JavaAttributeMapping specifiedMapping;
-
- protected AccessType defaultAccess;
-
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
-
- protected AbstractJavaPersistentAttribute(PersistentType parent, JavaResourcePersistentAttribute resourcePersistentAttribute) {
- super(parent);
- this.resourcePersistentAttribute = resourcePersistentAttribute;
- this.name = buildName();
- this.defaultMapping = buildDefaultMapping();
- this.specifiedMapping = buildSpecifiedMapping();
- this.defaultAccess = buildDefaultAccess();
- }
-
- public void update() {
- this.setName(this.buildName());
- this.updateDefaultMapping();
- this.updateSpecifiedMapping();
- this.setDefaultAccess(this.buildDefaultAccess());
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- getMapping().postUpdate();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return JavaStructureNodes.PERSISTENT_ATTRIBUTE_ID;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- return this;
- }
-
- public TextRange getSelectionTextRange() {
- return this.getSelectionTextRange(this.buildASTRoot());
- }
-
- protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentAttribute.getNameTextRange(astRoot);
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.resourcePersistentAttribute.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- public void dispose() {
- //nothing to dispose
- }
-
-
- // ********** AccessHolder implementation **********
-
- public AccessType getAccess() {
- AccessType access = this.getSpecifiedAccess();
- return (access != null) ? access : this.getDefaultAccess();
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType defaultAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = defaultAccess;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, defaultAccess);
- }
-
- protected AccessType buildDefaultAccess() {
- return this.resourcePersistentAttribute.isField() ? AccessType.FIELD : AccessType.PROPERTY;
- }
-
-
- // ********** [Java]PersistentAttribute implementation **********
-
- public JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.resourcePersistentAttribute;
- }
-
- public PersistentType getOwningPersistentType() {
- return this.getParent();
- }
-
- public TypeMapping getOwningTypeMapping() {
- return this.getOwningPersistentType().getMapping();
- }
-
- public String getPrimaryKeyColumnName() {
- return this.getMapping().getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- return this.resourcePersistentAttribute.getTypeName();
- }
-
- public boolean isVirtual() {
- return false;
- }
-
- public boolean contains(int offset, CompilationUnit astRoot) {
- TextRange fullTextRange = this.getFullTextRange(astRoot);
- // 'fullTextRange' will be null if the attribute no longer exists in the java;
- // the context model can be out of synch with the resource model
- // when a selection event occurs before the context model has a
- // chance to synch with the resource model via the update thread
- return (fullTextRange == null) ? false : fullTextRange.includes(offset);
- }
-
- protected TextRange getFullTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentAttribute.getTextRange(astRoot);
- }
-
- public Embeddable getEmbeddable() {
- return (getTypeName() == null) ?
- null : this.getPersistenceUnit().getEmbeddable(getTypeName());
- }
-
- public boolean isField() {
- return this.resourcePersistentAttribute.isField();
- }
-
- public boolean isProperty() {
- return this.resourcePersistentAttribute.isProperty();
- }
-
- public boolean isPublic() {
- return Modifier.isPublic(this.resourcePersistentAttribute.getModifiers());
- }
-
- public boolean isFinal() {
- return Modifier.isFinal(this.resourcePersistentAttribute.getModifiers());
- }
-
- // ***** Basic defaults
- /**
- * From the JPA spec, when the basic mapping applies:
- * If the type of the attribute (field or property) is one of the following
- * it must be mapped as @Basic:
- * byte[]
- * java.lang.Byte[]
- * char[]
- * java.lang.Character[]
- * primitive types (except 'void')
- * primitive wrappers (except 'java.lang.Void')
- * java.lang.String
- * java.math.BigInteger
- * java.math.BigDecimal
- * java.util.Date
- * java.util.Calendar
- * java.sql.Date
- * java.sql.Time
- * java.sql.Timestamp
- * enums
- * any other type that implements java.io.Serializable
- */
- public boolean typeIsBasic() {
- // 'typeName' may include array brackets but not generic type arguments
- String typeName = getTypeName();
- if (typeName == null) {
- return false;
- }
-
- int arrayDepth = ReflectionTools.getArrayDepthForTypeDeclaration(typeName);
- if (arrayDepth > 1) {
- return false; // multi-dimensional arrays are not supported
- }
-
- if (arrayDepth == 1) {
- String elementTypeName = ReflectionTools.getElementTypeNameForTypeDeclaration(typeName, 1);
- return this.elementTypeIsValidForBasicArray(elementTypeName);
- }
-
- // arrayDepth == 0
- if (ClassName.isVariablePrimitive(typeName)) {
- return true; // any primitive but 'void'
- }
- if (ClassName.isVariablePrimitiveWrapper(typeName)) {
- return true; // any primitive wrapper but 'java.lang.Void'
- }
- if (this.typeIsOtherValidBasicType(typeName)) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsEnum()) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsSubTypeOf(SERIALIZABLE_TYPE_NAME)) {
- return true;
- }
- return false;
- }
-
- /**
- * Return whether the specified type is a valid element type for
- * a one-dimensional array that can default to a Basic mapping:
- * byte
- * char
- * java.lang.Byte
- * java.lang.Character
- */
- protected boolean elementTypeIsValidForBasicArray(String elementTypeName) {
- return ArrayTools.contains(VALID_BASIC_ARRAY_ELEMENT_TYPE_NAMES, elementTypeName);
- }
-
- protected static final String[] VALID_BASIC_ARRAY_ELEMENT_TYPE_NAMES = {
- byte.class.getName(),
- char.class.getName(),
- java.lang.Byte.class.getName(),
- java.lang.Character.class.getName()
- };
-
- /**
- * Return whether the specified type is among the various "other" types
- * that can default to a Basic mapping.
- */
- protected boolean typeIsOtherValidBasicType(String typeName) {
- return ArrayTools.contains(OTHER_VALID_BASIC_TYPE_NAMES, typeName);
- }
-
- protected static final String[] OTHER_VALID_BASIC_TYPE_NAMES = {
- java.lang.String.class.getName(),
- java.math.BigInteger.class.getName(),
- java.math.BigDecimal.class.getName(),
- java.util.Date.class.getName(),
- java.util.Calendar.class.getName(),
- java.sql.Date.class.getName(),
- java.sql.Time.class.getName(),
- java.sql.Timestamp.class.getName(),
- };
-
- protected static final String SERIALIZABLE_TYPE_NAME = java.io.Serializable.class.getName();
-
- // ***** reference entities
- public String getSingleReferenceTargetTypeName() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- String typeName = getTypeName();
- if (typeName == null) {
- return null;
- }
- if (ReflectionTools.getArrayDepthForTypeDeclaration(typeName) != 0) {
- return null; // arrays cannot be entities
- }
- if (this.typeIsContainer(typeName)) {
- return null; // "containers" cannot be entities
- }
- return typeName;
- }
-
- public String getMultiReferenceTargetTypeName() {
- return this.getJpaContainer().getMultiReferenceTargetTypeName(this.resourcePersistentAttribute);
- }
-
- public String getMultiReferenceMapKeyTypeName() {
- return this.getJpaContainer().getMultiReferenceMapKeyTypeName(this.resourcePersistentAttribute);
- }
-
- /**
- * return whether the specified type is one of the container
- * types allowed by the JPA spec
- */
- protected boolean typeIsContainer(String typeName) {
- return this.getJpaContainer(typeName).isContainer();
- }
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- protected String buildName() {
- return this.resourcePersistentAttribute.getName();
- }
-
- // ***** mapping
- public JavaAttributeMapping getMapping() {
- return (this.specifiedMapping != null) ? this.specifiedMapping : this.defaultMapping;
- }
-
- public String getMappingKey() {
- return this.getMapping().getKey();
- }
-
-
- // ***** default mapping
- public JavaAttributeMapping getDefaultMapping() {
- return this.defaultMapping;
- }
-
- /**
- * clients do not set the "default" mapping
- */
- protected void setDefaultMapping(JavaAttributeMapping defaultMapping) {
- JavaAttributeMapping old = this.defaultMapping;
- this.defaultMapping = defaultMapping;
- this.firePropertyChanged(DEFAULT_MAPPING_PROPERTY, old, defaultMapping);
- }
-
- protected JavaAttributeMapping buildDefaultMapping() {
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getDefaultJavaAttributeMappingDefinition(this);
- return buildDefaultMapping(mappingDefinition);
- }
-
- protected JavaAttributeMapping buildDefaultMapping(JavaAttributeMappingDefinition mappingDefinition) {
- Annotation annotation = this.resourcePersistentAttribute.
- buildNullAnnotation(mappingDefinition.getAnnotationName());
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- mapping.initialize(annotation);
- return mapping;
- }
-
- /**
- * return null if there is no "default" mapping for the attribute
- */
- public String getDefaultMappingKey() {
- return this.defaultMapping.getKey();
- }
-
- /**
- * the mapping might be "default", but it still might be a "null" mapping...
- */
- public boolean mappingIsDefault(JavaAttributeMapping mapping) {
- return this.defaultMapping == mapping;
- }
-
- protected void updateDefaultMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping definition ...
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getDefaultJavaAttributeMappingDefinition(this);
- String mappingKey = mappingDefinition.getKey();
- if (this.valuesAreEqual(this.defaultMapping.getKey(), mappingKey)) {
- this.defaultMapping.update(this.resourcePersistentAttribute.
- buildNullAnnotation(mappingDefinition.getAnnotationName()));
- }
- else {
- setDefaultMapping(buildDefaultMapping(mappingDefinition));
- }
- }
-
- // ***** specified mapping
- public JavaAttributeMapping getSpecifiedMapping() {
- return this.specifiedMapping;
- }
-
- /**
- * clients do not set the "specified" mapping;
- * @see #setSpecifiedMappingKey(String)
- */
- protected void setSpecifiedMapping(JavaAttributeMapping specifiedMapping) {
- JavaAttributeMapping old = this.specifiedMapping;
- this.specifiedMapping = specifiedMapping;
- this.firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, old, specifiedMapping);
- }
-
- protected JavaAttributeMapping buildSpecifiedMapping() {
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(this);
- return buildSpecifiedMapping(mappingDefinition);
- }
-
- protected JavaAttributeMapping buildSpecifiedMapping(JavaAttributeMappingDefinition mappingDefinition) {
- Annotation annotation = this.resourcePersistentAttribute.
- getAnnotation(mappingDefinition.getAnnotationName());
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- // specified mappings may be null
- if (mapping != null) {
- mapping.initialize(annotation);
- }
- return mapping;
- }
-
- /**
- * return the key of the currently specified mapping or null
- * if there is no specified mapping for the attribute
- */
- protected String getSpecifiedMappingKey() {
- return (this.specifiedMapping == null) ? null : this.specifiedMapping.getKey();
- }
-
- // TODO support morphing mappings, i.e. copying common settings over
- // to the new mapping; this can't be done in the same was as XmlAttributeMapping
- // since we don't know all the possible mapping types
- public void setSpecifiedMappingKey(String key) {
- if (Tools.valuesAreEqual(key, this.getSpecifiedMappingKey())) {
- return;
- }
- JavaAttributeMapping old = this.specifiedMapping;
- JavaAttributeMapping newMapping = this.buildMappingFromMappingKey(key);
-
- this.specifiedMapping = newMapping;
-
- String newAnnotation = (newMapping == null) ? null : newMapping.getAnnotationName();
- JavaAttributeMapping mapping = (newMapping == null) ? this.defaultMapping : newMapping;
- this.resourcePersistentAttribute.setPrimaryAnnotation(newAnnotation, mapping.getSupportingAnnotationNames());
- this.firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, old, newMapping);
- }
- protected static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- /**
- * return the annotation name of the currently specified mapping or null
- * if there is no specified mapping for the attribute
- */
- protected String getSpecifiedMappingAnnotationName() {
- return (this.specifiedMapping == null) ? null : this.specifiedMapping.getAnnotationName();
- }
-
- protected JavaAttributeMapping buildMappingFromMappingKey(String key) {
- JavaAttributeMappingDefinition mappingDefinition = getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(key);
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- //no mapping.initialize(JavaResourcePersistentAttribute) call here
- //we do not yet have a mapping annotation so we can't call initialize
- return mapping;
- }
-
- protected Iterable<String> getSupportingAnnotationNames() {
- JavaAttributeMapping mapping = this.getMapping();
- return (mapping != null) ? mapping.getSupportingAnnotationNames() : EmptyIterable.<String>instance();
- }
-
- protected void updateSpecifiedMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping provider ...
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(this);
- String mappingKey = mappingDefinition.getKey();
- if (this.specifiedMapping != null
- && this.specifiedMapping.getKey().equals(mappingKey)) {
- this.specifiedMapping.update(this.resourcePersistentAttribute.
- getAnnotation(mappingDefinition.getAnnotationName()));
- }
- else {
- setSpecifiedMapping(buildSpecifiedMapping(mappingDefinition));
- }
- }
-
-
- // ********** misc overrides **********
-
- @Override
- public PersistentType getParent() {
- return (PersistentType) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- this.validateAttribute(messages, reporter, astRoot);
-
- if (this.specifiedMapping != null) {
- this.specifiedMapping.validate(messages, reporter, astRoot);
- }
- else if (this.defaultMapping != null) {
- this.defaultMapping.validate(messages, reporter, astRoot);
- }
- }
-
- protected void validateAttribute(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildAttibuteValidator(astRoot).validate(messages, reporter);
- }
-
- protected abstract JptValidator buildAttibuteValidator(CompilationUnit astRoot);
-
- protected PersistentAttributeTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaPersistentAttributeTextRangeResolver(this, astRoot);
- }
-
-
- // ********** Java completion proposals **********
-
- @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;
- }
- return this.getMapping().javaCompletionProposals(pos, filter, astRoot);
- }
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping());
- }
-
- public String getMetamodelTypeName() {
- String typeName = getTypeName();
- if (typeName == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- if (ClassName.isPrimitive(typeName)) {
- return ClassName.getWrapperClassName(typeName); // ???
- }
- return typeName;
- }
-
-
- // ********** JPA containers **********
-
- public JpaContainer getJpaContainer() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- return getJpaContainer(this.resourcePersistentAttribute.getTypeName());
- }
- /**
- * Return the JPA container corresponding to the specified type;
- * return a "null" JPA container if the specified type is not one of the
- * container types allowed by the JPA spec.
- */
- protected JpaContainer getJpaContainer(String typeName) {
- for (JpaContainer jpaContainer : JPA_CONTAINERS) {
- if (jpaContainer.getTypeName().equals(typeName)) {
- return jpaContainer;
- }
- }
- return JpaContainer.Null.instance();
- }
-
- protected static final Iterable<JpaContainer> JPA_CONTAINERS =
- new ArrayIterable<JpaContainer>(new JpaContainer[] {
- new CollectionJpaContainer(java.util.Collection.class, JPA2_0.COLLECTION_ATTRIBUTE),
- new CollectionJpaContainer(java.util.Set.class, JPA2_0.SET_ATTRIBUTE),
- new CollectionJpaContainer(java.util.List.class, JPA2_0.LIST_ATTRIBUTE),
- new MapJpaContainer(java.util.Map.class, JPA2_0.MAP_ATTRIBUTE)
- });
-
-
- /**
- * Abstract JPA container
- */
- protected abstract static class AbstractJpaContainer implements JpaContainer {
- protected final String typeName;
- protected final String metamodelContainerFieldTypeName;
-
- protected AbstractJpaContainer(Class<?> containerClass, String metamodelContainerFieldTypeName) {
- this(containerClass.getName(), metamodelContainerFieldTypeName);
- }
-
- protected AbstractJpaContainer(String typeName, String metamodelContainerFieldTypeName) {
- super();
- if ((typeName == null) || (metamodelContainerFieldTypeName == null)) {
- throw new NullPointerException();
- }
- this.typeName = typeName;
- this.metamodelContainerFieldTypeName = metamodelContainerFieldTypeName;
- }
-
- public String getTypeName() {
- return this.typeName;
- }
-
- public boolean isContainer() {
- return true;
- }
-
- public String getMetamodelContainerFieldTypeName() {
- return this.metamodelContainerFieldTypeName;
- }
-
- }
-
- /**
- * Collection JPA container
- */
- protected static class CollectionJpaContainer extends AbstractJpaContainer {
- protected CollectionJpaContainer(Class<?> collectionClass, String staticMetamodelTypeDeclarationTypeName) {
- super(collectionClass, staticMetamodelTypeDeclarationTypeName);
- }
-
- public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 1) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(0) :
- null;
- }
-
- public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return null;
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
- return null;
- }
-
- public boolean isMap() {
- return false;
- }
- }
-
- /**
- * Map JPA container
- */
- protected static class MapJpaContainer extends AbstractJpaContainer {
- protected MapJpaContainer(Class<?> mapClass, String staticMetamodelTypeDeclarationTypeName) {
- super(mapClass, staticMetamodelTypeDeclarationTypeName);
- }
-
- public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 2) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(1) :
- null;
- }
-
- public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 2) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(0) :
- null;
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
- return mapping.getMetamodelFieldMapKeyTypeName();
- }
-
- public boolean isMap() {
- return true;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java
deleted file mode 100644
index c08fa0d69b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java
+++ /dev/null
@@ -1,679 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaFile;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterators.ChainIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java persistent type:<ul>
- * <li>name
- * <li>access
- * <li>mapping
- * <li>attributes
- * <li>super persistent type
- * </ul>
- */
-public abstract class AbstractJavaPersistentType
- extends AbstractJavaJpaContextNode
- implements JavaPersistentType
-{
- protected JavaResourcePersistentType resourcePersistentType;
-
- protected String name;
-
- protected AccessType defaultAccess;
-
- protected AccessType specifiedAccess;
-
- protected JavaTypeMapping mapping;
-
- protected final Vector<JavaPersistentAttribute> attributes = new Vector<JavaPersistentAttribute>();
-
- protected PersistentType superPersistentType;
-
-
- protected AbstractJavaPersistentType(PersistentType.Owner parent, JavaResourcePersistentType jrpt) {
- super(parent);
- this.initialize(jrpt);
- }
-
- protected void initialize(JavaResourcePersistentType jrpt) {
- this.resourcePersistentType = jrpt;
- this.superPersistentType = this.buildSuperPersistentType();
- this.name = this.buildName();
- this.defaultAccess = buildDefaultAccess();
- this.specifiedAccess = buildSpecifiedAccess();
- this.mapping = buildMapping();
- this.initializeAttributes();
- }
-
-
- // ********** update **********
-
- public void update(JavaResourcePersistentType jrpt) {
- this.resourcePersistentType = jrpt;
- this.update();
- }
-
- public void update() {
- JpaFile jpaFile = this.getJpaFile();
- if (jpaFile != null) {
- // the JPA file can be null if the resource type is "external"
- jpaFile.addRootStructureNode(this.resourcePersistentType.getQualifiedName(), this);
- }
- this.setSuperPersistentType(this.buildSuperPersistentType());
- this.setName(this.buildName());
- this.updateAccess();
- this.updateMapping();
- this.updateAttributes();
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- this.mapping.postUpdate();
- for (PersistentAttribute attribute : this.getAttributes()) {
- attribute.postUpdate();
- }
- }
-
-
- // ********** AbstractJpaNode overrides **********
-
- @Override
- public PersistentType.Owner getParent() {
- return (PersistentType.Owner) super.getParent();
- }
-
- @Override
- public IResource getResource() {
- return this.resourcePersistentType.getFile();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return JavaStructureNodes.PERSISTENT_TYPE_ID;
- }
-
- // it would be nice if the we passed in an astRoot here, but then we
- // would need to pass it to the XML structure nodes too...
- public JpaStructureNode getStructureNode(int offset) {
- CompilationUnit astRoot = this.buildASTRoot();
-
- if (this.contains(offset, astRoot)) {
- for (JavaPersistentAttribute persistentAttribute : this.getAttributes()) {
- if (persistentAttribute.contains(offset, astRoot)) {
- return persistentAttribute;
- }
- }
- return this;
- }
- return null;
- }
-
- protected boolean contains(int offset, CompilationUnit astRoot) {
- TextRange fullTextRange = this.getFullTextRange(astRoot);
- // 'fullTextRange' will be null if the type no longer exists in the java;
- // the context model can be out of synch with the resource model
- // when a selection event occurs before the context model has a
- // chance to synch with the resource model via the update thread
- return (fullTextRange == null) ? false : fullTextRange.includes(offset);
- }
-
- protected TextRange getFullTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentType.getTextRange(astRoot);
- }
-
- public TextRange getSelectionTextRange() {
- return this.getSelectionTextRange(this.buildASTRoot());
- }
-
- protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentType.getNameTextRange(astRoot);
- }
-
- public void dispose() {
- JpaFile jpaFile = this.getJpaFile();
- if (jpaFile != null) {
- // the JPA file can be null if the .java file was deleted
- // or the resource type is "external"
- jpaFile.removeRootStructureNode(this.resourcePersistentType.getQualifiedName());
- }
- }
-
-
- // ********** PersistentType implementation **********
-
- public JavaResourcePersistentType getResourcePersistentType() {
- return this.resourcePersistentType;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public String getShortName(){
- return this.name.substring(this.name.lastIndexOf('.') + 1);
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- protected String buildName() {
- return this.resourcePersistentType.getQualifiedName();
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return (this.specifiedAccess != null) ? this.specifiedAccess : this.defaultAccess;
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType defaultAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = defaultAccess;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, defaultAccess);
- }
-
- public AccessType getSpecifiedAccess() {
- return this.specifiedAccess;
- }
-
- /**
- * Check the access "specified" by the Java resource model:<ul>
- * <li>Check Java annotations first
- * <li>If <code>null</code>, check XML mapping specified access
- * <li>If still <code>null</code>, check {@link #superPersistentType} access
- * <li>If still <code>null</code>, check <code>entity-mappings</code>
- * specified access setting if the corresponding <code>persistent-type</code>
- * is listed in a mapping (<code>orm.xml</code>) file
- * <li>If still <code>null</code>, check the <code>persistence-unit</code>
- * default Access
- * <li>Default to <code>FIELD</code> if all else fails.
- * </ul>
- */
- protected AccessType buildDefaultAccess() {
- AccessType accessType = AccessType.fromJavaResourceModel(this.resourcePersistentType.getAccess());
- if (accessType != null) {
- return accessType;
- }
- accessType = this.getOwnerOverrideAccess();
- if (accessType != null) {
- return accessType;
- }
-
- if (this.superPersistentType != null) {
- accessType = this.superPersistentType.getAccess();
- if (accessType != null) {
- return accessType;
- }
- }
-
- accessType = this.getOwnerDefaultAccess();
- if (accessType != null) {
- return accessType;
- }
-
- // last ditch attempt to allow the user to annotate *something*
- return AccessType.FIELD;
- }
-
- protected void updateAccess() {
- this.setDefaultAccess(this.buildDefaultAccess());
- }
-
- /**
- * Build an access type based on annotations from the resource model.
- * (This is JPA platform-dependent.)
- */
- protected abstract AccessType buildSpecifiedAccess();
-
-
- // ********** mapping **********
-
- public JavaTypeMapping getMapping() {
- return this.mapping;
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- public void setMappingKey(String key) {
- if (this.valuesAreEqual(key, this.mapping.getKey())) {
- return;
- }
- JavaTypeMapping oldMapping = this.mapping;
- JavaTypeMapping newMapping = this.buildMappingFromMappingKey(key);
-
- this.mapping = newMapping;
- this.resourcePersistentType.setPrimaryAnnotation(newMapping.getAnnotationName(), newMapping.getSupportingAnnotationNames());
- this.firePropertyChanged(MAPPING_PROPERTY, oldMapping, newMapping);
- }
-
- protected void setMapping(JavaTypeMapping mapping) {
- JavaTypeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(MAPPING_PROPERTY, old, mapping);
- }
-
- protected JavaTypeMapping buildMapping() {
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(this);
- return this.buildMapping(mappingDefinition);
- }
-
- protected JavaTypeMapping buildMapping(JavaTypeMappingDefinition mappingDefinition) {
- JavaTypeMapping jtMapping = mappingDefinition.buildMapping(this, this.getJpaFactory());
- // mapping may be null
- if (jtMapping != null) {
- jtMapping.initialize(this.resourcePersistentType);
- }
- return jtMapping;
- }
-
- protected JavaTypeMapping buildMappingFromMappingKey(String key) {
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(key);
- JavaTypeMapping jtMapping = mappingDefinition.buildMapping(this, this.getJpaFactory());
- //no mapping.initialize(JavaResourcePersistentType) call here
- //we do not yet have a mapping annotation so we can't call initialize
- return jtMapping;
- }
-
- protected void updateMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping definition ...
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(this);
- if ((this.mapping != null) && this.valuesAreEqual(this.mapping.getKey(), mappingDefinition.getKey())) {
- this.mapping.update(this.resourcePersistentType);
- } else {
- this.setMapping(this.buildMapping(mappingDefinition));
- }
- }
-
-
- // ********** attributes **********
-
- public ListIterator<JavaPersistentAttribute> attributes() {
- return new CloneListIterator<JavaPersistentAttribute>(this.attributes);
- }
-
- protected Iterable<JavaPersistentAttribute> getAttributes() {
- return new LiveCloneIterable<JavaPersistentAttribute>(this.attributes);
- }
-
- public int attributesSize() {
- return this.attributes.size();
- }
-
- private void addAttribute(int index, JavaPersistentAttribute attribute) {
- this.addItemToList(index, attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- private void removeAttribute(JavaPersistentAttribute attribute) {
- this.removeItemFromList(attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- private void moveAttribute(int index, JavaPersistentAttribute attribute) {
- this.moveItemInList(index, this.attributes.indexOf(attribute), this.attributes, ATTRIBUTES_LIST);
- }
-
- public Iterator<String> attributeNames() {
- return this.attributeNames(this.attributes());
- }
-
- protected Iterator<String> attributeNames(Iterator<? extends PersistentAttribute> attrs) {
- return new TransformationIterator<PersistentAttribute, String>(attrs) {
- @Override
- protected String transform(PersistentAttribute attribute) {
- return attribute.getName();
- }
- };
- }
-
- public JavaPersistentAttribute getAttributeNamed(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.attributesNamed(attributeName);
- return stream.hasNext() ? stream.next() : null;
- }
-
- public PersistentAttribute resolveAttribute(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.attributesNamed(attributeName);
- if (stream.hasNext()) {
- JavaPersistentAttribute attribute = stream.next();
- return stream.hasNext() ? null /*more than one*/: attribute;
- }
- return (this.superPersistentType == null) ? null : this.superPersistentType.resolveAttribute(attributeName);
- }
-
- protected Iterator<JavaPersistentAttribute> attributesNamed(final String attributeName) {
- return new FilteringIterator<JavaPersistentAttribute>(this.attributes()) {
- @Override
- protected boolean accept(JavaPersistentAttribute o) {
- return attributeName.equals(o.getName());
- }
- };
- }
-
- public Iterator<PersistentAttribute> allAttributes() {
- return new CompositeIterator<PersistentAttribute>(
- new TransformationIterator<PersistentType, Iterator<PersistentAttribute>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<PersistentAttribute> transform(PersistentType pt) {
- return pt.attributes();
- }
- }
- );
- }
-
- public Iterator<String> allAttributeNames() {
- return this.attributeNames(this.allAttributes());
- }
-
- protected void initializeAttributes() {
- for (Iterator<JavaResourcePersistentAttribute> stream = this.resourceAttributes(); stream.hasNext(); ) {
- this.attributes.add(this.createAttribute(stream.next()));
- }
- }
-
- protected Iterator<JavaResourcePersistentAttribute> resourceAttributes() {
- return (this.getAccess() == AccessType.PROPERTY) ?
- this.resourcePersistentType.persistableProperties() :
- this.resourcePersistentType.persistableFields();
- }
-
- protected void updateAttributes() {
- HashBag<JavaPersistentAttribute> contextAttributesToRemove = CollectionTools.bag(this.attributes(), this.attributesSize());
- ArrayList<JavaPersistentAttribute> contextAttributesToUpdate = new ArrayList<JavaPersistentAttribute>(this.attributesSize());
- int resourceIndex = 0;
-
- for (Iterator<JavaResourcePersistentAttribute> resourceAttributes = this.resourceAttributes(); resourceAttributes.hasNext(); ) {
- JavaResourcePersistentAttribute resourceAttribute = resourceAttributes.next();
- boolean match = false;
- for (Iterator<JavaPersistentAttribute> contextAttributes = contextAttributesToRemove.iterator(); contextAttributes.hasNext(); ) {
- JavaPersistentAttribute contextAttribute = contextAttributes.next();
- if (contextAttribute.getResourcePersistentAttribute() == resourceAttribute) {
- this.moveAttribute(resourceIndex, contextAttribute);
- contextAttributes.remove();
- contextAttributesToUpdate.add(contextAttribute);
- match = true;
- break;
- }
- }
- if ( ! match) {
- this.addAttribute(resourceIndex, this.createAttribute(resourceAttribute));
- }
- resourceIndex++;
- }
- for (JavaPersistentAttribute contextAttribute : contextAttributesToRemove) {
- this.removeAttribute(contextAttribute);
- }
- // handle adding and removing attributes first, update the
- // remaining attributes last; this reduces the churn during "update"
- for (JavaPersistentAttribute contextAttribute : contextAttributesToUpdate) {
- contextAttribute.update();
- }
- }
-
- protected JavaPersistentAttribute createAttribute(JavaResourcePersistentAttribute jrpa) {
- return this.getJpaFactory().buildJavaPersistentAttribute(this, jrpa);
- }
-
- public boolean hasAnyAnnotatedAttributes() {
- return this.resourcePersistentType.hasAnyAnnotatedAttributes();
- }
-
-
- // ********** super persistent type **********
-
- public PersistentType getSuperPersistentType() {
- return this.superPersistentType;
- }
-
- protected void setSuperPersistentType(PersistentType superPersistentType) {
- PersistentType old = this.superPersistentType;
- this.superPersistentType = superPersistentType;
- this.firePropertyChanged(SUPER_PERSISTENT_TYPE_PROPERTY, old, superPersistentType);
- }
-
- protected PersistentType buildSuperPersistentType() {
- HashSet<JavaResourcePersistentType> visited = new HashSet<JavaResourcePersistentType>();
- visited.add(this.resourcePersistentType);
- PersistentType spt = this.getSuperPersistentType(this.resourcePersistentType.getSuperclassQualifiedName(), visited);
- if (spt == null) {
- return null;
- }
- if (CollectionTools.contains(spt.inheritanceHierarchy(), this)) {
- return null; // short-circuit in this case, we have circular inheritance
- }
- return spt.isMapped() ? spt : spt.getSuperPersistentType();
- }
-
- /**
- * The JPA spec allows non-persistent types in a persistent type's
- * inheritance hierarchy. We check for a persistent type with the
- * specified name in the persistence unit. If it is not found we use
- * resource persistent type and look for *its* super type.
- *
- * The 'visited' collection is used to detect a cycle in the *resource* type
- * inheritance hierarchy and prevent the resulting stack overflow.
- * Any cycles in the *context* type inheritance hierarchy are handled in
- * #buildSuperPersistentType().
- */
- protected PersistentType getSuperPersistentType(String typeName, Collection<JavaResourcePersistentType> visited) {
- if (typeName == null) {
- return null;
- }
- JavaResourcePersistentType resourceType = this.getJpaProject().getJavaResourcePersistentType(typeName);
- if ((resourceType == null) || visited.contains(resourceType)) {
- return null;
- }
- visited.add(resourceType);
- PersistentType spt = this.getPersistentType(typeName);
- return (spt != null) ? spt : this.getSuperPersistentType(resourceType.getSuperclassQualifiedName(), visited); // recurse
- }
-
- protected PersistentType getPersistentType(String typeName) {
- return this.getPersistenceUnit().getPersistentType(typeName);
- }
-
-
- // ********** inheritance **********
-
- public Iterator<PersistentType> inheritanceHierarchy() {
- return this.inheritanceHierarchyOf(this);
- }
-
- public Iterator<PersistentType> ancestors() {
- return this.inheritanceHierarchyOf(this.superPersistentType);
- }
-
- protected Iterator<PersistentType> inheritanceHierarchyOf(PersistentType start) {
- // using a chain iterator to traverse up the inheritance tree
- return new ChainIterator<PersistentType>(start) {
- @Override
- protected PersistentType nextLink(PersistentType persistentType) {
- return persistentType.getSuperPersistentType();
- }
- };
- }
-
-
- // ********** code completion **********
-
- @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;
- }
- Iterator<String> values = this.mapping.javaCompletionProposals(pos, filter, astRoot);
- if (values != null) {
- return values;
- }
- for (JavaPersistentAttribute attribute : this.getAttributes()) {
- values = attribute.javaCompletionProposals(pos, filter, astRoot);
- if (values != null) {
- return values;
- }
- }
- return EmptyIterator.instance();
- }
-
-
- // ********** validation **********
-
- public void validate(List<IMessage> messages, IReporter reporter) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- // TODO temporary hack since we don't know yet where to put
- // any messages for types in another project (e.g. referenced by
- // persistence.xml)
- IFile file = this.resourcePersistentType.getFile();
- // 'file' will be null if the type is "external" and binary;
- // the file will be in a different project if the type is "external" and source;
- // the type will be binary if it is in a JAR in the current project
- if ((file != null) && file.getProject().equals(this.getJpaProject().getProject()) &&
- (this.resourcePersistentType instanceof SourceNode)) {
- // build the AST root here to pass down
- this.validate(messages, reporter, this.buildASTRoot());
- }
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateMapping(messages, reporter, astRoot);
- this.validateAttributes(messages, reporter, astRoot);
- }
-
- protected void validateMapping(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- try {
- this.mapping.validate(messages, reporter, astRoot);
- } catch(Throwable t) {
- JptCorePlugin.log(t);
- }
- }
-
- protected void validateAttributes(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- for (JavaPersistentAttribute attribute : this.getAttributes()) {
- this.validateAttribute(attribute, reporter, messages, astRoot);
- }
- }
-
- protected void validateAttribute(JavaPersistentAttribute attribute, IReporter reporter, List<IMessage> messages, CompilationUnit astRoot) {
- try {
- attribute.validate(messages, reporter, astRoot);
- } catch(Throwable t) {
- JptCorePlugin.log(t);
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
-
- // ********** misc **********
-
- public boolean isFor(String typeName) {
- String className = this.getName();
- return className != null && className.equals(typeName);
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- String packageName = this.getPackageName();
- if (packageName != null && packageName.equals(packageFragment.getElementName())) {
- return true;
- }
- return false;
- }
-
- protected String getPackageName() {
- return getResourcePersistentType().getPackageName();
- }
-
- public boolean isMapped() {
- return this.mapping.isMapped();
- }
-
- public AccessType getOwnerOverrideAccess() {
- return this.getParent().getOverridePersistentTypeAccess();
- }
-
- public AccessType getOwnerDefaultAccess() {
- return this.getParent().getDefaultPersistentTypeAccess();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.resourcePersistentType.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- protected JpaFile getJpaFile() {
- return this.getJpaFile(this.resourcePersistentType.getFile());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java
deleted file mode 100644
index 0f3c687b3e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Query;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaQuery;
-import org.eclipse.jpt.core.context.java.JavaQueryHint;
-import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-
-
-public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode
- implements JavaQuery
-{
- protected String name;
-
- protected String query;
-
- protected final Vector<JavaQueryHint> hints;
-
- protected BaseNamedQueryAnnotation queryAnnotation;
-
- protected AbstractJavaQuery(JavaJpaContextNode parent) {
- super(parent);
- this.hints = new Vector<JavaQueryHint>();
- }
-
- protected BaseNamedQueryAnnotation getResourceQuery() {
- return this.queryAnnotation;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String oldName = this.name;
- this.name = newName;
- this.queryAnnotation.setName(newName);
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- protected void setName_(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String newQuery) {
- String oldQuery = this.query;
- this.query = newQuery;
- this.queryAnnotation.setQuery(newQuery);
- firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery);
- }
-
- protected void setQuery_(String newQuery) {
- String oldQuery = this.query;
- this.query = newQuery;
- firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery);
- }
-
- public ListIterator<JavaQueryHint> hints() {
- return new CloneListIterator<JavaQueryHint>(this.hints);
- }
-
- public int hintsSize() {
- return this.hints.size();
- }
-
- public JavaQueryHint addHint(int index) {
- JavaQueryHint hint = getJpaFactory().buildJavaQueryHint(this);
- this.hints.add(index, hint);
- this.getResourceQuery().addHint(index);
- this.fireItemAdded(HINTS_LIST, index, hint);
- return hint;
- }
-
- protected void addHint(int index, JavaQueryHint hint) {
- addItemToList(index, hint, this.hints, HINTS_LIST);
- }
-
- protected void addHint(JavaQueryHint hint) {
- addHint(this.hints.size(), hint);
- }
-
- public void removeHint(QueryHint queryHint) {
- removeHint(this.hints.indexOf(queryHint));
- }
-
- public void removeHint(int index) {
- JavaQueryHint removedHint = this.hints.remove(index);
- this.getResourceQuery().removeHint(index);
- fireItemRemoved(HINTS_LIST, index, removedHint);
- }
-
- protected void removeHint_(JavaQueryHint hint) {
- removeItemFromList(hint, this.hints, HINTS_LIST);
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hints, targetIndex, sourceIndex);
- this.getResourceQuery().moveHint(targetIndex, sourceIndex);
- fireItemMoved(HINTS_LIST, targetIndex, sourceIndex);
- }
-
- protected void initialize(BaseNamedQueryAnnotation annotation) {
- this.queryAnnotation = annotation;
- this.name = annotation.getName();
- this.query = annotation.getQuery();
- this.initializeQueryHints();
- }
-
- protected void update(BaseNamedQueryAnnotation annotation) {
- this.queryAnnotation = annotation;
- this.setName_(annotation.getName());
- this.setQuery_(annotation.getQuery());
- this.updateQueryHints();
- getPersistenceUnit().addQuery(this);
- }
-
- protected void initializeQueryHints() {
- for (ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints(); resourceHints.hasNext(); ) {
- this.hints.add(createQueryHint(resourceHints.next()));
- }
- }
-
- protected void updateQueryHints() {
- ListIterator<JavaQueryHint> contextHints = hints();
- ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints();
-
- while (contextHints.hasNext()) {
- JavaQueryHint hint = contextHints.next();
- if (resourceHints.hasNext()) {
- hint.update(resourceHints.next());
- }
- else {
- removeHint_(hint);
- }
- }
-
- while (resourceHints.hasNext()) {
- addHint(createQueryHint(resourceHints.next()));
- }
- }
-
- protected JavaQueryHint createQueryHint(QueryHintAnnotation resourceQueryHint) {
- JavaQueryHint queryHint = getJpaFactory().buildJavaQueryHint(this);
- queryHint.initialize(resourceQueryHint);
- return queryHint;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.queryAnnotation.getTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.queryAnnotation.getNameTextRange(astRoot);
- }
-
- public boolean overrides(Query other) {
- // java is at the base of the tree
- return false;
- }
-
- public boolean duplicates(Query other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java
deleted file mode 100644
index d0819044df..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaCascade;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCascade2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.utility.TextRange;
-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.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java relationship mapping
- */
-public abstract class AbstractJavaRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaAttributeMapping<T>
- implements JavaRelationshipMapping2_0
-{
- protected String specifiedTargetEntity;
- protected String defaultTargetEntity;
- protected String fullyQualifiedTargetEntity;
- protected PersistentType resolvedTargetType;
- protected Entity resolvedTargetEntity;
-
- protected final JavaRelationshipReference relationshipReference;
-
- protected final JavaCascade2_0 cascade;
-
- protected FetchType specifiedFetch;
-
-
- protected AbstractJavaRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.relationshipReference = buildRelationshipReference();
- this.cascade = buildCascade();
- }
-
-
- @Override
- protected void initialize() {
- super.initialize();
- this.relationshipReference.initialize();
- this.specifiedFetch = this.getResourceFetch();
- this.cascade.initialize();
- this.defaultTargetEntity = this.buildDefaultTargetEntity();
- this.specifiedTargetEntity = this.getResourceTargetEntity();
- this.fullyQualifiedTargetEntity = this.buildFullyQualifiedTargetEntity();
- this.resolvedTargetType = this.resolveTargetType();
- this.resolvedTargetEntity = this.resolveTargetEntity();
- }
-
- @Override
- protected void update() {
- super.update();
- this.relationshipReference.update();
- this.setSpecifiedFetch_(this.getResourceFetch());
- this.cascade.update();
- this.setDefaultTargetEntity(this.buildDefaultTargetEntity());
- this.setSpecifiedTargetEntity_(this.getResourceTargetEntity());
- this.setFullyQualifiedTargetEntity(this.buildFullyQualifiedTargetEntity());
- this.resolvedTargetType = this.resolveTargetType();
- this.setResolvedTargetEntity(this.resolveTargetEntity());
- }
-
-
- // ********** target entity **********
-
- public String getTargetEntity() {
- return (this.specifiedTargetEntity != null) ? this.specifiedTargetEntity : this.defaultTargetEntity;
- }
-
- public String getSpecifiedTargetEntity() {
- return this.specifiedTargetEntity;
- }
-
- public void setSpecifiedTargetEntity(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.mappingAnnotation.setTargetEntity(targetEntity);
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected void setSpecifiedTargetEntity_(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected String getResourceTargetEntity() {
- return this.mappingAnnotation.getTargetEntity();
- }
-
- public String getDefaultTargetEntity() {
- return this.defaultTargetEntity;
- }
-
- protected void setDefaultTargetEntity(String targetEntity) {
- String old = this.defaultTargetEntity;
- this.defaultTargetEntity = targetEntity;
- this.firePropertyChanged(DEFAULT_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected abstract String buildDefaultTargetEntity();
-
- public String getFullyQualifiedTargetEntity() {
- return this.fullyQualifiedTargetEntity;
- }
-
- protected void setFullyQualifiedTargetEntity(String targetEntity) {
- String old = this.fullyQualifiedTargetEntity;
- this.fullyQualifiedTargetEntity = targetEntity;
- this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected String buildFullyQualifiedTargetEntity() {
- return (this.specifiedTargetEntity == null) ?
- this.defaultTargetEntity :
- this.mappingAnnotation.getFullyQualifiedTargetEntityClassName();
- }
-
- public PersistentType getResolvedTargetType() {
- return this.resolvedTargetType;
- }
-
- protected PersistentType resolveTargetType() {
- return (this.fullyQualifiedTargetEntity == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedTargetEntity);
- }
-
- public Entity getResolvedTargetEntity() {
- return this.resolvedTargetEntity;
- }
-
- protected void setResolvedTargetEntity(Entity entity) {
- Entity old = this.resolvedTargetEntity;
- this.resolvedTargetEntity = entity;
- this.firePropertyChanged(RESOLVED_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected Entity resolveTargetEntity() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public Iterator<String> allTargetEntityAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEntityAttributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allMappingNames();
- }
- });
- }
-
- protected Iterator<AttributeMapping> allTargetEntityAttributeMappings() {
- return (this.resolvedTargetEntity != null) ?
- this.resolvedTargetEntity.allAttributeMappings() :
- EmptyIterator.<AttributeMapping> instance();
- }
-
- protected String getTargetEntityIdAttributeName() {
- PersistentAttribute attribute = this.getTargetEntityIdAttribute();
- return (attribute == null) ? null : attribute.getName();
- }
-
- protected PersistentAttribute getTargetEntityIdAttribute() {
- return (this.resolvedTargetEntity == null) ? null : this.resolvedTargetEntity.getIdAttribute();
- }
-
- public char getTargetEntityEnclosingTypeSeparator() {
- return '.';
- }
-
-
- // ********** relationship reference **********
-
- public JavaRelationshipReference getRelationshipReference() {
- return this.relationshipReference;
- }
-
- protected abstract JavaRelationshipReference buildRelationshipReference();
-
- @Override
- public boolean isRelationshipOwner() {
- return this.relationshipReference.isRelationshipOwner();
- }
-
- public RelationshipMapping getRelationshipOwner() {
- Entity targetEntity = this.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- for (PersistentAttribute each :
- CollectionTools.iterable(
- targetEntity.getPersistentType().allAttributes())) {
- if (this.isOwnedBy(each.getMapping())) {
- return (RelationshipMapping) each.getMapping();
- }
- }
- return null;
- }
-
- @Override
- public boolean isOwnedBy(AttributeMapping mapping) {
- if (mapping.isRelationshipOwner()) {
- return this.relationshipReference.isOwnedBy((RelationshipMapping) mapping);
- }
- return false;
- }
-
- @Override
- public boolean isOverridableAssociationMapping() {
- return this.relationshipReference.isOverridableAssociation();
- }
-
-
- // ********** cascade **********
-
- protected JavaCascade2_0 buildCascade() {
- return new GenericJavaCascade(this);
- }
-
- public JavaCascade2_0 getCascade() {
- return this.cascade;
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.getDefaultFetch();
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(fetch));
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType getResourceFetch() {
- return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch());
- }
-
-
- // ********** Java completion proposals **********
-
- @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;
- }
- return this.relationshipReference.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateTargetEntity(messages, astRoot);
- this.relationshipReference.validate(messages, reporter, astRoot);
- }
-
- protected void validateTargetEntity(List<IMessage> messages, CompilationUnit astRoot) {
- if (this.getTargetEntity() == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- else if (this.resolvedTargetEntity == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {this.getTargetEntity(), this.getName()},
- this,
- this.getTargetEntityTextRange(astRoot)
- )
- );
- }
- }
-
- protected TextRange getTargetEntityTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.mappingAnnotation.getTargetEntityTextRange(astRoot), astRoot);
- }
-
- protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
-
- // ********** metamodel **********
-
- @Override
- public String getMetamodelTypeName() {
- return (this.fullyQualifiedTargetEntity != null) ? this.fullyQualifiedTargetEntity : MetamodelField.DEFAULT_TYPE_NAME;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java
deleted file mode 100644
index 1b5ccb157d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public abstract class AbstractJavaRelationshipReference
- extends AbstractJavaJpaContextNode
- implements JavaRelationshipReference
-{
- // cache the strategy for property change notification
- protected JoiningStrategy cachedPredominantJoiningStrategy;
-
-
- public AbstractJavaRelationshipReference(JavaRelationshipMapping parent) {
- super(parent);
- }
-
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return (JavaRelationshipMapping) getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridableAssociation() {
- return getPredominantJoiningStrategy().isOverridableAssociation();
- }
-
- public boolean isParentVirtual() {
- return getRelationshipMapping().getPersistentAttribute().isVirtual();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
- // **************** predominant joining strategy ***************************
-
- public JoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy() {
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void setPredominantJoiningStrategy(JoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
-
- // **************** resource -> context ************************************
-
- public void initialize() {
- initializeJoiningStrategies();
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected abstract void initializeJoiningStrategies();
-
- public void update() {
- updateJoiningStrategies();
- setPredominantJoiningStrategy();
- }
-
- protected abstract void updateJoiningStrategies();
-
- protected abstract JoiningStrategy calculatePredominantJoiningStrategy();
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getRelationshipMapping().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java
deleted file mode 100644
index 02d7926656..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-
-/**
- *
- */
-public abstract class AbstractJavaSequenceGenerator extends AbstractJavaGenerator
- implements JavaSequenceGenerator
-{
- protected String specifiedSequenceName;
-
-
- protected AbstractJavaSequenceGenerator(JavaJpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** sequence name **********
-
- public String getSequenceName() {
- return (this.specifiedSequenceName != null) ? this.specifiedSequenceName : this.getDefaultSequenceName();
- }
-
- public String getSpecifiedSequenceName() {
- return this.specifiedSequenceName;
- }
-
- public void setSpecifiedSequenceName(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.getResourceGenerator().setSequenceName(specifiedSequenceName);
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- protected void setSpecifiedSequenceName_(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- public String getDefaultSequenceName() {
- return null;
- }
-
-
- // ********** resource => context **********
-
- public void initialize(SequenceGeneratorAnnotation resourceSequenceGenerator) {
- super.initialize(resourceSequenceGenerator);
- this.specifiedSequenceName = resourceSequenceGenerator.getSequenceName();
- }
-
- public void update(SequenceGeneratorAnnotation resourceSequenceGenerator) {
- super.update(resourceSequenceGenerator);
- this.setSpecifiedSequenceName_(resourceSequenceGenerator.getSequenceName());
- }
-
-
- // ********** Java completion proposals **********
-
- /**
- * called if the database is connected:
- * sequenceName
- */
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.sequenceNameTouches(pos, astRoot)) {
- return this.getJavaCandidateSequences(filter).iterator();
- }
- return null;
- }
-
- protected boolean sequenceNameTouches(int pos, CompilationUnit astRoot) {
- return this.getResourceGenerator().sequenceNameTouches(pos, astRoot);
- }
-
- protected Iterable<String> getJavaCandidateSequences(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSequences(filter));
- }
-
- protected Iterable<String> getCandidateSequences(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateSequences(), filter);
- }
-
- protected Iterable<String> getCandidateSequences() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema != null) ? dbSchema.getSortedSequenceIdentifiers() : EmptyIterable.<String> instance();
- }
-
-
- // ********** misc **********
-
- public int getDefaultInitialValue() {
- return SequenceGenerator.DEFAULT_INITIAL_VALUE;
- }
-
- @Override
- protected SequenceGeneratorAnnotation getResourceGenerator() {
- return (SequenceGeneratorAnnotation) super.getResourceGenerator();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
deleted file mode 100644
index 375f50d6e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java single relationship (1:1, m:1) mapping
- */
-public abstract class AbstractJavaSingleRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaRelationshipMapping<T>
- implements JavaSingleRelationshipMapping2_0
-{
- protected Boolean specifiedOptional;
-
- protected final JavaDerivedIdentity2_0 derivedIdentity;
-
-
- protected AbstractJavaSingleRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.derivedIdentity = buildDerivedIdentity();
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.specifiedOptional = this.getResourceOptional();
- this.derivedIdentity.initialize();
- }
-
- @Override
- protected void update() {
- super.update();
- this.setSpecifiedOptional_(this.getResourceOptional());
- this.derivedIdentity.update();
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_COLUMN);
- names.add(JPA.JOIN_COLUMNS);
- names.add(JPA.JOIN_TABLE);
- if (this.isJpa2_0Compatible()) {
- names.add(JPA.ID);
- names.add(JPA2_0.MAPS_ID);
- }
- }
-
-
- // ********** optional **********
-
- public boolean isOptional() {
- return (this.specifiedOptional != null) ? this.specifiedOptional.booleanValue() : this.isDefaultOptional();
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.setResourceOptional(optional);
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
- protected abstract Boolean getResourceOptional();
-
- protected abstract void setResourceOptional(Boolean newOptional);
-
-
- // ********** 2.0 derived identity **********
-
- protected JavaDerivedIdentity2_0 buildDerivedIdentity() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaDerivedIdentity(this) :
- new NullJavaDerivedIdentity2_0(this);
- }
-
- public JavaDerivedIdentity2_0 getDerivedIdentity() {
- return this.derivedIdentity;
- }
-
-
- // ********** AbstractJavaRelationshipMapping implementation **********
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getSingleReferenceTargetTypeName();
- }
-
-
- // ********** Fetchable implementation **********
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.derivedIdentity.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.derivedIdentity.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
deleted file mode 100644
index b99e9f5fc1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaBaseTable;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.BaseTableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java table
- */
-public abstract class AbstractJavaTable
- extends AbstractJavaJpaContextNode
- implements JavaBaseTable, UniqueConstraint.Owner
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final Vector<JavaUniqueConstraint> uniqueConstraints = new Vector<JavaUniqueConstraint>();
-
- protected final Owner owner;
-
- // ********** constructor **********
-
- protected AbstractJavaTable(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- protected Owner getOwner() {
- return this.owner;
- }
-
- // ********** abstract methods **********
-
- /**
- * Return the Java table annotation. Do not return null if the Java
- * annotation does not exist; return a null table annotation instead.
- */
- protected abstract BaseTableAnnotation getAnnotation();
-
- /**
- * Return the name of the Java annotation.
- */
- protected abstract String getAnnotationName();
-
- protected abstract String buildDefaultName();
-
- protected abstract String buildDefaultSchema();
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.getAnnotation().setName(name);
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String name) {
- String old = this.defaultName;
- this.defaultName = name;
- this.firePropertyChanged(DEFAULT_NAME_PROPERTY, old, name);
- }
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.getAnnotation().setSchema(schema);
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedSchema_(String newSpecifiedSchema) {
- String oldSpecifiedSchema = this.specifiedSchema;
- this.specifiedSchema = newSpecifiedSchema;
- firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, oldSpecifiedSchema, newSpecifiedSchema);
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.getAnnotation().setCatalog(catalog);
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedCatalog_(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
-
- // ********** unique constraints **********
-
- public @SuppressWarnings("unchecked") ListIterator<JavaUniqueConstraint> uniqueConstraints() {
- return new CloneListIterator<JavaUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public JavaUniqueConstraint addUniqueConstraint(int index) {
- JavaUniqueConstraint uniqueConstraint = getJpaFactory().buildJavaUniqueConstraint(this, this);
- this.uniqueConstraints.add(index, uniqueConstraint);
- UniqueConstraintAnnotation uniqueConstraintAnnotation = this.getAnnotation().addUniqueConstraint(index);
- uniqueConstraint.initialize(uniqueConstraintAnnotation);
- fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint);
- return uniqueConstraint;
- }
-
- public void removeUniqueConstraint(UniqueConstraint uniqueConstraint) {
- this.removeUniqueConstraint(this.uniqueConstraints.indexOf(uniqueConstraint));
- }
-
- public void removeUniqueConstraint(int index) {
- JavaUniqueConstraint removedUniqueConstraint = this.uniqueConstraints.remove(index);
- this.getAnnotation().removeUniqueConstraint(index);
- fireItemRemoved(UNIQUE_CONSTRAINTS_LIST, index, removedUniqueConstraint);
- }
-
- public void moveUniqueConstraint(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex);
- this.getAnnotation().moveUniqueConstraint(targetIndex, sourceIndex);
- fireItemMoved(UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex);
- }
-
- protected void addUniqueConstraint(int index, JavaUniqueConstraint uniqueConstraint) {
- addItemToList(index, uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void addUniqueConstraint(JavaUniqueConstraint uniqueConstraint) {
- this.addUniqueConstraint(this.uniqueConstraints.size(), uniqueConstraint);
- }
-
- protected void removeUniqueConstraint_(JavaUniqueConstraint uniqueConstraint) {
- removeItemFromList(uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void initializeUniqueConstraints(BaseTableAnnotation baseTableAnnotation) {
- for (Iterator<UniqueConstraintAnnotation> stream = baseTableAnnotation.uniqueConstraints(); stream.hasNext(); ) {
- this.uniqueConstraints.add(buildUniqueConstraint(stream.next()));
- }
- }
-
- protected void updateUniqueConstraints(BaseTableAnnotation baseTableAnnotation) {
- ListIterator<UniqueConstraintAnnotation> constraintAnnotations = baseTableAnnotation.uniqueConstraints();
- ListIterator<JavaUniqueConstraint> constraints = this.uniqueConstraints();
- while (constraints.hasNext()) {
- JavaUniqueConstraint uniqueConstraint = constraints.next();
- if (constraintAnnotations.hasNext()) {
- uniqueConstraint.update(constraintAnnotations.next());
- } else {
- this.removeUniqueConstraint_(uniqueConstraint);
- }
- }
-
- while (constraintAnnotations.hasNext()) {
- this.addUniqueConstraint(this.buildUniqueConstraint(constraintAnnotations.next()));
- }
- }
-
- protected JavaUniqueConstraint buildUniqueConstraint(UniqueConstraintAnnotation uniqueConstraintAnnotation) {
- JavaUniqueConstraint uniqueConstraint = this.getJpaFactory().buildJavaUniqueConstraint(this, this);
- uniqueConstraint.initialize(uniqueConstraintAnnotation);
- return uniqueConstraint;
- }
-
-
- // ********** convenience methods **********
-
- protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getNameTextRange(astRoot), astRoot);
- }
-
- protected boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().nameTouches(pos, astRoot);
- }
-
- public TextRange getSchemaTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getSchemaTextRange(astRoot), astRoot);
- }
-
- protected boolean schemaTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().schemaTouches(pos, astRoot);
- }
-
- public TextRange getCatalogTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getCatalogTextRange(astRoot), astRoot);
- }
-
- protected boolean catalogTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().catalogTouches(pos, astRoot);
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(BaseTableAnnotation baseTableAnnotation) {
- this.defaultName = this.buildDefaultName();
- this.specifiedName = baseTableAnnotation.getName();
-
- this.defaultSchema = this.buildDefaultSchema();
- this.specifiedSchema = baseTableAnnotation.getSchema();
-
- this.defaultCatalog = this.buildDefaultCatalog();
- this.specifiedCatalog = baseTableAnnotation.getCatalog();
-
- this.initializeUniqueConstraints(baseTableAnnotation);
- }
-
- protected void update(BaseTableAnnotation baseTableAnnotation) {
- this.setDefaultName(this.buildDefaultName());
- this.setSpecifiedName_(baseTableAnnotation.getName());
-
- this.setDefaultSchema(this.buildDefaultSchema());
- this.setSpecifiedSchema_(baseTableAnnotation.getSchema());
-
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.setSpecifiedCatalog_(baseTableAnnotation.getCatalog());
-
- this.updateUniqueConstraints(baseTableAnnotation);
- }
-
-
- // ********** database **********
-
- public org.eclipse.jpt.db.Table getDbTable() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema == null) ? null : dbSchema.getTableForIdentifier(this.getName());
- }
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- public boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- public boolean hasResolvedSchema() {
- return this.getDbSchema() != null;
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public boolean hasResolvedCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.getDbCatalog(catalog) != null);
- }
-
-
- // ********** UniqueConstraint.Owner implementation **********
-
- public Iterator<String> candidateUniqueConstraintColumnNames() {
- org.eclipse.jpt.db.Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers().iterator() : EmptyIterator.<String>instance();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getTextRange(astRoot), astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildTableValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildTableValidator(CompilationUnit astRoot) {
- return this.getOwner().buildTableValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected TableTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTableTextRangeResolver(this, astRoot);
- }
-
- // ********** Java completion proposals **********
-
- @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;
- }
- for (JavaUniqueConstraint constraint : CollectionTools.iterable(this.uniqueConstraints())) {
- result = constraint.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * called if the database is connected:
- * name, schema, catalog
- */
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.getJavaCandidateNames(filter).iterator();
- }
- if (this.schemaTouches(pos, astRoot)) {
- return this.getJavaCandidateSchemata(filter).iterator();
- }
- if (this.catalogTouches(pos, astRoot)) {
- return this.getJavaCandidateCatalogs(filter).iterator();
- }
- return null;
- }
-
- protected Iterable<String> getJavaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames(filter));
- }
-
- protected Iterable<String> getCandidateNames(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateNames(), filter);
- }
-
- protected Iterable<String> getCandidateNames() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance();
- }
-
- protected Iterable<String> getJavaCandidateSchemata(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSchemata(filter));
- }
-
- protected Iterable<String> getCandidateSchemata(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateSchemata(), filter);
- }
-
- protected Iterable<String> getCandidateSchemata() {
- return this.getDbSchemaContainer().getSortedSchemaIdentifiers();
- }
-
- protected Iterable<String> getJavaCandidateCatalogs(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateCatalogs(filter));
- }
-
- protected Iterable<String> getCandidateCatalogs(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateCatalogs(), filter);
- }
-
- protected Iterable<String> getCandidateCatalogs() {
- Database db = this.getDatabase();
- return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
- }
-
-
- // ********** misc **********
-
- /**
- * covariant override
- */
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.getQualifiedName());
- }
-
- protected String getQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java
deleted file mode 100644
index 17a6b06938..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaTypeMapping extends AbstractJavaJpaContextNode
- implements JavaTypeMapping
-{
- protected JavaResourcePersistentType javaResourcePersistentType;
-
-
- protected AbstractJavaTypeMapping(JavaPersistentType parent) {
- super(parent);
- }
-
- @Override
- public JavaPersistentType getParent() {
- return (JavaPersistentType) super.getParent();
- }
-
- protected JavaResourcePersistentType getResourcePersistentType() {
- return this.javaResourcePersistentType;
- }
-
- protected Annotation getResourceMappingAnnotation() {
- return this.javaResourcePersistentType.getAnnotation(getAnnotationName());
- }
-
- //***************** TypeMapping impl ***************************************
-
- public String getName() {
- return getPersistentType().getName();
- }
-
- public JavaPersistentType getPersistentType() {
- return getParent();
- }
-
- /* default implementation */
- public JavaPersistentType getIdClass() {
- return null;
- }
-
- public String getPrimaryTableName() {
- return null;
- }
-
- public org.eclipse.jpt.db.Table getPrimaryDbTable() {
- return null;
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return null;
- }
-
- public Schema getDbSchema() {
- return null;
- }
-
- public boolean attributeMappingKeyAllowed(String attributeMappingKey) {
- return true;
- }
-
- public Iterator<Table> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTablesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public TypeMapping getSuperTypeMapping() {
- return (getPersistentType().getSuperPersistentType() == null) ?
- null
- : getPersistentType().getSuperPersistentType().getMapping();
- }
-
- /**
- * Return an iterator of TypeMappings, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- public Iterator<TypeMapping> inheritanceHierarchy() {
- return this.getInheritanceHierarchy().iterator();
- }
-
- public Iterable<TypeMapping> getInheritanceHierarchy() {
- return new TransformationIterable<PersistentType, TypeMapping>(CollectionTools.iterable(getPersistentType().inheritanceHierarchy())) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- public Iterator<JavaAttributeMapping> attributeMappings() {
- return new TransformationIterator<JavaPersistentAttribute, JavaAttributeMapping>(getPersistentType().attributes()) {
- @Override
- protected JavaAttributeMapping transform(JavaPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public Iterable<JavaAttributeMapping> getAttributeMappings(final String mappingKey) {
- return new FilteringIterable<JavaAttributeMapping>(CollectionTools.collection(attributeMappings())) {
- @Override
- protected boolean accept(JavaAttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<AttributeMapping> allAttributeMappings() {
- return new CompositeIterator<AttributeMapping>(
- new TransformationIterator<TypeMapping, Iterator<AttributeMapping>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<AttributeMapping> transform(TypeMapping typeMapping) {
- return typeMapping == null ? EmptyIterator.<AttributeMapping> instance() : typeMapping.attributeMappings();
- }
- });
- }
-
- public Iterable<AttributeMapping> getAllAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(allAttributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<String> overridableAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAttributeNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAttributeNames();
- }
- });
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- Column resolvedColumn = attributeMapping.resolveOverriddenColumn(attributeName);
- if (resolvedColumn != null) {
- return resolvedColumn;
- }
- }
- return null;
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- RelationshipReference resolvedRelationshipReference = attributeMapping.resolveRelationshipReference(attributeName);
- if (resolvedRelationshipReference != null) {
- return resolvedRelationshipReference;
- }
- }
- return null;
- }
-
- public Iterator<String> overridableAssociationNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAssociationNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAssociationNames();
- }
- });
- }
-
-
- //******************** updating *********************
- public void initialize(JavaResourcePersistentType jrpt) {
- this.javaResourcePersistentType = jrpt;
- }
-
- public void update(JavaResourcePersistentType jrpt) {
- this.javaResourcePersistentType = jrpt;
- }
-
- //******************** validation *********************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- validateType(messages, reporter, astRoot);
- }
-
- protected void validateType(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildTypeMappingValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildTypeMappingValidator(CompilationUnit astRoot) {
- return new GenericTypeMappingValidator(this, this.javaResourcePersistentType, buildTextRangeResolver(astRoot));
- }
-
- protected TypeMappingTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTypeMappingTextRangeResolver(this, astRoot);
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getPersistenceUnit().shouldValidateAgainstDatabase();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceMappingAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getPersistentType().getValidationTextRange(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getPersistentType().getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java
deleted file mode 100644
index 65e6850206..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-public abstract class AbstractJavaTypeMappingDefinition
- implements JavaTypeMappingDefinition
-{
- protected AbstractJavaTypeMappingDefinition() {
- super();
- }
-
-
- /**
- * Default implementation. Override if the mapping definition needs to do more analysis.
- */
- public boolean test(JavaPersistentType persistentType) {
- return persistentType.getResourcePersistentType().getAnnotation(getAnnotationName())
- != null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getAnnotationName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java
deleted file mode 100644
index 0f1f2760db..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaVersionMapping
- extends AbstractJavaAttributeMapping<VersionAnnotation>
- implements JavaVersionMapping
-{
- protected final JavaColumn column;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
- protected AbstractJavaVersionMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = getJpaFactory().buildJavaColumn(this, this);
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
- @Override
- protected void initialize( ) {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) getResourcePersistentAttribute().
- getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- //************** JavaAttributeMapping implementation ***************
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return VersionAnnotation.ANNOTATION_NAME;
- }
-
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.TEMPORAL);
- }
-
- //************** NamedColumn.Owner implementation ***************
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- //************** VersionMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
- @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 = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- //*********** Validation ******************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.getColumn().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java
deleted file mode 100644
index 7d52f032ce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class GenericJavaIdClassReference
- extends AbstractJavaJpaContextNode
- implements JavaIdClassReference
-{
- protected String idClassName;
-
- protected String fullyQualifiedIdClassName;
-
- protected JavaPersistentType idClass;
-
-
- public GenericJavaIdClassReference(JavaTypeMapping parent) {
- super(parent);
- }
-
-
- protected JavaTypeMapping getTypeMapping() {
- return (JavaTypeMapping) getParent();
- }
-
- protected JavaPersistentType getPersistentType() {
- return getTypeMapping().getPersistentType();
- }
-
-
- // **************** PersistentType.Owner impl *****************************
-
- public AccessType getOverridePersistentTypeAccess() {
- return getPersistentType().getAccess();
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- // this shouldn't be needed, since we've specified an override access, but just to be safe ...
- return getPersistentType().getAccess();
- }
-
-
- // **************** IdClassReference impl *********************************
-
- public String getSpecifiedIdClassName() {
- return this.idClassName;
- }
-
- public void setSpecifiedIdClassName(String newClassName) {
- String oldClassName = this.idClassName;
- this.idClassName = newClassName;
- if (this.valuesAreDifferent(newClassName, oldClassName)) {
- if (newClassName != null) {
- if (getIdClassAnnotation() == null) {
- addIdClassAnnotation();
- }
- getIdClassAnnotation().setValue(newClassName);
- }
- else {
- removeIdClassAnnotation();
- }
- }
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected void setIdClassName_(String newClassName) {
- String oldClassName = this.idClassName;
- this.idClassName = newClassName;
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected String buildIdClassName() {
- IdClassAnnotation annotation = getIdClassAnnotation();
- if (annotation != null) {
- return annotation.getValue();
- }
- return null;
- }
-
- public String getDefaultIdClassName() {
- return null;
- }
-
- public String getIdClassName() {
- return getSpecifiedIdClassName();
- }
-
- public boolean isSpecified() {
- return getSpecifiedIdClassName() != null;
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClass;
- }
-
- protected void setIdClass_(JavaPersistentType newIdClass) {
- JavaPersistentType oldIdClass = this.idClass;
- this.idClass = newIdClass;
- firePropertyChanged(ID_CLASS_PROPERTY, oldIdClass, newIdClass);
- }
-
- protected JavaPersistentType buildIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- return (resourceIdClass == null) ?
- null : this.buildIdClass(resourceIdClass);
- }
-
- protected JavaPersistentType buildIdClass(JavaResourcePersistentType resourceClass) {
- return getJpaFactory().buildJavaPersistentType(this, resourceClass);
- }
-
- protected JavaResourcePersistentType getResourcePersistentType() {
- return getPersistentType().getResourcePersistentType();
- }
-
- protected IdClassAnnotation getIdClassAnnotation() {
- return (IdClassAnnotation) getResourcePersistentType().
- getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected void addIdClassAnnotation() {
- getResourcePersistentType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeIdClassAnnotation() {
- getResourcePersistentType().removeAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaResourcePersistentType getResourceIdClass() {
- return (this.fullyQualifiedIdClassName == null) ?
- null : getJpaProject().getJavaResourcePersistentType(this.fullyQualifiedIdClassName);
- }
-
- public String getFullyQualifiedIdClassName() {
- return this.fullyQualifiedIdClassName;
- }
-
- protected void setFullyQualifiedIdClassName(String idClass) {
- String old = this.fullyQualifiedIdClassName;
- this.fullyQualifiedIdClassName = idClass;
- this.firePropertyChanged(FULLY_QUALIFIED_ID_CLASS_PROPERTY, old, idClass);
- }
-
- protected String buildFullyQualifiedIdClassName() {
- IdClassAnnotation annotation = getIdClassAnnotation();
- return (annotation == null) ?
- null : annotation.getFullyQualifiedClassName();
- }
-
- public char getIdClassEnclosingTypeSeparator() {
- return '.';
- }
-
- public void initialize() {
- this.idClassName = buildIdClassName();
- this.fullyQualifiedIdClassName = this.buildFullyQualifiedIdClassName();
- this.idClass = buildIdClass();
- }
-
- public void update() {
- setIdClassName_(buildIdClassName());
- this.setFullyQualifiedIdClassName(this.buildFullyQualifiedIdClassName());
- updateIdClass();
- }
-
- protected void updateIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- if (resourceIdClass == null) {
- setIdClass_(null);
- }
- else {
- if (this.idClass == null || this.idClass.getResourcePersistentType() != resourceIdClass) {
- setIdClass_(buildIdClass(resourceIdClass));
- }
- this.idClass.update(resourceIdClass);
- }
- }
-
-
- // **************** validation ********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return (getIdClassAnnotation() == null) ?
- getTypeMapping().getValidationTextRange(astRoot)
- : getIdClassAnnotation().getTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java
deleted file mode 100644
index f671423307..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn.Owner;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-
-public class GenericJavaJoinColumnInAssociationOverrideJoiningStrategy
- extends AbstractJavaJoinColumnJoiningStrategy
- implements JavaJoinColumnInAssociationOverrideJoiningStrategy
-{
- protected transient AssociationOverrideAnnotation associationOverrideAnnotation;
-
- public GenericJavaJoinColumnInAssociationOverrideJoiningStrategy(JavaAssociationOverrideRelationshipReference parent) {
- super(parent);
- }
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- if (relationshipMapping != null) {
- return relationshipMapping.getRelationshipReference().isTargetForeignKeyRelationship();
- }
- return false;
- }
-
- public TypeMapping getRelationshipSource() {
- if (isTargetForeignKeyRelationship()) {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
- return getAssociationOverrideOwner().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- if (isTargetForeignKeyRelationship()) {
- return getAssociationOverrideOwner().getTypeMapping();
- }
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget != null) && (relationshipTarget.getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) ? (Entity) relationshipTarget : null;
- }
-
- @Override
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverrideOwner().getRelationshipMapping(getAttributeName());
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- @Override
- public String getTableName() {
- if (isTargetForeignKeyRelationship()) {
- return super.getTableName();
- }
- return getAssociationOverrideOwner().getDefaultTableName();
- }
-
- @Override
- public boolean tableNameIsInvalid(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.tableNameIsInvalid(tableName);
- }
- return getAssociationOverrideOwner().tableNameIsInvalid(tableName);
- }
-
- @Override
- public Iterator<String> candidateTableNames() {
- if (isTargetForeignKeyRelationship()) {
- return super.candidateTableNames();
- }
- return getAssociationOverrideOwner().candidateTableNames();
- }
-
- @Override
- public Table getDbTable(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.getDbTable(tableName);
- }
- return getAssociationOverrideOwner().getDbTable(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- protected JavaAssociationOverride getAssociationOverride() {
- return this.getRelationshipReference().getAssociationOverride();
- }
-
- protected JavaAssociationOverride.Owner getAssociationOverrideOwner() {
- return getAssociationOverride().getOwner();
- }
-
- @Override
- public JavaAssociationOverrideRelationshipReference getRelationshipReference() {
- return (JavaAssociationOverrideRelationshipReference) super.getRelationshipReference();
- }
-
- @Override
- protected ListIterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return this.associationOverrideAnnotation.joinColumns();
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.associationOverrideAnnotation);
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation(int index) {
- return this.associationOverrideAnnotation.addJoinColumn(index);
- }
-
- @Override
- protected void removeAnnotation(int index) {
- this.associationOverrideAnnotation.removeJoinColumn(index);
- }
-
- @Override
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.associationOverrideAnnotation.moveJoinColumn(targetIndex, sourceIndex);
- }
-
- public void initialize(AssociationOverrideAnnotation associationOverride) {
- this.associationOverrideAnnotation = associationOverride;
- super.initialize();
- }
-
- public void update(AssociationOverrideAnnotation associationOverride) {
- this.associationOverrideAnnotation = associationOverride;
- super.update();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
-// ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
-
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getAttributeName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return getAssociationOverrideOwner().buildColumnValidator(getAssociationOverride(), (BaseColumn) column, this, (BaseColumnTextRangeResolver) textRangeResolver);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java
deleted file mode 100644
index 859d781ec6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference;
-
-public class GenericJavaJoinColumnJoiningStrategy
- extends AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy
-{
-
- public GenericJavaJoinColumnJoiningStrategy(JavaJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public TypeMapping getRelationshipSource() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return getRelationshipTargetEntity();
- }
-
- @Override
- protected Entity getRelationshipTargetEntity() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java
deleted file mode 100644
index f2e1aaecae..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.java.JavaJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.InverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableValidator;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class GenericJavaJoinTableJoiningStrategy
- extends AbstractJavaJoinTableJoiningStrategy
-{
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
-
- public GenericJavaJoinTableJoiningStrategy(JavaJoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new JoinTableValidator((JoinTable) table, textRangeResolver);
- }
-
- public boolean isOverridableAssociation() {
- return getJpaPlatformVariation().isJoinTableOverridable();
- }
-
- @Override
- public JavaJoinTableEnabledRelationshipReference getParent() {
- return (JavaJoinTableEnabledRelationshipReference) super.getParent();
- }
-
- @Override
- public JavaJoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getRelationshipMapping().shouldValidateAgainstDatabase();
- }
-
-
- // **************** join table *********************************************
-
- @Override
- protected JoinTableAnnotation addAnnotation() {
- return (JoinTableAnnotation) this.resourcePersistentAttribute.
- addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void removeAnnotation() {
- this.resourcePersistentAttribute.
- removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- public void initialize() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- super.initialize();
- }
-
- @Override
- public void update() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- super.update();
- }
-
- public JoinTableAnnotation getAnnotation() {
- return (JoinTableAnnotation) this.resourcePersistentAttribute.
- getNonNullAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new InverseJoinColumnValidator(column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java
deleted file mode 100644
index 0844f8f36f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaManyToManyRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaManyToManyRelationshipReference
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- public GenericJavaManyToManyRelationshipReference(JavaManyToManyMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- public JavaManyToManyMapping getRelationshipMapping() {
- return (JavaManyToManyMapping) getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- return this.joinTableJoiningStrategy;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table joining strategy ***************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public void setJoinTableJoiningStrategy() {
- // join table is default option, so no need to add to resource
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java
deleted file mode 100644
index 7373ddbba2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.java.NullJavaJoinTableJoiningStrategy;
-
-public class GenericJavaManyToOneRelationshipReference
- extends AbstractJavaManyToOneRelationshipReference
-{
-
- public GenericJavaManyToOneRelationshipReference(JavaManyToOneMapping parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- // the only joining strategy
- return this.joinColumnJoiningStrategy;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java
deleted file mode 100644
index 6fe3a331a0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaMappedByJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaMappedByJoiningStrategy
-{
- protected OwnableRelationshipMappingAnnotation mappingAnnotation;
-
- protected String mappedByAttribute;
-
-
- public GenericJavaMappedByJoiningStrategy(JavaOwnableRelationshipReference parent) {
- super(parent);
- }
-
-
- @Override
- public JavaOwnableRelationshipReference getParent() {
- return (JavaOwnableRelationshipReference) super.getParent();
- }
-
- public JavaOwnableRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return getParent().getRelationshipMapping();
- }
-
- public String getTableName() {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? false : owner.getRelationshipReference().getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- //this will not be called if getRelationshipOwner() is null
- return getRelationshipOwner().getRelationshipReference().getPredominantJoiningStrategy().getColumnTableNotValidDescription();
- }
-
- protected RelationshipMapping getRelationshipOwner() {
- return getRelationshipMapping().getRelationshipOwner();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public boolean relationshipIsOwnedBy(RelationshipMapping otherMapping) {
- String thisEntity =
- (getRelationshipReference().getEntity()) == null ?
- null : getRelationshipReference().getEntity().getName();
- String otherTargetEntity =
- (otherMapping.getResolvedTargetEntity() == null) ?
- null : otherMapping.getResolvedTargetEntity().getName();
- return StringTools.stringsAreEqual(
- thisEntity,
- otherTargetEntity)
- && StringTools.stringsAreEqual(
- getMappedByAttribute(),
- otherMapping.getName());
- }
-
- public String getMappedByAttribute() {
- return this.mappedByAttribute;
- }
-
- public void setMappedByAttribute(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- this.mappingAnnotation.setMappedBy(newMappedByAttribute);
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- protected void setMappedByAttribute_(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- public void addStrategy() {
- if (this.mappedByAttribute == null) {
- setMappedByAttribute(""); //$NON-NLS-1$
- }
- }
-
- public void removeStrategy() {
- if (this.mappedByAttribute != null) {
- setMappedByAttribute(null);
- }
- }
-
- public void initialize() {
- this.mappingAnnotation = this.getRelationshipReference().getMappingAnnotation();
- this.mappedByAttribute = this.mappingAnnotation.getMappedBy();
- }
-
- public void update() {
- this.mappingAnnotation = this.getRelationshipReference().getMappingAnnotation();
- setMappedByAttribute_(this.mappingAnnotation.getMappedBy());
- }
-
- @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;
- }
- if (this.mappingAnnotation.mappedByTouches(pos, astRoot)) {
- result = javaCandidateMappedByAttributeNames(filter);
- }
- return result;
- }
-
- public Iterator<String> candidateMappedByAttributeNames() {
- return getRelationshipMapping().allTargetEntityAttributeNames();
- }
-
- public Iterator<String> candidateMappedByAttributeNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateMappedByAttributeNames(), filter);
- }
-
- protected Iterator<String> javaCandidateMappedByAttributeNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateMappedByAttributeNames(filter));
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.mappingAnnotation.getMappedByTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- if (getMappedByAttribute() == null) {
- return;
- }
-
- Entity targetEntity = this.getRelationshipMapping().getResolvedTargetEntity();
- if (targetEntity == null) {
- return; // null target entity is validated elsewhere
- }
-
- AttributeMapping mappedByMapping = targetEntity.resolveAttributeMapping(this.mappedByAttribute);
-
- if (mappedByMapping == null) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
- new String[] {this.mappedByAttribute},
- astRoot));
- return;
- }
-
- if (! this.getRelationshipReference().mayBeMappedBy(mappedByMapping)) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_INVALID_MAPPED_BY,
- new String[] {this.mappedByAttribute},
- astRoot));
- return;
- }
-
- // if mappedByMapping is not a relationship owner, then it should have
- // been flagged in above rule (mappedByIsValid)
- if (! ((RelationshipMapping) mappedByMapping).isRelationshipOwner()) {
- messages.add(buildMessage(
- JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
- new String[] {this.mappedByAttribute},
- astRoot));
- }
- }
-
- protected IMessage buildMessage(String msgID, String[] params, CompilationUnit astRoot) {
- PersistentAttribute attribute = getRelationshipMapping().getPersistentAttribute();
- String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
-
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(params, 0, attributeDesc),
- this,
- this.getValidationTextRange(astRoot));
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java
deleted file mode 100644
index a1cd310525..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.java.NullJavaJoinTableJoiningStrategy;
-
-public class GenericJavaOneToOneRelationshipReference
- extends AbstractJavaOneToOneRelationshipReference
-{
-
- public GenericJavaOneToOneRelationshipReference(JavaOneToOneMapping parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
- return this.joinColumnJoiningStrategy;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java
deleted file mode 100644
index b26539e2eb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.OneToOnePrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaPrimaryKeyJoinColumnJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaPrimaryKeyJoinColumnJoiningStrategy
-{
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
- protected final Vector<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = new Vector<JavaPrimaryKeyJoinColumn>();
- protected final JavaJoinColumn.Owner joinColumnOwner;
-
-
- public GenericJavaPrimaryKeyJoinColumnJoiningStrategy(
- JavaPrimaryKeyJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- @Override
- public JavaPrimaryKeyJoinColumnEnabledRelationshipReference getParent() {
- return (JavaPrimaryKeyJoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public JavaPrimaryKeyJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return getParent();
- }
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public String getTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- protected TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- // **************** primary key join columns *******************************
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return new CloneListIterator<JavaPrimaryKeyJoinColumn>(this.primaryKeyJoinColumns);
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.primaryKeyJoinColumns.size();
- }
-
- public boolean hasPrimaryKeyJoinColumns() {
- return ! this.primaryKeyJoinColumns.isEmpty();
- }
-
- public JavaPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn pkJoinColumn =
- getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.joinColumnOwner);
- this.primaryKeyJoinColumns.add(index, pkJoinColumn);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnAnnotation = addAnnotation(index);
- pkJoinColumn.initialize(pkJoinColumnAnnotation);
- fireItemAdded(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, pkJoinColumn);
- return pkJoinColumn;
- }
-
- protected void addPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn joinColumn) {
- addItemToList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn joinColumn) {
- addPrimaryKeyJoinColumn(this.primaryKeyJoinColumns.size(), joinColumn);
- }
-
- public void removePrimaryKeyJoinColumn(PrimaryKeyJoinColumn pkJoinColumn) {
- removePrimaryKeyJoinColumn(this.primaryKeyJoinColumns.indexOf(pkJoinColumn));
- }
-
- public void removePrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn pkJoinColumn = this.primaryKeyJoinColumns.remove(index);
- removeAnnotation(index);
- fireItemRemoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, pkJoinColumn);
- }
-
- protected void removePrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void movePrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.primaryKeyJoinColumns, targetIndex, sourceIndex);
- moveAnnotation(targetIndex, sourceIndex);
- fireItemMoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- protected PrimaryKeyJoinColumnAnnotation addAnnotation(int index) {
- return (PrimaryKeyJoinColumnAnnotation) this.resourcePersistentAttribute.
- addAnnotation(
- index,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeAnnotation(int index) {
- this.resourcePersistentAttribute.
- removeAnnotation(
- index,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.resourcePersistentAttribute.
- moveAnnotation(
- targetIndex,
- sourceIndex,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- public void addStrategy() {
- if (primaryKeyJoinColumnsSize() == 0) {
- addPrimaryKeyJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (PrimaryKeyJoinColumn each : CollectionTools.iterable(primaryKeyJoinColumns())) {
- removePrimaryKeyJoinColumn(each);
- }
- }
-
-
- // **************** resource -> context ************************************
-
- public void initialize() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- initializePrimaryKeyJoinColumns();
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- Iterator<NestableAnnotation> annotations =
- this.resourcePersistentAttribute.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (annotations.hasNext()) {
- this.primaryKeyJoinColumns.add(
- buildPrimaryKeyJoinColumn(
- (PrimaryKeyJoinColumnAnnotation) annotations.next()));
- }
- }
-
- public void update() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- updatePrimaryKeyJoinColumns();
- }
-
- protected void updatePrimaryKeyJoinColumns() {
- ListIterator<JavaPrimaryKeyJoinColumn> joinColumns = primaryKeyJoinColumns();
- Iterator<NestableAnnotation> annotations =
- this.resourcePersistentAttribute.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (joinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn joinColumn = joinColumns.next();
- if (annotations.hasNext()) {
- joinColumn.update(
- (PrimaryKeyJoinColumnAnnotation) annotations.next());
- }
- else {
- removePrimaryKeyJoinColumn_(joinColumn);
- }
- }
-
- while (annotations.hasNext()) {
- addPrimaryKeyJoinColumn(
- buildPrimaryKeyJoinColumn(
- (PrimaryKeyJoinColumnAnnotation) annotations.next()));
- }
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(
- PrimaryKeyJoinColumnAnnotation annotation) {
- JavaPrimaryKeyJoinColumn joinColumn =
- getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.joinColumnOwner);
- joinColumn.initialize(annotation);
- return joinColumn;
- }
-
-
- // **************** Java completion proposals ******************************
-
- @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;
- }
- for (JavaPrimaryKeyJoinColumn column : CollectionTools.iterable(this.primaryKeyJoinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- for (Iterator<JavaPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- }
-
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getTableName();
- }
-
- public Entity getRelationshipTarget() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getTypeMapping();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- Entity targetEntity = getRelationshipTarget();
- return (targetEntity == null) ? null : targetEntity.getPrimaryDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public String getDefaultColumnName() {
- return null;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public int joinColumnsSize() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.primaryKeyJoinColumnsSize();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new OneToOnePrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java
deleted file mode 100644
index 9b989cf72b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaBaseColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements BaseColumnTextRangeResolver
-{
-
- public JavaBaseColumnTextRangeResolver(JavaBaseColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaBaseColumn getColumn() {
- return (JavaBaseColumn) super.getColumn();
- }
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java
deleted file mode 100644
index 1f6ae3ca21..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-
-public class JavaBasicMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaBasicMappingDefinition INSTANCE =
- new JavaBasicMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaBasicMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return BasicAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaBasicMapping(parent);
- }
-
- @Override
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.typeIsBasic();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java
deleted file mode 100644
index 2a94eab3b8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-
-public class JavaEmbeddableDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddableDefinition INSTANCE =
- new JavaEmbeddableDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEmbeddableDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddableAnnotation.ANNOTATION_NAME;
- }
-
- public JavaEmbeddable buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaEmbeddable(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
deleted file mode 100644
index fe78cadb6a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-
-public class JavaEmbeddedIdMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddedIdMappingDefinition INSTANCE =
- new JavaEmbeddedIdMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singletong usage
- */
- private JavaEmbeddedIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddedIdAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaEmbeddedIdMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java
deleted file mode 100644
index 5910a5327e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-
-public class JavaEmbeddedMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddedMappingDefinition INSTANCE =
- new JavaEmbeddedMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEmbeddedMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddedAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaEmbeddedMapping(parent);
- }
-
- @Override
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getEmbeddable() != null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java
deleted file mode 100644
index 58df102ce8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-
-public class JavaEntityDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaEntityDefinition INSTANCE =
- new JavaEntityDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEntityDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EntityAnnotation.ANNOTATION_NAME;
- }
-
- public JavaEntity buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaEntity(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java
deleted file mode 100644
index 944789b3fa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaEntityTextRangeResolver
- implements EntityTextRangeResolver
-{
- private JavaEntity entity;
-
- private CompilationUnit astRoot;
-
-
- public JavaEntityTextRangeResolver(JavaEntity entity, CompilationUnit astRoot) {
- this.entity = entity;
- this.astRoot = astRoot;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.entity.getValidationTextRange(this.astRoot);
- }
-
- public TextRange getIdClassTextRange() {
- return this.entity.getIdClassReference().getValidationTextRange(this.astRoot);
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.entity.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java
deleted file mode 100644
index 3e6e059340..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-
-public class JavaIdMappingDefinition
- extends AbstractJavaIdMappingDefinition
-{
- // singleton
- private static final JavaIdMappingDefinition INSTANCE =
- new JavaIdMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaIdMappingDefinition() {
- super();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
deleted file mode 100644
index 86843504fd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaJoinColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements
- BaseColumnTextRangeResolver,
- JoinColumnTextRangeResolver
-{
-
- public JavaJoinColumnTextRangeResolver(JavaJoinColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaJoinColumn getColumn() {
- return (JavaJoinColumn) super.getColumn();
- }
-
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange(this.astRoot);
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java
deleted file mode 100644
index e8e8382779..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-
-public class JavaManyToManyMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaManyToManyMappingDefinition INSTANCE =
- new JavaManyToManyMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaManyToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return ManyToManyAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaManyToManyMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java
deleted file mode 100644
index 6eef2bbd55..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-
-public class JavaManyToOneMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaManyToOneMappingDefinition INSTANCE =
- new JavaManyToOneMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaManyToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaManyToOneMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java
deleted file mode 100644
index d14c61cb57..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-
-public class JavaMappedSuperclassDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaMappedSuperclassDefinition INSTANCE =
- new JavaMappedSuperclassDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaMappedSuperclassDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return MappedSuperclassAnnotation.ANNOTATION_NAME;
- }
-
- public JavaMappedSuperclass buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaMappedSuperclass(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java
deleted file mode 100644
index 35f5d8ae22..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaMappedSuperclassTextRangeResolver
- implements PrimaryKeyTextRangeResolver
-{
- private JavaMappedSuperclass mappedSuperclass;
-
- private CompilationUnit astRoot;
-
-
- public JavaMappedSuperclassTextRangeResolver(
- JavaMappedSuperclass mappedSuperclass, CompilationUnit astRoot) {
-
- this.mappedSuperclass = mappedSuperclass;
- this.astRoot = astRoot;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.mappedSuperclass.getValidationTextRange(this.astRoot);
- }
-
- public TextRange getIdClassTextRange() {
- return this.mappedSuperclass.getIdClassReference().getValidationTextRange(this.astRoot);
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.mappedSuperclass.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java
deleted file mode 100644
index 4c10481f0f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaNamedColumnTextRangeResolver
- implements NamedColumnTextRangeResolver
-{
- protected final JavaNamedColumn javaNamedColumn;
-
- protected final CompilationUnit astRoot;
-
- public JavaNamedColumnTextRangeResolver(JavaNamedColumn javaNamedColumn, CompilationUnit astRoot) {
- this.javaNamedColumn = javaNamedColumn;
- this.astRoot = astRoot;
- }
-
- protected JavaNamedColumn getColumn() {
- return this.javaNamedColumn;
- }
-
- public TextRange getNameTextRange() {
- return this.javaNamedColumn.getNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
deleted file mode 100644
index cbb5e22867..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public class JavaNullTypeMapping extends AbstractJavaTypeMapping
-{
- public JavaNullTypeMapping(JavaPersistentType parent) {
- super(parent);
- }
-
- public String getAnnotationName() {
- return null;
- }
-
- public String getKey() {
- return MappingKeys.NULL_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return false;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- /**
- * We added this message here because the most likely solution is to add
- * an annotation to the .java file.
- * This message used to be found on the <class> tag in persistence.xml.
- * The other possible way to fix the error is to remove it from persistence.xml.
- * This can be accomplished with the Synchronize Classes action.
- * We could also add a quick fix for this error.
- */
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_INVALID_CLASS,
- new String[] {this.getPersistentType().getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getPersistentType().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java
deleted file mode 100644
index 019d6f8c3d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-
-public class JavaOneToManyMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaOneToManyMappingDefinition INSTANCE =
- new JavaOneToManyMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaOneToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaOneToManyMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java
deleted file mode 100644
index c785d6cf0d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-
-public class JavaOneToOneMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaOneToOneMappingDefinition INSTANCE =
- new JavaOneToOneMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaOneToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaOneToOneMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java
deleted file mode 100644
index 598b53d31d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaOverride;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaOverrideTextRangeResolver
- implements OverrideTextRangeResolver
-{
- protected final JavaOverride javaOverride;
-
- protected final CompilationUnit astRoot;
-
- public JavaOverrideTextRangeResolver(JavaOverride javaOverride, CompilationUnit astRoot) {
- this.javaOverride = javaOverride;
- this.astRoot = astRoot;
- }
-
- protected JavaOverride getOverride() {
- return this.javaOverride;
- }
-
- public TextRange getNameTextRange() {
- return this.javaOverride.getNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java
deleted file mode 100644
index 4b9da4bce3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaPersistentAttributeTextRangeResolver
- implements PersistentAttributeTextRangeResolver
-{
- private JavaPersistentAttribute javaPersistentAttribute;
-
- private CompilationUnit astRoot;
-
- public JavaPersistentAttributeTextRangeResolver(JavaPersistentAttribute javaPersistentAttribute, CompilationUnit astRoot) {
- this.javaPersistentAttribute = javaPersistentAttribute;
- this.astRoot = astRoot;
- }
-
- public TextRange getAttributeTextRange() {
- return this.javaPersistentAttribute.getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java
deleted file mode 100644
index 1c7d6eafe6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaPrimaryKeyJoinColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements
- BaseJoinColumnTextRangeResolver
-{
-
- public JavaPrimaryKeyJoinColumnTextRangeResolver(JavaPrimaryKeyJoinColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaPrimaryKeyJoinColumn getColumn() {
- return (JavaPrimaryKeyJoinColumn) super.getColumn();
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java
deleted file mode 100644
index 3c8479c886..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaBaseTable;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaTableTextRangeResolver
- implements TableTextRangeResolver
-{
- protected final JavaBaseTable javaTable;
-
- protected final CompilationUnit astRoot;
-
- public JavaTableTextRangeResolver(JavaBaseTable javaTable, CompilationUnit astRoot) {
- this.javaTable = javaTable;
- this.astRoot = astRoot;
- }
-
- protected JavaBaseTable getTable() {
- return this.javaTable;
- }
-
- public TextRange getNameTextRange() {
- return this.javaTable.getNameTextRange(this.astRoot);
- }
-
- public TextRange getCatalogTextRange() {
- return this.javaTable.getCatalogTextRange(this.astRoot);
- }
-
- public TextRange getSchemaTextRange() {
- return this.javaTable.getSchemaTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java
deleted file mode 100644
index 197f4e9512..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-
-public class JavaTransientMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaTransientMappingDefinition INSTANCE =
- new JavaTransientMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaTransientMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return TransientAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaTransientMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java
deleted file mode 100644
index 5cf551e98b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaTypeMappingTextRangeResolver
- implements TypeMappingTextRangeResolver
-{
- private JavaTypeMapping typeMapping;
-
- private CompilationUnit astRoot;
-
- public JavaTypeMappingTextRangeResolver(JavaTypeMapping typeMapping, CompilationUnit astRoot) {
- this.typeMapping = typeMapping;
- this.astRoot = astRoot;
- }
-
- public TextRange getTypeMappingTextRange() {
- return this.typeMapping.getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java
deleted file mode 100644
index dc674b492a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-
-public class JavaVersionMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaVersionMappingDefinition INSTANCE =
- new JavaVersionMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaVersionMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return VersionAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaVersionMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java
deleted file mode 100644
index debfe67de5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * javax.persistence.AssociationOverride
- */
-public abstract class VirtualAssociationOverrideAnnotation
- extends VirtualOverrideAnnotation
- implements AssociationOverrideAnnotation
-{
- protected JoiningStrategy joiningStrategy;
-
- private final Vector<JoinColumnAnnotation> joinColumns;
-
- protected VirtualAssociationOverrideAnnotation(JavaResourcePersistentMember parent, String name, JoiningStrategy joiningStrategy) {
- super(parent, name);
- this.joiningStrategy = joiningStrategy;
- this.joinColumns = this.buildJoinColumns();
- }
-
- protected Vector<JoinColumnAnnotation> buildJoinColumns() {
- if (this.joiningStrategy instanceof JoinColumnJoiningStrategy) {
- Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(((JoinColumnJoiningStrategy) this.joiningStrategy).joinColumnsSize());
- for (JoinColumn joinColumn : CollectionTools.iterable(((JoinColumnJoiningStrategy) this.joiningStrategy).joinColumns())) {
- result.add(new VirtualAssociationOverrideJoinColumnAnnotation(this, joinColumn));
- }
- return result;
- }
- return new Vector<JoinColumnAnnotation>();
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected AssociationOverrideAnnotation addAnnotation() {
- return (AssociationOverrideAnnotation) super.addAnnotation();
- }
-
- // ***** join columns
- public ListIterator<JoinColumnAnnotation> joinColumns() {
- return this.joinColumns.listIterator();
- }
-
- public JoinColumnAnnotation joinColumnAt(int index) {
- return this.joinColumns.elementAt(index);
- }
-
- public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) {
- return this.joinColumns.indexOf(joinColumn);
- }
-
- public int joinColumnsSize() {
- return this.joinColumns.size();
- }
-
- public JoinColumnAnnotation addJoinColumn(int index) {
- throw new UnsupportedOperationException();
- }
-
- public void removeJoinColumn(int index) {
- throw new UnsupportedOperationException();
- }
-
- public void moveJoinColumn(int targetIndex, int sourceIndex) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- super.synchronizeWith(astRoot);
- //Rebuilt every time so no need to implement update()
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java
deleted file mode 100644
index b782216bfb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.internal.resource.java.NullBaseColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * javax.persistence.Column
- */
-public final class VirtualAssociationOverrideJoinColumnAnnotation extends NullBaseColumnAnnotation
- implements JoinColumnAnnotation
-{
- private JoinColumn joinColumn;
-
- public VirtualAssociationOverrideJoinColumnAnnotation(Annotation parent, JoinColumn joinColumn) {
- super(parent);
- this.joinColumn = joinColumn;
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getName() {
- return this.joinColumn.getSpecifiedName();
- }
-
- @Override
- public void setName(String name) {
- throw new UnsupportedOperationException();
- }
-
- public String getReferencedColumnName() {
- return this.joinColumn.getSpecifiedReferencedColumnName();
- }
-
- public void setReferencedColumnName(String referencedColumnName) {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) {
- return null;
- }
-
- public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) {
- return false;
- }
-
- @Override
- public String getColumnDefinition() {
- return this.joinColumn.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String columnDefinition) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getTable() {
- return this.joinColumn.getSpecifiedTable();
- }
-
- @Override
- public void setTable(String table) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getInsertable() {
- return this.joinColumn.getSpecifiedInsertable();
- }
-
- @Override
- public void setInsertable(Boolean insertable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getUpdatable() {
- return this.joinColumn.getSpecifiedUpdatable();
- }
-
- @Override
- public void setUpdatable(Boolean updatable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getNullable() {
- return this.joinColumn.getSpecifiedNullable();
- }
-
- @Override
- public void setNullable(Boolean nullable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getUnique() {
- return this.joinColumn.getSpecifiedUnique();
- }
-
- @Override
- public void setUnique(Boolean unique) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java
deleted file mode 100644
index 25e71fa18e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.context.java;
-
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-
-/**
- * javax.persistence.AssociationOverride
- */
-public class VirtualAttributeOverrideAnnotation
- extends VirtualOverrideAnnotation
- implements AttributeOverrideAnnotation
-{
- private final VirtualAttributeOverrideColumnAnnotation column;
-
-
- public VirtualAttributeOverrideAnnotation(JavaResourcePersistentMember parent, String name, Column column) {
- super(parent, name);
- this.column = new VirtualAttributeOverrideColumnAnnotation(this, column);
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected AttributeOverrideAnnotation addAnnotation() {
- return (AttributeOverrideAnnotation) super.addAnnotation();
- }
-
- // ****** column
- public ColumnAnnotation getColumn() {
- return this.column;
- }
-
- public ColumnAnnotation getNonNullColumn() {
- return this.getColumn();
- }
-
- public ColumnAnnotation addColumn() {
- throw new UnsupportedOperationException();
- }
-
- public void removeColumn() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java
deleted file mode 100644
index 89ebcab07c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 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.context.java;
-
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-
-/**
- * javax.persistence.Column
- */
-public class VirtualAttributeOverrideColumnAnnotation
- extends NullAttributeOverrideColumnAnnotation
-{
- private Column column;
-
- public VirtualAttributeOverrideColumnAnnotation(AttributeOverrideAnnotation parent, Column column) {
- super(parent);
- this.column = column;
- }
-
- @Override
- public String getName() {
- return this.column.getSpecifiedName();
- }
-
- @Override
- public String getColumnDefinition() {
- return this.column.getColumnDefinition();
- }
-
- @Override
- public String getTable() {
- return this.column.getSpecifiedTable();
- }
-
- @Override
- public Boolean getInsertable() {
- return this.column.getSpecifiedInsertable();
- }
-
- @Override
- public Boolean getUpdatable() {
- return this.column.getSpecifiedUpdatable();
- }
-
- @Override
- public Boolean getNullable() {
- return this.column.getSpecifiedNullable();
- }
-
- @Override
- public Boolean getUnique() {
- return this.column.getSpecifiedUnique();
- }
-
- @Override
- public Integer getLength() {
- return this.column.getSpecifiedLength();
- }
-
- @Override
- public Integer getScale() {
- return this.column.getSpecifiedScale();
- }
-
- @Override
- public Integer getPrecision() {
- return this.column.getSpecifiedPrecision();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java
deleted file mode 100644
index 01f16152ed..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.NullAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.OverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Common behavior for virtual versions of
- * javax.persistence.AttributeOverride
- * and
- * javax.persistence.AssociationOverride
- */
-public abstract class VirtualOverrideAnnotation
- extends NullAnnotation
- implements OverrideAnnotation
-{
- private final String name;
-
- public VirtualOverrideAnnotation(JavaResourcePersistentMember parent, String name) {
- super(parent);
- this.name = name;
- }
-
- @Override
- protected OverrideAnnotation addAnnotation() {
- return (OverrideAnnotation) super.addAnnotation();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (name != null) {
- this.addAnnotation().setName(name);
- }
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return null;
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return false;
- }
-
-}

Back to the top