diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src')
17 files changed, 716 insertions, 253 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java index d1da7aa946..1b5569a42f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Oracle. All rights reserved. + * Copyright (c) 2007, 2008 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. @@ -103,6 +103,7 @@ import org.eclipse.jpt.core.resource.orm.OrmResource; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; import org.eclipse.jpt.core.resource.persistence.PersistenceResource; import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef; import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef; @@ -212,7 +213,7 @@ public interface JpaFactory OrmTable buildOrmTable(OrmEntity parent); - OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent); + OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent, XmlSecondaryTable xmlSecondaryTable); OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmAbstractJoinColumn.Owner owner); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/SecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/SecondaryTable.java index 2d2ecd3593..efe29892f8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/SecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/SecondaryTable.java @@ -75,9 +75,10 @@ public interface SecondaryTable extends Table * Move the specified primary key join column from the source index to the target index. */ void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex); - -// boolean containsSpecifiedPrimaryKeyJoinColumns(); -// -// boolean isVirtual(); + /** + * Return true if the secondary table exists as specified on the owning object, + * or false if the secondary table is a result of defaults calculation + */ + boolean isVirtual(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmEntity.java index eb7c75a4ce..e10ad2ffcb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmEntity.java @@ -23,8 +23,55 @@ import org.eclipse.jpt.core.resource.orm.XmlEntity; * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface OrmEntity extends Entity, OrmTypeMapping +public interface OrmEntity extends OrmTypeMapping, Entity { + + /** + * Return a list iterator of the virtual(not specified) secondary tables. + * This will not be null. + */ + ListIterator<OrmSecondaryTable> virtualSecondaryTables(); + String VIRTUAL_SECONDARY_TABLES_LIST = "virtualSecondaryTablesList"; + + /** + * Return the number of virtual secondary tables. + */ + int virtualSecondaryTablesSize(); + + /** + * Return whether the entity contains the given secondary table in its list of + * virtual secondary tables + */ + boolean containsVirtualSecondaryTable(OrmSecondaryTable secondaryTable); + + /** + * Return true if there are no virtual secondary tables on the orm entity. + * This is used to determine whether you can add specified secondary tables. + * You must first make sure all virtual secondary tables have been specified + * in xml before adding more. This is because adding one secondary table to xml + * will override all the secondary tables specified in the java entity + */ + boolean secondaryTablesDefinedInXml(); + + /** + * If true, then all virtual secondary tables are added in as specified secondary tables to the xml. + * If false, then all the specified secondary tables are remvoed from the xml. + */ + void setSecondaryTablesDefinedInXml(boolean defineInXml); + + /** + * Return the Java Entity this ORM Entity corresponds to. Return null if there is no + * java entity. + */ + JavaEntity javaEntity(); + + void initialize(XmlEntity entity); + + void update(XmlEntity entity); + + + //************ covariant overrides ************* + OrmTable getTable(); OrmDiscriminatorColumn getDiscriminatorColumn(); @@ -41,12 +88,6 @@ public interface OrmEntity extends Entity, OrmTypeMapping ListIterator<OrmSecondaryTable> specifiedSecondaryTables(); OrmSecondaryTable addSpecifiedSecondaryTable(int index); - ListIterator<OrmSecondaryTable> virtualSecondaryTables(); - int virtualSecondaryTablesSize(); - boolean containsVirtualSecondaryTable(OrmSecondaryTable secondaryTable); - //TODO this might need to move to IEntity, for the UI - String VIRTUAL_SECONDARY_TABLES_LIST = "virtualSecondaryTablesList"; - @SuppressWarnings("unchecked") ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns(); @@ -79,10 +120,4 @@ public interface OrmEntity extends Entity, OrmTypeMapping @SuppressWarnings("unchecked") ListIterator<OrmNamedNativeQuery> namedNativeQueries(); OrmNamedNativeQuery addNamedNativeQuery(int index); - - JavaEntity javaEntity(); - - void initialize(XmlEntity entity); - - void update(XmlEntity entity); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java index 67eb42f65a..9aafa28f73 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java @@ -26,4 +26,6 @@ public interface OrmPrimaryKeyJoinColumn extends PrimaryKeyJoinColumn, OrmAbstra void initialize(XmlPrimaryKeyJoinColumn column); void update(XmlPrimaryKeyJoinColumn column); + + void initializeFrom(PrimaryKeyJoinColumn oldPkJoinColumn); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSecondaryTable.java index 6b960551ec..2061fb6b50 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSecondaryTable.java @@ -24,6 +24,14 @@ import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; */ public interface OrmSecondaryTable extends SecondaryTable, OrmJpaContextNode { + + void update(XmlSecondaryTable secondaryTable); + + void initializeFrom(SecondaryTable oldSecondaryTable); + + + //************ covariant overrides ************* + OrmEntity parent(); @SuppressWarnings("unchecked") @@ -36,7 +44,4 @@ public interface OrmSecondaryTable extends SecondaryTable, OrmJpaContextNode OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index); - void initialize(XmlSecondaryTable secondaryTable); - - void update(XmlSecondaryTable secondaryTable); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java index 7f042863ec..f66a3787ba 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java @@ -54,14 +54,6 @@ public abstract class AbstractOrmNamedColumn<T extends XmlNamedColumn> extends return this.owner; } -// @Override -// protected void addInsignificantXmlFeatureIdsTo(Set<Integer> insignificantXmlFeatureIds) { -// super.addInsignificantXmlFeatureIdsTo(insignificantXmlFeatureIds); -// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.INAMED_COLUMN__DEFAULT_NAME); -// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.INAMED_COLUMN__NAME); -// } - - public String getName() { return (this.specifiedName != null) ? this.specifiedName : this.defaultName; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java index 903a0d5220..d0e85c137f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java @@ -274,10 +274,12 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } public OrmSecondaryTable addSpecifiedSecondaryTable(int index) { - OrmSecondaryTable secondaryTable = jpaFactory().buildOrmSecondaryTable(this); - this.specifiedSecondaryTables.add(index, secondaryTable); + if (!secondaryTablesDefinedInXml()) { + throw new IllegalStateException("Virtual secondary tables exist, must first call setSecondaryTablesDefinedInXml(true)"); + } XmlSecondaryTable secondaryTableResource = OrmFactory.eINSTANCE.createXmlSecondaryTableImpl(); - secondaryTable.initialize(secondaryTableResource); + OrmSecondaryTable secondaryTable = buildSecondaryTable(secondaryTableResource); + this.specifiedSecondaryTables.add(index, secondaryTable); typeMappingResource().getSecondaryTables().add(index, secondaryTableResource); fireItemAdded(Entity.SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable); return secondaryTable; @@ -333,6 +335,70 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen return false; } + public boolean secondaryTablesDefinedInXml() { + return virtualSecondaryTablesSize() == 0; + } + + public void setSecondaryTablesDefinedInXml(boolean defineInXml) { + if (defineInXml == secondaryTablesDefinedInXml()) { + return; + } + if (defineInXml) { + specifySecondaryTablesInXml(); + } + else { + removeSecondaryTablesFromXml(); + } + } + + /** + * This is used to take all the java secondary tables and specify them in the xml. You must + * use setSecondaryTablesDefinedInXml(boolean) before calling addSpecifiedSecondaryTable(). + * + * Yes this code looks odd, but be careful making changes to it + */ + protected void specifySecondaryTablesInXml() { + if (virtualSecondaryTablesSize() != 0) { + List<OrmSecondaryTable> virtualSecondaryTables = CollectionTools.list(this.virtualSecondaryTables()); + List<OrmSecondaryTable> virtualSecondaryTable2 = CollectionTools.list(this.virtualSecondaryTables()); + //remove all the virtual secondary tables without firing change notification. + for (OrmSecondaryTable virtualSecondaryTable : CollectionTools.iterable(virtualSecondaryTables())) { + this.virtualSecondaryTables.remove(virtualSecondaryTable); + } + //add specified secondary tables for each virtual secondary table. If the virtual secondary tables + //are not removed first, they will be removed as a side effect of adding the first specified secondary table. + //This screws up the change notification to the UI, since that change notification is in a different thread + for (OrmSecondaryTable virtualSecondaryTable : virtualSecondaryTable2) { + XmlSecondaryTable secondaryTableResource = OrmFactory.eINSTANCE.createXmlSecondaryTableImpl(); + OrmSecondaryTable specifiedSecondaryTable = buildSecondaryTable(secondaryTableResource); + this.specifiedSecondaryTables.add(specifiedSecondaryTable); + typeMappingResource().getSecondaryTables().add(secondaryTableResource); + specifiedSecondaryTable.initializeFrom(virtualSecondaryTable); + } + //fire change notification at the end + fireItemsRemoved(OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST, 0, virtualSecondaryTables); + fireItemsAdded(Entity.SPECIFIED_SECONDARY_TABLES_LIST, 0, this.specifiedSecondaryTables); + } + } + + protected void removeSecondaryTablesFromXml() { + if (specifiedSecondaryTablesSize() != 0) { + List<OrmSecondaryTable> specifiedSecondaryTables = CollectionTools.list(this.specifiedSecondaryTables()); + for (OrmSecondaryTable specifiedSecondaryTable : CollectionTools.iterable(specifiedSecondaryTables())) { + int index = this.specifiedSecondaryTables.indexOf(specifiedSecondaryTable); + this.specifiedSecondaryTables.remove(specifiedSecondaryTable); + if (this.specifiedSecondaryTables.size() == 0) { + initializeVirtualSecondaryTables(); + } + typeMappingResource().getSecondaryTables().remove(index); + } + fireItemsRemoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, 0, specifiedSecondaryTables); + if (this.virtualSecondaryTables.size() != 0) { + fireItemsAdded(OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST, 0, this.virtualSecondaryTables); + } + } + } + protected Iterator<String> tableNames(Iterator<Table> tables) { return new TransformationIterator<Table, String>(tables) { @Override @@ -566,7 +632,7 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) { OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = jpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn); - this.typeMappingResource().getPrimaryKeyJoinColumns().add(index, OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn()); + this.typeMappingResource().getPrimaryKeyJoinColumns().add(index, OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl()); this.fireItemAdded(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); return primaryKeyJoinColumn; } @@ -1012,7 +1078,7 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen protected void initializeSpecifiedSecondaryTables(XmlEntity entity) { for (XmlSecondaryTable secondaryTable : entity.getSecondaryTables()) { - this.specifiedSecondaryTables.add(createSecondaryTable(secondaryTable)); + this.specifiedSecondaryTables.add(buildSecondaryTable(secondaryTable)); } } @@ -1159,7 +1225,7 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } while (resourceSecondaryTables.hasNext()) { - addSpecifiedSecondaryTable(specifiedSecondaryTablesSize(), createSecondaryTable(resourceSecondaryTables.next())); + addSpecifiedSecondaryTable(specifiedSecondaryTablesSize(), buildSecondaryTable(resourceSecondaryTables.next())); } } @@ -1188,17 +1254,12 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } } - protected OrmSecondaryTable createSecondaryTable(XmlSecondaryTable secondaryTable) { - OrmSecondaryTable ormSecondaryTable = jpaFactory().buildOrmSecondaryTable(this); - ormSecondaryTable.initialize(secondaryTable); - return ormSecondaryTable; + protected OrmSecondaryTable buildSecondaryTable(XmlSecondaryTable xmlSecondaryTable) { + return jpaFactory().buildOrmSecondaryTable(this, xmlSecondaryTable); } protected OrmSecondaryTable buildVirtualSecondaryTable(JavaSecondaryTable javaSecondaryTable) { - OrmSecondaryTable virtualSecondaryTable = jpaFactory().buildOrmSecondaryTable(this); - VirtualXmlSecondaryTable virtualXmlSecondaryTable = new VirtualXmlSecondaryTable(javaSecondaryTable); - virtualSecondaryTable.initialize(virtualXmlSecondaryTable); - return virtualSecondaryTable; + return buildSecondaryTable(new VirtualXmlSecondaryTable(javaSecondaryTable)); } protected void updateTableGenerator(XmlEntity entity) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumn.java index c9d8830233..f953f3c628 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Oracle. All rights reserved. + * Copyright (c) 2007, 2008 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. @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.context.orm; import org.eclipse.jpt.core.TextRange; +import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; import org.eclipse.jpt.core.context.orm.OrmAbstractJoinColumn; import org.eclipse.jpt.core.context.orm.OrmJpaContextNode; import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn; @@ -30,6 +31,11 @@ public class GenericOrmPrimaryKeyJoinColumn extends AbstractOrmNamedColumn<XmlPr super(parent, owner); } + public void initializeFrom(PrimaryKeyJoinColumn oldPkJoinColumn) { + super.initializeFrom(oldPkJoinColumn); + setSpecifiedReferencedColumnName(oldPkJoinColumn.getSpecifiedReferencedColumnName()); + } + @Override protected XmlPrimaryKeyJoinColumn columnResource() { return this.primaryKeyJoinColumn; @@ -61,6 +67,12 @@ public class GenericOrmPrimaryKeyJoinColumn extends AbstractOrmNamedColumn<XmlPr columnResource().setReferencedColumnName(newSpecifiedReferencedColumnName); firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, oldSpecifiedReferencedColumnName, newSpecifiedReferencedColumnName); } + + protected void setSpecifiedReferencedColumnName_(String newSpecifiedReferencedColumnName) { + String oldSpecifiedReferencedColumnName = this.specifiedReferencedColumnName; + this.specifiedReferencedColumnName = newSpecifiedReferencedColumnName; + firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, oldSpecifiedReferencedColumnName, newSpecifiedReferencedColumnName); + } public String getDefaultReferencedColumnName() { return this.defaultReferencedColumnName; @@ -111,7 +123,7 @@ public class GenericOrmPrimaryKeyJoinColumn extends AbstractOrmNamedColumn<XmlPr public void initialize(XmlPrimaryKeyJoinColumn column) { this.primaryKeyJoinColumn = column; super.initialize(column); - this.specifiedReferencedColumnName = column.getReferencedColumnName(); + this.specifiedReferencedColumnName = specifiedReferencedColumnName(column); this.defaultReferencedColumnName = defaultReferencedColumnName(); } @@ -119,12 +131,16 @@ public class GenericOrmPrimaryKeyJoinColumn extends AbstractOrmNamedColumn<XmlPr public void update(XmlPrimaryKeyJoinColumn column) { this.primaryKeyJoinColumn = column; super.update(column); - this.setSpecifiedReferencedColumnName(column.getReferencedColumnName()); + this.setSpecifiedReferencedColumnName_(specifiedReferencedColumnName(column)); this.setDefaultReferencedColumnName(defaultReferencedColumnName()); } + protected String specifiedReferencedColumnName(XmlPrimaryKeyJoinColumn column) { + return column == null ? null : column.getReferencedColumnName(); + } + + //TODO not correct when we start supporting primaryKeyJoinColumns in 1-1 mappings protected String defaultReferencedColumnName() { - //TODO - return null; + return defaultName(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java index e69565f337..100200b5b8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java @@ -1,8 +1,8 @@ /******************************************************************************* - * Copyright (c) 2007 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. + * Copyright (c) 2007, 2008 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 @@ -14,6 +14,7 @@ import java.util.List; import java.util.ListIterator; import org.eclipse.jpt.core.TextRange; import org.eclipse.jpt.core.context.AbstractJoinColumn; +import org.eclipse.jpt.core.context.Entity; import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn; import org.eclipse.jpt.core.context.SecondaryTable; import org.eclipse.jpt.core.context.TypeMapping; @@ -29,6 +30,8 @@ import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; import org.eclipse.jpt.db.internal.Table; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; +import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; +import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -39,13 +42,20 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable protected final List<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns; - protected final List<OrmPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns; + protected OrmPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn; - public GenericOrmSecondaryTable(OrmEntity parent) { + public GenericOrmSecondaryTable(OrmEntity parent, XmlSecondaryTable xmlSecondaryTable) { super(parent); this.specifiedPrimaryKeyJoinColumns = new ArrayList<OrmPrimaryKeyJoinColumn>(); - this.defaultPrimaryKeyJoinColumns = new ArrayList<OrmPrimaryKeyJoinColumn>(); -// this.getDefaultPrimaryKeyJoinColumns().add(this.createPrimaryKeyJoinColumn(0)); + initialize(xmlSecondaryTable); + } + + public void initializeFrom(SecondaryTable oldSecondaryTable) { + super.initializeFrom(oldSecondaryTable); + for (PrimaryKeyJoinColumn oldPkJoinColumn : CollectionTools.iterable(oldSecondaryTable.specifiedPrimaryKeyJoinColumns())) { + OrmPrimaryKeyJoinColumn newPkJoinColumn = addSpecifiedPrimaryKeyJoinColumn(specifiedPrimaryKeyJoinColumnsSize()); + newPkJoinColumn.initializeFrom(oldPkJoinColumn); + } } @Override @@ -56,20 +66,25 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable public OrmEntity ormEntity() { return parent(); } - - public ListIterator<OrmPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() { - return new CloneListIterator<OrmPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumns); - } - + public OrmPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() { - // TODO Auto-generated method stub - return null; + return this.defaultPrimaryKeyJoinColumn; + } + + protected void setDefaultPrimaryKeyJoinColumn(OrmPrimaryKeyJoinColumn newPkJoinColumn) { + OrmPrimaryKeyJoinColumn oldPkJoinColumn = this.defaultPrimaryKeyJoinColumn; + this.defaultPrimaryKeyJoinColumn = newPkJoinColumn; + firePropertyChanged(SecondaryTable.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldPkJoinColumn, newPkJoinColumn); } public ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns() { - return this.specifiedPrimaryKeyJoinColumns.isEmpty() ? this.defaultPrimaryKeyJoinColumns() : this.specifiedPrimaryKeyJoinColumns(); + return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumns() : this.defaultPrimaryKeyJoinColumns(); } + public int primaryKeyJoinColumnsSize() { + return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.defaultPrimaryKeyJoinColumnsSize(); + } + public ListIterator<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() { return new CloneListIterator<OrmPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns); } @@ -78,12 +93,15 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable return this.specifiedPrimaryKeyJoinColumns.size(); } - public int defaultPrimaryKeyJoinColumnsSize() { - return this.defaultPrimaryKeyJoinColumns.size(); + protected ListIterator<OrmPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() { + if (this.defaultPrimaryKeyJoinColumn != null) { + return new SingleElementListIterator<OrmPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn); + } + return EmptyListIterator.instance(); } - public int primaryKeyJoinColumnsSize() { - return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.defaultPrimaryKeyJoinColumnsSize(); + protected int defaultPrimaryKeyJoinColumnsSize() { + return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1; } public boolean containsSpecifiedPrimaryKeyJoinColumns() { @@ -91,10 +109,24 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) { + OrmPrimaryKeyJoinColumn oldDefaultPkJoinColumn = this.getDefaultPrimaryKeyJoinColumn(); + if (oldDefaultPkJoinColumn != null) { + //null the default join column now if one already exists. + //if one does not exist, there is already a specified join column. + //Remove it now so that it doesn't get removed during an update and + //cause change notifications to be sent to the UI in the wrong order + this.defaultPrimaryKeyJoinColumn = null; + } + XmlPrimaryKeyJoinColumn xmlPrimaryKeyJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = jpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); + primaryKeyJoinColumn.initialize(xmlPrimaryKeyJoinColumn); this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn); - this.secondaryTable.getPrimaryKeyJoinColumns().add(index, OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn()); + this.secondaryTable.getPrimaryKeyJoinColumns().add(index, xmlPrimaryKeyJoinColumn); + this.fireItemAdded(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); + if (oldDefaultPkJoinColumn != null) { + this.firePropertyChanged(SecondaryTable.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null); + } return primaryKeyJoinColumn; } @@ -112,8 +144,18 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable public void removeSpecifiedPrimaryKeyJoinColumn(int index) { OrmPrimaryKeyJoinColumn removedPrimaryKeyJoinColumn = this.specifiedPrimaryKeyJoinColumns.remove(index); + if (!containsSpecifiedPrimaryKeyJoinColumns()) { + //create the defaultJoinColumn now or this will happen during project update + //after removing the join column from the resource model. That causes problems + //in the UI because the change notifications end up in the wrong order. + this.defaultPrimaryKeyJoinColumn = createPrimaryKeyJoinColumn(null); + } this.secondaryTable.getPrimaryKeyJoinColumns().remove(index); fireItemRemoved(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn); + if (this.defaultPrimaryKeyJoinColumn != null) { + //fire change notification if a defaultJoinColumn was created above + this.firePropertyChanged(Entity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, null, this.defaultPrimaryKeyJoinColumn); + } } protected void removeSpecifiedPrimaryKeyJoinColumn_(OrmPrimaryKeyJoinColumn primaryKeyJoinColumn) { @@ -148,10 +190,11 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable return this.secondaryTable; } - public void initialize(XmlSecondaryTable secondaryTable) { + protected void initialize(XmlSecondaryTable secondaryTable) { this.secondaryTable = secondaryTable; super.initialize(secondaryTable); this.initializeSpecifiedPrimaryKeyJoinColumns(secondaryTable); + this.initializeDefaultPrimaryKeyJoinColumn(secondaryTable); } protected void initializeSpecifiedPrimaryKeyJoinColumns(XmlSecondaryTable secondaryTable) { @@ -160,10 +203,23 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } } + protected boolean shouldBuildDefaultPrimaryKeyJoinColumn() { + return !containsSpecifiedPrimaryKeyJoinColumns(); + } + + protected void initializeDefaultPrimaryKeyJoinColumn(XmlSecondaryTable secondaryTable) { + if (!shouldBuildDefaultPrimaryKeyJoinColumn()) { + return; + } + this.defaultPrimaryKeyJoinColumn = this.jpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); + this.defaultPrimaryKeyJoinColumn.initialize(null); + } + public void update(XmlSecondaryTable secondaryTable) { this.secondaryTable = secondaryTable; super.update(secondaryTable); this.updateSpecifiedPrimaryKeyJoinColumns(secondaryTable); + this.updateDefaultPrimaryKeyJoinColumn(secondaryTable); } protected void updateSpecifiedPrimaryKeyJoinColumns(XmlSecondaryTable secondaryTable) { @@ -185,6 +241,21 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } } + protected void updateDefaultPrimaryKeyJoinColumn(XmlSecondaryTable secondaryTable) { + if (!shouldBuildDefaultPrimaryKeyJoinColumn()) { + setDefaultPrimaryKeyJoinColumn(null); + return; + } + if (getDefaultPrimaryKeyJoinColumn() == null) { + OrmPrimaryKeyJoinColumn joinColumn = this.jpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); + joinColumn.initialize(null); + this.setDefaultPrimaryKeyJoinColumn(joinColumn); + } + else { + this.defaultPrimaryKeyJoinColumn.update(null); + } + } + protected OrmPrimaryKeyJoinColumn createPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn primaryKeyJoinColumn) { OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = jpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); ormPrimaryKeyJoinColumn.initialize(primaryKeyJoinColumn); @@ -266,7 +337,7 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } public boolean isVirtual(AbstractJoinColumn joinColumn) { - return GenericOrmSecondaryTable.this.defaultPrimaryKeyJoinColumns.contains(joinColumn); + return GenericOrmSecondaryTable.this.defaultPrimaryKeyJoinColumn == joinColumn; } public String defaultColumnName() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java new file mode 100644 index 0000000000..5d7c92f0ca --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.core.internal.context.orm; + +import org.eclipse.jpt.core.TextRange; +import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.resource.common.AbstractJpaEObject; +import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; + +/** + * A virtual primary key join column is used to represent the XmlPrimaryKeyJoinColumn resource object + * within a virtual secondary table. A virtual secondary table is one which is not specified + * in the orm.xml file, but is implied from the underlying java. Virtual pk join column + * is not used when the secondary table is specified in the orm.xml. + * + * A virtual pk join column delegates to the underlying java pk join column for its state. + */ +public class VirtualXmlPrimaryKeyJoinColumn extends AbstractJpaEObject implements XmlPrimaryKeyJoinColumn +{ + + protected JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn; + + + protected VirtualXmlPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) { + super(); + this.javaPrimaryKeyJoinColumn = javaPrimaryKeyJoinColumn; + } + + public String getName() { + return this.javaPrimaryKeyJoinColumn.getName(); + } + + public void setName(String value) { + throw new UnsupportedOperationException("cannot set values on a virtual mapping"); + } + + public String getColumnDefinition() { + return this.javaPrimaryKeyJoinColumn.getColumnDefinition(); + } + + public void setColumnDefinition(String value) { + throw new UnsupportedOperationException("cannot set values on a virtual mapping"); + } + + public String getReferencedColumnName() { + return this.javaPrimaryKeyJoinColumn.getReferencedColumnName(); + } + + public void setReferencedColumnName(String value) { + throw new UnsupportedOperationException("cannot set values on a virtual mapping"); + } + + public TextRange nameTextRange() { + return null; + } + + public TextRange referencedColumnNameTextRange() { + return null; + } + + public void update(JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) { + this.javaPrimaryKeyJoinColumn = javaPrimaryKeyJoinColumn; + } +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java index 5783fa462b..4be8595812 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java @@ -12,13 +12,23 @@ package org.eclipse.jpt.core.internal.context.orm; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.jpt.core.TextRange; +import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn; import org.eclipse.jpt.core.context.java.JavaSecondaryTable; import org.eclipse.jpt.core.resource.common.AbstractJpaEObject; import org.eclipse.jpt.core.resource.orm.OrmPackage; import org.eclipse.jpt.core.resource.orm.UniqueConstraint; import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; +import org.eclipse.jpt.utility.internal.CollectionTools; +/** + * A virtual secondary table is used to represent the XmlSecondaryTable resource object. + * A virtual secondary table is one which is not specified in the orm.xml file, + * but is implied from the underlying java. Virtual secondary table + * is not used when the secondary table is specified in the orm.xml. + * + * A virtual secondary table delegates to the underlying java secondary table for its state. + */ public class VirtualXmlSecondaryTable extends AbstractJpaEObject implements XmlSecondaryTable { @@ -62,6 +72,11 @@ public class VirtualXmlSecondaryTable extends AbstractJpaEObject implements XmlS { primaryKeyJoinColumns = new EObjectContainmentEList<XmlPrimaryKeyJoinColumn>(XmlPrimaryKeyJoinColumn.class, this, OrmPackage.XML_SECONDARY_TABLE_IMPL__PRIMARY_KEY_JOIN_COLUMNS); } + for (JavaPrimaryKeyJoinColumn pkJoinColumn : CollectionTools.iterable(javaSecondaryTable.specifiedPrimaryKeyJoinColumns())) { + XmlPrimaryKeyJoinColumn xmlPkJoinColumn = new VirtualXmlPrimaryKeyJoinColumn(pkJoinColumn); + primaryKeyJoinColumns.add(xmlPkJoinColumn); + } + return primaryKeyJoinColumns; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java index 9daa4c4eca..87f561434b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Oracle. All rights reserved. + * Copyright (c) 2007, 2008 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. @@ -194,6 +194,7 @@ import org.eclipse.jpt.core.resource.orm.OrmResourceModel; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; import org.eclipse.jpt.core.resource.persistence.PersistenceResource; import org.eclipse.jpt.core.resource.persistence.PersistenceResourceModel; import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef; @@ -504,8 +505,8 @@ public class GenericJpaFactory implements JpaFactory return new GenericOrmTable(parent); } - public OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent) { - return new GenericOrmSecondaryTable(parent); + public OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent, XmlSecondaryTable xmlSecondaryTable) { + return new GenericOrmSecondaryTable(parent, xmlSecondaryTable); } public OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmAbstractJoinColumn.Owner owner) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/translators/PrimaryKeyJoinColumnTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/translators/PrimaryKeyJoinColumnTranslator.java index 236324d307..3ab0f25fa7 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/translators/PrimaryKeyJoinColumnTranslator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/translators/PrimaryKeyJoinColumnTranslator.java @@ -9,7 +9,9 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.resource.orm.translators; +import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.wst.common.internal.emf.resource.IDTranslator; import org.eclipse.wst.common.internal.emf.resource.Translator; @@ -24,6 +26,11 @@ public class PrimaryKeyJoinColumnTranslator extends Translator } @Override + public EObject createEMFObject(String nodeName, String readAheadName) { + return OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); + } + + @Override public Translator[] getChildren(Object target, int versionID) { if (this.children == null) { this.children = createChildren(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmFactory.java index b95617e455..c99bdf5300 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmFactory.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmFactory.java @@ -129,7 +129,7 @@ public class OrmFactory extends EFactoryImpl case OrmPackage.PRE_PERSIST: return (EObject)createPrePersist(); case OrmPackage.PRE_REMOVE: return (EObject)createPreRemove(); case OrmPackage.PRE_UPDATE: return (EObject)createPreUpdate(); - case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN: return (EObject)createXmlPrimaryKeyJoinColumn(); + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL: return (EObject)createXmlPrimaryKeyJoinColumnImpl(); case OrmPackage.XML_QUERY_HINT: return (EObject)createXmlQueryHint(); case OrmPackage.XML_TABLE: return (EObject)createXmlTable(); case OrmPackage.XML_SECONDARY_TABLE_IMPL: return (EObject)createXmlSecondaryTableImpl(); @@ -705,10 +705,10 @@ public class OrmFactory extends EFactoryImpl * <!-- end-user-doc --> * @generated */ - public XmlPrimaryKeyJoinColumn createXmlPrimaryKeyJoinColumn() + public XmlPrimaryKeyJoinColumnImpl createXmlPrimaryKeyJoinColumnImpl() { - XmlPrimaryKeyJoinColumn xmlPrimaryKeyJoinColumn = new XmlPrimaryKeyJoinColumn(); - return xmlPrimaryKeyJoinColumn; + XmlPrimaryKeyJoinColumnImpl xmlPrimaryKeyJoinColumnImpl = new XmlPrimaryKeyJoinColumnImpl(); + return xmlPrimaryKeyJoinColumnImpl; } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java index 0217cc0121..9de6569f0d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/OrmPackage.java @@ -4041,7 +4041,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlBaseTable() * @generated */ - public static final int XML_BASE_TABLE = 76; + public static final int XML_BASE_TABLE = 77; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4169,7 +4169,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getAbstractXmlBaseTable() * @generated */ - public static final int ABSTRACT_XML_BASE_TABLE = 75; + public static final int ABSTRACT_XML_BASE_TABLE = 76; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4713,7 +4713,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION = ABSTRACT_XML_NAMED_COLUMN__COLUMN_DEFINITION; + public static final int XML_PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION = XML_NAMED_COLUMN__COLUMN_DEFINITION; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4722,7 +4722,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_PRIMARY_KEY_JOIN_COLUMN__NAME = ABSTRACT_XML_NAMED_COLUMN__NAME; + public static final int XML_PRIMARY_KEY_JOIN_COLUMN__NAME = XML_NAMED_COLUMN__NAME; /** * The feature id for the '<em><b>Referenced Column Name</b></em>' attribute. @@ -4731,7 +4731,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME = ABSTRACT_XML_NAMED_COLUMN_FEATURE_COUNT + 0; + public static final int XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME = XML_NAMED_COLUMN_FEATURE_COUNT + 0; /** * The number of structural features of the '<em>Xml Primary Key Join Column</em>' class. @@ -4740,7 +4740,53 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_PRIMARY_KEY_JOIN_COLUMN_FEATURE_COUNT = ABSTRACT_XML_NAMED_COLUMN_FEATURE_COUNT + 1; + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_FEATURE_COUNT = XML_NAMED_COLUMN_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl <em>Xml Primary Key Join Column Impl</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl + * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlPrimaryKeyJoinColumnImpl() + * @generated + */ + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_IMPL = 74; + + /** + * The feature id for the '<em><b>Column Definition</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__COLUMN_DEFINITION = ABSTRACT_XML_NAMED_COLUMN__COLUMN_DEFINITION; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__NAME = ABSTRACT_XML_NAMED_COLUMN__NAME; + + /** + * The feature id for the '<em><b>Referenced Column Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME = ABSTRACT_XML_NAMED_COLUMN_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Xml Primary Key Join Column Impl</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_PRIMARY_KEY_JOIN_COLUMN_IMPL_FEATURE_COUNT = ABSTRACT_XML_NAMED_COLUMN_FEATURE_COUNT + 1; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.XmlQueryHint <em>Xml Query Hint</em>}' class. @@ -4750,7 +4796,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlQueryHint() * @generated */ - public static final int XML_QUERY_HINT = 74; + public static final int XML_QUERY_HINT = 75; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4787,7 +4833,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlTable() * @generated */ - public static final int XML_TABLE = 77; + public static final int XML_TABLE = 78; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4842,7 +4888,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlSecondaryTable() * @generated */ - public static final int XML_SECONDARY_TABLE = 78; + public static final int XML_SECONDARY_TABLE = 79; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4906,7 +4952,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlSecondaryTableImpl() * @generated */ - public static final int XML_SECONDARY_TABLE_IMPL = 79; + public static final int XML_SECONDARY_TABLE_IMPL = 80; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -4970,7 +5016,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlGenerator() * @generated */ - public static final int XML_GENERATOR = 80; + public static final int XML_GENERATOR = 81; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5016,7 +5062,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlSequenceGenerator() * @generated */ - public static final int XML_SEQUENCE_GENERATOR = 81; + public static final int XML_SEQUENCE_GENERATOR = 82; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5071,7 +5117,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlSequenceGeneratorImpl() * @generated */ - public static final int XML_SEQUENCE_GENERATOR_IMPL = 82; + public static final int XML_SEQUENCE_GENERATOR_IMPL = 83; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5126,7 +5172,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getSqlResultSetMapping() * @generated */ - public static final int SQL_RESULT_SET_MAPPING = 83; + public static final int SQL_RESULT_SET_MAPPING = 84; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5172,7 +5218,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlTableGenerator() * @generated */ - public static final int XML_TABLE_GENERATOR = 84; + public static final int XML_TABLE_GENERATOR = 85; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5281,7 +5327,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlTableGeneratorImpl() * @generated */ - public static final int XML_TABLE_GENERATOR_IMPL = 85; + public static final int XML_TABLE_GENERATOR_IMPL = 86; /** * The feature id for the '<em><b>Name</b></em>' attribute. @@ -5390,7 +5436,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getUniqueConstraint() * @generated */ - public static final int UNIQUE_CONSTRAINT = 86; + public static final int UNIQUE_CONSTRAINT = 87; /** * The feature id for the '<em><b>Column Names</b></em>' attribute list. @@ -5418,7 +5464,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getAccessType() * @generated */ - public static final int ACCESS_TYPE = 87; + public static final int ACCESS_TYPE = 88; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.DiscriminatorType <em>Discriminator Type</em>}' enum. @@ -5428,7 +5474,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getDiscriminatorType() * @generated */ - public static final int DISCRIMINATOR_TYPE = 88; + public static final int DISCRIMINATOR_TYPE = 89; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.EnumType <em>Enum Type</em>}' enum. @@ -5438,7 +5484,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getEnumType() * @generated */ - public static final int ENUM_TYPE = 89; + public static final int ENUM_TYPE = 90; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.FetchType <em>Fetch Type</em>}' enum. @@ -5448,7 +5494,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getFetchType() * @generated */ - public static final int FETCH_TYPE = 90; + public static final int FETCH_TYPE = 91; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.GenerationType <em>Generation Type</em>}' enum. @@ -5458,7 +5504,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getGenerationType() * @generated */ - public static final int GENERATION_TYPE = 91; + public static final int GENERATION_TYPE = 92; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.InheritanceType <em>Inheritance Type</em>}' enum. @@ -5468,7 +5514,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getInheritanceType() * @generated */ - public static final int INHERITANCE_TYPE = 92; + public static final int INHERITANCE_TYPE = 93; /** * The meta object id for the '{@link org.eclipse.jpt.core.resource.orm.TemporalType <em>Temporal Type</em>}' enum. @@ -5478,7 +5524,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getTemporalType() * @generated */ - public static final int TEMPORAL_TYPE = 93; + public static final int TEMPORAL_TYPE = 94; /** * The meta object id for the '<em>Discriminator Value</em>' data type. @@ -5488,7 +5534,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getDiscriminatorValue() * @generated */ - public static final int DISCRIMINATOR_VALUE = 94; + public static final int DISCRIMINATOR_VALUE = 95; /** * The meta object id for the '<em>Enumerated</em>' data type. @@ -5498,7 +5544,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getEnumerated() * @generated */ - public static final int ENUMERATED = 95; + public static final int ENUMERATED = 96; /** * The meta object id for the '<em>Order By</em>' data type. @@ -5508,7 +5554,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getOrderBy() * @generated */ - public static final int ORDER_BY = 96; + public static final int ORDER_BY = 97; /** * The meta object id for the '<em>Version Type</em>' data type. @@ -5518,7 +5564,7 @@ public class OrmPackage extends EPackageImpl * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getVersionType() * @generated */ - public static final int VERSION_TYPE = 97; + public static final int VERSION_TYPE = 98; /** * <!-- begin-user-doc --> @@ -6043,6 +6089,13 @@ public class OrmPackage extends EPackageImpl * <!-- end-user-doc --> * @generated */ + private EClass xmlPrimaryKeyJoinColumnImplEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ private EClass xmlQueryHintEClass = null; /** @@ -9525,6 +9578,20 @@ public class OrmPackage extends EPackageImpl /** + * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl <em>Xml Primary Key Join Column Impl</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Xml Primary Key Join Column Impl</em>'. + * @see org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl + * @generated + */ + public EClass getXmlPrimaryKeyJoinColumnImpl() + { + return xmlPrimaryKeyJoinColumnImplEClass; + } + + + /** * Returns the meta object for class '{@link org.eclipse.jpt.core.resource.orm.XmlQueryHint <em>Xml Query Hint</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -10507,6 +10574,8 @@ public class OrmPackage extends EPackageImpl xmlPrimaryKeyJoinColumnEClass = createEClass(XML_PRIMARY_KEY_JOIN_COLUMN); createEAttribute(xmlPrimaryKeyJoinColumnEClass, XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME); + xmlPrimaryKeyJoinColumnImplEClass = createEClass(XML_PRIMARY_KEY_JOIN_COLUMN_IMPL); + xmlQueryHintEClass = createEClass(XML_QUERY_HINT); createEAttribute(xmlQueryHintEClass, XML_QUERY_HINT__NAME); createEAttribute(xmlQueryHintEClass, XML_QUERY_HINT__VALUE); @@ -10670,7 +10739,9 @@ public class OrmPackage extends EPackageImpl prePersistEClass.getESuperTypes().add(this.getEventMethod()); preRemoveEClass.getESuperTypes().add(this.getEventMethod()); preUpdateEClass.getESuperTypes().add(this.getEventMethod()); - xmlPrimaryKeyJoinColumnEClass.getESuperTypes().add(this.getAbstractXmlNamedColumn()); + xmlPrimaryKeyJoinColumnEClass.getESuperTypes().add(this.getXmlNamedColumn()); + xmlPrimaryKeyJoinColumnImplEClass.getESuperTypes().add(this.getAbstractXmlNamedColumn()); + xmlPrimaryKeyJoinColumnImplEClass.getESuperTypes().add(this.getXmlPrimaryKeyJoinColumn()); abstractXmlBaseTableEClass.getESuperTypes().add(this.getXmlBaseTable()); xmlTableEClass.getESuperTypes().add(this.getAbstractXmlBaseTable()); xmlSecondaryTableEClass.getESuperTypes().add(this.getXmlBaseTable()); @@ -10977,9 +11048,11 @@ public class OrmPackage extends EPackageImpl initEClass(preUpdateEClass, PreUpdate.class, "PreUpdate", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEClass(xmlPrimaryKeyJoinColumnEClass, XmlPrimaryKeyJoinColumn.class, "XmlPrimaryKeyJoinColumn", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEClass(xmlPrimaryKeyJoinColumnEClass, XmlPrimaryKeyJoinColumn.class, "XmlPrimaryKeyJoinColumn", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXmlPrimaryKeyJoinColumn_ReferencedColumnName(), theXMLTypePackage.getString(), "referencedColumnName", null, 0, 1, XmlPrimaryKeyJoinColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEClass(xmlPrimaryKeyJoinColumnImplEClass, XmlPrimaryKeyJoinColumnImpl.class, "XmlPrimaryKeyJoinColumnImpl", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEClass(xmlQueryHintEClass, XmlQueryHint.class, "XmlQueryHint", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXmlQueryHint_Name(), theXMLTypePackage.getString(), "name", null, 1, 1, XmlQueryHint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXmlQueryHint_Value(), theXMLTypePackage.getString(), "value", null, 1, 1, XmlQueryHint.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -13027,6 +13100,16 @@ public class OrmPackage extends EPackageImpl public static final EAttribute XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME = eINSTANCE.getXmlPrimaryKeyJoinColumn_ReferencedColumnName(); /** + * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl <em>Xml Primary Key Join Column Impl</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl + * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlPrimaryKeyJoinColumnImpl() + * @generated + */ + public static final EClass XML_PRIMARY_KEY_JOIN_COLUMN_IMPL = eINSTANCE.getXmlPrimaryKeyJoinColumnImpl(); + + /** * The meta object literal for the '{@link org.eclipse.jpt.core.resource.orm.XmlQueryHint <em>Xml Query Hint</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumn.java index 440d4d1ea0..64db56d964 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumn.java @@ -9,13 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.resource.orm; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.jpt.core.TextRange; -import org.eclipse.jpt.core.internal.emfutility.DOMUtilities; -import org.eclipse.jpt.core.internal.resource.orm.translators.OrmXmlMapper; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; /** * <!-- begin-user-doc --> @@ -36,51 +30,11 @@ import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; * </p> * * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlPrimaryKeyJoinColumn() - * @model kind="class" + * @model kind="class" interface="true" abstract="true" * @generated */ -public class XmlPrimaryKeyJoinColumn extends AbstractXmlNamedColumn +public interface XmlPrimaryKeyJoinColumn extends XmlNamedColumn { - /** - * The default value of the '{@link #getReferencedColumnName() <em>Referenced Column Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReferencedColumnName() - * @generated - * @ordered - */ - protected static final String REFERENCED_COLUMN_NAME_EDEFAULT = null; - - /** - * The cached value of the '{@link #getReferencedColumnName() <em>Referenced Column Name</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getReferencedColumnName() - * @generated - * @ordered - */ - protected String referencedColumnName = REFERENCED_COLUMN_NAME_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected XmlPrimaryKeyJoinColumn() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() - { - return OrmPackage.Literals.XML_PRIMARY_KEY_JOIN_COLUMN; - } /** * Returns the value of the '<em><b>Referenced Column Name</b></em>' attribute. @@ -96,10 +50,7 @@ public class XmlPrimaryKeyJoinColumn extends AbstractXmlNamedColumn * @model dataType="org.eclipse.emf.ecore.xml.type.String" * @generated */ - public String getReferencedColumnName() - { - return referencedColumnName; - } + String getReferencedColumnName(); /** * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn#getReferencedColumnName <em>Referenced Column Name</em>}' attribute. @@ -109,101 +60,13 @@ public class XmlPrimaryKeyJoinColumn extends AbstractXmlNamedColumn * @see #getReferencedColumnName() * @generated */ - public void setReferencedColumnName(String newReferencedColumnName) - { - String oldReferencedColumnName = referencedColumnName; - referencedColumnName = newReferencedColumnName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME, oldReferencedColumnName, referencedColumnName)); - } + void setReferencedColumnName(String value); - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) - { - switch (featureID) - { - case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME: - return getReferencedColumnName(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) - { - switch (featureID) - { - case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME: - setReferencedColumnName((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) - { - switch (featureID) - { - case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME: - setReferencedColumnName(REFERENCED_COLUMN_NAME_EDEFAULT); - return; - } - super.eUnset(featureID); - } /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated + * Return the {@link TextRange} for the referenced-column-name attibute. If the referenced-column-name attibute + * does not exist return the {@link TextRange} for the *table element. */ - @Override - public boolean eIsSet(int featureID) - { - switch (featureID) - { - case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME: - return REFERENCED_COLUMN_NAME_EDEFAULT == null ? referencedColumnName != null : !REFERENCED_COLUMN_NAME_EDEFAULT.equals(referencedColumnName); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() - { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (referencedColumnName: "); - result.append(referencedColumnName); - result.append(')'); - return result.toString(); - } - - public TextRange referencedColumnNameTextRange() { - IDOMNode referencedColumnNameNode = (IDOMNode) DOMUtilities.getChildAttributeNode(this.node, OrmXmlMapper.REFERENCED_COLUMN_NAME); - return (referencedColumnNameNode == null) ? validationTextRange() : buildTextRange(referencedColumnNameNode); - } - + TextRange referencedColumnNameTextRange(); } // PrimaryKeyJoinColumn diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumnImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumnImpl.java new file mode 100644 index 0000000000..ebfe2c2a4a --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/orm/XmlPrimaryKeyJoinColumnImpl.java @@ -0,0 +1,239 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.core.resource.orm; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.jpt.core.TextRange; +import org.eclipse.jpt.core.internal.emfutility.DOMUtilities; +import org.eclipse.jpt.core.internal.resource.orm.translators.OrmXmlMapper; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Xml Primary Key Join Column Impl</b></em>'. + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * <!-- end-user-doc --> + * + * + * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlPrimaryKeyJoinColumnImpl() + * @model kind="class" + * @generated + */ +public class XmlPrimaryKeyJoinColumnImpl extends AbstractXmlNamedColumn implements XmlPrimaryKeyJoinColumn +{ + /** + * The default value of the '{@link #getReferencedColumnName() <em>Referenced Column Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getReferencedColumnName() + * @generated + * @ordered + */ + protected static final String REFERENCED_COLUMN_NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getReferencedColumnName() <em>Referenced Column Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getReferencedColumnName() + * @generated + * @ordered + */ + protected String referencedColumnName = REFERENCED_COLUMN_NAME_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected XmlPrimaryKeyJoinColumnImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() + { + return OrmPackage.Literals.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL; + } + + /** + * Returns the value of the '<em><b>Referenced Column Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Referenced Column Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Referenced Column Name</em>' attribute. + * @see #setReferencedColumnName(String) + * @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlPrimaryKeyJoinColumn_ReferencedColumnName() + * @model dataType="org.eclipse.emf.ecore.xml.type.String" + * @generated + */ + public String getReferencedColumnName() + { + return referencedColumnName; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumnImpl#getReferencedColumnName <em>Referenced Column Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Referenced Column Name</em>' attribute. + * @see #getReferencedColumnName() + * @generated + */ + public void setReferencedColumnName(String newReferencedColumnName) + { + String oldReferencedColumnName = referencedColumnName; + referencedColumnName = newReferencedColumnName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME, oldReferencedColumnName, referencedColumnName)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME: + return getReferencedColumnName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME: + setReferencedColumnName((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) + { + switch (featureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME: + setReferencedColumnName(REFERENCED_COLUMN_NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME: + return REFERENCED_COLUMN_NAME_EDEFAULT == null ? referencedColumnName != null : !REFERENCED_COLUMN_NAME_EDEFAULT.equals(referencedColumnName); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) + { + if (baseClass == XmlPrimaryKeyJoinColumn.class) + { + switch (derivedFeatureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME: return OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) + { + if (baseClass == XmlPrimaryKeyJoinColumn.class) + { + switch (baseFeatureID) + { + case OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME: return OrmPackage.XML_PRIMARY_KEY_JOIN_COLUMN_IMPL__REFERENCED_COLUMN_NAME; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (referencedColumnName: "); + result.append(referencedColumnName); + result.append(')'); + return result.toString(); + } + + public TextRange referencedColumnNameTextRange() { + IDOMNode referencedColumnNameNode = (IDOMNode) DOMUtilities.getChildAttributeNode(this.node, OrmXmlMapper.REFERENCED_COLUMN_NAME); + return (referencedColumnNameNode == null) ? validationTextRange() : buildTextRange(referencedColumnNameNode); + } +} // XmlPrimaryKeyJoinColumnImpl |