301437 - refactored 1-m relationship reference joinColumnJoiningStrategy to remove some duplication
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
index 5ae75dc..6299d97 100644
--- 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * 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
@@ -16,6 +16,7 @@
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;
@@ -32,12 +33,15 @@
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() {
@@ -47,6 +51,8 @@
protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
return new GenericJavaJoinTableJoiningStrategy(this);
}
+
+ protected abstract JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy();
@Override
public JavaOneToManyMapping getRelationshipMapping() {
@@ -74,6 +80,9 @@
if (result == null) {
result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
}
+ if (result == null) {
+ result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
+ }
return result;
}
@@ -92,6 +101,7 @@
protected void setMappedByJoiningStrategy_() {
this.mappedByJoiningStrategy.addStrategy();
this.joinTableJoiningStrategy.removeStrategy();
+ this.joinColumnJoiningStrategy.removeStrategy();
}
public final void unsetMappedByJoiningStrategy() {
@@ -130,6 +140,7 @@
protected void setJoinTableJoiningStrategy_() {
// join table is default, so no need to add annotation
this.mappedByJoiningStrategy.removeStrategy();
+ this.joinColumnJoiningStrategy.removeStrategy();
}
public final void unsetJoinTableJoiningStrategy() {
@@ -142,7 +153,36 @@
}
public boolean mayHaveDefaultJoinTable() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
+ 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 this.mappedByJoiningStrategy.getMappedByAttribute() == null
+ && this.joinTableJoiningStrategy.getJoinTable() == null;
}
@@ -152,12 +192,14 @@
protected void initializeJoiningStrategies() {
this.mappedByJoiningStrategy.initialize();
this.joinTableJoiningStrategy.initialize();
+ this.joinColumnJoiningStrategy.initialize();
}
@Override
protected void updateJoiningStrategies() {
this.mappedByJoiningStrategy.update();
this.joinTableJoiningStrategy.update();
+ this.joinColumnJoiningStrategy.update();
}
@@ -168,5 +210,6 @@
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/orm/AbstractOrmOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java
index ebe6d24..800a1b6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * 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
@@ -14,6 +14,7 @@
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.orm.OrmJoinColumnJoiningStrategy;
import org.eclipse.jpt.core.context.orm.OrmJoinTable;
import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
@@ -31,10 +32,11 @@
implements OrmOneToManyRelationshipReference2_0
{
protected OrmMappedByJoiningStrategy mappedByJoiningStrategy;
-
+
protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
+
+ protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
+
protected AbstractOrmOneToManyRelationshipReference(
OrmOneToManyMapping parent, XmlOneToMany resource) {
super(parent, resource);
@@ -44,6 +46,7 @@
@Override
protected void initializeJoiningStrategies() {
this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
+ this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
// initialize join table last, as the existence of a default join
// table is dependent on the other mechanisms (mappedBy)
@@ -58,6 +61,8 @@
protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping());
}
+
+ protected abstract OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy();
public void initializeOn(OrmRelationshipReference newRelationshipReference) {
newRelationshipReference.initializeFromOwnableRelationshipReference(this);
@@ -115,6 +120,7 @@
protected void setMappedByJoiningStrategy_() {
this.mappedByJoiningStrategy.addStrategy();
this.joinTableJoiningStrategy.removeStrategy();
+ this.joinColumnJoiningStrategy.removeStrategy();
}
public final void unsetMappedByJoiningStrategy() {
@@ -153,6 +159,7 @@
protected void setJoinTableJoiningStrategy_() {
// join table is default, so no need to add to resource
this.mappedByJoiningStrategy.removeStrategy();
+ this.joinColumnJoiningStrategy.removeStrategy();
}
public final void unsetJoinTableJoiningStrategy() {
@@ -165,7 +172,35 @@
}
public boolean mayHaveDefaultJoinTable() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
+ return this.mappedByJoiningStrategy.getMappedByAttribute() == null
+ && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
+ }
+
+
+ // **************** join columns *******************************************
+
+ public OrmJoinColumnJoiningStrategy 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;
}
@@ -174,6 +209,7 @@
@Override
protected void updateJoiningStrategies() {
this.mappedByJoiningStrategy.update();
+ this.joinColumnJoiningStrategy.update();
// update join table last, as the existence of a default join
// table is dependent on the other mechanisms (mappedBy)
@@ -189,5 +225,6 @@
super.validate(messages, reporter);
this.mappedByJoiningStrategy.validate(messages, reporter);
this.joinTableJoiningStrategy.validate(messages, reporter);
+ this.joinColumnJoiningStrategy.validate(messages, reporter);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOneToManyRelationshipReference.java
index 47cccff..5c60531 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOneToManyRelationshipReference.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOneToManyRelationshipReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * 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
@@ -18,35 +18,34 @@
public class GenericJavaOneToManyRelationshipReference
extends AbstractJavaOneToManyRelationshipReference
{
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
public GenericJavaOneToManyRelationshipReference(JavaOneToManyMapping parent) {
super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
}
+ @Override
protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new NullJavaJoinColumnJoiningStrategy(this);
}
// **************** join columns *******************************************
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
+ @Override
public boolean usesJoinColumnJoiningStrategy() {
return false;
}
+ @Override
public void setJoinColumnJoiningStrategy() {
throw new UnsupportedOperationException("join column joining strategy not supported on a 1.0 1-m mapping"); //$NON-NLS-1$
}
+ @Override
public void unsetJoinColumnJoiningStrategy() {
throw new UnsupportedOperationException("join column joining strategy not supported on a 1.0 1-m mapping"); //$NON-NLS-1$
}
+ @Override
public boolean mayHaveDefaultJoinColumn() {
return false;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/NullJavaJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/NullJavaJoinColumnJoiningStrategy.java
index 21085ad..abc3147 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/NullJavaJoinColumnJoiningStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/NullJavaJoinColumnJoiningStrategy.java
@@ -53,7 +53,7 @@
}
public void removeStrategy() {
- throw new UnsupportedOperationException();
+ //do nothing, no join column to remove
}
@@ -86,7 +86,7 @@
}
public boolean hasSpecifiedJoinColumns() {
- throw new UnsupportedOperationException();
+ return false;
}
public JavaJoinColumn addSpecifiedJoinColumn(int index) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOneToManyRelationshipReference.java
index f430455..6244252 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOneToManyRelationshipReference.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOneToManyRelationshipReference.java
@@ -19,7 +19,6 @@
public class GenericOrmOneToManyRelationshipReference
extends AbstractOrmOneToManyRelationshipReference
{
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
public GenericOrmOneToManyRelationshipReference(
OrmOneToManyMapping parent, XmlOneToMany resource) {
@@ -28,12 +27,6 @@
}
@Override
- protected void initializeJoiningStrategies() {
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- super.initializeJoiningStrategies();
- }
-
-
protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new NullOrmJoinColumnJoiningStrategy(this);
}
@@ -50,24 +43,23 @@
// **************** join columns *******************************************
- public OrmJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
+ @Override
public boolean usesJoinColumnJoiningStrategy() {
return false;
}
+ @Override
public void setJoinColumnJoiningStrategy() {
throw new UnsupportedOperationException("join column joining strategy not supported on a 1.0 1-m mapping"); //$NON-NLS-1$
}
+ @Override
public void unsetJoinColumnJoiningStrategy() {
throw new UnsupportedOperationException("join column joining strategy not supported on a 1.0 1-m mapping"); //$NON-NLS-1$
}
+ @Override
public boolean mayHaveDefaultJoinColumn() {
return false;
}
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/NullOrmJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/NullOrmJoinColumnJoiningStrategy.java
index b1dd4aa..2c5f2be 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/NullOrmJoinColumnJoiningStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/NullOrmJoinColumnJoiningStrategy.java
@@ -52,7 +52,7 @@
}
public void removeStrategy() {
- throw new UnsupportedOperationException();
+ //do nothing, no join column to remove
}
@@ -84,7 +84,7 @@
}
public boolean hasSpecifiedJoinColumns() {
- throw new UnsupportedOperationException();
+ return false;
}
public OrmJoinColumn addSpecifiedJoinColumn(int index) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java
index 73468cd..46f6187 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java
@@ -10,43 +10,24 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.jpa2.context.java;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.JoiningStrategy;
import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToManyRelationshipReference;
import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinColumnJoiningStrategy;
-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 GenericJavaOneToManyRelationshipReference2_0
extends AbstractJavaOneToManyRelationshipReference
{
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
public GenericJavaOneToManyRelationshipReference2_0(JavaOneToManyMapping parent) {
super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
}
+ @Override
protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new GenericJavaJoinColumnJoiningStrategy(this);
}
-
- @Override
- protected void initializeJoiningStrategies() {
- this.joinColumnJoiningStrategy.initialize();
- super.initializeJoiningStrategies();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.joinColumnJoiningStrategy.update();
- super.updateJoiningStrategies();
- }
@Override
protected JoiningStrategy calculatePredominantJoiningStrategy() {
@@ -60,70 +41,4 @@
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.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
- // **************** mapped by **********************************************
-
- @Override
- protected void setMappedByJoiningStrategy_() {
- super.setMappedByJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- // **************** join table *********************************************
-
- @Override
- protected void setJoinTableJoiningStrategy_() {
- super.setJoinTableJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
- public boolean mayHaveDefaultJoinTable() {
- return super.mayHaveDefaultJoinTable()
- && ! 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 this.mappedByJoiningStrategy.getMappedByAttribute() == null
- && this.joinTableJoiningStrategy.getJoinTable() == null;
- }
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.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/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java
index e5c9dcf..0a527b4 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.jpa2.context.orm;
-import java.util.List;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.JoinColumn;
@@ -24,14 +23,10 @@
import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinColumnJoiningStrategy;
import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class GenericOrmOneToManyRelationshipReference2_0
extends AbstractOrmOneToManyRelationshipReference
{
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
public GenericOrmOneToManyRelationshipReference2_0(
OrmOneToManyMapping parent, XmlOneToMany resource) {
@@ -39,22 +34,16 @@
}
@Override
- protected void initializeJoiningStrategies() {
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- super.initializeJoiningStrategies();
- }
-
-
protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new GenericOrmJoinColumnJoiningStrategy(this, getResourceMapping());
}
-
+
@Override
public void initializeOn(OrmRelationshipReference newRelationshipReference) {
super.initializeOn(newRelationshipReference);
newRelationshipReference.initializeFromJoinColumnEnabledRelationshipReference(this);
}
-
+
@Override
public void initializeFromJoinColumnEnabledRelationshipReference(
OrmJoinColumnEnabledRelationshipReference oldRelationshipReference) {
@@ -63,16 +52,11 @@
for (JoinColumn joinColumn :
CollectionTools.iterable(
oldRelationshipReference.getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- OrmJoinColumn newJoinColumn = getJoinColumnJoiningStrategy().addSpecifiedJoinColumn(index++);
+ OrmJoinColumn newJoinColumn = this.joinColumnJoiningStrategy.addSpecifiedJoinColumn(index++);
newJoinColumn.initializeFrom(joinColumn);
}
}
-
- @Override
- public XmlOneToMany getResourceMapping() {
- return super.getResourceMapping();
- }
-
+
@Override
protected OrmJoiningStrategy calculatePredominantJoiningStrategy() {
if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
@@ -90,74 +74,8 @@
// **************** mapped by **********************************************
@Override
- protected void setMappedByJoiningStrategy_() {
- super.setMappedByJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
return super.mayBeMappedBy(mappedByMapping) ||
mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
}
-
-
- // **************** join table *********************************************
-
- @Override
- protected void setJoinTableJoiningStrategy_() {
- super.setJoinTableJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
- public boolean mayHaveDefaultJoinTable() {
- return super.mayHaveDefaultJoinTable()
- && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
- }
-
-
- // **************** join columns *******************************************
-
- public OrmJoinColumnJoiningStrategy 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 updateJoiningStrategies() {
- this.joinColumnJoiningStrategy.update();
- super.updateJoiningStrategies();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkOneToManyRelationshipReference.java
index b8e6f56..65f33a1 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkOneToManyRelationshipReference.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkOneToManyRelationshipReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Oracle.
+ * 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
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.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;
@@ -20,24 +17,18 @@
import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToManyRelationshipReference;
import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinColumnJoiningStrategy;
import org.eclipse.jpt.eclipselink.core.v2_0.context.EclipseLinkOneToManyRelationshipReference2_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 class JavaEclipseLinkOneToManyRelationshipReference
extends AbstractJavaOneToManyRelationshipReference
implements EclipseLinkOneToManyRelationshipReference2_0
{
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
-
public JavaEclipseLinkOneToManyRelationshipReference(
JavaEclipseLinkOneToManyMapping parent) {
super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
}
+ @Override
protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new GenericJavaJoinColumnJoiningStrategy(this);
}
@@ -61,95 +52,12 @@
}
}
- @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);
- }
- return result;
- }
-
// **************** mapped by **********************************************
@Override
- protected void setMappedByJoiningStrategy_() {
- super.setMappedByJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
return super.mayBeMappedBy(mappedByMapping) ||
mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
}
-
-
- // **************** join table *********************************************
-
- @Override
- protected void setJoinTableJoiningStrategy_() {
- super.setJoinTableJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
- public boolean mayHaveDefaultJoinTable() {
- return super.mayHaveDefaultJoinTable()
- && ! 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 this.mappedByJoiningStrategy.getMappedByAttribute() == null
- && this.joinTableJoiningStrategy.getJoinTable() == null;
- }
-
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.joinColumnJoiningStrategy.initialize();
- super.initializeJoiningStrategies();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.joinColumnJoiningStrategy.update();
- super.updateJoiningStrategies();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkOneToManyRelationshipReference.java
index 5904a72..abdfdd6 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkOneToManyRelationshipReference.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkOneToManyRelationshipReference.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.core.internal.context.orm;
-import java.util.List;
import org.eclipse.jpt.core.MappingKeys;
import org.eclipse.jpt.core.context.AttributeMapping;
import org.eclipse.jpt.core.context.JoinColumn;
@@ -24,32 +23,22 @@
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany;
import org.eclipse.jpt.eclipselink.core.v2_0.context.EclipseLinkOneToManyRelationshipReference2_0;
import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class OrmEclipseLinkOneToManyRelationshipReference
extends AbstractOrmOneToManyRelationshipReference
implements EclipseLinkOneToManyRelationshipReference2_0
{
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
public OrmEclipseLinkOneToManyRelationshipReference(
OrmEclipseLinkOneToManyMapping parent, XmlOneToMany resource) {
super(parent, resource);
}
-
@Override
- protected void initializeJoiningStrategies() {
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- super.initializeJoiningStrategies();
- }
-
protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
return new GenericOrmJoinColumnJoiningStrategy(this, getResourceMapping());
}
-
+
@Override
public void initializeOn(OrmRelationshipReference newRelationshipReference) {
super.initializeOn(newRelationshipReference);
@@ -64,7 +53,7 @@
for (JoinColumn joinColumn :
CollectionTools.iterable(
oldRelationshipReference.getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- OrmJoinColumn newJoinColumn = getJoinColumnJoiningStrategy().addSpecifiedJoinColumn(index++);
+ OrmJoinColumn newJoinColumn = this.joinColumnJoiningStrategy.addSpecifiedJoinColumn(index++);
newJoinColumn.initializeFrom(joinColumn);
}
}
@@ -91,74 +80,8 @@
// **************** mapped by **********************************************
@Override
- protected void setMappedByJoiningStrategy_() {
- super.setMappedByJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
return super.mayBeMappedBy(mappedByMapping) ||
mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
}
-
-
- // **************** join table *********************************************
-
- @Override
- protected void setJoinTableJoiningStrategy_() {
- super.setJoinTableJoiningStrategy_();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- @Override
- public boolean mayHaveDefaultJoinTable() {
- return super.mayHaveDefaultJoinTable()
- && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
- }
-
-
- // **************** join columns *******************************************
-
- public OrmJoinColumnJoiningStrategy 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 updateJoiningStrategies() {
- this.joinColumnJoiningStrategy.update();
- super.updateJoiningStrategies();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- }
}