Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorkmoore2012-05-02 21:42:24 +0000
committerkmoore2012-05-02 21:42:24 +0000
commit84c442586a730e5c0de85dee621b1beeb8b9f668 (patch)
tree9f282e35578406890bde2fb9f806d9e8c7931f9a /jpa
parent3e33134e1204be2c12e220f05b1d829ab4a8c97c (diff)
downloadwebtools.dali-84c442586a730e5c0de85dee621b1beeb8b9f668.tar.gz
webtools.dali-84c442586a730e5c0de85dee621b1beeb8b9f668.tar.xz
webtools.dali-84c442586a730e5c0de85dee621b1beeb8b9f668.zip
Bug 342171 - join columns - choose 'Override Default' in Details and receive out-of-bounds error
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JoinColumnRelationshipStrategy.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ReferenceTable.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/SecondaryTable.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/TenantDiscriminatorColumnsComposite.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java16
22 files changed, 259 insertions, 173 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
index 6e890cf29e..9bff01e452 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
@@ -20,7 +20,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.2
* @since 2.0
*/
public interface Entity
@@ -210,6 +210,8 @@ public interface Entity
ListIterable<? extends PrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns();
String SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST = "specifiedPrimaryKeyJoinColumns"; //$NON-NLS-1$
+ PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index);
+
int getSpecifiedPrimaryKeyJoinColumnsSize();
PrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index);
@@ -222,6 +224,18 @@ public interface Entity
void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex);
+ /**
+ * Add specified primary key join column for each default join column
+ * with the same name and referenced column name. As a side-effect in the
+ * update, the default primary key join columns will be recalculated.
+ */
+ void convertDefaultPrimaryKeyJoinColumnsToSpecified();
+
+ /**
+ * Remove all the specified primary key join columns. As a side-effect in the
+ * update, the default primary key join columns will be recalculated.
+ */
+ void clearSpecifiedPrimaryKeyJoinColumns();
// ********** containers **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JoinColumnRelationshipStrategy.java
index e796fa3791..bb80811a70 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/JoinColumnRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -24,7 +24,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
* @see AssociationOverride
* @see JoinColumnRelationship
*
- * @version 2.3
+ * @version 3.2
* @since 2.2
*/
public interface JoinColumnRelationshipStrategy
@@ -74,4 +74,19 @@ public interface JoinColumnRelationshipStrategy
// ********** default join column **********
JoinColumn getDefaultJoinColumn();
+
+
+ /**
+ * Add specified join columns for each default join column
+ * with the same name and referenced column name. As a side-effect in the
+ * update, the default join columns will be recalculated
+ */
+ void convertDefaultJoinColumnsToSpecified();
+
+ /**
+ * Remove all the specified join columns. As a side-effect in the
+ * update, the default join columns will be recalculated
+ */
+ void clearSpecifiedJoinColumns();
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ReferenceTable.java
index ebda45d015..c75590b5bf 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ReferenceTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ReferenceTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -32,10 +32,17 @@ public interface ReferenceTable
// ********** join columns **********
/**
- * Convert the reference table's default join column to a specified join column.
+ * Convert the reference table's default join column to a specified join column.
+ * As a side-effect in the update, the default join columns will be recalculated.
*/
void convertDefaultJoinColumnToSpecified();
+ /**
+ * Remove all the specified join columns. As a side-effect in the
+ * update, the default join columns will be recalculated.
+ */
+ void clearSpecifiedJoinColumns();
+
ListIterable<? extends JoinColumn> getJoinColumns();
ListIterable<? extends JoinColumn> getSpecifiedJoinColumns();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/SecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/SecondaryTable.java
index 9c91492b04..bcad4bf174 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/SecondaryTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/SecondaryTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -20,7 +20,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.2
* @since 2.0
*/
public interface SecondaryTable
@@ -29,6 +29,7 @@ public interface SecondaryTable
ListIterable<? extends PrimaryKeyJoinColumn> getPrimaryKeyJoinColumns();
ListIterable<? extends PrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns();
PrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn();
+ PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index);
/**
* Add a specified primary key join column to the secondary table.
@@ -58,4 +59,18 @@ public interface SecondaryTable
* index to the specified target index.
*/
void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex);
+
+ /**
+ * Add specified primary key join column for each default join column
+ * with the same name and referenced column name. As a side-effect in the
+ * update, the default primary key join columns will be recalculated.
+ */
+ void convertDefaultPrimaryKeyJoinColumnsToSpecified();
+
+ /**
+ * Remove all the specified primary key join columns. As a side-effect in the
+ * update, the default primary key join columns will be recalculated.
+ */
+ void clearSpecifiedPrimaryKeyJoinColumns();
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
index 70b9f653b4..0f5e255a7c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
@@ -550,6 +550,10 @@ public abstract class AbstractJavaEntity
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements();
}
+ public PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index) {
+ return this.specifiedPrimaryKeyJoinColumnContainer.get(index);
+ }
+
public int getSpecifiedPrimaryKeyJoinColumnsSize() {
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElementsSize();
}
@@ -575,6 +579,26 @@ public abstract class AbstractJavaEntity
this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumnContainer.indexOfContextElement((JavaPrimaryKeyJoinColumn) joinColumn));
}
+ public void convertDefaultPrimaryKeyJoinColumnsToSpecified() {
+ if (this.defaultPrimaryKeyJoinColumn == null) {
+ throw new IllegalStateException("default PK join column is null"); //$NON-NLS-1$
+ }
+ // Add a PK join column by creating a specified one using the default one
+ String columnName = this.defaultPrimaryKeyJoinColumn.getDefaultName();
+ String referencedColumnName = this.defaultPrimaryKeyJoinColumn.getDefaultReferencedColumnName();
+
+ PrimaryKeyJoinColumn pkJoinColumn = this.addSpecifiedPrimaryKeyJoinColumn(0);
+ pkJoinColumn.setSpecifiedName(columnName);
+ pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ public void clearSpecifiedPrimaryKeyJoinColumns() {
+ for (int index = this.getSpecifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) {
+ this.getJavaResourceType().removeAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME);
+ }
+ this.specifiedPrimaryKeyJoinColumnContainer.clearContextList();
+ }
+
public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
this.getJavaResourceType().removeAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME);
this.specifiedPrimaryKeyJoinColumnContainer.removeContextElement(index);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java
index 707fc994e2..bd400ef1fe 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2012 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.
@@ -115,6 +115,27 @@ public abstract class AbstractJavaJoinColumnRelationshipStrategy
this.specifiedJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
}
+ //default join column will get set in the update
+ public void convertDefaultJoinColumnsToSpecified() {
+ if (this.defaultJoinColumn == null) {
+ throw new IllegalStateException("default join column is null"); //$NON-NLS-1$
+ }
+ // Add a join column by creating a specified one using the default one
+ String columnName = this.defaultJoinColumn.getDefaultName();
+ String referencedColumnName = this.defaultJoinColumn.getDefaultReferencedColumnName();
+
+ JoinColumn joinColumn = this.addSpecifiedJoinColumn(0);
+ joinColumn.setSpecifiedName(columnName);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ public void clearSpecifiedJoinColumns() {
+ for (int index = getSpecifiedJoinColumnsSize(); --index >= 0; ) {
+ this.removeJoinColumnAnnotation(index);
+ }
+ this.specifiedJoinColumnContainer.clearContextList();
+ }
+
protected void syncSpecifiedJoinColumns() {
this.specifiedJoinColumnContainer.synchronizeWithResourceModel();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
index c2bafa60b0..5f6ef4fcbd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
@@ -790,6 +790,10 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements();
}
+ public PrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index) {
+ return this.specifiedPrimaryKeyJoinColumnContainer.get(index);
+ }
+
protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getReadOnlySpecifiedPrimaryKeyJoinColumns() {
return new SuperListIterableWrapper<ReadOnlyPrimaryKeyJoinColumn>(this.getSpecifiedPrimaryKeyJoinColumns());
}
@@ -824,6 +828,22 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
this.xmlTypeMapping.getPrimaryKeyJoinColumns().remove(index);
}
+ public void convertDefaultPrimaryKeyJoinColumnsToSpecified() {
+ for (ReadOnlyPrimaryKeyJoinColumn defaultJoinColumn : this.getDefaultPrimaryKeyJoinColumns()) {
+ String columnName = defaultJoinColumn.getName();
+ String referencedColumnName = defaultJoinColumn.getReferencedColumnName();
+
+ PrimaryKeyJoinColumn pkJoinColumn = this.addSpecifiedPrimaryKeyJoinColumn();
+ pkJoinColumn.setSpecifiedName(columnName);
+ pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+ }
+
+ public void clearSpecifiedPrimaryKeyJoinColumns() {
+ this.specifiedPrimaryKeyJoinColumnContainer.clearContextList();
+ this.xmlTypeMapping.getPrimaryKeyJoinColumns().clear();
+ }
+
public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
this.specifiedPrimaryKeyJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
this.xmlTypeMapping.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
index 63ef3ad811..043b819a69 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
@@ -124,6 +124,23 @@ public abstract class AbstractOrmJoinColumnRelationshipStrategy
this.getXmlJoinColumnContainer().getJoinColumns().remove(index);
}
+ public void convertDefaultJoinColumnsToSpecified() {
+ if (this.defaultJoinColumn == null) {
+ throw new IllegalStateException("default join column is null"); //$NON-NLS-1$
+ }
+ String columnName = this.defaultJoinColumn.getDefaultName();
+ String referencedColumnName = this.defaultJoinColumn.getDefaultReferencedColumnName();
+
+ JoinColumn joinColumn = this.addSpecifiedJoinColumn(0);
+ joinColumn.setSpecifiedName(columnName);
+ joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ public void clearSpecifiedJoinColumns() {
+ this.specifiedJoinColumnContainer.clearContextList();
+ this.getXmlJoinColumnContainer().getJoinColumns().clear();
+ }
+
public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
this.specifiedJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
this.getXmlJoinColumnContainer().getJoinColumns().move(targetIndex, sourceIndex);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java
index a829e4e29a..9dad944af2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java
@@ -158,9 +158,11 @@ public class GenericJavaJoinTable
public void clearSpecifiedInverseJoinColumns() {
// for now, we have to remove annotations one at a time...
- for (int i = this.getSpecifiedInverseJoinColumnsSize(); i-- > 0; ) {
- this.removeSpecifiedInverseJoinColumn(i);
+ for (int index = this.getSpecifiedInverseJoinColumnsSize(); --index >= 0; ) {
+ this.getTableAnnotation().removeInverseJoinColumn(index);
}
+ this.removeTableAnnotationIfUnset();
+ this.specifiedInverseJoinColumnContainer.clearContextList();
}
protected void syncSpecifiedInverseJoinColumns() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java
index fe0ead9f0e..ffef9ec507 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 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.
@@ -123,6 +123,15 @@ public abstract class GenericJavaReferenceTable<A extends ReferenceTableAnnotati
this.specifiedJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
}
+ public void clearSpecifiedJoinColumns() {
+ // for now, we have to remove annotations one at a time...
+ for (int index = this.getSpecifiedJoinColumnsSize(); --index >= 0; ) {
+ this.getTableAnnotation().removeJoinColumn(index);
+ }
+ this.removeTableAnnotationIfUnset();
+ this.specifiedJoinColumnContainer.clearContextList();
+ }
+
protected void syncSpecifiedJoinColumns() {
this.specifiedJoinColumnContainer.synchronizeWithResourceModel();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java
index 3fafa6103e..425f950fbb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java
@@ -119,6 +119,10 @@ public class GenericJavaSecondaryTable
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements();
}
+ public JavaPrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index) {
+ return this.specifiedPrimaryKeyJoinColumnContainer.get(index);
+ }
+
public int getSpecifiedPrimaryKeyJoinColumnsSize() {
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElementsSize();
}
@@ -146,6 +150,28 @@ public class GenericJavaSecondaryTable
this.specifiedPrimaryKeyJoinColumnContainer.removeContextElement(index);
}
+ //default PK join column will get set in the update
+ public void convertDefaultPrimaryKeyJoinColumnsToSpecified() {
+ if (this.defaultPrimaryKeyJoinColumn == null) {
+ throw new IllegalStateException("default PK join column is null"); //$NON-NLS-1$
+ }
+ // Add a PK join column by creating a specified one using the default one
+ String columnName = this.defaultPrimaryKeyJoinColumn.getDefaultName();
+ String referencedColumnName = this.defaultPrimaryKeyJoinColumn.getDefaultReferencedColumnName();
+
+ PrimaryKeyJoinColumn pkJoinColumn = this.addSpecifiedPrimaryKeyJoinColumn(0);
+ pkJoinColumn.setSpecifiedName(columnName);
+ pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ public void clearSpecifiedPrimaryKeyJoinColumns() {
+ for (int index = this.getSpecifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) {
+ this.tableAnnotation.removePkJoinColumn(index);
+ }
+ this.removeTableAnnotationIfUnset();
+ this.specifiedPrimaryKeyJoinColumnContainer.clearContextList();
+ }
+
public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
this.tableAnnotation.movePkJoinColumn(targetIndex, sourceIndex);
this.specifiedPrimaryKeyJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java
index df7fd609dd..1787c7655b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2012 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.
@@ -88,6 +88,13 @@ public class NullJavaJoinColumnRelationshipStrategy
throw new UnsupportedOperationException();
}
+ public void clearSpecifiedJoinColumns() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void convertDefaultJoinColumnsToSpecified() {
+ throw new UnsupportedOperationException();
+ }
// ********** default join column **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
index 0c1005835b..1c99fd10df 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java
@@ -129,6 +129,11 @@ public abstract class GenericOrmReferenceTable<X extends AbstractXmlReferenceTab
this.getXmlTable().getJoinColumns().move(targetIndex, sourceIndex);
}
+ public void clearSpecifiedJoinColumns() {
+ this.specifiedJoinColumnContainer.clearContextList();
+ this.getXmlTable().getJoinColumns().clear();
+ }
+
protected void syncSpecifiedJoinColumns() {
this.specifiedJoinColumnContainer.synchronizeWithResourceModel();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
index f91546bee1..11ab77c427 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java
@@ -131,6 +131,10 @@ public class GenericOrmSecondaryTable
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements();
}
+ public OrmPrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index) {
+ return this.specifiedPrimaryKeyJoinColumnContainer.get(index);
+ }
+
public int getSpecifiedPrimaryKeyJoinColumnsSize() {
return this.specifiedPrimaryKeyJoinColumnContainer.getContextElementsSize();
}
@@ -163,6 +167,25 @@ public class GenericOrmSecondaryTable
this.xmlSecondaryTable.getPrimaryKeyJoinColumns().remove(index);
}
+ //default PK join column will get set in the update
+ public void convertDefaultPrimaryKeyJoinColumnsToSpecified() {
+ if (this.defaultPrimaryKeyJoinColumn == null) {
+ throw new IllegalStateException("default PK join column is null"); //$NON-NLS-1$
+ }
+ // Add a PK join column by creating a specified one using the default one
+ String columnName = this.defaultPrimaryKeyJoinColumn.getDefaultName();
+ String referencedColumnName = this.defaultPrimaryKeyJoinColumn.getDefaultReferencedColumnName();
+
+ PrimaryKeyJoinColumn pkJoinColumn = this.addSpecifiedPrimaryKeyJoinColumn(0);
+ pkJoinColumn.setSpecifiedName(columnName);
+ pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
+ }
+
+ public void clearSpecifiedPrimaryKeyJoinColumns() {
+ this.specifiedPrimaryKeyJoinColumnContainer.clearContextList();
+ this.xmlSecondaryTable.getPrimaryKeyJoinColumns().clear();
+ }
+
public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
this.specifiedPrimaryKeyJoinColumnContainer.moveContextElement(targetIndex, sourceIndex);
this.xmlSecondaryTable.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java
index 5cd0538991..e783742082 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java
@@ -87,6 +87,14 @@ public class NullOrmJoinColumnRelationshipStrategy
throw new UnsupportedOperationException();
}
+ public void clearSpecifiedJoinColumns() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void convertDefaultJoinColumnsToSpecified() {
+ throw new UnsupportedOperationException();
+ }
+
// ********** default join column **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/TenantDiscriminatorColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/TenantDiscriminatorColumnsComposite.java
index d9ab0cdf4e..8098eebae1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/TenantDiscriminatorColumnsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/TenantDiscriminatorColumnsComposite.java
@@ -10,8 +10,6 @@
package org.eclipse.jpt.jpa.eclipselink.ui.internal.details;
import java.util.ArrayList;
-import java.util.EventListener;
-import java.util.EventObject;
import java.util.List;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -22,19 +20,12 @@ import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane;
import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.AbstractAdapter;
import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
@@ -183,7 +174,7 @@ public class TenantDiscriminatorColumnsComposite<T extends JpaNode> extends Pane
}
private ListValueModel<ReadOnlyTenantDiscriminatorColumn2_3> buildTenantDiscriminatorColumnsListModel() {
- return new LocalItemPropertyListValueModelAdapter<ReadOnlyTenantDiscriminatorColumn2_3>(buildTenantDiscriminatorColumnsListHolder(),
+ return new ItemPropertyListValueModelAdapter<ReadOnlyTenantDiscriminatorColumn2_3>(buildTenantDiscriminatorColumnsListHolder(),
ReadOnlyNamedColumn.SPECIFIED_NAME_PROPERTY,
ReadOnlyNamedColumn.DEFAULT_NAME_PROPERTY);
}
@@ -296,49 +287,4 @@ public class TenantDiscriminatorColumnsComposite<T extends JpaNode> extends Pane
*/
void removeTenantDiscriminatorColumns(T subject, int[] selectedIndices);
}
-
- private class LocalItemPropertyListValueModelAdapter<E> extends ItemPropertyListValueModelAdapter<E> {
-
- public LocalItemPropertyListValueModelAdapter(ListValueModel<E> listHolder, String... propertyNames) {
- super(listHolder, propertyNames);
- }
-
- public LocalItemPropertyListValueModelAdapter(CollectionValueModel<E> collectionHolder, String[] propertyNames) {
- super(collectionHolder, propertyNames);
- }
-
- /**
- * bug 310720
- * Override to just fire an itemReplaced event instead of a listChanged event.
- * An aspect of the item as changed, so no reason to say that the entire list has changed.
- * Added a LocalChangeSupport so that I can fire a ListReplacedEvent for an old list
- * and new list containing the same item.
- */
- @Override
- protected void itemAspectChanged(EventObject event) {
- Object item = event.getSource();
- this.getChangeSupport().fireItemsReplaced(
- new ListReplaceEvent(this, LIST_VALUES, CollectionTools.indexOf(this.listHolder, item), item, item));
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new LocalChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
- }
-
- private class LocalChangeSupport extends SingleAspectChangeSupport {
- public LocalChangeSupport(Model source, Class<? extends EventListener> validListenerClass, String validAspectName) {
- super(source, validListenerClass, validAspectName);
- }
- @Override
- public boolean fireItemsReplaced(ListReplaceEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- if (event.getItemsSize() != 0) {
- this.fireItemsReplaced_(event);
- return true;
- }
- return false;
- }
- }
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java
index 0363b90ede..eded583800 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/AbstractPrimaryKeyJoinColumnsComposite.java
@@ -178,7 +178,7 @@ public abstract class AbstractPrimaryKeyJoinColumnsComposite<T extends Entity> e
}
private ModifiablePropertyValueModel<Boolean> buildOverrideDefaultJoinColumnHolder() {
- return new OverrideDefaultJoinColumnHolder();
+ return new OverrideDefaultPrimaryKeyJoinColumnHolder();
}
private ListValueModel<ReadOnlyPrimaryKeyJoinColumn> buildPrimaryKeyJoinColumnsListHolder() {
@@ -283,39 +283,29 @@ public abstract class AbstractPrimaryKeyJoinColumnsComposite<T extends Entity> e
);
}
- void updateJoinColumns(boolean selected) {
-
- if (isPopulating()) {
+ void updatePrimaryKeyJoinColumns(boolean selected) {
+ if (this.isPopulating()) {
return;
}
- setPopulating(true);
+ this.setPopulating(true);
try {
- // Add a join column by creating a specified one using the default
- // one if it exists
if (selected) {
-
- switchDefaultToSpecified();
- }
- // Remove all the specified join columns
- else {
- for (int index = getSubject().getSpecifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) {
- getSubject().removeSpecifiedPrimaryKeyJoinColumn(index);
- }
+ getSubject().convertDefaultPrimaryKeyJoinColumnsToSpecified();
+ this.joinColumnHolder.setValue(getSubject().getSpecifiedPrimaryKeyJoinColumn(0));
+ } else {
+ getSubject().clearSpecifiedPrimaryKeyJoinColumns();
}
- }
- finally {
- setPopulating(false);
+ } finally {
+ this.setPopulating(false);
}
}
-
- protected abstract void switchDefaultToSpecified();
- private class OverrideDefaultJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean>
+ private class OverrideDefaultPrimaryKeyJoinColumnHolder extends ListPropertyValueModelAdapter<Boolean>
implements ModifiablePropertyValueModel<Boolean> {
- public OverrideDefaultJoinColumnHolder() {
+ public OverrideDefaultPrimaryKeyJoinColumnHolder() {
super(buildSpecifiedJoinColumnsListHolder());
}
@@ -325,7 +315,7 @@ public abstract class AbstractPrimaryKeyJoinColumnsComposite<T extends Entity> e
}
public void setValue(Boolean value) {
- updateJoinColumns(value.booleanValue());
+ updatePrimaryKeyJoinColumns(value.booleanValue());
}
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java
index 78be6ca6b3..8c56beeea9 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JoiningStrategyJoinColumnsWithOverrideOptionComposite.java
@@ -120,28 +120,14 @@ public class JoiningStrategyJoinColumnsWithOverrideOptionComposite
try {
JoinColumnRelationshipStrategy subject = (JoinColumnRelationshipStrategy) getSubject();
-
- // Add a join column by creating a specified one using the default
- // one if it exists
if (selected) {
- ReadOnlyJoinColumn defaultJoinColumn = subject.getDefaultJoinColumn();//TODO could be null, disable override default check box?
-
- if (defaultJoinColumn != null) {
- String columnName = defaultJoinColumn.getDefaultName();
- String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
-
- JoinColumn joinColumn = subject.addSpecifiedJoinColumn();
- joinColumn.setSpecifiedName(columnName);
- joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
-
- JoiningStrategyJoinColumnsWithOverrideOptionComposite.this.setSelectedJoinColumn(joinColumn);
+ if (subject.getDefaultJoinColumn() != null) {//TODO can this be null, disable override default check box? or have it checked if there are not default join columns?
+ subject.convertDefaultJoinColumnsToSpecified();
+ JoiningStrategyJoinColumnsWithOverrideOptionComposite.this.setSelectedJoinColumn(subject.getSpecifiedJoinColumn(0));
}
}
- // Remove all the specified join columns
else {
- for (int index = subject.getSpecifiedJoinColumnsSize(); --index >= 0; ) {
- subject.removeSpecifiedJoinColumn(index);
- }
+ subject.clearSpecifiedJoinColumns();
}
}
finally {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
index b969acf880..3f598db3c0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PrimaryKeyJoinColumnsInSecondaryTableComposite.java
@@ -338,42 +338,26 @@ public class PrimaryKeyJoinColumnsInSecondaryTableComposite extends Pane<ReadOnl
}
}
- void updateJoinColumns(boolean selected) {
-
- if (isPopulating()) {
+ void updatePrimaryKeyJoinColumns(boolean selected) {
+ if (this.isPopulating()) {
return;
}
- setPopulating(true);
+ SecondaryTable secondaryTable = (SecondaryTable) this.getSubject();
- try {
- SecondaryTable secondaryTable = (SecondaryTable) getSubject();
+ this.setPopulating(true);
- // Add a join column by creating a specified one using the default
- // one if it exists
+ try {
if (selected) {
-
- PrimaryKeyJoinColumn defaultJoinColumn = secondaryTable.getDefaultPrimaryKeyJoinColumn();
-
- if (defaultJoinColumn != null) {
- String columnName = defaultJoinColumn.getDefaultName();
- String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
-
- PrimaryKeyJoinColumn pkJoinColumn = secondaryTable.addSpecifiedPrimaryKeyJoinColumn(0);
- pkJoinColumn.setSpecifiedName(columnName);
- pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
-
- joinColumnHolder.setValue(pkJoinColumn);
+ if (secondaryTable.getDefaultPrimaryKeyJoinColumn() != null) { //TODO can this be null?
+ secondaryTable.convertDefaultPrimaryKeyJoinColumnsToSpecified();
+ this.joinColumnHolder.setValue(secondaryTable.getSpecifiedPrimaryKeyJoinColumn(0));
}
+ } else {
+ secondaryTable.clearSpecifiedPrimaryKeyJoinColumns();
}
- else {
- for (int index = secondaryTable.getSpecifiedPrimaryKeyJoinColumnsSize(); --index >= 0; ) {
- secondaryTable.removeSpecifiedPrimaryKeyJoinColumn(index);
- }
- }
- }
- finally {
- setPopulating(false);
+ } finally {
+ this.setPopulating(false);
}
}
@@ -395,7 +379,7 @@ public class PrimaryKeyJoinColumnsInSecondaryTableComposite extends Pane<ReadOnl
}
public void setValue(Boolean value) {
- updateJoinColumns(value.booleanValue());
+ updatePrimaryKeyJoinColumns(value.booleanValue());
}
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java
index d523ae932b..54eb77426d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/ReferenceTableComposite.java
@@ -294,9 +294,7 @@ public abstract class ReferenceTableComposite<T extends ReadOnlyReferenceTable>
referenceTable.convertDefaultJoinColumnToSpecified();
setSelectedJoinColumn(referenceTable.getSpecifiedJoinColumn(0));
} else {
- for (int index = referenceTable.getSpecifiedJoinColumnsSize(); --index >= 0; ) {
- referenceTable.removeSpecifiedJoinColumn(index);
- }
+ referenceTable.clearSpecifiedJoinColumns();
}
} finally {
this.setPopulating(false);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java
index 6e5f06c6cb..2f0bd1e99d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/JavaPrimaryKeyJoinColumnsComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -47,21 +47,4 @@ public class JavaPrimaryKeyJoinColumnsComposite extends AbstractPrimaryKeyJoinCo
}
};
}
-
- @Override
- protected void switchDefaultToSpecified() {
- PrimaryKeyJoinColumn defaultJoinColumn = getSubject().getDefaultPrimaryKeyJoinColumn();
-
- if (defaultJoinColumn != null) {
- String columnName = defaultJoinColumn.getDefaultName();
- String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
-
- PrimaryKeyJoinColumn pkJoinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn();
- pkJoinColumn.setSpecifiedName(columnName);
- pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
-
- this.joinColumnHolder.setValue(pkJoinColumn);
- }
- }
-
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java
index df9fc2d4ad..cecc8931fb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmPrimaryKeyJoinColumnsComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2012 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.
@@ -13,7 +13,6 @@ import org.eclipse.jpt.common.ui.internal.widgets.Pane;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn;
import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
import org.eclipse.jpt.jpa.ui.internal.details.AbstractPrimaryKeyJoinColumnsComposite;
@@ -50,17 +49,4 @@ public class OrmPrimaryKeyJoinColumnsComposite extends AbstractPrimaryKeyJoinCol
}
};
}
-
- @Override
- protected void switchDefaultToSpecified() {
- for (ReadOnlyPrimaryKeyJoinColumn defaultJoinColumn : getSubject().getDefaultPrimaryKeyJoinColumns()) {
- String columnName = defaultJoinColumn.getName();
- String referencedColumnName = defaultJoinColumn.getReferencedColumnName();
-
- PrimaryKeyJoinColumn pkJoinColumn = getSubject().addSpecifiedPrimaryKeyJoinColumn();
- pkJoinColumn.setSpecifiedName(columnName);
- pkJoinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
- }
- }
-
} \ No newline at end of file

Back to the top