Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java320
1 files changed, 0 insertions, 320 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java
deleted file mode 100644
index 47085a1fde..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 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.jpa.core.internal.jpa1.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.OverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.internal.context.java.GenericJavaOverrideJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaOverrideJoinTableRelationshipStrategy2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MappingRelationshipStrategy2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverride2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOverrideRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaOverrideRelationship
- extends AbstractJavaJpaContextNode
- implements JavaOverrideRelationship2_0
-{
- protected JavaRelationshipStrategy strategy;
-
- protected final JavaJoinColumnRelationshipStrategy joinColumnStrategy;
-
- // JPA 2.0
- protected final JavaJoinTableRelationshipStrategy joinTableStrategy;
-
-
- public GenericJavaOverrideRelationship(JavaAssociationOverride parent) {
- super(parent);
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.setStrategy(this.buildStrategy());
- this.joinColumnStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- public JavaRelationshipStrategy getStrategy() {
- return this.strategy;
- }
-
- protected void setStrategy(JavaRelationshipStrategy strategy) {
- JavaRelationshipStrategy old = this.strategy;
- this.strategy = strategy;
- this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy);
- }
-
- protected JavaRelationshipStrategy buildStrategy() {
- return this.isJpa2_0Compatible() ?
- this.buildStrategy2_0() :
- this.joinColumnStrategy;
- }
-
- /**
- * The overridden mapping determines the override's strategy.
- */
- protected JavaRelationshipStrategy buildStrategy2_0() {
- MappingRelationshipStrategy2_0 mappingStrategy = this.getMappingStrategy();
- return (mappingStrategy != null) ?
- (JavaRelationshipStrategy) mappingStrategy.selectOverrideStrategy(this) :
- this.buildMissingMappingStrategy();
- }
-
- /**
- * Get the strategy from the overridden mapping.
- */
- protected MappingRelationshipStrategy2_0 getMappingStrategy() {
- RelationshipMapping mapping = this.getMapping();
- return (mapping == null) ? null : (MappingRelationshipStrategy2_0) mapping.getRelationship().getStrategy();
- }
-
- /**
- * Return the strategy to use when the override's name does not match the
- * name of an appropriate relationship mapping.
- */
- protected JavaRelationshipStrategy buildMissingMappingStrategy() {
- return this.joinColumnStrategy.hasSpecifiedJoinColumns() ?
- this.joinColumnStrategy :
- this.joinTableStrategy;
- }
-
-
- // ********** join column strategy **********
-
- public JavaJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- throw new UnsupportedOperationException();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- // association overrides do not have defaults
- return false;
- }
-
- protected JavaJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return new GenericJavaOverrideJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public JavaJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public void setStrategyToJoinTable() {
- throw new UnsupportedOperationException();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- // association overrides do not have defaults
- return false;
- }
-
- protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return this.isJpa2_0Compatible() ?
- new GenericJavaOverrideJoinTableRelationshipStrategy2_0(this) :
- new NullJavaJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeFrom(ReadOnlyRelationship oldRelationship) {
- oldRelationship.initializeOn(this);
- }
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromJoinTableRelationship(this);
- newRelationship.initializeFromJoinColumnRelationship(this);
- }
-
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- // NOP
- }
-
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
- public void initializeFromVirtual(ReadOnlyOverrideRelationship virtualRelationship) {
- virtualRelationship.initializeOnSpecified(this);
- }
-
- public void initializeOnSpecified(OverrideRelationship specifiedRelationship) {
- throw new UnsupportedOperationException();
- }
-
- public void initializeFromVirtualJoinTableRelationship(ReadOnlyJoinTableRelationship virtualRelationship) {
- this.joinTableStrategy.initializeFromVirtual(virtualRelationship.getJoinTableStrategy());
- }
-
- public void initializeFromVirtualJoinColumnRelationship(ReadOnlyJoinColumnRelationship virtualRelationship) {
- this.joinColumnStrategy.initializeFromVirtual(virtualRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaAssociationOverride getParent() {
- return (JavaAssociationOverride) super.getParent();
- }
-
- protected JavaAssociationOverride getAssociationOverride() {
- return this.getParent();
- }
-
- protected JavaAssociationOverride2_0 getAssociationOverride2_0() {
- return (JavaAssociationOverride2_0) this.getAssociationOverride();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getAssociationOverride().getTypeMapping();
- }
-
- public String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getAssociationOverride().tableNameIsInvalid(tableName);
- }
-
- public Iterable<String> getCandidateTableNames() {
- return this.getAssociationOverride().getCandidateTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getAssociationOverride().resolveDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return this.getAssociationOverride().getDefaultTableName();
- }
-
- public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) {
- return this.getAssociationOverride().buildColumnValidator(column, owner, textRangeResolver);
- }
-
- public AssociationOverrideAnnotation getOverrideAnnotation() {
- return this.getAssociationOverride().getOverrideAnnotation();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = this.getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isVirtual() {
- return false;
- }
-
- public RelationshipMapping getMapping() {
- return this.getAssociationOverride().getMapping();
- }
-
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return this.strategy.getJavaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getAssociationOverride().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.strategy.validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) {
- return this.getAssociationOverride2_0().buildJoinTableValidator(table, textRangeResolver);
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return this.getAssociationOverride2_0().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver);
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver);
- }
-}

Back to the top