diff options
author | nhauge | 2012-03-26 14:35:24 +0000 |
---|---|---|
committer | nhauge | 2012-03-26 14:35:24 +0000 |
commit | b66a2364196a55a9dffb3ccf20954bb89ce008ea (patch) | |
tree | b89f210039cfc69a5a9332564ca9170f462a1285 /jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1 | |
parent | b6b980a61465e86a3d5b22ae89f3256d46a289ab (diff) | |
download | webtools.dali-b66a2364196a55a9dffb3ccf20954bb89ce008ea.tar.gz webtools.dali-b66a2364196a55a9dffb3ccf20954bb89ce008ea.tar.xz webtools.dali-b66a2364196a55a9dffb3ccf20954bb89ce008ea.zip |
This commit was manufactured by cvs2svn to create tag 'v201203261436'.v201203261436
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1')
190 files changed, 0 insertions, 25630 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java deleted file mode 100644 index a35e675b89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1; - -import org.eclipse.jpt.jpa.core.JpaDataSource; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.internal.AbstractJpaNode; -import org.eclipse.jpt.jpa.db.ConnectionAdapter; -import org.eclipse.jpt.jpa.db.ConnectionListener; -import org.eclipse.jpt.jpa.db.ConnectionProfile; -import org.eclipse.jpt.jpa.db.ConnectionProfileFactory; -import org.eclipse.jpt.jpa.db.ConnectionProfileListener; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.DatabaseIdentifierAdapter; -import org.eclipse.jpt.jpa.db.Table; - -/** - * GenericJpaDataSource - */ -public class GenericJpaDataSource - extends AbstractJpaNode - implements JpaDataSource -{ - /** - * cache the connection profile name so we can detect when - * it changes and notify listeners - */ - protected String connectionProfileName; - - protected transient ConnectionProfile connectionProfile; - - /** - * listen for the connection to be added or removed or its name changed - */ - protected final ConnectionProfileListener connectionProfileListener; - - /** - * listen for the connection to be opened or closed - */ - protected final ConnectionListener connectionListener; - - - // ********** constructor/initialization ********** - - public GenericJpaDataSource(JpaProject jpaProject, String connectionProfileName) { - super(jpaProject); - //moving the building of the connection profile before the connectionProfileListener - //is added. Need to make sure the loading of db profiles is completed before - //listening, otherwise we get notifications before our model is finished being built. - //this means our updater is called before it is set which results in an IllegalStateException. - //Hopefully this change is temporary and DTP will fix bug 246270 where I suggest they - //not fire events when building profiles. - this.connectionProfileName = connectionProfileName; - this.connectionProfile = this.buildConnectionProfile(connectionProfileName); - - this.connectionProfileListener = this.buildConnectionProfileListener(); - this.getConnectionProfileFactory().addConnectionProfileListener(this.connectionProfileListener); - - this.connectionListener = this.buildConnectionListener(); - if (this.connectionProfile != null) { - this.connectionProfile.addConnectionListener(this.connectionListener); - } - } - - protected ConnectionProfileFactory getConnectionProfileFactory() { - return this.getJpaPlatform().getConnectionProfileFactory(); - } - - protected ConnectionProfileListener buildConnectionProfileListener() { - return new LocalConnectionProfileListener(); - } - - protected ConnectionListener buildConnectionListener() { - return new LocalConnectionListener(); - } - - - // ********** JpaDataSource implementation ********** - - public String getConnectionProfileName() { - return this.connectionProfileName; - } - - public void setConnectionProfileName(String name) { - String old = this.connectionProfileName; - this.connectionProfileName = name; - if (this.firePropertyChanged(CONNECTION_PROFILE_NAME_PROPERTY, old, name)) { - // sync the connection profile when the name changes - this.setConnectionProfile(this.buildConnectionProfile(name)); - JptJpaCorePlugin.setConnectionProfileName(this.getJpaProject().getProject(), name); - } - } - - public ConnectionProfile getConnectionProfile() { - return this.connectionProfile; - } - - @Override - public boolean connectionProfileIsActive() { - ConnectionProfile cp = this.connectionProfile; - return (cp != null) && cp.isActive(); - } - - @Override - public Database getDatabase() { - ConnectionProfile cp = this.connectionProfile; - return (cp == null) ? null : cp.getDatabase(); - } - - public Table selectTableForIdentifier(Iterable<Table> tables, String identifier) { - Database db = this.getDatabase(); - return (db == null) ? null : db.selectTableForIdentifier(tables, identifier); - } - - public void dispose() { - if (this.connectionProfile != null) { - this.connectionProfile.removeConnectionListener(this.connectionListener); - } - this.getConnectionProfileFactory().removeConnectionProfileListener(this.connectionProfileListener); - } - - - // ********** internal methods ********** - - protected ConnectionProfile buildConnectionProfile(String name) { - return this.getConnectionProfileFactory().buildConnectionProfile(name, this.buildDatabaseIdentifierAdapter()); - } - - protected DatabaseIdentifierAdapter buildDatabaseIdentifierAdapter() { - return this.isJpa2_0Compatible() ? - this.getJpaFactory2_0().buildDatabaseIdentifierAdapter(this) : - DatabaseIdentifierAdapter.Default.instance(); - } - - protected void setConnectionProfile(ConnectionProfile connectionProfile) { - ConnectionProfile old = this.connectionProfile; - if (old != null) { - old.removeConnectionListener(this.connectionListener); - } - this.connectionProfile = connectionProfile; - if (connectionProfile != null) { - connectionProfile.addConnectionListener(this.connectionListener); - } - this.firePropertyChanged(CONNECTION_PROFILE_PROPERTY, old, connectionProfile); - } - - - // ********** overrides ********** - - @Override - public void toString(StringBuilder sb) { - sb.append(this.connectionProfileName); - } - - - // ********** member classes ********** - - /** - * Listen for a connection profile with our name being removed. - * Also listen for our connection's name being changed. - */ - protected class LocalConnectionProfileListener - implements ConnectionProfileListener - { - protected LocalConnectionProfileListener() { - super(); - } - - public void connectionProfileAdded(String name) { - // check to see if a connection profile with our name was added - // (assume our connection profile is null) - if (GenericJpaDataSource.this.connectionProfile == null) { - if (name.equals(GenericJpaDataSource.this.getConnectionProfileName())) { - GenericJpaDataSource.this.setConnectionProfileName(name); // this will trigger creation of CP - } - } - } - - public void connectionProfileRemoved(String name) { - if (GenericJpaDataSource.this.connectionProfile == null) { - return; - } - if (name.equals(GenericJpaDataSource.this.connectionProfile.getName())) { - GenericJpaDataSource.this.setConnectionProfile(null); - } - } - - public void connectionProfileRenamed(String oldName, String newName) { - if (GenericJpaDataSource.this.connectionProfile == null) { - if (newName.equals(GenericJpaDataSource.this.connectionProfileName)) { - GenericJpaDataSource.this.setConnectionProfileName(newName); - } - return; - } - // the connection profile will already have the new name, - // we just need to sync the name held by the data source - if (newName.equals(GenericJpaDataSource.this.connectionProfile.getName())) { - GenericJpaDataSource.this.setConnectionProfileName(newName); - } - } - } - - - /** - * Whenever the connection is opened or closed trigger a project update. - */ - protected class LocalConnectionListener - extends ConnectionAdapter - { - @Override - public void opened(ConnectionProfile profile) { - GenericJpaDataSource.this.stateChanged(); - } - - @Override - public void closed(ConnectionProfile profile) { - GenericJpaDataSource.this.stateChanged(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFactory.java deleted file mode 100644 index 5c44239337..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1; - -import org.eclipse.jpt.jpa.core.internal.AbstractJpaFactory; - -/** - * Generic JPA - */ -public class GenericJpaFactory - extends AbstractJpaFactory -{ - public GenericJpaFactory() { - super(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFile.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFile.java deleted file mode 100644 index 0316462b02..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaFile.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1; - -import java.util.Hashtable; -import java.util.Set; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.common.core.JptResourceModel; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.internal.AbstractJpaNode; - -/** - * The transition between a JPA project and the resource model associated - * with a file. - * Hold the associated root structure nodes, which are hooks to the - * context model. - */ -public class GenericJpaFile - extends AbstractJpaNode - implements JpaFile -{ - /** - * typically a .java or .xml file. - */ - protected final IFile file; - - /** - * cache the content type - if the content type changes, the JPA project - * will throw out the JPA file and build a new one - */ - protected final IContentType contentType; - - /** - * the resource model corresponding to the file - */ - protected final JptResourceModel resourceModel; - - /** - * the root structure (context model) nodes corresponding to the resource - * model - */ - protected final Hashtable<Object, JpaStructureNode> rootStructureNodes = new Hashtable<Object, JpaStructureNode>(); - - - // ********** construction ********** - - public GenericJpaFile(JpaProject jpaProject, IFile file, IContentType contentType, JptResourceModel resourceModel) { - super(jpaProject); - this.file = file; - this.contentType = contentType; - this.resourceModel = resourceModel; - } - - /** - * Changes to {@link #ROOT_STRUCTURE_NODES_COLLECTION} do not need to trigger a - * project update. Only the UI cares about the root structure nodes. - * If a project update is allowed to happen, an infinite loop will result - * if any Java class is specified in more than one location in the - * persistence unit. - */ - @Override - protected void addNonUpdateAspectNamesTo(Set<String> nonUpdateAspectNames) { - super.addNonUpdateAspectNamesTo(nonUpdateAspectNames); - nonUpdateAspectNames.add(ROOT_STRUCTURE_NODES_COLLECTION); - } - - - // ********** file ********** - - public IFile getFile() { - return this.file; - } - - public IContentType getContentType() { - return this.contentType; - } - - public JptResourceModel getResourceModel() { - return this.resourceModel; - } - - public JptResourceModel getResourceModel(IContentType ct) { - return this.contentType.isKindOf(ct) ? this.resourceModel : null; - } - - - // ********** root structure nodes ********** - - public Iterable<JpaStructureNode> getRootStructureNodes() { - return new LiveCloneIterable<JpaStructureNode>(this.rootStructureNodes.values()); - } - - public int getRootStructureNodesSize() { - return this.rootStructureNodes.size(); - } - - public void addRootStructureNode(Object key, JpaStructureNode rootStructureNode) { - JpaStructureNode old = this.rootStructureNodes.put(key, rootStructureNode); - if (rootStructureNode != old) { - if (old != null) { - this.fireItemRemoved(ROOT_STRUCTURE_NODES_COLLECTION, old); - } - this.fireItemAdded(ROOT_STRUCTURE_NODES_COLLECTION, rootStructureNode); - } - } - - public void removeRootStructureNode(Object key, JpaStructureNode rootStructureNode) { - if (Tools.valuesAreEqual(rootStructureNode, this.rootStructureNodes.get(key))) { - this.fireItemRemoved(ROOT_STRUCTURE_NODES_COLLECTION, this.rootStructureNodes.remove(key)); - } - } - - public JpaStructureNode getStructureNode(int textOffset) { - for (JpaStructureNode rootNode : this.getRootStructureNodes()) { - JpaStructureNode node = rootNode.getStructureNode(textOffset); - if (node != null) { - return node; - } - } - return null; - } - - - // ********** misc ********** - - @Override - public void toString(StringBuilder sb) { - sb.append(this.file); - sb.append('['); - sb.append(this.contentType.getName()); - sb.append(']'); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java deleted file mode 100644 index 2502f19457..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaProject.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1; - -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.internal.AbstractJpaProject; - -/** - * Not much different from the abstract JPA project. - */ -public class GenericJpaProject - extends AbstractJpaProject -{ - - // ********** constructor/initialization ********** - - public GenericJpaProject(JpaProject.Config config) { - super(config); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java deleted file mode 100644 index 6cb8ecdbf1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractEntityPrimaryKeyValidator.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; - -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractEntityPrimaryKeyValidator extends - AbstractPrimaryKeyValidator { - - protected AbstractEntityPrimaryKeyValidator(Entity entity, - PrimaryKeyTextRangeResolver textRangeResolver) { - super(entity, textRangeResolver); - } - - protected Entity entity() { - return (Entity) this.typeMapping(); - } - - @Override - protected IdClassReference idClassReference() { - return entity().getIdClassReference(); - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - // if an entity is non-root, it is not allowed to define primary keys - if (! entity().isRootEntity()) { - validatePrimaryKeyForNonRoot(messages, reporter); - } - else { - validatePrimaryKeyForRoot(messages, reporter); - } - return true; - } - - protected void validatePrimaryKeyForNonRoot(List<IMessage> messages, IReporter reporter) { - validateNonRootEntityDoesNotSpecifyIdClass(messages, reporter); - validateNonRootEntityDoesNotSpecifyPrimaryKeyAttributes(messages, reporter); - } - - protected void validatePrimaryKeyForRoot(List<IMessage> messages, IReporter reporter) { - validatePrimaryKeyIsNotRedefined(messages, reporter); - validateIdClassIsUsedIfNecessary(messages, reporter); - - // if the primary key is not defined on an ancestor, it must be defined here - if (! definesPrimaryKey(typeMapping())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ENTITY_NO_PK, - EMPTY_STRING_ARRAY, - entity(), - textRangeResolver().getTypeMappingTextRange())); - } - - // if primary key is composite, it may either use an id class or embedded id, not both - validateOneOfIdClassOrEmbeddedIdIsUsed(messages, reporter); - // ... and only one embedded id - validateOneEmbeddedId(messages, reporter); - // ... and not both id and embedded id - validateOneOfEmbeddedOrIdIsUsed(messages, reporter); - - validateMapsIdMappings(messages, reporter); - - if (specifiesIdClass()) { - validateIdClass(idClassReference().getIdClass(), messages, reporter); - } - } - - protected void validateNonRootEntityDoesNotSpecifyIdClass(List<IMessage> messages, IReporter reporter) { - if (idClassReference().isSpecified()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ENTITY_NON_ROOT_ID_CLASS_SPECIFIED, - EMPTY_STRING_ARRAY, - entity(), - textRangeResolver().getIdClassTextRange())); - } - } - - protected void validateNonRootEntityDoesNotSpecifyPrimaryKeyAttributes(List<IMessage> messages, IReporter reporter) { - for (AttributeMapping each : getPrimaryKeyMappingsDefinedLocally(typeMapping())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED, - EMPTY_STRING_ARRAY, - each, - textRangeResolver().getAttributeMappingTextRange(each.getName()))); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractJoinTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractJoinTableValidator.java deleted file mode 100644 index 56d9ae3421..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractJoinTableValidator.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public abstract class AbstractJoinTableValidator - extends AbstractTableValidator -{ - protected AbstractJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - super(table, textRangeResolver); - } - - protected AbstractJoinTableValidator(ReadOnlyPersistentAttribute persistentAttribute, ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - super(persistentAttribute, table, textRangeResolver); - } - - @Override - protected String getUnresolvedCatalogMessage() { - return JpaValidationMessages.JOIN_TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getUnresolvedSchemaMessage() { - return JpaValidationMessages.JOIN_TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.JOIN_TABLE_UNRESOLVED_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractMappedSuperclassPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractMappedSuperclassPrimaryKeyValidator.java deleted file mode 100644 index 48440aac5e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractMappedSuperclassPrimaryKeyValidator.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractMappedSuperclassPrimaryKeyValidator - extends AbstractPrimaryKeyValidator -{ - protected AbstractMappedSuperclassPrimaryKeyValidator( - MappedSuperclass mappedSuperclass, PrimaryKeyTextRangeResolver textRangeResolver) { - - super(mappedSuperclass, textRangeResolver); - } - - - protected MappedSuperclass mappedSuperclass() { - return (MappedSuperclass) this.typeMapping(); - } - - @Override - protected IdClassReference idClassReference() { - return mappedSuperclass().getIdClassReference(); - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - validatePrimaryKeyIsNotRedefined(messages, reporter); - validateIdClassIsUsedIfNecessary(messages, reporter); - - // if primary key is composite, it may either use an id class or embedded id, not both - validateOneOfIdClassOrEmbeddedIdIsUsed(messages, reporter); - // ... and only one embedded id - validateOneEmbeddedId(messages, reporter); - // ... and not both id and embedded id - validateOneOfEmbeddedOrIdIsUsed(messages, reporter); - - if (specifiesIdClass()) { - validateIdClass(idClassReference().getIdClass(), messages, reporter); - } - return true; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java deleted file mode 100644 index 40592c0ac7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java +++ /dev/null @@ -1,239 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractNamedColumnValidator<C extends ReadOnlyNamedColumn, R extends NamedColumnTextRangeResolver> - implements JptValidator -{ - /** this is <code>null</code> for columns defined on entities and secondary tables */ - protected final ReadOnlyPersistentAttribute persistentAttribute; - - protected final C column; - - protected final R textRangeResolver; - - protected final TableDescriptionProvider tableDescriptionProvider; - - protected final JptValidator tableValidator; - - - protected AbstractNamedColumnValidator( - C column, - R textRangeResolver) { - this(null, column, textRangeResolver); - } - - protected AbstractNamedColumnValidator( - C column, - R textRangeResolver, - TableDescriptionProvider provider) { - this(null, column, textRangeResolver, provider); - } - - protected AbstractNamedColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - C column, - R textRangeResolver) { - this(persistentAttribute, column, textRangeResolver, TableDescriptionProvider.Null.instance()); - } - - protected AbstractNamedColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - C column, - R textRangeResolver, - TableDescriptionProvider tableDescriptionProvider) { - this.persistentAttribute = persistentAttribute; - this.column = column; - this.textRangeResolver = textRangeResolver; - this.tableDescriptionProvider = tableDescriptionProvider; - this.tableValidator = this.buildTableValidator(); - } - - protected JptValidator buildTableValidator() { - return JptValidator.Null.instance(); - } - - public final boolean validate(List<IMessage> messages, IReporter reporter) { - if (this.tableValidator.validate(messages, reporter)) { - // validate the name only if the table is valid - this.validateName(messages); - } - return true; - } - - protected void validateName(List<IMessage> messages) { - Table dbTable = this.column.getDbTable(); - if ((dbTable != null) && ! this.column.isResolved()) { - messages.add(this.buildUnresolvedNameMessage()); - } - } - - protected IMessage buildUnresolvedNameMessage() { - return this.columnIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnresolvedNameMessage() : - this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); - } - - protected IMessage buildUnresolvedNameMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] { - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getUnresolvedNameMessage(); - - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedNameMessage(); - - protected boolean columnIsPartOfVirtualAttribute() { - return (this.persistentAttribute != null) && - this.persistentAttribute.isVirtual(); - } - - - // ********** table description provider ********** - - public interface TableDescriptionProvider { - String getColumnTableDescriptionMessage(); - - final class Null - implements TableDescriptionProvider - { - private static final TableDescriptionProvider INSTANCE = new Null(); - public static TableDescriptionProvider instance() { - return INSTANCE; - } - // ensure single instance - private Null() { - super(); - } - public String getColumnTableDescriptionMessage() { - throw new UnsupportedOperationException(); - } - @Override - public String toString() { - return StringTools.buildSingletonToString(this); - } - } - } - - - // ********** base column table validator ********** - - /** - * This column table validator (or its subclasses) can only be used by - * a validator for a <em>base</em> column, which specifies a table. This - * includes both normal columns and join columns. - */ - protected class BaseColumnTableValidator - implements JptValidator - { - protected BaseColumnTableValidator() { - super(); - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - if (this.getColumn().tableNameIsInvalid()) { - messages.add(this.buildTableNotValidMessage()); - return false; - } - return true; - } - - protected ReadOnlyTableColumn getColumn() { - return (ReadOnlyTableColumn) AbstractNamedColumnValidator.this.column; - } - - protected IMessage buildTableNotValidMessage() { - return AbstractNamedColumnValidator.this.columnIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeTableNotValidMessage() : - this.buildTableNotValidMessage_(); - } - - protected IMessage buildTableNotValidMessage_() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getColumnTableNotValidMessage(), - new String[] { - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - protected String getColumnTableNotValidMessage() { - return JpaValidationMessages.COLUMN_TABLE_NOT_VALID; - } - - protected String getColumnTableDescriptionMessage() { - return AbstractNamedColumnValidator.this.tableDescriptionProvider.getColumnTableDescriptionMessage(); - } - - protected TableColumnTextRangeResolver getTextRangeResolver() { - return (TableColumnTextRangeResolver) AbstractNamedColumnValidator.this.textRangeResolver; - } - - protected IMessage buildVirtualAttributeTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeColumnTableNotValidMessage(), - new String[] { - AbstractNamedColumnValidator.this.persistentAttribute.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java deleted file mode 100644 index 3cf01eabc4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractPersistentAttributeValidator - implements JptValidator -{ - protected ReadOnlyPersistentAttribute persistentAttribute; - - protected PersistentAttributeTextRangeResolver textRangeResolver; - - - protected AbstractPersistentAttributeValidator( - ReadOnlyPersistentAttribute persistentAttribute, PersistentAttributeTextRangeResolver textRangeResolver) { - this.persistentAttribute = persistentAttribute; - this.textRangeResolver = textRangeResolver; - } - - public final boolean validate(List<IMessage> messages, IReporter reporter) { - if (this.persistentAttribute.getMappingKey() != MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY) { - this.validateMappedAttribute(messages); - } - return true; - } - - protected abstract void validateMappedAttribute(List<IMessage> messages); - - protected IMessage buildAttributeMessage(String msgID) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - msgID, - new String[] {this.persistentAttribute.getName()}, - this.persistentAttribute, - this.textRangeResolver.getAttributeTextRange() - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java deleted file mode 100644 index a01439d3a3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPrimaryKeyValidator.java +++ /dev/null @@ -1,771 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.Collection; -import java.util.List; -import org.eclipse.jpt.common.core.resource.java.JavaResourceField; -import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod; -import org.eclipse.jpt.common.utility.internal.ClassName; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.HashBag; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.IdClassReference; -import org.eclipse.jpt.jpa.core.context.IdMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.PropertyAccessor; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractPrimaryKeyValidator - implements JptValidator -{ - private final TypeMapping typeMapping; - - private final PrimaryKeyTextRangeResolver textRangeResolver; - - public static final String[] EMPTY_STRING_ARRAY = StringTools.EMPTY_STRING_ARRAY; - - protected AbstractPrimaryKeyValidator( - TypeMapping typeMapping, PrimaryKeyTextRangeResolver textRangeResolver) { - - this.typeMapping = typeMapping; - this.textRangeResolver = textRangeResolver; - } - - - protected TypeMapping typeMapping() { - return this.typeMapping; - } - - protected abstract IdClassReference idClassReference(); - - protected PrimaryKeyTextRangeResolver textRangeResolver() { - return this.textRangeResolver; - } - - // for JPA portability, a hierarchy must define its primary key on one class - // (entity *or* mapped superclass) - protected void validatePrimaryKeyIsNotRedefined(List<IMessage> messages, IReporter reporter) { - if (definesPrimaryKeyOnAncestor(typeMapping())) { - if (idClassReference().isSpecified()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_PK_REDEFINED_ID_CLASS, - EMPTY_STRING_ARRAY, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - for (AttributeMapping each : getPrimaryKeyMappingsDefinedLocally(typeMapping())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_PK_REDEFINED_ID_ATTRIBUTE, - EMPTY_STRING_ARRAY, - each, - textRangeResolver().getAttributeMappingTextRange(each.getName()))); - } - return; - } - } - - // if a primary key defining class has multiple primary keys, it must use an id class - protected void validateIdClassIsUsedIfNecessary(List<IMessage> messages, IReporter reporter) { - if (! specifiesIdClass() && idClassIsRequired()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_REQUIRED, - EMPTY_STRING_ARRAY, - typeMapping(), - textRangeResolver().getTypeMappingTextRange())); - } - } - - // only one composite primary key strategy may be used - protected void validateOneOfIdClassOrEmbeddedIdIsUsed(List<IMessage> messages, IReporter reporter) { - if (idClassReference().isSpecified() - && CollectionTools.size(typeMapping().getAllAttributeMappings(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)) > 0) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_AND_EMBEDDED_ID_BOTH_USED, - EMPTY_STRING_ARRAY, - typeMapping(), - textRangeResolver().getTypeMappingTextRange())); - } - } - - //only embedded or id, both may not be used - protected void validateOneOfEmbeddedOrIdIsUsed(List<IMessage> messages, IReporter reporter) { - if (definesEmbeddedIdMapping(typeMapping) && definesIdMapping(typeMapping)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_AND_EMBEDDED_ID_BOTH_USED, - EMPTY_STRING_ARRAY, - typeMapping(), - textRangeResolver().getTypeMappingTextRange())); - } - } - - // only one embedded id may be used - protected void validateOneEmbeddedId(List<IMessage> messages, IReporter reporter) { - if (CollectionTools.size(getEmbeddedIdMappings(typeMapping())) > 1) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_MULTIPLE_EMBEDDED_ID, - EMPTY_STRING_ARRAY, - typeMapping(), - textRangeResolver().getTypeMappingTextRange())); - } - } - - protected void validateMapsIdMappings(List<IMessage> messages, IReporter reporter) { - for (SingleRelationshipMapping2_0 mapsIdRelationshipMapping : getMapsIdMappingsDefinedLocally(typeMapping())) { - // can't use maps id mappings with an id class - if (definesIdClass(typeMapping())) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_WITH_MAPS_ID, - new String[] {mapsIdRelationshipMapping.getName()}, - mapsIdRelationshipMapping, - textRangeResolver().getAttributeMappingTextRange(mapsIdRelationshipMapping.getName()))); - } - - AttributeMapping resolvedAttributeMapping = - mapsIdRelationshipMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getDerivedIdAttributeMapping(); - if (resolvedAttributeMapping != null - && ! ClassName.areAutoboxEquivalents( - resolvedAttributeMapping.getPersistentAttribute().getTypeName(), - getTargetEntityPrimaryKeyTypeName(mapsIdRelationshipMapping))) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_MAPS_ID_ATTRIBUTE_TYPE_DOES_NOT_AGREE, - new String[] {mapsIdRelationshipMapping.getName()}, - mapsIdRelationshipMapping, - textRangeResolver().getAttributeMappingTextRange(mapsIdRelationshipMapping.getName()))); - } - } - } - - protected void validateIdClass(JavaPersistentType idClass, List<IMessage> messages, IReporter reporter) { - // there should already be a validation error if the id class does not resolve to a class - if (idClass == null) { - return; - } - - if (hasDerivedIdMappingMatchingIdClass(idClass)) { - validateIdClass_derivedIdMappingMatchingIdClass(idClass, messages, reporter); - return; - } - - for (JavaPersistentAttribute idClassAttribute : this.getAllIdClassAttributes(idClass)) { - boolean foundMatch = false; - for (AttributeMapping attributeMapping : getAttributeMappings(typeMapping())) { - if (idClassAttribute.getName().equals(attributeMapping.getName())) { - foundMatch = true; - - // the matching attribute should be a primary key - if (! definesPrimaryKey(attributeMapping)) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_NOT_PRIMARY_KEY, - new String[] {idClassAttribute.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - - // the matching attribute's type should agree - String idClassAttributeTypeName = idClassAttribute.getTypeName(); - String attributeMappingTypeName = getTypeNameForIdClass(attributeMapping); - if (attributeMappingTypeName != null // if it's null, there should be - // another failing validation elsewhere - && ! ClassName.areAutoboxEquivalents(idClassAttributeTypeName, attributeMappingTypeName)) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_TYPE_DOES_NOT_AGREE, - new String[] {idClassAttribute.getName(), idClassAttributeTypeName}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - } - } - - if (! foundMatch) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_NO_MATCH, - new String[] {idClassAttribute.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - } - - // This is for validating if a type mapping has extra id attributes that do not match - // an attribute on the id class, which is a supplement of the validation right above - for (AttributeMapping attributeMapping : getPrimaryKeyMappings(typeMapping())) { - AccessType type = attributeMapping.getPersistentAttribute().getOwningPersistentType().getAccess(); - if (type == AccessType.FIELD) { - checkMissingAttribute(idClass, attributeMapping, messages, reporter); - } else if (type == AccessType.PROPERTY) { - // EclipseLink does not care about the existence status of property methods, - // but the matching field in the id class still needs to exist - if (!CollectionTools.contains(getIdClassFieldNames(idClass), attributeMapping.getName())) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_DOES_NOT_EXIST, - new String[] {attributeMapping.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } else { - // Validation for missing property methods is only for generic platform - checkMissingAttributeWithPropertyAccess(idClass, attributeMapping, messages, reporter); - } - } - } - - // This is for validating cases when id class has property-based access - if (typeMapping().getPersistentType().getAccess() == AccessType.PROPERTY) { - validateIdClassAttributesWithPropertyAccess(idClass, messages, reporter); - } - - validateIdClassConstructor(idClass, messages, reporter); - } - - protected void checkMissingAttribute(JavaPersistentType idClass, - AttributeMapping attributeMapping, List<IMessage> messages, IReporter reporter) { - if (!CollectionTools.contains(getIdClassAttributeNames(idClass), attributeMapping.getName())) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_DOES_NOT_EXIST, - new String[] {attributeMapping.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange()) - ); - } - } - - protected abstract void validateIdClassAttributesWithPropertyAccess( - JavaPersistentType idClass, List<IMessage> messages, - IReporter reporter); - - protected void validateIdClassConstructor(JavaPersistentType idClass, - List<IMessage> messages, IReporter reporter) { - if (!idClass.getJavaResourceType().hasNoArgConstructor()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_MISSING_NO_ARG_CONSTRUCTOR, - new String[] {idClass.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange()) - ); - } - } - - protected void checkMissingAttributeWithPropertyAccess(JavaPersistentType idClass, - AttributeMapping attributeMapping, - List<IMessage> messages, IReporter reporter) { - // do nothing - } - - protected void validateIdClass_derivedIdMappingMatchingIdClass( - JavaPersistentType idClass, List<IMessage> messages, IReporter reporter) { - - Collection<AttributeMapping> errorMappings = new HashBag<AttributeMapping>(); - for (AttributeMapping each - : new CompositeIterable<AttributeMapping>(getIdMappings(typeMapping()), getEmbeddedIdMappings(typeMapping()))) { - errorMappings.add(each); - } - Collection<AttributeMapping> errorDerivedIdMappings = new HashBag<AttributeMapping>(); - for (SingleRelationshipMapping2_0 each : getDerivedIdMappings(typeMapping())) { - if (idClass.getName().equals(getTargetEntityPrimaryKeyTypeName(each))) { - errorDerivedIdMappings.add(each); - } - else { - errorMappings.add(each); - } - } - for (AttributeMapping each : errorMappings) { - addNoIdClassAttributeMatchError(each, messages); - } - if (CollectionTools.size(errorDerivedIdMappings) > 1) { - for (AttributeMapping each : errorDerivedIdMappings) { - addDuplicateIdClassAttributeMatchError(each, messages); - } - } - } - - protected void addNoIdClassAttributeMatchError(AttributeMapping attributeMapping, List<IMessage> messages) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_MAPPING_NO_MATCH, - new String[] {attributeMapping.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - - protected void addDuplicateIdClassAttributeMatchError(AttributeMapping attributeMapping, List<IMessage> messages) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_ATTRIBUTE_MAPPING_DUPLICATE_MATCH, - new String[] {attributeMapping.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - - protected void validateIdClassPropertyMethods( - JavaPersistentType idClass, List<IMessage> messages, IReporter reporter) { - - for (JavaPersistentAttribute attribute : getAllIdClassAttributes(idClass)) { - PropertyAccessor accessor = (PropertyAccessor)attribute.getAccessor(); - - // validate getter method - JavaResourceMethod getter = accessor.getResourceGetter(); - if (getter != null) { - validatePropertyMethod(idClass, getter.getMethodName(), messages, reporter); - } - - // validate setter method - JavaResourceMethod setter = accessor.getResourceSetter(); - if (setter != null) { - validatePropertyMethod(idClass, setter.getMethodName(), messages, reporter); - } - } - } - - private void validatePropertyMethod(JavaPersistentType idClass, - String methodName, List<IMessage> messages, IReporter reporter) { - - JavaResourceMethod method = idClass.getJavaResourceType().getMethod(methodName); - - if (!method.isPublicOrProtected()) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_PROPERTY_METHOD_NOT_PUBLIC, - new String[] {idClass.getJavaResourceType().getQualifiedName(), methodName}, - typeMapping(), - textRangeResolver().getIdClassTextRange() - )); - } - } - - protected Iterable<String> getIdClassAttributeNames(JavaPersistentType idClass) { - return new TransformationIterable<JavaPersistentAttribute, String>(getAllIdClassAttributes(idClass)) { - @Override - protected String transform(JavaPersistentAttribute attribute) { - return attribute.getName(); - } - }; - } - - protected Iterable<JavaPersistentAttribute> getAllIdClassAttributes(JavaPersistentType idClass) { - return new SubIterableWrapper<ReadOnlyPersistentAttribute, JavaPersistentAttribute>(idClass.getAllAttributes()); - } - - protected Iterable<String> getIdClassFieldNames(JavaPersistentType idClass) { - return new TransformationIterable<JavaResourceField, String>(idClass.getJavaResourceType().getFields()) { - @Override - protected String transform(JavaResourceField attribute) { - return attribute.getName(); - } - }; - } - - // **************** convenience methods ******************************************************** - - // **************** primary key overall ******************************************************** - - /** - * Return whether an ancestor class has defined any aspect of the primary key - */ - protected boolean definesPrimaryKeyOnAncestor(TypeMapping typeMapping) { - for (TypeMapping each : typeMapping.getInheritanceHierarchy()) { - if (each != typeMapping && definesPrimaryKey(each)) { - return true; - } - } - return false; - } - - /** - * Return whether the type mapping has defined any aspect of the primary key - */ - protected boolean definesPrimaryKey(TypeMapping typeMapping) { - return getIdClass(typeMapping) != null - || ! CollectionTools.isEmpty(getPrimaryKeyMappings(typeMapping)); - } - - /** - * Return true if the type mapping has defined any aspect of a complex primary key - */ - protected boolean definesComplexPrimaryKey(TypeMapping typeMapping) { - return definesIdClass(typeMapping) - || getEmbeddedIdMapping(typeMapping) != null; - } - - /** - * Return the overriding type name of the primary key for the type mapping. - * This may be - * - type of the single simple primary key (id) attribute - * - type of the single complex primary key (embedded id) attribute - * - type of the id class - * - null if none of the above are coherent (i.e. there are multiple possibilities, or the - * primary key is invalid) - */ - protected String getPrimaryKeyTypeName(TypeMapping typeMapping) { - JavaPersistentType idClass = getIdClass(typeMapping); - if (idClass != null) { - return idClass.getName(); - } - EmbeddedIdMapping embeddedId = getEmbeddedIdMapping(typeMapping); - if (embeddedId != null) { - return embeddedId.getPersistentAttribute().getTypeName(); - } - IdMapping id = getIdMapping(typeMapping); - if (id != null) { - return id.getPersistentAttribute().getTypeName(); - } - return null; - } - - /** - * Return whether the attribute mapping has defined any aspect of the primary key - */ - protected boolean definesPrimaryKey(AttributeMapping attributeMapping) { - String mappingKey = attributeMapping.getKey(); - if (CollectionTools.contains(this.getIdMappingKeys(), mappingKey)) { - return true; - } - if (CollectionTools.contains(this.getSingleRelationshipMappingKeys(), mappingKey)) { - SingleRelationshipMapping2_0 relationshipMapping = (SingleRelationshipMapping2_0) attributeMapping; - return (relationshipMapping.getDerivedIdentity().usesIdDerivedIdentityStrategy() - || relationshipMapping.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy()); - } - return false; - } - - protected Iterable<String> getIdMappingKeys() { - return ID_MAPPING_KEYS; - } - - protected static final String[] ID_MAPPING_KEYS_ARRAY = new String[] { - MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, - MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY - }; - - protected static final Iterable<String> ID_MAPPING_KEYS = new ArrayIterable<String>(ID_MAPPING_KEYS_ARRAY); - - protected Iterable<String> getSingleRelationshipMappingKeys() { - return SINGLE_RELATIONSHIP_MAPPING_KEYS; - } - - protected static final String[] SINGLE_RELATIONSHIP_MAPPING_KEYS_ARRAY = new String[] { - MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, - MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY - }; - - protected static final Iterable<String> SINGLE_RELATIONSHIP_MAPPING_KEYS = new ArrayIterable<String>(SINGLE_RELATIONSHIP_MAPPING_KEYS_ARRAY); - - - // **************** id class ********************************************** - - protected boolean specifiesIdClass() { - return idClassReference().isSpecified(); - } - - /** - * Return whether an id class is defined on the class - * NOTE: this is different from whether an id class is *specified*. If a specified id class - * is not resolved, it is not defined. There will be a validation error to that effect. - */ - protected boolean definesIdClass(TypeMapping typeMapping) { - return getIdClass(typeMapping) != null; - } - - /** - * Return whether an ancestor class has defined an id class - */ - protected boolean definesIdClassOnAncestor(TypeMapping typeMapping) { - for (TypeMapping each : typeMapping.getInheritanceHierarchy()) { - if (each != typeMapping && definesIdClass(each)) { - return true; - } - } - return false; - } - - /** - * Return the id class to be used for the type mapping, whether that be locally - * or on an ancestor - */ - protected JavaPersistentType getIdClass(TypeMapping typeMapping) { - for (TypeMapping each : typeMapping.getInheritanceHierarchy()) { - if (each.getIdClass() != null) { - return each.getIdClass(); - } - } - return null; - } - - - // **************** attribute mappings in general ************************* - - /** - * Return all the attribute mappings of the given type - * mapping with transient attribute mappings being excluded - */ - protected Iterable<AttributeMapping> getAttributeMappings(TypeMapping typeMapping) { - return new FilteringIterable<AttributeMapping>(CollectionTools.collection(typeMapping.getAllAttributeMappings())) { - @Override - protected boolean accept(AttributeMapping o) { - return !StringTools.stringsAreEqual(o.getKey(), MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY); - } - }; - } - - /** - * Return all primary key mappings, defined on and above the type mapping - */ - protected Iterable<AttributeMapping> getPrimaryKeyMappings(TypeMapping typeMapping) { - return new CompositeIterable<AttributeMapping>( - getIdMappings(typeMapping), - getEmbeddedIdMappings(typeMapping), - getDerivedIdMappings(typeMapping), - getMapsIdMappings(typeMapping)); - } - - /** - * Return primary key mappings declared directly on the type mapping - */ - protected Iterable<AttributeMapping> getPrimaryKeyMappingsDefinedLocally(TypeMapping typeMapping) { - return new CompositeIterable<AttributeMapping>( - getIdMappingsDefinedLocally(typeMapping), - getEmbeddedIdMappingsDefinedLocally(typeMapping), - getDerivedIdMappingsDefinedLocally(typeMapping), - getMapsIdMappingsDefinedLocally(typeMapping)); - } - - protected boolean hasAnyPrimaryKeyMappings(TypeMapping typeMapping) { - return ! CollectionTools.isEmpty(getPrimaryKeyMappings(typeMapping)); - } - - // **************** id mappings ******************************************* - - protected IdMapping getIdMapping(TypeMapping typeMapping) { - Iterable<IdMapping> idMappings = getIdMappings(typeMapping); - if (CollectionTools.size(idMappings) == 1) { - return idMappings.iterator().next(); - } - return null; - } - - protected Iterable<IdMapping> getIdMappings(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, IdMapping>( - typeMapping.getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY)); - } - - protected Iterable<IdMapping> getIdMappingsDefinedLocally(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, IdMapping>( - typeMapping.getAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY)); - } - - - // **************** embedded id mappings ********************************** - - /** - * Return whether an embedded id is defined for this class, whether that be locally - * or on an ancestor - */ - protected boolean definesEmbeddedIdMapping(TypeMapping typeMapping) { - return ! CollectionTools.isEmpty(getEmbeddedIdMappings(typeMapping)); - } - - /** - * Return whether an id is defined for this class, whether that be locally - * or on an ancestor - */ - protected boolean definesIdMapping(TypeMapping typeMapping) { - return ! CollectionTools.isEmpty(getIdMappings(typeMapping)); - } - - protected EmbeddedIdMapping getEmbeddedIdMapping(TypeMapping typeMapping) { - Iterable<EmbeddedIdMapping> embeddedIdMappings = getEmbeddedIdMappings(typeMapping); - if (CollectionTools.size(embeddedIdMappings) == 1) { - return embeddedIdMappings.iterator().next(); - } - return null; - } - - protected Iterable<EmbeddedIdMapping> getEmbeddedIdMappings(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, EmbeddedIdMapping>( - typeMapping.getAllAttributeMappings(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)); - } - - protected Iterable<EmbeddedIdMapping> getEmbeddedIdMappingsDefinedLocally(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, EmbeddedIdMapping>( - typeMapping.getAttributeMappings(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)); - } - - - // **************** derived id mappings *********************************** - - protected Iterable<SingleRelationshipMapping2_0> getDerivedIdMappings(TypeMapping typeMapping) { - return new FilteringIterable<SingleRelationshipMapping2_0>(this.getAllSingleRelationshipMappings(typeMapping)) { - @Override - protected boolean accept(SingleRelationshipMapping2_0 o) { - return o.getDerivedIdentity().usesIdDerivedIdentityStrategy(); - } - }; - } - - protected Iterable<SingleRelationshipMapping2_0> getAllSingleRelationshipMappings(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(this.getAllSingleRelationshipMappings_(typeMapping)); - } - - @SuppressWarnings("unchecked") - protected Iterable<AttributeMapping> getAllSingleRelationshipMappings_(TypeMapping typeMapping) { - return new CompositeIterable<AttributeMapping>( - typeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY), - typeMapping.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) - ); - } - - protected Iterable<SingleRelationshipMapping2_0> getDerivedIdMappingsDefinedLocally(TypeMapping typeMapping) { - return new FilteringIterable<SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings(typeMapping)) { - @Override - protected boolean accept(SingleRelationshipMapping2_0 o) { - return o.getDerivedIdentity().usesIdDerivedIdentityStrategy(); - } - }; - } - - protected Iterable<SingleRelationshipMapping2_0> getSingleRelationshipMappings(TypeMapping typeMapping) { - return new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings_(typeMapping)); - } - - @SuppressWarnings("unchecked") - protected Iterable<AttributeMapping> getSingleRelationshipMappings_(TypeMapping typeMapping) { - return new CompositeIterable<AttributeMapping>( - typeMapping.getAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY), - typeMapping.getAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) - ); - } - - - // **************** maps id mappings ************************************** - - protected Iterable<SingleRelationshipMapping2_0> getMapsIdMappings(TypeMapping typeMapping) { - return new FilteringIterable<SingleRelationshipMapping2_0>(this.getAllSingleRelationshipMappings(typeMapping)) { - @Override - protected boolean accept(SingleRelationshipMapping2_0 o) { - return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy(); - } - }; - } - - protected Iterable<SingleRelationshipMapping2_0> getMapsIdMappingsDefinedLocally(TypeMapping typeMapping) { - return new FilteringIterable<SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings(typeMapping)) { - @Override - protected boolean accept(SingleRelationshipMapping2_0 o) { - return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy(); - } - }; - } - - - // **************** misc ************************************************** - - /** - * Return whether an id class is required for this class - */ - protected boolean idClassIsRequired() { - // An id class is required if - // - there are multiple "simple" primary key mappings - // - or there is at least one "complex" primary key mapping - // A simple primary key mapping can be - // - an id mapping - // - a derived id relationship mapping to an entity with a simple primary key - // A complex primary key mapping can be - // - a derived id relationship mapping to an entity with a complex primary key - int simplePrimaryKeyMappingCount = - CollectionTools.size(getIdMappings(typeMapping())); - if (simplePrimaryKeyMappingCount > 1) { - return true; - } - for (SingleRelationshipMapping2_0 relationshipMapping : getDerivedIdMappings(typeMapping())) { - Entity entity = relationshipMapping.getResolvedTargetEntity(); - if (entity != null) { - if (definesComplexPrimaryKey(entity)) { - return true; - } - simplePrimaryKeyMappingCount++; - if (simplePrimaryKeyMappingCount > 1) { - return true; - } - } - } - return false; - } - - protected boolean hasDerivedIdMappingMatchingIdClass(JavaPersistentType idClass) { - for (SingleRelationshipMapping2_0 each : getDerivedIdMappings(typeMapping())) { - String primaryKeyTypeName = getTargetEntityPrimaryKeyTypeName(each); - if (idClass.getName().equals(primaryKeyTypeName)) { - return true; - } - } - return false; - } - - protected String getTargetEntityPrimaryKeyTypeName(SingleRelationshipMapping2_0 relationshipMapping) { - Entity targetEntity = relationshipMapping.getResolvedTargetEntity(); - if (targetEntity != null) { - return getPrimaryKeyTypeName(targetEntity); - } - return null; - } - - protected String getTypeNameForIdClass(AttributeMapping attributeMapping) { - String mappingKey = attributeMapping.getKey(); - if (CollectionTools.contains(this.getIdMappingKeys(), mappingKey)) { - return attributeMapping.getPersistentAttribute().getTypeName(); - } - if (CollectionTools.contains(this.getSingleRelationshipMappingKeys(), mappingKey)) { - SingleRelationshipMapping2_0 relationshipMapping = (SingleRelationshipMapping2_0) attributeMapping; - Entity targetEntity = relationshipMapping.getResolvedTargetEntity(); - if (targetEntity != null) { - return getPrimaryKeyTypeName(targetEntity); - } - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java deleted file mode 100644 index da999a22e5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java +++ /dev/null @@ -1,191 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractTableValidator - implements JptValidator -{ - /** this is <code>null</code> for tables defined on entities */ - protected final ReadOnlyPersistentAttribute persistentAttribute; - - protected final ReadOnlyTable table; - - protected final TableTextRangeResolver textRangeResolver; - - protected AbstractTableValidator( - ReadOnlyTable table, - TableTextRangeResolver textRangeResolver) { - this(null, table, textRangeResolver); - } - - protected AbstractTableValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyTable table, - TableTextRangeResolver textRangeResolver) { - super(); - this.persistentAttribute = persistentAttribute; - this.table = table; - this.textRangeResolver = textRangeResolver; - } - - protected TableTextRangeResolver getTextRangeResolver() { - return this.textRangeResolver; - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - return this.validatesAgainstDatabase() && - this.validateAgainstDatabase(messages); - } - - protected boolean validatesAgainstDatabase() { - return this.table.validatesAgainstDatabase(); - } - - protected boolean validateAgainstDatabase(List<IMessage> messages) { - if ( ! this.table.catalogIsResolved()) { - messages.add(this.buildUnresolvedCatalogMessage()); - return false; - } - - if ( ! this.table.schemaIsResolved()) { - messages.add(this.buildUnresolvedSchemaMessage()); - return false; - } - - if ( ! this.table.isResolved()) { - if (this.table.getName() != null) { //if name is null, the validation will be handled elsewhere, such as the target entity is not defined - messages.add(this.buildUnresolvedNameMessage()); - } - return false; - } - return true; - } - - protected IMessage buildUnresolvedCatalogMessage() { - return this.tableIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnresolvedCatalogMessage() : - this.buildUnresolvedCatalogMessage(this.getUnresolvedCatalogMessage()); - } - - protected abstract String getUnresolvedCatalogMessage(); - - protected IMessage buildUnresolvedCatalogMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] { - this.table.getCatalog(), - this.table.getName() - }, - this.table, - this.textRangeResolver.getCatalogTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnresolvedCatalogMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedCatalogMessage(), - new String[] { - this.persistentAttribute.getName(), - this.table.getCatalog(), - this.table.getName() - }, - this.table, - this.textRangeResolver.getCatalogTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedCatalogMessage(); - - protected IMessage buildUnresolvedSchemaMessage() { - return this.tableIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnresolvedSchemaMessage() : - this.buildUnresolvedSchemaMessage(this.getUnresolvedSchemaMessage()); - } - - protected abstract String getUnresolvedSchemaMessage(); - - protected IMessage buildUnresolvedSchemaMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] { - this.table.getSchema(), - this.table.getName() - }, - this.table, - this.textRangeResolver.getSchemaTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnresolvedSchemaMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedSchemaMessage(), - new String[] { - this.persistentAttribute.getName(), - this.table.getSchema(), - this.table.getName() - }, - this.table, - this.textRangeResolver.getSchemaTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedSchemaMessage(); - - protected IMessage buildUnresolvedNameMessage() { - return this.tableIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnresolvedNameMessage() : - this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); - } - - protected abstract String getUnresolvedNameMessage(); - - protected IMessage buildUnresolvedNameMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] {this.table.getName()}, - this.table, - this.textRangeResolver.getNameTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.table.getName() - }, - this.table, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedNameMessage(); - - protected boolean tableIsPartOfVirtualAttribute() { - return (this.persistentAttribute != null) && - this.persistentAttribute.isVirtual(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java deleted file mode 100644 index 353e98aa69..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTemporalConverterValidator.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.BaseTemporalConverter; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractTemporalConverterValidator - implements JptValidator -{ - protected final BaseTemporalConverter converter; - - protected final ConverterTextRangeResolver textRangeResolver; - - protected AbstractTemporalConverterValidator(BaseTemporalConverter converter, ConverterTextRangeResolver textRangeResolver) { - super(); - this.converter = converter; - this.textRangeResolver = textRangeResolver; - } - - protected ConverterTextRangeResolver getTextRangeResolver() { - return this.textRangeResolver; - } - - protected AttributeMapping getAttributeMapping() { - return this.converter.getParent(); - } - - protected PersistentAttribute getPersistentAttribute() { - return this.getAttributeMapping().getPersistentAttribute(); - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - return this.validateAttributeTypeWithTemporal(messages); - } - - protected boolean validateAttributeTypeWithTemporal(List<IMessage> messages) { - String typeName = this.getTypeName(); - if (typeName == null) { - //validation for a null type name is handled elsewhere, no need to have a temporal validation error - return true; - } - if (!ArrayTools.contains(BaseTemporalConverter.TEMPORAL_MAPPING_SUPPORTED_TYPES, typeName)) { - messages.add(this.buildInvalidTemporalMappingTypeMessage()); - return false; - } - return true; - } - - protected abstract String getTypeName(); - - protected IMessage buildInvalidTemporalMappingTypeMessage() { - return this.getPersistentAttribute().isVirtual() ? - this.buildVirtualAttributeInvalidTemporalMappingTypeMessage() : - this.buildInvalidTemporalMappingTypeMessage_(); - } - - protected IMessage buildInvalidTemporalMappingTypeMessage_() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getInvalidTemporalMappingType(), - StringTools.EMPTY_STRING_ARRAY, - this.converter, - this.getTextRangeResolver().getConverterTextRange() - ); - } - - protected abstract String getInvalidTemporalMappingType(); - - protected IMessage buildVirtualAttributeInvalidTemporalMappingTypeMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeInvalidTemporalMappingType(), - new String[] {this.getPersistentAttribute().getName()}, - this.converter, - this.getTextRangeResolver().getConverterTextRange() - ); - } - - protected abstract String getVirtualAttributeInvalidTemporalMappingType(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java deleted file mode 100644 index c38baf9152..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractTypeMappingValidator<T extends TypeMapping> - implements JptValidator -{ - protected T typeMapping; - - protected JavaResourceType jrt; - - protected TypeMappingTextRangeResolver textRangeResolver; - - - protected AbstractTypeMappingValidator( - T typeMapping, JavaResourceType jrt, TypeMappingTextRangeResolver textRangeResolver) { - this.typeMapping = typeMapping; - this.jrt = jrt; - this.textRangeResolver = textRangeResolver; - } - - - public boolean validate(List<IMessage> messages, IReporter reporter) { - this.validateType(messages); - return true; - } - - protected abstract void validateType(List<IMessage> messages); - - protected boolean isMemberType() { - if (this.jrt == null) { - return false; - } - return this.jrt.isMemberType(); - } - - protected boolean isStaticType() { - if (this.jrt == null) { - return false; - } - return this.jrt.isStatic(); - } - - protected boolean isFinalType() { - if (this.jrt == null) { - return false; - } - return this.jrt.isFinal(); - } - - protected boolean hasPrivateNoArgConstructor() { - if (this.jrt == null) { - return false; - } - return this.jrt.hasPrivateNoArgConstructor(); - } - - protected boolean hasNoArgConstructor() { - if (this.jrt == null) { - return false; - } - return this.jrt.hasNoArgConstructor(); - } - - protected IMessage buildTypeMessage(String msgID) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - msgID, - new String[] {this.typeMapping.getName()}, - this.typeMapping, - this.textRangeResolver.getTypeMappingTextRange() - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java deleted file mode 100644 index d7df3d59c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideInverseJoinColumnValidator.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class AssociationOverrideInverseJoinColumnValidator - extends InverseJoinColumnValidator -{ - final ReadOnlyAssociationOverride override; - - public AssociationOverrideInverseJoinColumnValidator( - ReadOnlyAssociationOverride override, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(column, joinColumnOwner, textRangeResolver, provider); - this.override = override; - } - - public AssociationOverrideInverseJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAssociationOverride override, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, joinColumnOwner, textRangeResolver, provider); - this.override = override; - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedNameMessage() : - super.buildUnresolvedNameMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME, - new String[] { - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedReferencedColumnNameMessage() : - super.buildUnresolvedReferencedColumnNameMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, - new String[] { - this.override.getName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedReferencedColumnNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnspecifiedNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualOverrideUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, - new String[] {this.override.getName()}, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - } - - @Override - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualOverrideUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, - new String[] {this.override.getName()}, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS; - } - - - // ********** table validator ********** - - public class TableValidator - extends InverseJoinColumnValidator.TableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected IMessage buildTableNotValidMessage() { - return AssociationOverrideInverseJoinColumnValidator.this.override.isVirtual() ? - this.buildVirtualOverrideColumnTableNotValidMessage() : - super.buildTableNotValidMessage(); - } - - protected IMessage buildVirtualOverrideColumnTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualOverrideColumnTableNotValidMessage(), - new String[] { - AssociationOverrideInverseJoinColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - protected String getVirtualOverrideColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected IMessage buildVirtualAttributeTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeColumnTableNotValidMessage(), - new String[] { - AssociationOverrideInverseJoinColumnValidator.this.persistentAttribute.getName(), - AssociationOverrideInverseJoinColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java deleted file mode 100644 index a495440ed5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinColumnValidator.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class AssociationOverrideJoinColumnValidator - extends JoinColumnValidator -{ - final ReadOnlyAssociationOverride override; - - - public AssociationOverrideJoinColumnValidator( - ReadOnlyAssociationOverride override, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(column, joinColumnOwner, textRangeResolver, provider); - this.override = override; - } - - public AssociationOverrideJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAssociationOverride override, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, joinColumnOwner, textRangeResolver, provider); - this.override = override; - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedNameMessage() : - super.buildUnresolvedNameMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME, - new String[] { - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedReferencedColumnNameMessage() : - super.buildUnresolvedReferencedColumnNameMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, - new String[] { - this.override.getName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedReferencedColumnNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnspecifiedNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualOverrideUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, - new String[] {this.override.getName()}, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualOverrideUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, - new String[] {this.override.getName()}, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - - // ********** table validator ********** - - protected class TableValidator - extends JoinColumnValidator.TableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected IMessage buildTableNotValidMessage() { - return AssociationOverrideJoinColumnValidator.this.override.isVirtual() ? - this.buildVirtualOverrideColumnTableNotValidMessage() : - super.buildTableNotValidMessage(); - } - - protected IMessage buildVirtualOverrideColumnTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualOverrideColumnTableNotValidMessage(), - new String[] { - AssociationOverrideJoinColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - protected String getVirtualOverrideColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected IMessage buildVirtualAttributeTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeColumnTableNotValidMessage(), - new String[] { - AssociationOverrideJoinColumnValidator.this.persistentAttribute.getName(), - AssociationOverrideJoinColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_JOIN_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinTableValidator.java deleted file mode 100644 index 24731b8de4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideJoinTableValidator.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class AssociationOverrideJoinTableValidator - extends AbstractJoinTableValidator -{ - private final ReadOnlyAssociationOverride override; - - public AssociationOverrideJoinTableValidator( - ReadOnlyAssociationOverride override, - ReadOnlyJoinTable table, - TableTextRangeResolver textRangeResolver) { - super(table, textRangeResolver); - this.override = override; - } - - public AssociationOverrideJoinTableValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAssociationOverride override, - ReadOnlyJoinTable table, - TableTextRangeResolver textRangeResolver) { - super(persistentAttribute, table, textRangeResolver); - this.override = override; - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedNameMessage() : - super.buildUnresolvedNameMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME, - new String[] { - this.override.getName(), - this.table.getName() - }, - this.table, - this.getTextRangeResolver().getNameTextRange() - ); - } - - @Override - protected IMessage buildUnresolvedCatalogMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedCatalogMessage() : - super.buildUnresolvedCatalogMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedCatalogMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG, - new String[] { - this.override.getName(), - this.table.getCatalog() - }, - this.table, - this.getTextRangeResolver().getCatalogTextRange() - ); - } - - @Override - protected IMessage buildUnresolvedSchemaMessage() { - return this.override.isVirtual() ? - this.buildVirtualOverrideUnresolvedSchemaMessage() : - super.buildUnresolvedSchemaMessage(); - } - - protected IMessage buildVirtualOverrideUnresolvedSchemaMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA, - new String[] { - this.override.getName(), - this.table.getSchema() - }, - this.table, - this.getTextRangeResolver().getSchemaTextRange() - ); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedCatalogMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedSchemaMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - @Override - protected String getVirtualAttributeUnresolvedCatalogMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - @Override - protected String getVirtualAttributeUnresolvedSchemaMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw this.buildNestedJoinTableNotSupportedException(); - } - - protected UnsupportedOperationException buildNestedJoinTableNotSupportedException() { - return new UnsupportedOperationException("A nested relationship mapping cannot specify a join table"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideValidator.java deleted file mode 100644 index b8417c6248..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AssociationOverrideValidator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class AssociationOverrideValidator - extends OverrideValidator -{ - public AssociationOverrideValidator( - ReadOnlyAssociationOverride override, - AssociationOverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - super(override, container, textRangeResolver, overrideDescriptionProvider); - } - - public AssociationOverrideValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAssociationOverride override, - AssociationOverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - super(persistentAttribute, override, container, textRangeResolver, overrideDescriptionProvider); - } - - @Override - protected String getVirtualOverrideUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVALID_NAME; - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.ASSOCIATION_OVERRIDE_INVALID_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ASSOCIATION_OVERRIDE_INVALID_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java deleted file mode 100644 index 7f514740be..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideColumnValidator.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class AttributeOverrideColumnValidator - extends NamedColumnValidator -{ - final ReadOnlyAttributeOverride override; - - public AttributeOverrideColumnValidator( - ReadOnlyAttributeOverride override, - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider message) { - super(column, textRangeResolver, message); - this.override = override; - } - - public AttributeOverrideColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAttributeOverride override, - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider message) { - super(persistentAttribute, column, textRangeResolver, message); - this.override = override; - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.override.isVirtual() ? - this.buildVirtualColumnUnresolvedNameMessage() : - super.buildUnresolvedNameMessage(); - } - - protected IMessage buildVirtualColumnUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualOverrideUnresolvedNameMessage(), - new String[] { - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - protected String getVirtualOverrideUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - } - - - // ********** table validator ********** - - protected class TableValidator - extends BaseColumnTableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected IMessage buildTableNotValidMessage() { - return AttributeOverrideColumnValidator.this.override.isVirtual() ? - this.buildVirtualOverrideColumnTableNotValidMessage() : - super.buildTableNotValidMessage(); - } - - protected IMessage buildVirtualOverrideColumnTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualOverrideColumnTableNotValidMessage(), - new String[] { - AttributeOverrideColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - protected String getVirtualOverrideColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected IMessage buildVirtualAttributeTableNotValidMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeColumnTableNotValidMessage(), - new String[] { - AttributeOverrideColumnValidator.this.persistentAttribute.getName(), - AttributeOverrideColumnValidator.this.override.getName(), - this.getColumn().getTable(), - this.getColumn().getName(), - this.getColumnTableDescriptionMessage() - }, - this.getColumn(), - this.getTextRangeResolver().getTableTextRange() - ); - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideValidator.java deleted file mode 100644 index 7f820a41c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AttributeOverrideValidator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class AttributeOverrideValidator - extends OverrideValidator -{ - public AttributeOverrideValidator( - ReadOnlyAttributeOverride override, - AttributeOverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - super(override, container, textRangeResolver, overrideDescriptionProvider); - } - - public AttributeOverrideValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAttributeOverride override, - AttributeOverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - super(persistentAttribute, override, container, textRangeResolver, overrideDescriptionProvider); - } - - @Override - protected String getVirtualOverrideUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_INVALID_NAME; - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.ATTRIBUTE_OVERRIDE_INVALID_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java deleted file mode 100644 index 5bab03af96..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java +++ /dev/null @@ -1,176 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public abstract class BaseJoinColumnValidator<C extends ReadOnlyBaseJoinColumn, R extends BaseJoinColumnTextRangeResolver> - extends AbstractNamedColumnValidator<C, R> -{ - private final ReadOnlyBaseJoinColumn.Owner joinColumnOwner; - - protected BaseJoinColumnValidator( - C column, - ReadOnlyBaseJoinColumn.Owner joinColumnOwner, - R textRangeResolver, - TableDescriptionProvider provider) { - super(column, textRangeResolver, provider); - this.joinColumnOwner = joinColumnOwner; - } - - protected BaseJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - C column, - ReadOnlyBaseJoinColumn.Owner joinColumnOwner, - R textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, textRangeResolver, provider); - this.joinColumnOwner = joinColumnOwner; - } - - @Override - //this method will only be called if the table validates correctly - protected void validateName(List<IMessage> messages) { - this.validateJoinColumnName(messages); - this.validateReferencedColumnName(messages); - } - - protected void validateJoinColumnName(List<IMessage> messages) { - if ((this.column.getSpecifiedName() == null) && (this.joinColumnOwner.getJoinColumnsSize() > 1)) { - messages.add(this.buildUnspecifiedNameMultipleJoinColumnsMessage()); - } - else if (this.column.getName() != null){ - super.validateName(messages); - } - //If the name is null and there is only one join-column, one of these validation messages will apply - // 1. target entity does not have a primary key - // 2. target entity is not specified - // 3. target entity is not an entity - } - - protected void validateReferencedColumnName(List<IMessage> messages) { - if ((this.column.getSpecifiedReferencedColumnName() == null) && (this.joinColumnOwner.getJoinColumnsSize() > 1)) { - messages.add(this.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage()); - } - //bug 315292 is the reason we are only validating if there is a specified referenced column name - else if (this.column.getSpecifiedReferencedColumnName() != null) { - if ((this.column.getReferencedColumnDbTable() != null) && ! this.column.referencedColumnIsResolved()) { - messages.add(this.buildUnresolvedReferencedColumnNameMessage()); - } - } - //If the referenced column name is null and there is only one join-column, one of these validation messages will apply - // 1. target entity does not have a primary key - // 2. target entity is not specified - // 3. target entity is not an entity - } - - protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.columnIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnresolvedReferencedColumnNameMessage() : - this.buildUnresolvedReferencedColumnNameMessage(this.getUnresolvedReferencedColumnNameMessage()); - } - - protected abstract String getUnresolvedReferencedColumnNameMessage(); - - protected IMessage buildUnresolvedReferencedColumnNameMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] { - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedReferencedColumnNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedReferencedColumnNameMessage(); - - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.columnIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() : - this.buildUnspecifiedNameMultipleJoinColumnsMessage(this.getUnspecifiedNameMultipleJoinColumnsMessage()); - } - - protected abstract String getUnspecifiedNameMultipleJoinColumnsMessage(); - - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - StringTools.EMPTY_STRING_ARRAY, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(), - new String[] {this.persistentAttribute.getName()}, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(); - - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.columnIsPartOfVirtualAttribute() ? - this.buildVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : - this.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(this.getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage()); - } - - protected abstract String getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); - - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - StringTools.EMPTY_STRING_ARRAY, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - protected IMessage buildVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(), - new String[] {this.persistentAttribute.getName()}, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/CollectionTableTableDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/CollectionTableTableDescriptionProvider.java deleted file mode 100644 index 4e0deec3dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/CollectionTableTableDescriptionProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages; - -public class CollectionTableTableDescriptionProvider - implements AbstractNamedColumnValidator.TableDescriptionProvider -{ - public String getColumnTableDescriptionMessage() { - return JpaValidationDescriptionMessages.DOES_NOT_MATCH_COLLECTION_TABLE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/ConverterTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/ConverterTextRangeResolver.java deleted file mode 100644 index 793fd8dc46..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/ConverterTextRangeResolver.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.common.core.utility.TextRange; - -/** - * Interface to resolve text ranges on converters. - */ -public interface ConverterTextRangeResolver -{ - TextRange getConverterTextRange(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/DiscriminatorColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/DiscriminatorColumnValidator.java deleted file mode 100644 index c993c07889..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/DiscriminatorColumnValidator.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class DiscriminatorColumnValidator - extends AbstractNamedColumnValidator<ReadOnlyNamedColumn, NamedColumnTextRangeResolver> -{ - public DiscriminatorColumnValidator( - ReadOnlyNamedColumn namedColumn, - NamedColumnTextRangeResolver textRangeResolver) { - super(namedColumn, textRangeResolver); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.DISCRIMINATOR_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EmbeddableOverrideDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EmbeddableOverrideDescriptionProvider.java deleted file mode 100644 index 615e1c2ed0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EmbeddableOverrideDescriptionProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.internal.jpa1.context.OverrideValidator.OverrideDescriptionProvider; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages; - -public class EmbeddableOverrideDescriptionProvider implements OverrideDescriptionProvider -{ - public String getOverrideDescriptionMessage() { - return JpaValidationDescriptionMessages.ON_EMBEDDABLE; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityPrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityPrimaryKeyJoinColumnValidator.java deleted file mode 100644 index cafc2d9552..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityPrimaryKeyJoinColumnValidator.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; - -public class EntityPrimaryKeyJoinColumnValidator - extends PrimaryKeyJoinColumnValidator -{ - public EntityPrimaryKeyJoinColumnValidator( - ReadOnlyBaseJoinColumn column, - ReadOnlyBaseJoinColumn.Owner owner, - BaseJoinColumnTextRangeResolver textRangeResolver) { - super(column, owner, textRangeResolver); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityTableDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityTableDescriptionProvider.java deleted file mode 100644 index 26a00ab41d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/EntityTableDescriptionProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages; - -public class EntityTableDescriptionProvider - implements AbstractNamedColumnValidator.TableDescriptionProvider -{ - public String getColumnTableDescriptionMessage() { - return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericEntityPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericEntityPrimaryKeyValidator.java deleted file mode 100644 index 058f7b010f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericEntityPrimaryKeyValidator.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * 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 - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericEntityPrimaryKeyValidator - extends AbstractEntityPrimaryKeyValidator -{ - public GenericEntityPrimaryKeyValidator(Entity entity, PrimaryKeyTextRangeResolver textRangeResolver) { - super(entity, textRangeResolver); - } - - @Override - protected boolean idClassIsRequired() { - //Short circuit check for idClassIsRequired if any part of the primary key is defined - //in a superclass for Generic types. Other validation will exist and needs to be - //addressed first - if(definesPrimaryKeyOnAncestor(typeMapping())){ - return false; - } - return super.idClassIsRequired(); - } - - @Override - protected void validateIdClassConstructor(JavaPersistentType idClass, - List<IMessage> messages, IReporter reporter) { - if (!idClass.getJavaResourceType().hasPublicNoArgConstructor()) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_MISSING_PUBLIC_NO_ARG_CONSTRUCTOR, - new String[] {idClass.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - } - - @Override - protected void checkMissingAttributeWithPropertyAccess(JavaPersistentType idClass, AttributeMapping attributeMapping, - List<IMessage> messages, IReporter reporter) { - // Missing attribute is reported if missing getter or/and setter - // property method(s) in Id class with property access - checkMissingAttribute(idClass, attributeMapping, messages, reporter); - } - - @Override - protected void validateIdClassAttributesWithPropertyAccess( - JavaPersistentType idClass, List<IMessage> messages, - IReporter reporter) { - validateIdClassPropertyMethods(idClass, messages, reporter); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericMappedSuperclassPrimaryKeyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericMappedSuperclassPrimaryKeyValidator.java deleted file mode 100644 index c431490852..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericMappedSuperclassPrimaryKeyValidator.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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 - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.MappedSuperclass; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericMappedSuperclassPrimaryKeyValidator extends - AbstractMappedSuperclassPrimaryKeyValidator { - - public GenericMappedSuperclassPrimaryKeyValidator(MappedSuperclass mappedSuperclass, PrimaryKeyTextRangeResolver textRangeResolver) { - super(mappedSuperclass, textRangeResolver); - } - - @Override - protected boolean idClassIsRequired() { - //Short circuit check for idClassIsRequired if any part of the primary key is defined - //in a superclass for Generic types. Other validation will exist and needs to be - //addressed first - if(definesPrimaryKeyOnAncestor(typeMapping())){ - return false; - } - return super.idClassIsRequired(); - } - - @Override - protected void validateIdClassConstructor(JavaPersistentType idClass, - List<IMessage> messages, IReporter reporter) { - if (!idClass.getJavaResourceType().hasPublicNoArgConstructor()) { - messages.add(DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TYPE_MAPPING_ID_CLASS_MISSING_PUBLIC_NO_ARG_CONSTRUCTOR, - new String[] {idClass.getName()}, - typeMapping(), - textRangeResolver().getIdClassTextRange())); - } - } - - @Override - protected void checkMissingAttributeWithPropertyAccess(JavaPersistentType idClass, AttributeMapping attributeMapping, - List<IMessage> messages, IReporter reporter) { - // Missing attribute is reported if missing getter or/and setter - // property method(s) in Id class with property access - checkMissingAttribute(idClass, attributeMapping, messages, reporter); - } - - @Override - protected void validateIdClassAttributesWithPropertyAccess( - JavaPersistentType idClass, List<IMessage> messages, - IReporter reporter) { - validateIdClassPropertyMethods(idClass, messages, reporter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java deleted file mode 100644 index 03deea394b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java +++ /dev/null @@ -1,328 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType; -import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.HashBag; -import org.eclipse.jpt.jpa.core.JpaProject; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.MappingFileRoot; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.internal.context.AbstractJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.MetamodelSynchronizer; -import org.eclipse.jpt.jpa.core.jpa2.context.JpaRootContextNode2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceXml2_0; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * the context model root - */ -public class GenericRootContextNode - extends AbstractJpaContextNode - implements JpaRootContextNode2_0 -{ - /* This object has no parent, so it must point to the JPA project explicitly. */ - protected final JpaProject jpaProject; - - /* Main context object. */ - protected PersistenceXml persistenceXml; - - - public GenericRootContextNode(JpaProject jpaProject) { - super(null); // the JPA project is not really a "parent"... - - if (jpaProject == null) { - throw new NullPointerException(); - } - this.jpaProject = jpaProject; - this.persistenceXml = this.buildPersistenceXml(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncPersistenceXml(); - } - - @Override - public void update() { - super.update(); - this.updatePersistenceXml(); - } - - - // ********** persistence.xml ********** - - public PersistenceXml getPersistenceXml() { - return this.persistenceXml; - } - - protected void setPersistenceXml(PersistenceXml persistenceXml) { - PersistenceXml old = this.persistenceXml; - this.persistenceXml = persistenceXml; - this.firePropertyChanged(PERSISTENCE_XML_PROPERTY, old, persistenceXml); - } - - protected PersistenceXml buildPersistenceXml() { - JpaXmlResource xmlResource = this.resolvePersistenceXmlResource(); - return (xmlResource == null) ? null : this.buildPersistenceXml(xmlResource); - } - - protected void syncPersistenceXml() { - this.syncPersistenceXml(true); - } - - /** - * We call this method from both {@link #syncPersistenceXml()} and - * {@link #updatePersistenceXml()} because<ul> - * <li>a <em>sync</em> will occur when the file is edited directly; - * and the user could modify something (e.g. the version number) that - * triggers the file being "resolved" or not; - * see {@link #resolvePersistenceXmlResource()} - * <li>an <em>update</em> will occur whenever the entire file is added or - * removed - * </ul> - */ - protected void syncPersistenceXml(boolean sync) { - JpaXmlResource xmlResource = this.resolvePersistenceXmlResource(); - if (xmlResource == null) { - if (this.persistenceXml != null) { - this.persistenceXml.dispose(); - this.setPersistenceXml(null); - } - } else { - if (this.persistenceXml == null) { - this.setPersistenceXml(this.buildPersistenceXml(xmlResource)); - } else { - if (sync) { - this.persistenceXml.synchronizeWithResourceModel(); - } else { - this.persistenceXml.update(); - } - } - } - } - - protected JpaXmlResource resolvePersistenceXmlResource() { - JpaXmlResource xmlResource = this.jpaProject.getPersistenceXmlResource(); - if (xmlResource == null) { - return null; - } - if (xmlResource.isReverting()) { - // 308254 - this can happen when persistence.xml is closed without saving; - // the model is completely whacked in another thread - so wipe our model(?) - return null; - } - JptResourceType resourceType = xmlResource.getResourceType(); - if (resourceType == null) { - return null; - } - if ( ! this.getJpaPlatform().supportsResourceType(resourceType)) { - return null; - } - return xmlResource; - } - - /** - * pre-condition: 'xmlResource' is not <code>null</code> - */ - protected PersistenceXml buildPersistenceXml(JpaXmlResource xmlResource) { - return this.getJpaFactory().buildPersistenceXml(this, xmlResource); - } - - protected void updatePersistenceXml() { - this.syncPersistenceXml(false); - } - - - // ********** misc ********** - - @Override - protected boolean requiresParent() { - return false; - } - - @Override - public void stateChanged() { - super.stateChanged(); - // forward to JPA project - this.jpaProject.stateChanged(); - } - - @Override - public JpaProject getJpaProject() { - return this.jpaProject; - } - - @Override - public IResource getResource() { - return this.getProject(); - } - - protected IProject getProject() { - return this.jpaProject.getProject(); - } - - @Override - public PersistenceUnit getPersistenceUnit() { - return null; - } - - @Override - public MappingFileRoot getMappingFileRoot() { - return null; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.jpaProject.getName()); - } - - - // ********** metamodel ********** - - public void initializeMetamodel() { - if (this.persistenceXml != null) { - ((PersistenceXml2_0) this.persistenceXml).initializeMetamodel(); - } - } - - public IStatus synchronizeMetamodel(IProgressMonitor monitor) { - return (this.persistenceXml != null) ? - ((PersistenceXml2_0) this.persistenceXml).synchronizeMetamodel(monitor) : - Status.OK_STATUS; - } - - public void disposeMetamodel() { - if (this.persistenceXml != null) { - ((PersistenceXml2_0) this.persistenceXml).disposeMetamodel(); - } - } - - - // ********** validation ********** - - public void validate(List<IMessage> messages, IReporter reporter) { - if (reporter.isCancelled()) { - throw new ValidationCancelledException(); - } - - if (this.persistenceXml == null) { - messages.add(buildPersistenceXmlValidationMessage()); - return; - } - if ( ! this.jpaProject.discoversAnnotatedClasses()) { - this.validateOrphanClasses(messages); - } - this.persistenceXml.validate(messages, reporter); - } - - protected IMessage buildPersistenceXmlValidationMessage() { - int severity = IMessage.HIGH_SEVERITY; - IFile file = getPlatformFile(); - if (file != null && file.exists()) { - JpaXmlResource xmlResource = this.jpaProject.getPersistenceXmlResource(); - if (xmlResource != null - && ! getJpaPlatform().supportsResourceType(xmlResource.getResourceType())) { - return DefaultJpaValidationMessages.buildMessage( - severity, - JpaValidationMessages.PERSISTENCE_XML_UNSUPPORTED_CONTENT, - file); - } - return DefaultJpaValidationMessages.buildMessage( - severity, - JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT, - file); - } - return DefaultJpaValidationMessages.buildMessage( - severity, - JpaValidationMessages.PROJECT_NO_PERSISTENCE_XML, - this); - } - - protected IFile getPlatformFile() { - return this.jpaProject.getPlatformFile(JptJpaCorePlugin.DEFAULT_PERSISTENCE_XML_RUNTIME_PATH); - } - - protected void validateOrphanClasses(List<IMessage> messages) { - Persistence persistence = this.persistenceXml.getPersistence(); - if (persistence == null) { - return; // handled with other validation - } - if (persistence.getPersistenceUnitsSize() != 1) { - return; // the context model currently only supports 1 persistence unit - } - - PersistenceUnit persistenceUnit = persistence.getPersistenceUnits().iterator().next(); - HashBag<String> annotatedClassNames = CollectionTools.bag(this.jpaProject.getAnnotatedJavaSourceClassNames()); - HashBag<String> orphans = annotatedClassNames.clone(); - for (String annotatedClassName : annotatedClassNames) { - if (persistenceUnit.specifiesPersistentType(annotatedClassName)) { - orphans.remove(annotatedClassName); - } - else if (MetamodelSynchronizer.MetamodelTools.isMetamodel(getJpaProject().getJavaResourceType(annotatedClassName))) { - orphans.remove(annotatedClassName); - } - } - - // TODO remove 'jrcu' - // replace jrcu.getFile() with jrpt.getFile() - // replace jrpt.getMappingAnnotation().getTextRange(jrcu.buildASTRoot()) - // with jrpt.getMappingAnnotation().getTextRange() - // (new method #getTextRange() ?) - Iterable<String> typeMappingAnnotationNames = this.jpaProject.getTypeMappingAnnotationNames(); - for (String orphan : orphans) { - JavaResourceAbstractType jrt = this.jpaProject.getJavaResourceType(orphan); - JavaResourceCompilationUnit jrcu = jrt.getJavaResourceCompilationUnit(); - if (jrt.isAnnotatedWithAnyOf(typeMappingAnnotationNames)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, - new String[] {jrt.getQualifiedName()}, - jrt.getFile(), - jrt.getNameTextRange(jrcu.buildASTRoot()) - ) - ); - } - else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.NORMAL_SEVERITY, - JpaValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, - new String[] {jrt.getName()}, - jrt.getFile(), - jrt.getNameTextRange(jrcu.buildASTRoot()) - ) - ); - } - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericTypeMappingValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericTypeMappingValidator.java deleted file mode 100644 index 21e505ec43..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericTypeMappingValidator.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class GenericTypeMappingValidator - extends AbstractTypeMappingValidator<TypeMapping> -{ - public GenericTypeMappingValidator(TypeMapping typeMapping, JavaResourceType jrt, TypeMappingTextRangeResolver textRangeResolver) { - super(typeMapping, jrt, textRangeResolver); - } - - @Override - protected void validateType(List<IMessage> messages) { - if (this.isFinalType()) { - messages.add(this.buildTypeMessage(JpaValidationMessages.TYPE_MAPPING_FINAL_CLASS)); - } - if (this.isMemberType()) { - messages.add(this.buildTypeMessage(JpaValidationMessages.TYPE_MAPPING_MEMBER_CLASS)); - } - if (this.hasNoArgConstructor()) { - if (this.hasPrivateNoArgConstructor()) { - messages.add(this.buildTypeMessage(JpaValidationMessages.TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR)); - } - } - else { - messages.add(this.buildTypeMessage(JpaValidationMessages.TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR)); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/InverseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/InverseJoinColumnValidator.java deleted file mode 100644 index a495cc48ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/InverseJoinColumnValidator.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class InverseJoinColumnValidator - extends BaseJoinColumnValidator<ReadOnlyJoinColumn, JoinColumnTextRangeResolver> -{ - protected InverseJoinColumnValidator( - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(column, joinColumnOwner, textRangeResolver, provider); - } - - public InverseJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, joinColumnOwner, textRangeResolver, provider); - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - - // ********** table validator ********** - - protected class TableValidator - extends BaseColumnTableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected String getColumnTableNotValidMessage() { - return JpaValidationMessages.INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinColumnValidator.java deleted file mode 100644 index 87ddf14046..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinColumnValidator.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class JoinColumnValidator - extends BaseJoinColumnValidator<ReadOnlyJoinColumn, JoinColumnTextRangeResolver> -{ - protected JoinColumnValidator( - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(column, joinColumnOwner, textRangeResolver, provider); - } - - public JoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyJoinColumn column, - ReadOnlyJoinColumn.Owner joinColumnOwner, - JoinColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, joinColumnOwner, textRangeResolver, provider); - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - - // ********** table validator ********** - - protected class TableValidator - extends BaseColumnTableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected String getColumnTableNotValidMessage() { - return JpaValidationMessages.JOIN_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableTableDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableTableDescriptionProvider.java deleted file mode 100644 index 91a0fbc3e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableTableDescriptionProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages; - -public class JoinTableTableDescriptionProvider - implements AbstractNamedColumnValidator.TableDescriptionProvider -{ - public String getColumnTableDescriptionMessage() { - return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableValidator.java deleted file mode 100644 index 982d7c16c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/JoinTableValidator.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class JoinTableValidator - extends AbstractJoinTableValidator -{ - public JoinTableValidator(ReadOnlyPersistentAttribute persistentAttribute, ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - super(persistentAttribute, table, textRangeResolver); - } - - @Override - protected String getVirtualAttributeUnresolvedCatalogMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getVirtualAttributeUnresolvedSchemaMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideColumnValidator.java deleted file mode 100644 index d9c3c2f232..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideColumnValidator.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class MapKeyAttributeOverrideColumnValidator - extends AttributeOverrideColumnValidator -{ - public MapKeyAttributeOverrideColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAttributeOverride override, - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, override, column, textRangeResolver, provider); - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected String getVirtualOverrideUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME; - } - - - // ********** table validator ********** - - protected class TableValidator - extends AttributeOverrideColumnValidator.TableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected String getVirtualOverrideColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideValidator.java deleted file mode 100644 index 951bd5634b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyAttributeOverrideValidator.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class MapKeyAttributeOverrideValidator - extends AttributeOverrideValidator -{ - public MapKeyAttributeOverrideValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyAttributeOverride override, - AttributeOverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - super(persistentAttribute, override, container, textRangeResolver, overrideDescriptionProvider); - } - - @Override - protected String getVirtualOverrideUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_INVALID_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyColumnValidator.java deleted file mode 100644 index ceced2be43..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MapKeyColumnValidator.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class MapKeyColumnValidator - extends AbstractNamedColumnValidator<ReadOnlyBaseColumn, TableColumnTextRangeResolver> -{ - public MapKeyColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, textRangeResolver, provider); - } - - @Override - protected JptValidator buildTableValidator() { - return new TableValidator(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.MAP_KEY_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_UNRESOLVED_NAME; - } - - - // ********** table validator ********** - - protected class TableValidator - extends BaseColumnTableValidator - { - protected TableValidator() { - super(); - } - - @Override - protected String getColumnTableNotValidMessage() { - return JpaValidationMessages.MAP_KEY_COLUMN_TABLE_NOT_VALID; - } - - @Override - protected String getVirtualAttributeColumnTableNotValidMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MappedSuperclassOverrideDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MappedSuperclassOverrideDescriptionProvider.java deleted file mode 100644 index 71a7dc083e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/MappedSuperclassOverrideDescriptionProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.internal.jpa1.context.OverrideValidator.OverrideDescriptionProvider; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages; - -public class MappedSuperclassOverrideDescriptionProvider implements OverrideDescriptionProvider -{ - public String getOverrideDescriptionMessage() { - return JpaValidationDescriptionMessages.ON_MAPPED_SUPERCLASS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/NamedColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/NamedColumnValidator.java deleted file mode 100644 index 0487f75ba9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/NamedColumnValidator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class NamedColumnValidator - extends AbstractNamedColumnValidator<ReadOnlyBaseColumn, TableColumnTextRangeResolver> -{ - - protected NamedColumnValidator( - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(column, textRangeResolver, provider); - } - - public NamedColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyBaseColumn column, - TableColumnTextRangeResolver textRangeResolver, - TableDescriptionProvider provider) { - super(persistentAttribute, column, textRangeResolver, provider); - } - - @Override - protected JptValidator buildTableValidator() { - return new BaseColumnTableValidator(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OneToOnePrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OneToOnePrimaryKeyJoinColumnValidator.java deleted file mode 100644 index 5f29dd78dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OneToOnePrimaryKeyJoinColumnValidator.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class OneToOnePrimaryKeyJoinColumnValidator - extends PrimaryKeyJoinColumnValidator -{ - public OneToOnePrimaryKeyJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyBaseJoinColumn column, - ReadOnlyBaseJoinColumn.Owner owner, - BaseJoinColumnTextRangeResolver textRangeResolver) { - super(persistentAttribute, column, owner, textRangeResolver); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java deleted file mode 100644 index 30605494ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/OverrideValidator.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.context.OverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class OverrideValidator - implements JptValidator -{ - /** this is <code>null</code> for overrides defined on entities */ - protected final ReadOnlyPersistentAttribute persistentAttribute; - - protected final ReadOnlyOverride override; - - protected final OverrideContainer container; - - protected final OverrideTextRangeResolver textRangeResolver; - - protected final OverrideDescriptionProvider overrideDescriptionProvider; - - protected OverrideValidator( - ReadOnlyOverride override, - OverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - this(null, override, container, textRangeResolver, overrideDescriptionProvider); - } - - - protected OverrideValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyOverride override, - OverrideContainer container, - OverrideTextRangeResolver textRangeResolver, - OverrideDescriptionProvider overrideDescriptionProvider) { - this.persistentAttribute = persistentAttribute; - this.override = override; - this.container = container; - this.textRangeResolver = textRangeResolver; - this.overrideDescriptionProvider = overrideDescriptionProvider; - } - - protected String getOverrideDescriptionMessage() { - return this.overrideDescriptionProvider.getOverrideDescriptionMessage(); - } - - public boolean validate(List<IMessage> messages, IReporter reporter) { - if (this.validateType(messages)) { - // validate the name only if the type is valid - return this.validateName(messages); - } - return false; - } - - protected boolean validateType(List<IMessage> messages) { - if (this.container.getOverridableTypeMapping() == null) { - messages.add(this.buildUnresolvedOverrideTypeMessage()); - return false; - } - return true; - } - - protected IMessage buildUnresolvedOverrideTypeMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getUnresolvedOverrideTypeMessage(), - new String[] {this.override.getName()}, - this.override, - this.textRangeResolver.getNameTextRange() - ); - } - - protected String getUnresolvedOverrideTypeMessage() { - return this.override.isVirtual() ? - JpaValidationMessages.VIRTUAL_ATTRIBUTE_OVERRIDE_INVALID_TYPE : - JpaValidationMessages.ATTRIBUTE_OVERRIDE_INVALID_TYPE; - } - - protected boolean validateName(List<IMessage> messages) { - if ( ! CollectionTools.contains(this.container.getAllOverridableNames(), this.override.getName())) { - messages.add(this.buildUnresolvedNameMessage()); - return false; - } - return true; - } - - protected IMessage buildUnresolvedNameMessage() { - if (this.override.isVirtual()) { - // this can happen when an erroneous Java override triggers a - // corresponding orm.xml virtual override - return this.buildVirtualUnresolvedNameMessage(); - } - if (this.overrideIsPartOfVirtualAttribute()) { - return this.buildVirtualAttributeUnresolvedNameMessage(); - } - return this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); - } - - protected IMessage buildVirtualUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualOverrideUnresolvedNameMessage(), - new String[] { - this.override.getName(), - this.getOverrideDescriptionMessage(), - this.container.getOverridableTypeMapping().getName() - }, - this.override, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getVirtualOverrideUnresolvedNameMessage(); - - protected IMessage buildUnresolvedNameMessage(String message) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - message, - new String[] { - this.override.getName(), - this.getOverrideDescriptionMessage(), - this.container.getOverridableTypeMapping().getName() - }, - this.override, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getUnresolvedNameMessage(); - - protected IMessage buildVirtualAttributeUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - this.getVirtualAttributeUnresolvedNameMessage(), - new String[] { - this.persistentAttribute.getName(), - this.override.getName(), - this.getOverrideDescriptionMessage(), - this.container.getOverridableTypeMapping().getName() - }, - this.override, - this.textRangeResolver.getNameTextRange() - ); - } - - protected abstract String getVirtualAttributeUnresolvedNameMessage(); - - protected boolean overrideIsPartOfVirtualAttribute() { - return (this.persistentAttribute != null) && - this.persistentAttribute.isVirtual(); - } - - public interface OverrideDescriptionProvider { - String getOverrideDescriptionMessage(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentFieldValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentFieldValidator.java deleted file mode 100644 index 6d06448154..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentFieldValidator.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.FieldAccessor; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class PersistentFieldValidator - extends AbstractPersistentAttributeValidator -{ - - protected FieldAccessor fieldAccessor; - - public PersistentFieldValidator( - ReadOnlyPersistentAttribute persistentAttribute, FieldAccessor fieldAccessor, PersistentAttributeTextRangeResolver textRangeResolver) - { - super(persistentAttribute, textRangeResolver); - this.fieldAccessor = fieldAccessor; - } - - @Override - protected void validateMappedAttribute(List<IMessage> messages) { - if (this.fieldAccessor.isFinal()) { - messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD)); - } - if (this.fieldAccessor.isPublic()) { - messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD)); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentPropertyValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentPropertyValidator.java deleted file mode 100644 index b4444380b2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PersistentPropertyValidator.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.PropertyAccessor; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class PersistentPropertyValidator - extends AbstractPersistentAttributeValidator -{ - - protected PropertyAccessor propertyAccessor; - - public PersistentPropertyValidator( - ReadOnlyPersistentAttribute persistentAttribute, PropertyAccessor propertyAccessor, PersistentAttributeTextRangeResolver textRangeResolver) - { - super(persistentAttribute, textRangeResolver); - this.propertyAccessor = propertyAccessor; - } - - @Override - //TODO validation for null getter or null setter - would apply to EclipseLink too - //TODO validation for annotated setter? - would apply to EclipseLink too - protected void validateMappedAttribute(List<IMessage> messages) { - if (this.propertyAccessor.getResourceGetter() != null && this.propertyAccessor.getResourceGetter().isFinal()) { - messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_GETTER)); - } - if (this.propertyAccessor.getResourceSetter() != null && this.propertyAccessor.getResourceSetter().isFinal()) { - messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_SETTER)); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PrimaryKeyJoinColumnValidator.java deleted file mode 100644 index c531b28f01..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/PrimaryKeyJoinColumnValidator.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public abstract class PrimaryKeyJoinColumnValidator - extends BaseJoinColumnValidator<ReadOnlyBaseJoinColumn, BaseJoinColumnTextRangeResolver> -{ - protected PrimaryKeyJoinColumnValidator( - ReadOnlyBaseJoinColumn column, - ReadOnlyBaseJoinColumn.Owner owner, - BaseJoinColumnTextRangeResolver textRangeResolver) { - super(column, owner, textRangeResolver, TableDescriptionProvider.Null.instance()); - } - - protected PrimaryKeyJoinColumnValidator( - ReadOnlyPersistentAttribute persistentAttribute, - ReadOnlyBaseJoinColumn column, - ReadOnlyBaseJoinColumn.Owner owner, - BaseJoinColumnTextRangeResolver textRangeResolver) { - super(persistentAttribute, column, owner, textRangeResolver, TableDescriptionProvider.Null.instance()); - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.column.isVirtual() ? - this.buildUnresolvedNameMessage(this.getVirtualPKJoinColumnUnresolvedNameMessage()) : - super.buildUnresolvedNameMessage(); - } - - protected String getVirtualPKJoinColumnUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.column.isVirtual() ? - this.buildUnresolvedReferencedColumnNameMessage(this.getVirtualPKJoinColumnUnresolvedReferencedColumnNameMessage()) : - super.buildUnresolvedReferencedColumnNameMessage(); - } - - protected String getVirtualPKJoinColumnUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.column.isVirtual() ? - this.buildUnspecifiedNameMultipleJoinColumnsMessage(this.getVirtualPKJoinColumnUnspecifiedNameMultipleJoinColumnsMessage()) : - super.buildUnspecifiedNameMultipleJoinColumnsMessage(); - } - - protected String getVirtualPKJoinColumnUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.column.isVirtual() ? - this.buildUnspecifiedNameMultipleJoinColumnsMessage(this.getVirtualPKJoinColumnUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage()) : - super.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); - } - - protected String getVirtualPKJoinColumnUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.VIRTUAL_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getUnresolvedReferencedColumnNameMessage() { - return JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME; - } - - @Override - protected String getUnspecifiedNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } - - @Override - protected String getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return JpaValidationMessages.PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/RelationshipStrategyTableDescriptionProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/RelationshipStrategyTableDescriptionProvider.java deleted file mode 100644 index 6877fdb639..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/RelationshipStrategyTableDescriptionProvider.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.RelationshipStrategy; - -public class RelationshipStrategyTableDescriptionProvider - implements AbstractNamedColumnValidator.TableDescriptionProvider -{ - private final RelationshipStrategy relationshipStrategy; - - public RelationshipStrategyTableDescriptionProvider(RelationshipStrategy relationshipStrategy) { - super(); - this.relationshipStrategy = relationshipStrategy; - } - - public String getColumnTableDescriptionMessage() { - return this.relationshipStrategy.getColumnTableNotValidDescription(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java deleted file mode 100644 index 7ecf62d72b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; - -public class SecondaryTablePrimaryKeyJoinColumnValidator - extends PrimaryKeyJoinColumnValidator -{ - private final ReadOnlySecondaryTable secondaryTable; - - public SecondaryTablePrimaryKeyJoinColumnValidator( - ReadOnlySecondaryTable secondaryTable, - ReadOnlyBaseJoinColumn column, - ReadOnlyBaseJoinColumn.Owner owner, - BaseJoinColumnTextRangeResolver textRangeResolver) { - super(column, owner, textRangeResolver); - this.secondaryTable = secondaryTable; - } - - protected boolean secondaryTableIsVirtual() { - return this.secondaryTable.isVirtual(); - } - - protected String getSecondaryTableName() { - return this.secondaryTable.getName(); - } - - @Override - protected IMessage buildUnresolvedNameMessage() { - return this.secondaryTableIsVirtual() ? - this.buildVirtualSecondaryTableUnresolvedNameMessage() : - super.buildUnresolvedNameMessage(); - } - - protected IMessage buildVirtualSecondaryTableUnresolvedNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME, - new String[] { - this.getSecondaryTableName(), - this.column.getName(), - this.column.getDbTable().getName() - }, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.secondaryTableIsVirtual() ? - this.buildVirtualSecondaryTableUnresolvedReferencedColumnNameMessage() : - super.buildUnresolvedReferencedColumnNameMessage(); - } - - protected IMessage buildVirtualSecondaryTableUnresolvedReferencedColumnNameMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME, - new String[] { - this.getSecondaryTableName(), - this.column.getReferencedColumnName(), - this.column.getReferencedColumnDbTable().getName() - }, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnresolvedReferencedColumnNameMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.secondaryTableIsVirtual() ? - this.buildVirtualSecondaryTableUnspecifiedNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualSecondaryTableUnspecifiedNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, - new String[] {this.getSecondaryTableName()}, - this.column, - this.textRangeResolver.getNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() { - throw new UnsupportedOperationException(); - } - - @Override - protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.secondaryTableIsVirtual() ? - this.buildVirtualSecondaryTableUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : - super.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); - } - - protected IMessage buildVirtualSecondaryTableUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS, - new String[] {this.getSecondaryTableName()}, - this.column, - this.textRangeResolver.getReferencedColumnNameTextRange() - ); - } - - @Override - protected String getVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTableValidator.java deleted file mode 100644 index ff7cbe3139..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTableValidator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class SecondaryTableValidator - extends AbstractTableValidator -{ - public SecondaryTableValidator(ReadOnlySecondaryTable table, TableTextRangeResolver textRangeResolver) { - super(table, textRangeResolver); - } - - @Override - protected String getUnresolvedCatalogMessage() { - return JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getVirtualAttributeUnresolvedCatalogMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - @Override - protected String getUnresolvedSchemaMessage() { - return JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getVirtualAttributeUnresolvedSchemaMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.SECONDARY_TABLE_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - protected UnsupportedOperationException buildAttributeTableNotSupportedException() { - return new UnsupportedOperationException("An attribute cannot specify a secondary table"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/TableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/TableValidator.java deleted file mode 100644 index 6a099e58b6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/TableValidator.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class TableValidator - extends AbstractTableValidator -{ - public TableValidator(ReadOnlyTable table, TableTextRangeResolver textRangeResolver) { - super(table, textRangeResolver); - } - - @Override - protected String getUnresolvedCatalogMessage() { - return JpaValidationMessages.TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getVirtualAttributeUnresolvedCatalogMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - @Override - protected String getUnresolvedSchemaMessage() { - return JpaValidationMessages.TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getVirtualAttributeUnresolvedSchemaMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.TABLE_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - throw this.buildAttributeTableNotSupportedException(); - } - - protected UnsupportedOperationException buildAttributeTableNotSupportedException() { - return new UnsupportedOperationException("An attribute cannot specify a table"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java deleted file mode 100644 index 413f615d76..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaConverter; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.ConverterTextRangeResolver; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractJavaConverter - extends AbstractJavaJpaContextNode - implements JavaConverter -{ - - protected final JavaConverter.Owner owner; - - protected AbstractJavaConverter(JavaAttributeMapping parent, JavaConverter.Owner owner) { - super(parent); - this.owner = owner; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.owner.buildValidator(this, this.buildConverterTextRangeResolver(astRoot)).validate(messages, reporter); - } - - - protected ConverterTextRangeResolver buildConverterTextRangeResolver(final CompilationUnit astRoot) { - return new ConverterTextRangeResolver() { - public TextRange getConverterTextRange() { - return getValidationTextRange(astRoot); - } - }; - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getAnnotationTextRange(astRoot); - return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(astRoot); - } - - protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getConverterAnnotation().getTextRange(astRoot); - } - - - // ********** misc ********** - - @Override - public JavaAttributeMapping getParent() { - return (JavaAttributeMapping) super.getParent(); - } - - protected JavaAttributeMapping getAttributeMapping() { - return this.getParent(); - } - - protected JavaResourceAttribute getResourceAttribute() { - return this.getAttributeMapping().getResourceAttribute(); - } - - public void dispose() { - // NOP - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaNamedDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaNamedDiscriminatorColumn.java deleted file mode 100644 index 10f4c4e22b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaNamedDiscriminatorColumn.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0, which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.DiscriminatorType; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyNamedDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaNamedColumn; -import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorColumnAnnotation; - -/** - * Java named discriminator column - */ -public abstract class AbstractJavaNamedDiscriminatorColumn<A extends DiscriminatorColumnAnnotation, O extends JavaReadOnlyNamedDiscriminatorColumn.Owner> - extends AbstractJavaNamedColumn<A, O> - implements JavaNamedDiscriminatorColumn -{ - protected DiscriminatorType specifiedDiscriminatorType; - protected DiscriminatorType defaultDiscriminatorType; - - protected Integer specifiedLength; - protected int defaultLength; - - protected AbstractJavaNamedDiscriminatorColumn(JavaJpaContextNode parent, O owner) { - this(parent, owner, null); - } - - protected AbstractJavaNamedDiscriminatorColumn(JavaJpaContextNode parent, O owner, A columnAnnotation) { - super(parent, owner, columnAnnotation); - this.specifiedDiscriminatorType = this.buildSpecifiedDiscriminatorType(); - this.specifiedLength = this.buildSpecifiedLength(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedDiscriminatorType_(this.buildSpecifiedDiscriminatorType()); - this.setSpecifiedLength_(this.buildSpecifiedLength()); - } - - @Override - public void update() { - super.update(); - this.setDefaultDiscriminatorType(this.buildDefaultDiscriminatorType()); - this.setDefaultLength(this.buildDefaultLength()); - } - - - // ********** column annotation ********** - - @Override - public abstract A getColumnAnnotation(); - - - // ********** discriminator type ********** - - public DiscriminatorType getDiscriminatorType() { - return (this.specifiedDiscriminatorType != null) ? this.specifiedDiscriminatorType : this.defaultDiscriminatorType; - } - - public DiscriminatorType getSpecifiedDiscriminatorType() { - return this.specifiedDiscriminatorType; - } - - public void setSpecifiedDiscriminatorType(DiscriminatorType discriminatorType) { - if (this.valuesAreDifferent(this.specifiedDiscriminatorType, discriminatorType)) { - this.getColumnAnnotation().setDiscriminatorType(DiscriminatorType.toJavaResourceModel(discriminatorType)); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedDiscriminatorType_(discriminatorType); - } - } - - protected void setSpecifiedDiscriminatorType_(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.specifiedDiscriminatorType; - this.specifiedDiscriminatorType = discriminatorType; - this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - protected DiscriminatorType buildSpecifiedDiscriminatorType() { - return DiscriminatorType.fromJavaResourceModel(this.getColumnAnnotation().getDiscriminatorType()); - } - - public DiscriminatorType getDefaultDiscriminatorType() { - return this.defaultDiscriminatorType; - } - - protected void setDefaultDiscriminatorType(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.defaultDiscriminatorType; - this.defaultDiscriminatorType = discriminatorType; - this.firePropertyChanged(DEFAULT_DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - protected DiscriminatorType buildDefaultDiscriminatorType() { - return this.owner.getDefaultDiscriminatorType(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength; - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - public void setSpecifiedLength(Integer length) { - if (this.valuesAreDifferent(this.specifiedLength, length)) { - this.getColumnAnnotation().setLength(length); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedLength_(length); - } - } - - protected void setSpecifiedLength_(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - return this.getColumnAnnotation().getLength(); - } - - public int getDefaultLength() { - return this.defaultLength; - } - - protected void setDefaultLength(int length) { - int old = this.defaultLength; - this.defaultLength = length; - this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, length); - } - - protected int buildDefaultLength() { - return this.owner.getDefaultLength(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java deleted file mode 100644 index 9671612069..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java +++ /dev/null @@ -1,593 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.Annotation; -import org.eclipse.jpt.common.core.resource.java.JavaResourceMember; -import org.eclipse.jpt.common.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.NotNullFilter; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.jpa.core.context.Override_; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.VirtualOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualOverride; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.java.OverrideAnnotation; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java override container - * <p> - * <strong>NB:</strong> Although not typical, a Java override container can - * correspond to only a subset of the annotations in the Java source code. - * In that case, the index of a specified override must be translated to its - * corresponding annotation's index before we manipulate the annotations. - * <p> - * As of JPA 2.0, the only place we need these translations is for the attribute - * overrides for an embedded collection. If an embedded collection is a - * {@link java.util.Map Map}, the attribute overrides can override the mappings - * for either the map's keys or the map's values. The names of the overrides for - * the map's keys are prefixed with <code>"key."</code> while the overrides - * for the map's values are prefixed with <code>"value."</code>. - * (Just a bit of hack, courtesy of the JPA spec committee.) - */ -public abstract class AbstractJavaOverrideContainer< - O extends JavaOverrideContainer.Owner, - R extends JavaReadOnlyOverride, - S extends JavaOverride, - V extends JavaVirtualOverride, - A extends OverrideAnnotation & NestableAnnotation - > - extends AbstractJavaJpaContextNode - implements JavaOverrideContainer2_0 -{ - /** - * this can be <code>null</code> if the container is "read-only" - * (i.e. a <em>null</em> container) - * @see #getOwner2_0() - */ - protected final O owner; - - protected final Vector<S> specifiedOverrides = new Vector<S>(); - protected final SpecifiedOverrideContainerAdapter specifiedOverrideContainerAdapter = new SpecifiedOverrideContainerAdapter(); - - protected final Vector<V> virtualOverrides = new Vector<V>(); - protected final VirtualOverrideContainerAdapter virtualOverrideContainerAdapter = new VirtualOverrideContainerAdapter(); - - - protected AbstractJavaOverrideContainer(JavaJpaContextNode parent, O owner) { - super(parent); - this.owner = owner; - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.synchronizeNodesWithResourceModel(this.getSpecifiedOverrides()); - // the virtual overrides do not need a sync - } - - @Override - public void update() { - super.update(); - this.updateSpecifiedOverrides(); - this.updateVirtualOverrides(); - } - - - // ********** overrides ********** - - @SuppressWarnings("unchecked") - public ListIterable<R> getOverrides() { - return new CompositeListIterable<R>(this.getReadOnlySpecifiedOverrides(), this.getReadOnlyVirtualOverrides()); - } - - public int getOverridesSize() { - return this.specifiedOverrides.size() + this.virtualOverrides.size(); - } - - public R getOverrideNamed(String name) { - return this.selectOverrideNamed(this.getOverrides(), name); - } - - public Iterable<String> getOverrideNames() { - return new FilteringIterable<String>(this.getOverrideNames_(), NotNullFilter.<String>instance()); - } - - protected Iterable<String> getOverrideNames_() { - return new TransformationIterable<R, String>(this.getOverrides()) { - @Override - protected String transform(R override) { - return override.getName(); - } - }; - } - - - // ********** override conversions ********** - - /** - * <em>Silently</em> add the new virtual override before removing the - * specified override, or the <em>update</em> will discover the missing - * virtual override and add it preemptively. - */ - public V convertOverrideToVirtual(Override_ override) { - if (override.isVirtual()) { - throw new IllegalArgumentException("Override is already virtual: " + override); //$NON-NLS-1$ - } - - @SuppressWarnings("unchecked") - S specifiedOverride = (S) override; - int virtualIndex = this.virtualOverrides.size(); - String overrideName = specifiedOverride.getName(); - V virtualOverride = null; - // make sure the specified override actually overrides something before building the virtual override - if (this.overrideWillBeVirtual(overrideName, specifiedOverride)) { - virtualOverride = this.buildVirtualOverride(overrideName); - this.virtualOverrides.add(virtualIndex, virtualOverride); - } - - this.removeSpecifiedOverride(specifiedOverride); // trigger update - - if (virtualOverride != null) { - this.fireItemAdded(VIRTUAL_OVERRIDES_LIST, virtualIndex, virtualOverride); - } - return virtualOverride; - } - - /** - * Return whether the specified override name will be a - * <em>virtual</em> override when the specified specified override is - * removed from the container. The override name must be among the - * valid override names and it must not correspond to any of the - * remaining specified overrides. - */ - protected boolean overrideWillBeVirtual(String overrideName, S specifiedOverrideToBeRemoved) { - return CollectionTools.contains(this.getAllOverridableNames(), overrideName) && - (this.getSpecifiedOverrideNamed(overrideName, specifiedOverrideToBeRemoved) == null); - } - - /** - * <em>Silently</em> remove the virtual override and add the new specified - * override before naming the specified override, or the <em>update</em> - * will discover the dangling virtual override and remove it preemptively. - */ - public S convertOverrideToSpecified(VirtualOverride override) { - if ( ! override.isVirtual()) { - throw new IllegalArgumentException("Override is already specified: " + override); //$NON-NLS-1$ - } - - @SuppressWarnings("unchecked") - V virtualOverride = (V) override; - int virtualIndex = this.virtualOverrides.indexOf(virtualOverride); - this.virtualOverrides.remove(virtualIndex); - - int specifiedIndex = this.specifiedOverrides.size(); - S specifiedOverride = this.buildSpecifiedOverride(this.buildOverrideAnnotation(specifiedIndex)); - this.specifiedOverrides.add(specifiedIndex, specifiedOverride); - - this.initializeSpecifiedOverride(specifiedOverride, virtualOverride); // trigger update - - this.fireItemRemoved(VIRTUAL_OVERRIDES_LIST, virtualIndex, virtualOverride); - this.fireItemAdded(SPECIFIED_OVERRIDES_LIST, specifiedIndex, specifiedOverride); - return specifiedOverride; - } - - protected abstract void initializeSpecifiedOverride(S specifiedOverride, V virtualOverride); - - - // ********** specified overrides ********** - - public ListIterable<S> getSpecifiedOverrides() { - return new LiveCloneListIterable<S>(this.specifiedOverrides); - } - - @SuppressWarnings("unchecked") - protected ListIterable<R> getReadOnlySpecifiedOverrides() { - // S should always be a subtype of R, but we can't enforce that in the - // class declaration... - return (ListIterable<R>) this.getSpecifiedOverrides(); - } - - public int getSpecifiedOverridesSize() { - return this.specifiedOverrides.size(); - } - - public S getSpecifiedOverride(int index) { - return this.specifiedOverrides.get(index); - } - - public S getSpecifiedOverrideNamed(String name) { - return this.getSpecifiedOverrideNamed(name, null); - } - - @SuppressWarnings("unchecked") - protected S getSpecifiedOverrideNamed(String name, S exclude) { - return (S) this.selectOverrideNamed(this.getReadOnlySpecifiedOverrides(), name, exclude); - } - - protected S addSpecifiedOverride() { - return this.addSpecifiedOverride(this.specifiedOverrides.size()); - } - - protected S addSpecifiedOverride(int index) { - A annotation = this.buildOverrideAnnotation(index); - return this.addSpecifiedOverride_(index, annotation); - } - - @SuppressWarnings("unchecked") - protected A buildOverrideAnnotation(int index) { - int annotationIndex = this.calculateNewAnnotationIndex(index); - return (A) this.getResourceMember().addAnnotation(annotationIndex, this.getOverrideAnnotationName()); - } - - protected int calculateNewAnnotationIndex(int index) { - // if we are adding to the end of the specified list, - // put the annotation after all the existing annotations - if (index == this.specifiedOverrides.size()) { - return CollectionTools.size(this.getOverrideAnnotations()); - } - - // if we are adding to the front of the specified list, - // put the annotation before of all the existing annotations - if (index == 0) { - return 0; - } - - // if we are adding to the middle of the specified list, - // put the annotation immediately after all the previous override's - // existing annotation - return this.translateToAnnotationIndex(index - 1) + 1; - } - - /** - * pre-condition: override exists at the specified index - */ - protected int translateToAnnotationIndex(int index) { - return CollectionTools.indexOf(this.getOverrideAnnotations(), this.specifiedOverrides.get(index).getOverrideAnnotation()); - } - - protected abstract String getOverrideAnnotationName(); - - protected void removeSpecifiedOverride(S override) { - this.removeSpecifiedOverride(this.specifiedOverrides.indexOf(override)); - } - - protected void removeSpecifiedOverride(int index) { - this.removeOverrideAnnotation(index); - this.removeSpecifiedOverride_(index); - } - - protected void removeOverrideAnnotation(int index) { - int annotationIndex = this.translateToAnnotationIndex(index); - this.getResourceMember().removeAnnotation(annotationIndex, this.getOverrideAnnotationName()); - } - - protected void removeSpecifiedOverride_(int index) { - this.removeItemFromList(index, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - } - - public void moveSpecifiedOverride(int targetIndex, int sourceIndex) { - this.moveOverrideAnnotation(targetIndex, sourceIndex); - this.moveItemInList(targetIndex, sourceIndex, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - } - - protected void moveOverrideAnnotation(int targetIndex, int sourceIndex) { - int targetAnnotationIndex = this.translateToAnnotationIndex(targetIndex); - int sourceAnnotationIndex = this.translateToAnnotationIndex(sourceIndex); - this.getResourceMember().moveAnnotation(targetAnnotationIndex, sourceAnnotationIndex, this.getOverrideAnnotationName()); - } - - protected abstract S buildSpecifiedOverride(A overrideAnnotation); - - protected void updateSpecifiedOverrides() { - ContextContainerTools.update(this.specifiedOverrideContainerAdapter); - } - - protected Iterable<A> getRelevantOverrideAnnotations() { - return new FilteringIterable<A>(this.getOverrideAnnotations()) { - @Override - protected boolean accept(A annotation) { - String overrideName = annotation.getName(); - return (overrideName != null) && this.getOwner().isRelevant(overrideName); - } - protected JavaOverrideContainer2_0.Owner getOwner() { - return AbstractJavaOverrideContainer.this.getOwner2_0(); - } - }; - } - - protected Iterable<A> getOverrideAnnotations() { - return new SubIterableWrapper<NestableAnnotation, A>((this.overrideAnnotations())); - } - - protected Iterable<NestableAnnotation> overrideAnnotations() { - return (this.owner == null) ? EmptyIterable.<NestableAnnotation>instance() : this.overrideAnnotations_(); - } - - /** - * pre-condition: {@link #owner} is not <code>null</code> - */ - protected Iterable<NestableAnnotation> overrideAnnotations_() { - return this.getResourceMember().getAnnotations(this.getOverrideAnnotationName()); - } - - protected void moveSpecifiedOverride_(int index, S override) { - this.moveItemInList(index, override, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - } - - protected S addSpecifiedOverride_(int index, A overrideAnnotation) { - S override = this.buildSpecifiedOverride(overrideAnnotation); - this.addItemToList(index, override, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - return override; - } - - protected void removeSpecifiedOverride_(S override) { - this.removeSpecifiedOverride_(this.specifiedOverrides.indexOf(override)); - } - - /** - * specified override container adapter - */ - protected class SpecifiedOverrideContainerAdapter - implements ContextContainerTools.Adapter<S, A> - { - public Iterable<S> getContextElements() { - return AbstractJavaOverrideContainer.this.getSpecifiedOverrides(); - } - public Iterable<A> getResourceElements() { - return AbstractJavaOverrideContainer.this.getRelevantOverrideAnnotations(); - } - @SuppressWarnings("unchecked") - public A getResourceElement(S contextElement) { - return (A) contextElement.getOverrideAnnotation(); - } - public void moveContextElement(int index, S element) { - AbstractJavaOverrideContainer.this.moveSpecifiedOverride_(index, element); - } - public void addContextElement(int index, A resourceElement) { - AbstractJavaOverrideContainer.this.addSpecifiedOverride_(index, resourceElement); - } - public void removeContextElement(S element) { - AbstractJavaOverrideContainer.this.removeSpecifiedOverride_(element); - } - } - - - // ********** virtual overrides ********** - - public ListIterable<V> getVirtualOverrides() { - return new LiveCloneListIterable<V>(this.virtualOverrides); - } - - public int getVirtualOverridesSize() { - return this.virtualOverrides.size(); - } - - @SuppressWarnings("unchecked") - protected ListIterable<R> getReadOnlyVirtualOverrides() { - // V should always be a subtype of R, but we can't enforce that in the - // class declaration... - return (ListIterable<R>) this.getVirtualOverrides(); - } - - protected void updateVirtualOverrides() { - ContextContainerTools.update(this.virtualOverrideContainerAdapter); - } - - /** - * Return the overridable names that are not already in the list of - * specified overrides. - */ - protected Iterable<String> getVirtualOverrideNames() { - return CollectionTools.iterable(this.virtualOverrideNames()); - } - - protected Iterator<String> virtualOverrideNames() { - return new FilteringIterator<String>(this.getAllOverridableNames()) { - @Override - protected boolean accept(String name) { - return AbstractJavaOverrideContainer.this.overrideIsVirtual(name); - } - }; - } - - protected boolean overrideIsVirtual(String name) { - return this.getSpecifiedOverrideNamed(name) == null; - } - - protected void moveVirtualOverride(int index, V override) { - this.moveItemInList(index, override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - } - - protected V addVirtualOverride(int index, String name) { - V override = this.buildVirtualOverride(name); - this.addItemToList(index, override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - return override; - } - - protected abstract V buildVirtualOverride(String name); - - protected void removeVirtualOverride(V override) { - this.removeItemFromList(override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - } - - /** - * virtual override container adapter - * NB: the context override is matched with a resource override by name - */ - protected class VirtualOverrideContainerAdapter - implements ContextContainerTools.Adapter<V, String> - { - public Iterable<V> getContextElements() { - return AbstractJavaOverrideContainer.this.getVirtualOverrides(); - } - public Iterable<String> getResourceElements() { - return AbstractJavaOverrideContainer.this.getVirtualOverrideNames(); - } - public String getResourceElement(V contextElement) { - return contextElement.getName(); - } - public void moveContextElement(int index, V element) { - AbstractJavaOverrideContainer.this.moveVirtualOverride(index, element); - } - public void addContextElement(int index, String resourceElement) { - AbstractJavaOverrideContainer.this.addVirtualOverride(index, resourceElement); - } - public void removeContextElement(V element) { - AbstractJavaOverrideContainer.this.removeVirtualOverride(element); - } - } - - - // ********** misc ********** - - protected JavaOverrideContainer2_0.Owner getOwner2_0() { - return (JavaOverrideContainer2_0.Owner) this.owner; - } - - public TypeMapping getTypeMapping() { - return this.owner.getTypeMapping(); - } - - protected JavaResourceMember getResourceMember() { - return this.owner.getResourceMember(); - } - - public TypeMapping getOverridableTypeMapping() { - return this.owner.getOverridableTypeMapping(); - } - - public Iterable<String> getAllOverridableNames() { - return (this.owner != null) ? this.owner.getAllOverridableNames() : EmptyIterable.<String>instance(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.owner.tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.owner.getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return this.owner.resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.owner.getDefaultTableName(); - } - - public JptValidator buildOverrideValidator(ReadOnlyOverride override, OverrideTextRangeResolver textRangeResolver) { - return this.owner.buildOverrideValidator(override, this, textRangeResolver); - } - - public JptValidator buildColumnValidator(ReadOnlyOverride override, ReadOnlyBaseColumn column, ReadOnlyBaseColumn.Owner columnOwner, TableColumnTextRangeResolver textRangeResolver) { - return this.owner.buildColumnValidator(override, column, columnOwner, textRangeResolver); - } - - public String getPossiblePrefix() { - return this.getOwner2_0().getPossiblePrefix(); - } - - public String getWritePrefix() { - return this.getOwner2_0().getWritePrefix(); - } - - protected R selectOverrideNamed(Iterable<R> overrides, String name) { - return this.selectOverrideNamed(overrides, name, null); - } - - protected R selectOverrideNamed(Iterable<R> overrides, String name, S exclude) { - for (R override : overrides) { - if (override == exclude) { - continue; // skip - } - if (this.valuesAreEqual(override.getName(), name)) { - return override; - } - } - return null; - } - - - // ********** code completion ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - for (R override : this.getOverrides()) { - result = override.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - for (R override: this.getOverrides()) { - override.validate(messages, reporter, astRoot); - } - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getValidationAnnotationTextRange(astRoot); - return (textRange != null) ? textRange : this.owner.getValidationTextRange(astRoot); - } - - protected TextRange getValidationAnnotationTextRange(CompilationUnit astRoot) { - Annotation annotation = this.getValidationAnnotation(); - return (annotation == null) ? null : annotation.getTextRange(astRoot); - } - - protected Annotation getValidationAnnotation() { - JavaResourceMember resourceMember = this.getResourceMember(); - return resourceMember.getAnnotation(this.getOverrideAnnotationName()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java deleted file mode 100644 index 1b9a7609a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jpt.common.core.JptCommonCorePlugin; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind; -import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot; -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.JarFile; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Context JAR file - */ -public class GenericJarFile - extends AbstractPersistenceXmlContextNode - implements JarFile, PersistentType.Owner -{ - protected final JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot; - - protected final ContextCollectionContainer<JavaPersistentType, JavaResourceType> javaPersistentTypeContainer; - - - // ********** constructor/initialization ********** - - public GenericJarFile(JarFileRef parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot) { - super(parent); - this.jarResourcePackageFragmentRoot = jarResourcePackageFragmentRoot; - this.javaPersistentTypeContainer = this.buildJavaPersistentTypeContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncJavaPersistentTypes(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getJavaPersistentTypes()); - } - - public JavaResourcePackageFragmentRoot getJarResourcePackageFragmentRoot() { - return this.jarResourcePackageFragmentRoot; - } - - - // ********** JpaStructureNode implementation ********** - - public ContextType getContextType() { - return new ContextType(this); - } - - public Class<JarFile> getType() { - return JarFile.class; - } - - public TextRange getSelectionTextRange() { - return null; - } - - public JpaStructureNode getStructureNode(int textOffset) { - return null; - } - - public void dispose() { - // nothing yet - } - - - // ********** JpaContextNode implementation ********** - - @Override - public JptResourceType getResourceType() { - return JptCommonCorePlugin.JAR_RESOURCE_TYPE; - } - - - // ********** Java persistent types ********** - - public JavaPersistentType getPersistentType(String typeName) { - for (JavaPersistentType pt : this.getJavaPersistentTypes()) { - if (pt.getName().equals(typeName)) { - return pt; - } - } - return null; - } - - public Iterable<JavaPersistentType> getJavaPersistentTypes() { - return this.javaPersistentTypeContainer.getContextElements(); - } - - public int getJavaPersistentTypesSize() { - return this.javaPersistentTypeContainer.getContextElementsSize(); - } - - protected void syncJavaPersistentTypes() { - this.javaPersistentTypeContainer.synchronizeWithResourceModel(); - } - - protected void addJavaPersistentType(JavaResourceType jrt) { - this.javaPersistentTypeContainer.addContextElement(getJavaPersistentTypesSize(), jrt); - } - - protected void removeJavaPersistentType(JavaPersistentType javaPersistentType ) { - this.javaPersistentTypeContainer.removeContextElement(javaPersistentType); - } - - //only accept types, enums aren't valid for JPA - protected Iterable<JavaResourceType> getJavaResourceTypes() { - return new SubIterableWrapper<JavaResourceAbstractType, JavaResourceType>( - new FilteringIterable<JavaResourceAbstractType>(this.getJavaResourceAbstractTypes()) { - @Override - protected boolean accept(JavaResourceAbstractType o) { - return o.getKind() == Kind.TYPE; - } - }); - } - - /** - * the resource JAR holds only annotated types, so we can use them all for - * building the context types - */ - protected Iterable<JavaResourceAbstractType> getJavaResourceAbstractTypes() { - return this.jarResourcePackageFragmentRoot.getTypes(); - } - - protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrt) { - return this.getJpaFactory().buildJavaPersistentType(this, jrt); - } - - protected ContextCollectionContainer<JavaPersistentType, JavaResourceType> buildJavaPersistentTypeContainer() { - JavaPersistentTypeContainer container = new JavaPersistentTypeContainer(); - container.initialize(); - return container; - } - - /** - * Java persistent type container - */ - protected class JavaPersistentTypeContainer - extends ContextCollectionContainer<JavaPersistentType, JavaResourceType> - { - @Override - protected String getContextElementsPropertyName() { - return JAVA_PERSISTENT_TYPES_COLLECTION; - } - @Override - protected JavaPersistentType buildContextElement(JavaResourceType resourceElement) { - return GenericJarFile.this.buildJavaPersistentType(resourceElement); - } - @Override - protected Iterable<JavaResourceType> getResourceElements() { - return GenericJarFile.this.getJavaResourceTypes(); - } - @Override - protected JavaResourceType getResourceElement(JavaPersistentType contextElement) { - return contextElement.getJavaResourceType(); - } - } - - - // ********** PersistentTypeContainer implementation ********** - - public Iterable<JavaPersistentType> getPersistentTypes() { - return this.getJavaPersistentTypes(); - } - - - // ********** PersistentType.Owner implementation ********** - - public AccessType getDefaultPersistentTypeAccess() { - return this.getPersistenceUnit().getDefaultAccess(); - } - - public AccessType getOverridePersistentTypeAccess() { - // no access type at this level overrides any local access type specification - return null; - } - - - // ********** JpaNode implementation ********** - - @Override - public JarFileRef getParent() { - return (JarFileRef) super.getParent(); - } - - protected JarFileRef getJarFileRef() { - return this.getParent(); - } - - @Override - public IResource getResource() { - return this.jarResourcePackageFragmentRoot.getFile(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - // TODO validate 'javaPersistentTypes' - } - - public boolean isIn(org.eclipse.core.resources.IFolder folder) { - IResource member = folder.findMember(this.jarResourcePackageFragmentRoot.getFile().getName()); - IFile file = this.jarResourcePackageFragmentRoot.getFile(); - return member != null && file != null && member.equals(file); - } - - public TextRange getValidationTextRange() { - return this.getJarFileRef().getValidationTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverride.java deleted file mode 100644 index 55f80de86c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverride.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaOverrideRelationship; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOverride; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Specified Java association override - */ -public class GenericJavaAssociationOverride - extends AbstractJavaOverride<JavaAssociationOverrideContainer, AssociationOverrideAnnotation> - implements JavaAssociationOverride2_0 -{ - protected final JavaOverrideRelationship relationship; - - - public GenericJavaAssociationOverride(JavaAssociationOverrideContainer parent, AssociationOverrideAnnotation annotation) { - super(parent, annotation); - this.relationship = this.buildRelationship(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.relationship.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.relationship.update(); - } - - - // ********** specified/virtual ********** - - @Override - public JavaVirtualAssociationOverride convertToVirtual() { - return (JavaVirtualAssociationOverride) super.convertToVirtual(); - } - - - // ********** relationship ********** - - public JavaOverrideRelationship getRelationship() { - return this.relationship; - } - - protected JavaOverrideRelationship buildRelationship() { - return this.getJpaFactory().buildJavaOverrideRelationship(this); - } - - - // ********** misc ********** - - @Override - protected JavaAssociationOverrideContainer2_0 getContainer2_0() { - return (JavaAssociationOverrideContainer2_0) super.getContainer2_0(); - } - - public RelationshipMapping getMapping() { - return this.getContainer().getRelationshipMapping(this.name); - } - - public void initializeFrom(ReadOnlyAssociationOverride oldOverride) { - super.initializeFrom(oldOverride); - this.relationship.initializeFrom(oldOverride.getRelationship()); - } - - public void initializeFromVirtual(ReadOnlyAssociationOverride virtualOverride) { - super.initializeFromVirtual(virtualOverride); - this.relationship.initializeFromVirtual(virtualOverride.getRelationship()); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.relationship.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - return null; - } - - @Override - protected Iterable<String> getCandidateNames() { - return this.getContainer().getAllOverridableNames(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.relationship.validate(messages, reporter, astRoot); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableValidator(this, table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableJoinColumnValidator(this, column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableInverseJoinColumnValidator(this, column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverrideContainer.java deleted file mode 100644 index 215fc57d2d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAssociationOverrideContainer.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation; - -/** - * Java attribute override container - */ -public class GenericJavaAssociationOverrideContainer - extends AbstractJavaOverrideContainer< - JavaAssociationOverrideContainer.Owner, - JavaReadOnlyAssociationOverride, - JavaAssociationOverride, - JavaVirtualAssociationOverride, - AssociationOverrideAnnotation - > - implements JavaAssociationOverrideContainer2_0 -{ - public GenericJavaAssociationOverrideContainer(JavaJpaContextNode parent, JavaAssociationOverrideContainer.Owner owner) { - super(parent, owner); - } - - - public RelationshipMapping getRelationshipMapping(String attributeName) { - return MappingTools.getRelationshipMapping(attributeName, this.owner.getOverridableTypeMapping()); - } - - public ReadOnlyRelationship resolveOverriddenRelationship(String associationOverrideName) { - return this.owner.resolveOverriddenRelationship(associationOverrideName); - } - - public ReadOnlyOverrideRelationship getOverrideRelationship(String overrideName) { - return this.getOverrideNamed(overrideName).getRelationship(); - } - - @Override - protected JavaAssociationOverrideContainer2_0.Owner getOwner2_0() { - return (JavaAssociationOverrideContainer2_0.Owner) super.getOwner2_0(); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner o, JoinColumnTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableJoinColumnValidator(override, column, o, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner o, JoinColumnTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableInverseJoinColumnValidator(override, column, o, textRangeResolver); - } - - public JptValidator buildJoinTableValidator(ReadOnlyAssociationOverride override, ReadOnlyTable table, TableTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableValidator(override, table, textRangeResolver); - } - - @Override - protected String getOverrideAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - @Override - protected JavaAssociationOverride buildSpecifiedOverride(AssociationOverrideAnnotation overrideAnnotation) { - return this.getJpaFactory().buildJavaAssociationOverride(this, overrideAnnotation); - } - - @Override - protected void initializeSpecifiedOverride(JavaAssociationOverride specifiedOverride, JavaVirtualAssociationOverride virtualOverride) { - specifiedOverride.initializeFromVirtual(virtualOverride); - } - - @Override - protected JavaVirtualAssociationOverride buildVirtualOverride(String name) { - return this.getJpaFactory().buildJavaVirtualAssociationOverride(this, name); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverride.java deleted file mode 100644 index 0f7fbabdfb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverride.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOverride; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.CompleteColumnAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Specified Java attribute override - */ -public class GenericJavaAttributeOverride - extends AbstractJavaOverride<JavaAttributeOverrideContainer, AttributeOverrideAnnotation> - implements JavaAttributeOverride, JavaColumn.Owner -{ - protected final JavaColumn column; - - - public GenericJavaAttributeOverride(JavaAttributeOverrideContainer parent, AttributeOverrideAnnotation annotation) { - super(parent, annotation); - this.column = this.buildColumn(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.column.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.column.update(); - } - - - // ********** specified/virtual ********** - - @Override - public JavaVirtualAttributeOverride convertToVirtual() { - return (JavaVirtualAttributeOverride) super.convertToVirtual(); - } - - - // ********** column ********** - - public JavaColumn getColumn() { - return this.column; - } - - protected JavaColumn buildColumn() { - return this.getJpaFactory().buildJavaColumn(this, this); - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyAttributeOverride oldOverride) { - super.initializeFrom(oldOverride); - this.column.initializeFrom(oldOverride.getColumn()); - } - - public void initializeFromVirtual(ReadOnlyAttributeOverride oldOverride) { - super.initializeFromVirtual(oldOverride); - this.column.initializeFromVirtual(oldOverride.getColumn()); - } - - - // ********** column owner implementation ********** - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return this.name; - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, (ReadOnlyBaseColumn) col, this, (TableColumnTextRangeResolver) textRangeResolver); - } - - public CompleteColumnAnnotation getColumnAnnotation() { - return this.getOverrideAnnotation().getNonNullColumn(); - } - - public void removeColumnAnnotation() { - this.getOverrideAnnotation().removeColumn(); - } - - - // ********** derived ********** - - protected boolean attributeIsDerivedId() { - return this.getTypeMapping().attributeIsDerivedId(this.name); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.column.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - return null; - } - - @Override - protected Iterable<String> getCandidateNames() { - return this.getContainer().getAllOverridableNames(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - - if (this.attributeIsDerivedId()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ATTRIBUTE_OVERRIDE_DERIVED_AND_SPECIFIED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange(astRoot) - ) - ); - - // validate the column if it is specified - if (this.columnAnnotationIsSpecified()) { - this.column.validate(messages, reporter, astRoot); - } - } else { - this.column.validate(messages, reporter, astRoot); - } - } - - protected boolean columnAnnotationIsSpecified() { - return this.getOverrideAnnotation().getColumn() != null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverrideContainer.java deleted file mode 100644 index 182d70f4aa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaAttributeOverrideContainer.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAttributeOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation; - -/** - * Java attribute override container - */ -public class GenericJavaAttributeOverrideContainer - extends AbstractJavaOverrideContainer< - JavaAttributeOverrideContainer.Owner, - JavaReadOnlyAttributeOverride, - JavaAttributeOverride, - JavaVirtualAttributeOverride, - AttributeOverrideAnnotation - > - implements JavaAttributeOverrideContainer2_0 -{ - public GenericJavaAttributeOverrideContainer(JavaJpaContextNode parent, JavaAttributeOverrideContainer.Owner owner) { - super(parent, owner); - } - - - public ReadOnlyColumn resolveOverriddenColumn(String attributeName) { - return (attributeName == null) ? null : this.owner.resolveOverriddenColumn(attributeName); - } - - public ReadOnlyColumn getOverrideColumn(String overrideName) { - return this.getOverrideNamed(overrideName).getColumn(); - } - - @Override - protected String getOverrideAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - @Override - protected JavaAttributeOverride buildSpecifiedOverride(AttributeOverrideAnnotation overrideAnnotation) { - return this.getJpaFactory().buildJavaAttributeOverride(this, overrideAnnotation); - } - - @Override - protected void initializeSpecifiedOverride(JavaAttributeOverride specifiedOverride, JavaVirtualAttributeOverride virtualOverride) { - specifiedOverride.initializeFromVirtual(virtualOverride); - } - - @Override - protected JavaVirtualAttributeOverride buildVirtualOverride(String name) { - return this.getJpaFactory().buildJavaVirtualAttributeOverride(this, name); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseEnumeratedConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseEnumeratedConverter.java deleted file mode 100644 index be8b74c1be..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseEnumeratedConverter.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.BaseEnumeratedConverter; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.EnumType; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaBaseEnumeratedConverter; -import org.eclipse.jpt.jpa.core.context.java.JavaConverter; -import org.eclipse.jpt.jpa.core.resource.java.BaseEnumeratedAnnotation; - -public class GenericJavaBaseEnumeratedConverter - extends AbstractJavaConverter - implements JavaBaseEnumeratedConverter -{ - protected final BaseEnumeratedAnnotation enumeratedAnnotation; - - protected EnumType specifiedEnumType; - protected EnumType defaultEnumType; - - - public GenericJavaBaseEnumeratedConverter(JavaAttributeMapping parent, BaseEnumeratedAnnotation enumeratedAnnotation, JavaConverter.Owner owner) { - super(parent, owner); - this.enumeratedAnnotation = enumeratedAnnotation; - this.specifiedEnumType = this.buildSpecifiedEnumType(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedEnumType_(this.buildSpecifiedEnumType()); - } - - @Override - public void update() { - super.update(); - this.setDefaultEnumType(this.buildDefaultEnumType()); - } - - - // ********** enum type ********** - - public EnumType getEnumType() { - return (this.specifiedEnumType != null) ? this.specifiedEnumType : this.defaultEnumType; - } - - public EnumType getSpecifiedEnumType() { - return this.specifiedEnumType; - } - - public void setSpecifiedEnumType(EnumType enumType) { - this.enumeratedAnnotation.setValue(EnumType.toJavaResourceModel(enumType)); - this.setSpecifiedEnumType_(enumType); - } - - protected void setSpecifiedEnumType_(EnumType enumType) { - EnumType old = this.specifiedEnumType; - this.specifiedEnumType = enumType; - this.firePropertyChanged(SPECIFIED_ENUM_TYPE_PROPERTY, old, enumType); - } - - protected EnumType buildSpecifiedEnumType() { - return EnumType.fromJavaResourceModel(this.enumeratedAnnotation.getValue()); - } - - public EnumType getDefaultEnumType() { - return this.defaultEnumType; - } - - protected void setDefaultEnumType(EnumType enumType) { - EnumType old = this.defaultEnumType; - this.defaultEnumType = enumType; - this.firePropertyChanged(DEFAULT_ENUM_TYPE_PROPERTY, old, enumType); - } - - protected EnumType buildDefaultEnumType() { - return DEFAULT_ENUM_TYPE; - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return BaseEnumeratedConverter.class; - } - - public BaseEnumeratedAnnotation getConverterAnnotation() { - return this.enumeratedAnnotation; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseTemporalConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseTemporalConverter.java deleted file mode 100644 index d871f4eab4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBaseTemporalConverter.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.BaseTemporalConverter; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.TemporalType; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaBaseTemporalConverter; -import org.eclipse.jpt.jpa.core.context.java.JavaConverter; -import org.eclipse.jpt.jpa.core.resource.java.BaseTemporalAnnotation; - -public class GenericJavaBaseTemporalConverter - extends AbstractJavaConverter - implements JavaBaseTemporalConverter -{ - protected final BaseTemporalAnnotation temporalAnnotation; - - protected TemporalType temporalType; - - - public GenericJavaBaseTemporalConverter(JavaAttributeMapping parent, BaseTemporalAnnotation temporalAnnotation, JavaConverter.Owner owner) { - super(parent, owner); - this.temporalAnnotation = temporalAnnotation; - this.temporalType = this.buildTemporalType(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setTemporalType_(this.buildTemporalType()); - } - - - // ********** temporal type ********** - - public TemporalType getTemporalType() { - return this.temporalType; - } - - public void setTemporalType(TemporalType temporalType) { - if (this.valuesAreDifferent(this.temporalType, temporalType)) { - this.temporalAnnotation.setValue(TemporalType.toJavaResourceModel(temporalType)); - this.removeTemporalAnnotationIfUnset(); - this.setTemporalType_(temporalType); - } - } - - protected void setTemporalType_(TemporalType temporalType) { - TemporalType old = this.temporalType; - this.temporalType = temporalType; - this.firePropertyChanged(TEMPORAL_TYPE_PROPERTY, old, temporalType); - } - - protected TemporalType buildTemporalType() { - return TemporalType.fromJavaResourceModel(this.temporalAnnotation.getValue()); - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return BaseTemporalConverter.class; - } - - public BaseTemporalAnnotation getConverterAnnotation() { - return this.temporalAnnotation; - } - - protected void removeTemporalAnnotationIfUnset() { - if (this.temporalAnnotation.isUnset()) { - this.temporalAnnotation.removeAnnotation(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBasicMapping.java deleted file mode 100644 index fc88aeed80..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaBasicMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaBasicMapping; - -public class GenericJavaBasicMapping - extends AbstractJavaBasicMapping -{ - public GenericJavaBasicMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java deleted file mode 100644 index 7a26de7fea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaRelationshipMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCascade2_0; -import org.eclipse.jpt.jpa.core.jpa2.resource.java.RelationshipMapping2_0Annotation; -import org.eclipse.jpt.jpa.core.resource.java.RelationshipMappingAnnotation; - -public class GenericJavaCascade - extends AbstractJavaJpaContextNode - implements JavaCascade2_0 -{ - protected boolean all; - - protected boolean persist; - - protected boolean merge; - - protected boolean remove; - - protected boolean refresh; - - /* JPA 2.0 */ - protected boolean detach; - - - /** - * This is built directly by the mapping implementation; as opposed to via - * a platform-specific factory. - * @see AbstractJavaRelationshipMapping#buildCascade() - */ - public GenericJavaCascade(JavaRelationshipMapping parent) { - super(parent); - this.all = this.buildAll(); - this.persist = this.buildPersist(); - this.merge = this.buildMerge(); - this.remove = this.buildRemove(); - this.refresh = this.buildRefresh(); - this.detach = this.buildDetach(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setAll_(this.buildAll()); - this.setPersist_(this.buildPersist()); - this.setMerge_(this.buildMerge()); - this.setRemove_(this.buildRemove()); - this.setRefresh_(this.buildRefresh()); - this.setDetach_(this.buildDetach()); - } - - - // ********** all ********** - - public boolean isAll() { - return this.all; - } - - public void setAll(boolean all) { - if (all != this.all) { - this.getMappingAnnotationForUpdate().setCascadeAll(all); - this.setAll_(all); - } - } - - protected void setAll_(boolean all) { - boolean old = this.all; - this.all = all; - this.firePropertyChanged(ALL_PROPERTY, old, all); - } - - protected boolean buildAll() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation != null) && annotation.isCascadeAll(); - } - - - // ********** persist ********** - - public boolean isPersist() { - return this.persist; - } - - public void setPersist(boolean persist) { - if (persist != this.persist) { - this.getMappingAnnotationForUpdate().setCascadePersist(persist); - this.setPersist_(persist); - } - } - - protected void setPersist_(boolean persist) { - boolean old = this.persist; - this.persist = persist; - this.firePropertyChanged(PERSIST_PROPERTY, old, persist); - } - - protected boolean buildPersist() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation != null) && annotation.isCascadePersist(); - } - - - // ********** merge ********** - - public boolean isMerge() { - return this.merge; - } - - public void setMerge(boolean merge) { - if (merge != this.merge) { - this.getMappingAnnotationForUpdate().setCascadeMerge(merge); - this.setMerge_(merge); - } - } - - protected void setMerge_(boolean merge) { - boolean old = this.merge; - this.merge = merge; - this.firePropertyChanged(MERGE_PROPERTY, old, merge); - } - - protected boolean buildMerge() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation != null) && annotation.isCascadeMerge(); - } - - - // ********** remove ********** - - public boolean isRemove() { - return this.remove; - } - - public void setRemove(boolean remove) { - if (remove != this.remove) { - this.getMappingAnnotationForUpdate().setCascadeRemove(remove); - this.setRemove_(remove); - } - } - - protected void setRemove_(boolean remove) { - boolean oldRemove = this.remove; - this.remove = remove; - this.firePropertyChanged(REMOVE_PROPERTY, oldRemove, remove); - } - - protected boolean buildRemove() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation != null) && annotation.isCascadeRemove(); - } - - - // ********** refresh ********** - - public boolean isRefresh() { - return this.refresh; - } - - public void setRefresh(boolean refresh) { - if (refresh != this.refresh) { - this.getMappingAnnotationForUpdate().setCascadeRefresh(refresh); - this.setRefresh_(refresh); - } - } - - protected void setRefresh_(boolean refresh) { - boolean old = this.refresh; - this.refresh = refresh; - this.firePropertyChanged(REFRESH_PROPERTY, old, refresh); - } - - protected boolean buildRefresh() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation != null) && annotation.isCascadeRefresh(); - } - - - // ********** detach ********** - - public boolean isDetach() { - return this.detach; - } - - public void setDetach(boolean detach) { - if (detach != this.detach) { - this.getMappingAnnotationForUpdate2_0().setCascadeDetach(detach); - this.setDetach_(detach); - } - } - - protected void setDetach_(boolean detach) { - boolean old = this.detach; - this.detach = detach; - this.firePropertyChanged(DETACH_PROPERTY, old, detach); - } - - protected boolean buildDetach() { - return this.isJpa2_0Compatible() && this.buildDetach_(); - } - - protected boolean buildDetach_() { - RelationshipMapping2_0Annotation annotation = this.getMappingAnnotation2_0(); - return (annotation != null) && annotation.isCascadeDetach(); - } - - - - // ********** misc ********** - - @Override - public JavaRelationshipMapping getParent() { - return (JavaRelationshipMapping) super.getParent(); - } - - protected JavaRelationshipMapping getMapping() { - return this.getParent(); - } - - protected RelationshipMappingAnnotation getMappingAnnotation() { - return this.getMapping().getMappingAnnotation(); - } - - protected RelationshipMappingAnnotation getMappingAnnotationForUpdate() { - return this.getMapping().getAnnotationForUpdate(); - } - - protected RelationshipMapping2_0Annotation getMappingAnnotation2_0() { - return (RelationshipMapping2_0Annotation) this.getMappingAnnotation(); - } - - protected RelationshipMapping2_0Annotation getMappingAnnotationForUpdate2_0() { - return (RelationshipMapping2_0Annotation) this.getMappingAnnotationForUpdate(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getAnnotationCascadeTextRange(); - return (textRange != null) ? textRange : this.getMapping().getValidationTextRange(astRoot); - } - - protected TextRange getAnnotationCascadeTextRange() { - RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation == null) ? null : annotation.getCascadeTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaColumn.java deleted file mode 100644 index 2af11ca6fa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaColumn.java +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaBaseColumn; -import org.eclipse.jpt.jpa.core.resource.java.CompleteColumnAnnotation; - -/** - * Java column - * <p> - * Note: The <code>Column</code> annotation is one of only 2 annotations that - * can be nested outside of an array (i.e. in an <code>AttributeOverride</code> - * annotation); the other is {@link GenericJavaJoinTable JoinTable}. - */ -public class GenericJavaColumn - extends AbstractJavaBaseColumn<CompleteColumnAnnotation, JavaColumn.Owner> - implements JavaColumn -{ - protected Integer specifiedLength; - protected int defaultLength; - - protected Integer specifiedPrecision; - protected int defaultPrecision; - - protected Integer specifiedScale; - protected int defaultScale; - - - public GenericJavaColumn(JavaJpaContextNode parent, JavaColumn.Owner owner) { - super(parent, owner); - this.specifiedLength = this.buildSpecifiedLength(); - this.specifiedPrecision = this.buildSpecifiedPrecision(); - this.specifiedScale = this.buildSpecifiedScale(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedLength_(this.buildSpecifiedLength()); - this.setSpecifiedPrecision_(this.buildSpecifiedPrecision()); - this.setSpecifiedScale_(this.buildSpecifiedScale()); - } - - @Override - public void update() { - super.update(); - this.setDefaultLength(this.buildDefaultLength()); - this.setDefaultPrecision(this.buildDefaultPrecision()); - this.setDefaultScale(this.buildDefaultScale()); - } - - - // ********** column annotation ********** - - @Override - public CompleteColumnAnnotation getColumnAnnotation() { - return this.owner.getColumnAnnotation(); - } - - @Override - protected void removeColumnAnnotation() { - this.owner.removeColumnAnnotation(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength; - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - public void setSpecifiedLength(Integer length) { - if (this.valuesAreDifferent(this.specifiedLength, length)) { - this.getColumnAnnotation().setLength(length); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedLength_(length); - } - } - - protected void setSpecifiedLength_(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - return this.getColumnAnnotation().getLength(); - } - - public int getDefaultLength() { - return this.defaultLength; - } - - protected void setDefaultLength(int length) { - int old = this.defaultLength; - this.defaultLength = length; - this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, length); - } - - protected int buildDefaultLength() { - return DEFAULT_LENGTH; - } - - - // ********** precision ********** - - public int getPrecision() { - return (this.specifiedPrecision != null) ? this.specifiedPrecision.intValue() : this.defaultPrecision; - } - - public Integer getSpecifiedPrecision() { - return this.specifiedPrecision; - } - - public void setSpecifiedPrecision(Integer precision) { - if (this.valuesAreDifferent(this.specifiedPrecision, precision)) { - this.getColumnAnnotation().setPrecision(precision); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedPrecision_(precision); - } - } - - protected void setSpecifiedPrecision_(Integer precision) { - Integer old = this.specifiedPrecision; - this.specifiedPrecision = precision; - this.firePropertyChanged(SPECIFIED_PRECISION_PROPERTY, old, precision); - } - - protected Integer buildSpecifiedPrecision() { - return this.getColumnAnnotation().getPrecision(); - } - - public int getDefaultPrecision() { - return this.defaultPrecision; - } - - protected void setDefaultPrecision(int precision) { - int old = this.defaultPrecision; - this.defaultPrecision = precision; - this.firePropertyChanged(DEFAULT_PRECISION_PROPERTY, old, precision); - } - - protected int buildDefaultPrecision() { - return DEFAULT_PRECISION; - } - - - // ********** scale ********** - - public int getScale() { - return (this.specifiedScale != null) ? this.specifiedScale.intValue() : this.defaultScale; - } - - public Integer getSpecifiedScale() { - return this.specifiedScale; - } - - public void setSpecifiedScale(Integer scale) { - if (this.valuesAreDifferent(this.specifiedScale, scale)) { - this.getColumnAnnotation().setScale(scale); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedScale_(scale); - } - } - - protected void setSpecifiedScale_(Integer scale) { - Integer old = this.specifiedScale; - this.specifiedScale = scale; - this.firePropertyChanged(SPECIFIED_SCALE_PROPERTY, old, scale); - } - - protected Integer buildSpecifiedScale() { - return this.getColumnAnnotation().getScale(); - } - - public int getDefaultScale() { - return this.defaultScale; - } - - protected void setDefaultScale(int scale) { - int old = this.defaultScale; - this.defaultScale = scale; - this.firePropertyChanged(DEFAULT_SCALE_PROPERTY, old, scale); - } - - protected int buildDefaultScale() { - return DEFAULT_SCALE; - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyColumn oldColumn) { - super.initializeFrom(oldColumn); - this.setSpecifiedLength(oldColumn.getSpecifiedLength()); - this.setSpecifiedPrecision(oldColumn.getSpecifiedPrecision()); - this.setSpecifiedScale(oldColumn.getSpecifiedScale()); - } - - public void initializeFromVirtual(ReadOnlyColumn virtualColumn) { - super.initializeFromVirtual(virtualColumn); - // ignore other settings? - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java deleted file mode 100644 index 4d2f68696b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.jpa.core.context.java.JavaDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorColumnAnnotation; - -/** - * Java discriminator column - */ -public class GenericJavaDiscriminatorColumn - extends AbstractJavaNamedDiscriminatorColumn<DiscriminatorColumnAnnotation, JavaDiscriminatorColumn.Owner> - implements JavaDiscriminatorColumn -{ - - public GenericJavaDiscriminatorColumn(JavaEntity parent, JavaDiscriminatorColumn.Owner owner) { - super(parent, owner); - } - - - // ********** column annotation ********** - - @Override - public DiscriminatorColumnAnnotation getColumnAnnotation() { - return (DiscriminatorColumnAnnotation) this.getJavaResourceType().getNonNullAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME); - } - - @Override - protected void removeColumnAnnotation() { - this.getJavaResourceType().removeAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME); - } - - - // ********** misc ********** - - @Override - public JavaEntity getParent() { - return (JavaEntity) super.getParent(); - } - - protected JavaEntity getEntity() { - return this.getParent(); - } - - protected JavaPersistentType getPersistentType() { - return this.getEntity().getPersistentType(); - } - - protected JavaResourceType getJavaResourceType() { - return this.getPersistentType().getJavaResourceType(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddable.java deleted file mode 100644 index 75bcc8579a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddable.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEmbeddable; -import org.eclipse.jpt.jpa.core.resource.java.EmbeddableAnnotation; - -/** - * Java embeddable type mapping - */ -public class GenericJavaEmbeddable - extends AbstractJavaEmbeddable -{ - public GenericJavaEmbeddable(JavaPersistentType parent, EmbeddableAnnotation mappingAnnotation) { - super(parent, mappingAnnotation); - } - - @Override - public boolean attributeMappingKeyAllowed(String attributeMappingKey) { - //generic only allows basic and transient within an Embeddable - return ArrayTools.contains(ALLOWED_ATTRIBUTE_MAPPING_KEYS, attributeMappingKey); - } - - public static final String[] ALLOWED_ATTRIBUTE_MAPPING_KEYS = - new String[] { - MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, - MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY - }; -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedIdMapping.java deleted file mode 100644 index f6ff5eb990..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedIdMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEmbeddedIdMapping; - -/** - * Java embedded ID mapping - */ -public class GenericJavaEmbeddedIdMapping - extends AbstractJavaEmbeddedIdMapping -{ - - public GenericJavaEmbeddedIdMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java deleted file mode 100644 index a72d2dc1b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEmbeddedMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEmbeddedMapping; - -/** - * Java embedded mapping - */ -public class GenericJavaEmbeddedMapping - extends AbstractJavaEmbeddedMapping -{ - - public GenericJavaEmbeddedMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEntity.java deleted file mode 100644 index e123367631..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEntity.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEntity; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.NullJavaCacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation; - -public class GenericJavaEntity - extends AbstractJavaEntity -{ - // EclipseLink holds its cacheable in its caching - protected final JavaCacheable2_0 cacheable; - - - public GenericJavaEntity(JavaPersistentType parent, EntityAnnotation mappingAnnotation) { - super(parent, mappingAnnotation); - this.cacheable = this.buildCacheable(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.cacheable.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.cacheable.update(); - } - - - // ********** cacheable ********** - - public JavaCacheable2_0 getCacheable() { - return this.cacheable; - } - - protected JavaCacheable2_0 buildCacheable() { - return this.isJpa2_0Compatible() ? - this.getJpaFactory2_0().buildJavaCacheable(this) : - new NullJavaCacheable2_0(this); - } - - public boolean calculateDefaultCacheable() { - Cacheable2_0 parentCacheable = this.getParentCacheable(); - return (parentCacheable != null) ? - parentCacheable.isCacheable() : - ((PersistenceUnit2_0) this.getPersistenceUnit()).calculateDefaultCacheable(); - } - - protected Cacheable2_0 getParentCacheable() { - CacheableHolder2_0 parentEntity = (CacheableHolder2_0) this.getParentEntity(); - return (parentEntity == null) ? null : parentEntity.getCacheable(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java deleted file mode 100644 index 4f8f3082fe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.GenerationType; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.java.JavaGeneratedValue; -import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java generated value - */ -public class GenericJavaGeneratedValue - extends AbstractJavaJpaContextNode - implements JavaGeneratedValue -{ - protected final GeneratedValueAnnotation generatedValueAnnotation; - - protected GenerationType specifiedStrategy; - protected GenerationType defaultStrategy; - - protected String specifiedGenerator; - protected String defaultGenerator; - - - public GenericJavaGeneratedValue(JavaIdMapping parent, GeneratedValueAnnotation generatedValueAnnotation) { - super(parent); - this.generatedValueAnnotation = generatedValueAnnotation; - this.specifiedStrategy = this.buildSpecifiedStrategy(); - this.specifiedGenerator = generatedValueAnnotation.getGenerator(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedStrategy_(this.buildSpecifiedStrategy()); - this.setSpecifiedGenerator_(this.generatedValueAnnotation.getGenerator()); - } - - @Override - public void update() { - super.update(); - this.setDefaultStrategy(this.buildDefaultStrategy()); - this.setDefaultGenerator(this.buildDefaultGenerator()); - } - - - // ********** strategy ********** - - public GenerationType getStrategy() { - return (this.specifiedStrategy != null) ? this.specifiedStrategy : this.defaultStrategy; - } - - public GenerationType getSpecifiedStrategy() { - return this.specifiedStrategy; - } - - public void setSpecifiedStrategy(GenerationType strategy) { - this.generatedValueAnnotation.setStrategy(GenerationType.toJavaResourceModel(strategy)); - this.setSpecifiedStrategy_(strategy); - } - - protected void setSpecifiedStrategy_(GenerationType strategy) { - GenerationType old = this.specifiedStrategy; - this.specifiedStrategy = strategy; - this.firePropertyChanged(SPECIFIED_STRATEGY_PROPERTY, old, strategy); - } - - protected GenerationType buildSpecifiedStrategy() { - return GenerationType.fromJavaResourceModel(this.generatedValueAnnotation.getStrategy()); - } - - public GenerationType getDefaultStrategy() { - return this.defaultStrategy; - } - - protected void setDefaultStrategy(GenerationType strategy) { - GenerationType old = this.defaultStrategy; - this.defaultStrategy = strategy; - this.firePropertyChanged(DEFAULT_STRATEGY_PROPERTY, old, strategy); - } - - protected GenerationType buildDefaultStrategy() { - return DEFAULT_STRATEGY; - } - - - // ********** generator ********** - - public String getGenerator() { - return (this.specifiedGenerator != null) ? this.specifiedGenerator : this.defaultGenerator; - } - - public String getSpecifiedGenerator() { - return this.specifiedGenerator; - } - - public void setSpecifiedGenerator(String generator) { - this.generatedValueAnnotation.setGenerator(generator); - this.setSpecifiedGenerator_(generator); - } - - protected void setSpecifiedGenerator_(String generator) { - String old = this.specifiedGenerator; - this.specifiedGenerator = generator; - this.firePropertyChanged(SPECIFIED_GENERATOR_PROPERTY, old, generator); - } - - public String getDefaultGenerator() { - return this.defaultGenerator; - } - - protected void setDefaultGenerator(String generator) { - String old = this.defaultGenerator; - this.defaultGenerator = generator; - this.firePropertyChanged(DEFAULT_GENERATOR_PROPERTY, old, generator); - } - - protected String buildDefaultGenerator() { - return null; - } - - - // ********** misc ********** - - @Override - public JavaIdMapping getParent() { - return (JavaIdMapping) super.getParent(); - } - - protected JavaIdMapping getIdMapping() { - return this.getParent(); - } - - public GeneratedValueAnnotation getGeneratedValueAnnotation() { - return this.generatedValueAnnotation; - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.generatorTouches(pos)) { - return this.getJavaCandidateGeneratorNames(filter); - } - return null; - } - - protected boolean generatorTouches(int pos) { - return this.generatedValueAnnotation.generatorTouches(pos); - } - - protected Iterable<String> getJavaCandidateGeneratorNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateGeneratorNames(filter)); - } - - protected Iterable<String> getCandidateGeneratorNames(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateGeneratorNames(), filter); - } - - protected Iterable<String> getCandidateGeneratorNames() { - return this.getPersistenceUnit().getUniqueGeneratorNames(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - - String generator = this.getGenerator(); - if (generator == null) { - return; - } - - for (Generator next : this.getPersistenceUnit().getGenerators()) { - if (generator.equals(next.getName())) { - return; - } - } - - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, - new String[] {generator}, - this.getIdMapping(), - this.getGeneratorTextRange(astRoot) - ) - ); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getAnnotationTextRange(astRoot); - return (textRange != null) ? textRange : this.getIdMapping().getValidationTextRange(astRoot); - } - - protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.generatedValueAnnotation.getTextRange(astRoot); - } - - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - return this.getValidationTextRange(this.generatedValueAnnotation.getGeneratorTextRange(), astRoot); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java deleted file mode 100644 index 350c7b1cb3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.NotNullFilter; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaSequenceGenerator; -import org.eclipse.jpt.jpa.core.context.java.JavaTableGenerator; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaGeneratorContainer - extends AbstractJavaJpaContextNode - implements JavaGeneratorContainer -{ - protected final ParentAdapter parentAdapter; - - protected JavaSequenceGenerator sequenceGenerator; - - protected JavaTableGenerator tableGenerator; - - - public GenericJavaGeneratorContainer(ParentAdapter parentAdapter) { - super(parentAdapter.getGeneratorContainerParent()); - this.parentAdapter = parentAdapter; - this.sequenceGenerator = this.buildSequenceGenerator(); - this.tableGenerator = this.buildTableGenerator(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSequenceGenerator(); - this.syncTableGenerator(); - } - - @Override - public void update() { - super.update(); - if (this.sequenceGenerator != null) { - this.sequenceGenerator.update(); - } - if (this.tableGenerator != null) { - this.tableGenerator.update(); - } - } - - - // ********** sequence generator ********** - - public JavaSequenceGenerator getSequenceGenerator() { - return this.sequenceGenerator; - } - - public JavaSequenceGenerator addSequenceGenerator() { - if (this.sequenceGenerator != null) { - throw new IllegalStateException("sequence generator already exists: " + this.sequenceGenerator); //$NON-NLS-1$ - } - SequenceGeneratorAnnotation annotation = this.buildSequenceGeneratorAnnotation(); - JavaSequenceGenerator generator = this.buildSequenceGenerator(annotation); - this.setSequenceGenerator(generator); - return generator; - } - - protected SequenceGeneratorAnnotation buildSequenceGeneratorAnnotation() { - return (SequenceGeneratorAnnotation) this.parentAdapter.getResourceAnnotatedElement().addAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME); - } - - public void removeSequenceGenerator() { - if (this.sequenceGenerator == null) { - throw new IllegalStateException("sequence generator does not exist"); //$NON-NLS-1$ - } - this.parentAdapter.getResourceAnnotatedElement().removeAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME); - this.setSequenceGenerator(null); - } - - protected JavaSequenceGenerator buildSequenceGenerator() { - SequenceGeneratorAnnotation annotation = this.getSequenceGeneratorAnnotation(); - return (annotation == null) ? null : this.buildSequenceGenerator(annotation); - } - - protected SequenceGeneratorAnnotation getSequenceGeneratorAnnotation() { - return (SequenceGeneratorAnnotation) this.parentAdapter.getResourceAnnotatedElement().getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME); - } - - protected JavaSequenceGenerator buildSequenceGenerator(SequenceGeneratorAnnotation sequenceGeneratorAnnotation) { - return this.parentAdapter.parentSupportsGenerators() ? - this.getJpaFactory().buildJavaSequenceGenerator(this, sequenceGeneratorAnnotation) : - null; - } - - protected void syncSequenceGenerator() { - SequenceGeneratorAnnotation annotation = this.getSequenceGeneratorAnnotation(); - if (annotation == null) { - if (this.sequenceGenerator != null) { - this.setSequenceGenerator(null); - } - } else { - if ((this.sequenceGenerator != null) && (this.sequenceGenerator.getGeneratorAnnotation() == annotation)) { - this.sequenceGenerator.synchronizeWithResourceModel(); - } else { - this.setSequenceGenerator(this.buildSequenceGenerator(annotation)); - } - } - } - - protected void setSequenceGenerator(JavaSequenceGenerator sequenceGenerator) { - JavaSequenceGenerator old = this.sequenceGenerator; - this.sequenceGenerator = sequenceGenerator; - this.firePropertyChanged(SEQUENCE_GENERATOR_PROPERTY, old, sequenceGenerator); - } - - - // ********** table generator ********** - - public JavaTableGenerator getTableGenerator() { - return this.tableGenerator; - } - - public JavaTableGenerator addTableGenerator() { - if (this.tableGenerator != null) { - throw new IllegalStateException("table generator already exists: " + this.tableGenerator); //$NON-NLS-1$ - } - TableGeneratorAnnotation annotation = this.buildTableGeneratorAnnotation(); - JavaTableGenerator generator = this.buildTableGenerator(annotation); - this.setTableGenerator(generator); - return generator; - } - - protected TableGeneratorAnnotation buildTableGeneratorAnnotation() { - return (TableGeneratorAnnotation) this.parentAdapter.getResourceAnnotatedElement().addAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME); - } - - public void removeTableGenerator() { - if (this.tableGenerator == null) { - throw new IllegalStateException("table generator does not exist"); //$NON-NLS-1$ - } - this.parentAdapter.getResourceAnnotatedElement().removeAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME); - this.setTableGenerator(null); - } - - protected JavaTableGenerator buildTableGenerator() { - TableGeneratorAnnotation annotation = this.getTableGeneratorAnnotation(); - return (annotation == null) ? null : this.buildTableGenerator(annotation); - } - - protected TableGeneratorAnnotation getTableGeneratorAnnotation() { - return (TableGeneratorAnnotation) this.parentAdapter.getResourceAnnotatedElement().getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME); - } - - protected JavaTableGenerator buildTableGenerator(TableGeneratorAnnotation tableGeneratorAnnotation) { - return this.parentAdapter.parentSupportsGenerators() ? - this.getJpaFactory().buildJavaTableGenerator(this, tableGeneratorAnnotation) : - null; - } - - protected void syncTableGenerator() { - TableGeneratorAnnotation annotation = this.getTableGeneratorAnnotation(); - if (annotation == null) { - if (this.tableGenerator != null) { - this.setTableGenerator(null); - } - } else { - if ((this.tableGenerator != null) && (this.tableGenerator.getGeneratorAnnotation() == annotation)) { - this.tableGenerator.synchronizeWithResourceModel(); - } else { - this.setTableGenerator(this.buildTableGenerator(annotation)); - } - } - } - - protected void setTableGenerator(JavaTableGenerator tableGenerator) { - JavaTableGenerator old = this.tableGenerator; - this.tableGenerator = tableGenerator; - this.firePropertyChanged(TABLE_GENERATOR_PROPERTY, old, tableGenerator); - } - - - // ********** code completion ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.tableGenerator != null) { - result = this.tableGenerator.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - if (this.sequenceGenerator != null) { - result = this.sequenceGenerator.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - - // ********** validation ********** - - /** - * The generators are validated in the persistence unit. - * @see org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#validateGenerators(List, IReporter) - */ - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - // generators are validated in the persistence unit - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getResourceTextRange(astRoot); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); - } - - protected TextRange getResourceTextRange(CompilationUnit astRoot) { - return this.parentAdapter.getResourceAnnotatedElement().getTextRange(astRoot); - } - - - // ********** misc ********** - - @Override - public JavaJpaContextNode getParent() { - return (JavaJpaContextNode) super.getParent(); - } - - public Iterable<Generator> getGenerators() { - return new FilteringIterable<Generator>(this.getGenerators_(), NotNullFilter.<Generator>instance()); - } - - protected Iterable<Generator> getGenerators_() { - return new ArrayIterable<Generator>(this.sequenceGenerator, this.tableGenerator); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaIdMapping.java deleted file mode 100644 index 7f1aca7b89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaIdMapping.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaIdMapping; - - -public class GenericJavaIdMapping - extends AbstractJavaIdMapping -{ - public GenericJavaIdMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java deleted file mode 100644 index dee7dcbdc0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaBaseColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.JavaJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.java.CompleteJoinColumnAnnotation; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Java join column - */ -public class GenericJavaJoinColumn - extends AbstractJavaBaseColumn<CompleteJoinColumnAnnotation, JavaReadOnlyJoinColumn.Owner> - implements JavaJoinColumn -{ - /** @see AbstractJavaNamedColumn#AbstractJavaNamedColumn(JavaJpaContextNode, org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyNamedColumn.Owner, org.eclipse.jpt.jpa.core.resource.java.NamedColumnAnnotation) */ - protected /* final */ CompleteJoinColumnAnnotation columnAnnotation; // never null - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericJavaJoinColumn(JavaJpaContextNode parent, JavaReadOnlyJoinColumn.Owner owner, CompleteJoinColumnAnnotation columnAnnotation) { - super(parent, owner, columnAnnotation); - this.specifiedReferencedColumnName = this.buildSpecifiedReferencedColumnName(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedReferencedColumnName_(this.buildSpecifiedReferencedColumnName()); - } - - @Override - public void update() { - super.update(); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** column annotation ********** - - @Override - public CompleteJoinColumnAnnotation getColumnAnnotation() { - return this.columnAnnotation; - } - - @Override - protected void setColumnAnnotation(CompleteJoinColumnAnnotation columnAnnotation) { - this.columnAnnotation = columnAnnotation; - } - - @Override - protected void removeColumnAnnotation() { - // we don't remove a join column annotation when it is empty - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - public void setSpecifiedReferencedColumnName(String name) { - if (this.valuesAreDifferent(this.specifiedReferencedColumnName, name)) { - this.getColumnAnnotation().setReferencedColumnName(name); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedReferencedColumnName_(name); - } - } - - protected void setSpecifiedReferencedColumnName_(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return this.getColumnAnnotation().getReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultReferencedColumnName() { - return MappingTools.buildJoinColumnDefaultReferencedColumnName(this.owner); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyJoinColumn oldColumn) { - super.initializeFrom(oldColumn); - this.setSpecifiedReferencedColumnName(oldColumn.getSpecifiedReferencedColumnName()); - } - - public void initializeFromVirtual(ReadOnlyJoinColumn virtualColumn) { - super.initializeFromVirtual(virtualColumn); - this.setSpecifiedReferencedColumnName(virtualColumn.getReferencedColumnName()); - } - - // ********** Java completion proposals ********** - - @Override - protected Iterable<String> getConnectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getConnectedJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.referencedColumnNameTouches(pos)) { - return this.getJavaCandidateReferencedColumnNames(filter); - } - return null; - } - - protected boolean referencedColumnNameTouches(int pos) { - return this.getColumnAnnotation().referencedColumnNameTouches(pos); - } - - protected Iterable<String> getJavaCandidateReferencedColumnNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateReferencedColumnNames(filter)); - } - - protected Iterable<String> getCandidateReferencedColumnNames(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateReferencedColumnNames(), filter); - } - - protected Iterable<String> getCandidateReferencedColumnNames() { - Table table = this.owner.getReferencedColumnDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } - - - // ********** validation ********** - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) { - return new JavaJoinColumnTextRangeResolver(this, astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getValidationTextRange(this.getColumnAnnotation().getReferencedColumnNameTextRange(), astRoot); - } -} 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 deleted file mode 100644 index a829e4e29a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinTable.java +++ /dev/null @@ -1,451 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.resource.java.NullJoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java join table - * <p> - * Note: The <code>JoinTable</code> annotation is one of only 2 annotations that - * can be nested outside of an array (i.e. in an <code>AssociationOverride</code> - * annotation); the other is {@link GenericJavaColumn Column}. - */ -public class GenericJavaJoinTable - extends GenericJavaReferenceTable<JoinTableAnnotation> - implements JavaJoinTable -{ - protected final ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> specifiedInverseJoinColumnContainer; - protected final JavaReadOnlyJoinColumn.Owner inverseJoinColumnOwner; - - protected JavaJoinColumn defaultInverseJoinColumn; - - - public GenericJavaJoinTable(JavaJoinTableRelationshipStrategy parent, Owner owner) { - super(parent, owner); - this.inverseJoinColumnOwner = this.buildInverseJoinColumnOwner(); - this.specifiedInverseJoinColumnContainer = this.buildSpecifiedInverseJoinColumnContainer(); - } - - @Override - protected JavaReadOnlyJoinColumn.Owner buildJoinColumnOwner() { - return new JoinColumnOwner(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedInverseJoinColumns(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedInverseJoinColumns()); - this.updateDefaultInverseJoinColumn(); - } - - - // ********** table annotation ********** - - @Override - public JoinTableAnnotation getTableAnnotation() { - return this.getRelationshipStrategy().getJoinTableAnnotation(); - } - - @Override - protected void removeTableAnnotation() { - // we don't remove a join table annotation when it is empty - } - - - // ********** inverse join columns ********** - - public ListIterable<JavaJoinColumn> getInverseJoinColumns() { - return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumns() : this.getDefaultInverseJoinColumns(); - } - - public int getInverseJoinColumnsSize() { - return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumnsSize() : this.defaultInverseJoinColumnsSize(); - } - - public void convertDefaultInverseJoinColumnToSpecified() { - MappingTools.convertJoinTableDefaultToSpecifiedInverseJoinColumn(this); - } - - - // ********** specified inverse join columns ********** - - public ListIterable<JavaJoinColumn> getSpecifiedInverseJoinColumns() { - return this.specifiedInverseJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedInverseJoinColumnsSize() { - return this.specifiedInverseJoinColumnContainer.getContextElementsSize(); - } - - public boolean hasSpecifiedInverseJoinColumns() { - return this.getSpecifiedInverseJoinColumnsSize() != 0; - } - - public JavaJoinColumn getSpecifiedInverseJoinColumn(int index) { - return this.specifiedInverseJoinColumnContainer.getContextElement(index); - } - - public JavaJoinColumn addSpecifiedInverseJoinColumn() { - return this.addSpecifiedInverseJoinColumn(this.getSpecifiedInverseJoinColumnsSize()); - } - - public JavaJoinColumn addSpecifiedInverseJoinColumn(int index) { - JoinColumnAnnotation annotation = this.getTableAnnotation().addInverseJoinColumn(index); - return this.specifiedInverseJoinColumnContainer.addContextElement(index, annotation); - } - - public void removeSpecifiedInverseJoinColumn(JoinColumn joinColumn) { - this.removeSpecifiedInverseJoinColumn(this.specifiedInverseJoinColumnContainer.indexOfContextElement((JavaJoinColumn) joinColumn)); - } - - public void removeSpecifiedInverseJoinColumn(int index) { - this.getTableAnnotation().removeInverseJoinColumn(index); - this.removeTableAnnotationIfUnset(); - this.specifiedInverseJoinColumnContainer.removeContextElement(index); - } - - public void moveSpecifiedInverseJoinColumn(int targetIndex, int sourceIndex) { - this.getTableAnnotation().moveInverseJoinColumn(targetIndex, sourceIndex); - this.specifiedInverseJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - } - - public void clearSpecifiedInverseJoinColumns() { - // for now, we have to remove annotations one at a time... - for (int i = this.getSpecifiedInverseJoinColumnsSize(); i-- > 0; ) { - this.removeSpecifiedInverseJoinColumn(i); - } - } - - protected void syncSpecifiedInverseJoinColumns() { - this.specifiedInverseJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<JoinColumnAnnotation> getInverseJoinColumnAnnotations() { - return this.getTableAnnotation().getInverseJoinColumns(); - } - - /** - * inverse join column container - */ - protected class SpecifiedInverseJoinColumnContainer - extends ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_INVERSE_JOIN_COLUMNS_LIST; - } - @Override - protected JavaJoinColumn buildContextElement(JoinColumnAnnotation resourceElement) { - return GenericJavaJoinTable.this.buildInverseJoinColumn(resourceElement); - } - @Override - protected ListIterable<JoinColumnAnnotation> getResourceElements() { - return GenericJavaJoinTable.this.getInverseJoinColumnAnnotations(); - } - @Override - protected JoinColumnAnnotation getResourceElement(JavaJoinColumn contextElement) { - return (JoinColumnAnnotation) contextElement.getColumnAnnotation(); - } - } - - protected JavaReadOnlyJoinColumn.Owner buildInverseJoinColumnOwner() { - return new InverseJoinColumnOwner(); - } - - protected ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> buildSpecifiedInverseJoinColumnContainer() { - SpecifiedInverseJoinColumnContainer container = new SpecifiedInverseJoinColumnContainer(); - container.initialize(); - return container; - } - - // ********** default inverse join column ********** - - public JavaJoinColumn getDefaultInverseJoinColumn() { - return this.defaultInverseJoinColumn; - } - - protected void setDefaultInverseJoinColumn(JavaJoinColumn joinColumn) { - JavaJoinColumn old = this.defaultInverseJoinColumn; - this.defaultInverseJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_INVERSE_JOIN_COLUMN, old, joinColumn); - } - - protected ListIterable<JavaJoinColumn> getDefaultInverseJoinColumns() { - return (this.defaultInverseJoinColumn != null) ? - new SingleElementListIterable<JavaJoinColumn>(this.defaultInverseJoinColumn) : - EmptyListIterable.<JavaJoinColumn>instance(); - } - - protected int defaultInverseJoinColumnsSize() { - return (this.defaultInverseJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultInverseJoinColumn() { - if (this.buildsDefaultInverseJoinColumn()) { - if (this.defaultInverseJoinColumn == null) { - this.setDefaultInverseJoinColumn(this.buildInverseJoinColumn(new NullJoinColumnAnnotation(this.getTableAnnotation()))); - } else { - this.defaultInverseJoinColumn.update(); - } - } else { - this.setDefaultInverseJoinColumn(null); - } - } - - protected boolean buildsDefaultInverseJoinColumn() { - return ! this.hasSpecifiedInverseJoinColumns(); - } - - - // ********** misc ********** - - @Override - public JavaJoinTableRelationshipStrategy getParent() { - return (JavaJoinTableRelationshipStrategy) super.getParent(); - } - - protected JavaJoinTableRelationshipStrategy getRelationshipStrategy() { - return this.getParent(); - } - - @Override - protected String buildDefaultName() { - return this.getRelationshipStrategy().getJoinTableDefaultName(); - } - - public void initializeFrom(ReadOnlyJoinTable oldTable) { - super.initializeFrom(oldTable); - for (ReadOnlyJoinColumn joinColumn : oldTable.getSpecifiedInverseJoinColumns()) { - this.addSpecifiedInverseJoinColumn().initializeFrom(joinColumn); - } - } - - public void initializeFromVirtual(ReadOnlyJoinTable virtualTable) { - super.initializeFromVirtual(virtualTable); - for (ReadOnlyJoinColumn joinColumn : virtualTable.getInverseJoinColumns()) { - this.addSpecifiedInverseJoinColumn().initializeFromVirtual(joinColumn); - } - } - - protected JavaJoinColumn buildInverseJoinColumn(JoinColumnAnnotation joinColumnAnnotation) { - return this.buildJoinColumn(this.inverseJoinColumnOwner, joinColumnAnnotation); - } - - public RelationshipMapping getRelationshipMapping() { - return this.getRelationshipStrategy().getRelationship().getMapping(); - } - - public PersistentAttribute getPersistentAttribute() { - return this.getRelationshipMapping().getPersistentAttribute(); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - for (JavaJoinColumn column : this.getInverseJoinColumns()) { - result = column.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - - // ********** validation ********** - - @Override - protected void validateJoinColumns(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validateJoinColumns(messages, reporter, astRoot); - this.validateNodes(this.getInverseJoinColumns(), messages, reporter, astRoot); - } - - public boolean validatesAgainstDatabase() { - return this.getRelationshipStrategy().validatesAgainstDatabase(); - } - - - // ********** join column owners ********** - - /** - * just a little common behavior - */ - protected abstract class AbstractJoinColumnOwner - implements JavaReadOnlyJoinColumn.Owner - { - protected AbstractJoinColumnOwner() { - super(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return MappingTools.buildJoinColumnDefaultName((ReadOnlyJoinColumn) column, this); - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. The table is always the join table. - */ - public boolean tableNameIsInvalid(String tableName) { - return Tools.valuesAreDifferent(this.getDefaultTableName(), tableName); - } - - /** - * the join column can only be on the join table itself - */ - public Iterable<String> getCandidateTableNames() { - return EmptyIterable.instance(); - } - - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - return Tools.valuesAreEqual(GenericJavaJoinTable.this.getName(), tableName) ? - GenericJavaJoinTable.this.getDbTable() : - null; - } - - /** - * by default, the join column is, obviously, in the join table; - * not sure whether it can be anywhere else... - */ - public String getDefaultTableName() { - return GenericJavaJoinTable.this.getName(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return GenericJavaJoinTable.this.getValidationTextRange(astRoot); - } - - protected JavaRelationship getRelationship() { - return this.getRelationshipStrategy().getRelationship(); - } - - protected JavaJoinTableRelationshipStrategy getRelationshipStrategy() { - return GenericJavaJoinTable.this.getRelationshipStrategy(); - } - } - - - /** - * owner for "back-pointer" join columns; - * these point at the source/owning entity - */ - protected class JoinColumnOwner - extends AbstractJoinColumnOwner - { - protected JoinColumnOwner() { - super(); - } - - public Entity getRelationshipTarget() { - return this.getRelationship().getEntity(); - } - - public String getAttributeName() { - return MappingTools.getTargetAttributeName(GenericJavaJoinTable.this.getRelationshipMapping()); - } - - public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() { - return this.getTypeMapping().getPrimaryDbTable(); - } - - protected TypeMapping getTypeMapping() { - return this.getRelationship().getTypeMapping(); - } - - public int getJoinColumnsSize() { - return GenericJavaJoinTable.this.getJoinColumnsSize(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return this.getRelationshipStrategy().buildJoinTableJoinColumnValidator((ReadOnlyJoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver); - } - } - - - /** - * owner for "forward-pointer" join columns; - * these point at the target/inverse entity - */ - protected class InverseJoinColumnOwner - extends AbstractJoinColumnOwner - { - protected InverseJoinColumnOwner() { - super(); - } - - public Entity getRelationshipTarget() { - RelationshipMapping relationshipMapping = GenericJavaJoinTable.this.getRelationshipMapping(); - return (relationshipMapping == null) ? null : relationshipMapping.getResolvedTargetEntity(); - } - - public String getAttributeName() { - RelationshipMapping relationshipMapping = GenericJavaJoinTable.this.getRelationshipMapping(); - return (relationshipMapping == null) ? null : relationshipMapping.getName(); - } - - public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() { - Entity relationshipTarget = this.getRelationshipTarget(); - return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable(); - } - - public int getJoinColumnsSize() { - return GenericJavaJoinTable.this.getInverseJoinColumnsSize(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return this.getRelationshipStrategy().buildJoinTableInverseJoinColumnValidator((ReadOnlyJoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java deleted file mode 100644 index c5c1ff4e57..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.LobConverter; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaConverter; -import org.eclipse.jpt.jpa.core.context.java.JavaLobConverter; -import org.eclipse.jpt.jpa.core.resource.java.LobAnnotation; - -public class GenericJavaLobConverter - extends AbstractJavaConverter - implements JavaLobConverter -{ - protected final LobAnnotation lobAnnotation; - - public GenericJavaLobConverter(JavaAttributeMapping parent, LobAnnotation lobAnnotation, JavaConverter.Owner owner) { - super(parent, owner); - this.lobAnnotation = lobAnnotation; - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return LobConverter.class; - } - - public LobAnnotation getConverterAnnotation() { - return this.lobAnnotation; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToManyMapping.java deleted file mode 100644 index 935834c6d3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToManyMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManyToManyMapping; - -public class GenericJavaManyToManyMapping - extends AbstractJavaManyToManyMapping -{ - public GenericJavaManyToManyMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToOneMapping.java deleted file mode 100644 index 4cdc288501..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaManyToOneMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManyToOneMapping; - -public class GenericJavaManyToOneMapping - extends AbstractJavaManyToOneMapping -{ - public GenericJavaManyToOneMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappedSuperclass.java deleted file mode 100644 index 36d734b5b4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappedSuperclass.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaMappedSuperclass; -import org.eclipse.jpt.jpa.core.resource.java.MappedSuperclassAnnotation; - -/** - * Java mapped superclass - */ -public class GenericJavaMappedSuperclass - extends AbstractJavaMappedSuperclass -{ - public GenericJavaMappedSuperclass(JavaPersistentType parent, MappedSuperclassAnnotation mappingAnnotation) { - super(parent, mappingAnnotation); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappingJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappingJoinTableRelationshipStrategy.java deleted file mode 100644 index d088cf32c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaMappingJoinTableRelationshipStrategy.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.JoinTable; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.java.JavaMappingJoinTableRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.InverseJoinColumnValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinColumnValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableValidator; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaMappingJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation; - -public class GenericJavaMappingJoinTableRelationshipStrategy - extends AbstractJavaJoinTableRelationshipStrategy - implements JavaMappingJoinTableRelationshipStrategy2_0 -{ - public GenericJavaMappingJoinTableRelationshipStrategy(JavaMappingJoinTableRelationship parent) { - super(parent); - } - - - // ********** join table annotation ********** - - public JoinTableAnnotation getJoinTableAnnotation() { - return (JoinTableAnnotation) this.getResourceAttribute().getNonNullAnnotation(JoinTableAnnotation.ANNOTATION_NAME); - } - - @Override - protected JoinTableAnnotation addJoinTableAnnotation() { - return (JoinTableAnnotation) this.getResourceAttribute().addAnnotation(JoinTableAnnotation.ANNOTATION_NAME); - } - - @Override - protected void removeJoinTableAnnotation() { - this.getResourceAttribute().removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME); - } - - - // ********** misc ********** - - protected JavaResourceAttribute getResourceAttribute() { - return this.getRelationship().getMapping().getResourceAttribute(); - } - - @Override - public JavaMappingJoinTableRelationship getParent() { - return (JavaMappingJoinTableRelationship) super.getParent(); - } - - @Override - public JavaMappingJoinTableRelationship getRelationship() { - return this.getParent(); - } - - public boolean isOverridable() { - return this.getJpaPlatformVariation().isJoinTableOverridable(); - } - - public ReadOnlyRelationshipStrategy selectOverrideStrategy(ReadOnlyOverrideRelationship2_0 overrideRelationship) { - return overrideRelationship.getJoinTableStrategy(); - } - - - // ********** validation ********** - - public boolean validatesAgainstDatabase() { - return this.getRelationshipMapping().validatesAgainstDatabase(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getRelationship().getValidationTextRange(astRoot); - } - - protected PersistentAttribute getPersistentAttribute() { - return this.getRelationshipMapping().getPersistentAttribute(); - } - - public JptValidator buildTableValidator(ReadOnlyTable table, TableTextRangeResolver textRangeResolver) { - return new JoinTableValidator(this.getPersistentAttribute(), (JoinTable) table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new JoinColumnValidator(this.getPersistentAttribute(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new InverseJoinColumnValidator(this.getPersistentAttribute(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java deleted file mode 100644 index f059eb1a64..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; -import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> named native query - */ -public class GenericJavaNamedNativeQuery - extends AbstractJavaQuery<NamedNativeQueryAnnotation> - implements JavaNamedNativeQuery -{ - protected String resultClass; - protected String fullyQualifiedResultClass; - - protected String resultSetMapping; - - - public GenericJavaNamedNativeQuery(JavaQueryContainer parent, NamedNativeQueryAnnotation queryAnnotation) { - super(parent, queryAnnotation); - this.resultClass = queryAnnotation.getResultClass(); - this.resultSetMapping = queryAnnotation.getResultSetMapping(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setResultClass_(this.queryAnnotation.getResultClass()); - this.setResultSetMapping_(this.queryAnnotation.getResultSetMapping()); - } - - @Override - public void update() { - super.update(); - this.setFullyQualifiedResultClass(this.buildFullyQualifiedResultClass()); - } - - // ********** result class ********** - - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - this.queryAnnotation.setResultClass(resultClass); - this.setResultClass_(resultClass); - } - - protected void setResultClass_(String resultClass) { - String old = this.resultClass; - this.resultClass = resultClass; - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); - } - - public String getFullyQualifiedResultClass() { - return this.fullyQualifiedResultClass; - } - - protected void setFullyQualifiedResultClass(String resultClass) { - String old = this.fullyQualifiedResultClass; - this.fullyQualifiedResultClass = resultClass; - this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_PROPERTY, old, resultClass); - } - - protected String buildFullyQualifiedResultClass() { - return this.queryAnnotation.getFullyQualifiedResultClassName(); - } - - public char getResultClassEnclosingTypeSeparator() { - return '.'; - } - - - // ********** result set mapping ********** - - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - this.queryAnnotation.setResultSetMapping(resultSetMapping); - this.setResultSetMapping_(resultSetMapping); - } - - protected void setResultSetMapping_(String resultSetMapping) { - String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); - } - - // ********** metadata conversion ********* - - public void convertTo(OrmQueryContainer queryContainer) { - queryContainer.addNamedNativeQuery().convertFrom(this); - } - - public void delete() { - this.getParent().removeNamedNativeQuery(this); - } - - // ********** validation ********** - - @Override - protected void validateQuery_(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) { - // nothing yet - } - - @Override - public boolean isEquivalentTo(JpaNamedContextNode node) { - return super.isEquivalentTo(node) - && this.isEquivalentTo((NamedNativeQuery) node); - } - - protected boolean isEquivalentTo(NamedNativeQuery nativeQuery) { - return Tools.valuesAreEqual(this.resultClass, nativeQuery.getResultClass()) && - Tools.valuesAreEqual(this.resultSetMapping, nativeQuery.getResultSetMapping()); - } - - // ********** misc ********** - - public Class<NamedNativeQuery> getType() { - return NamedNativeQuery.class; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java deleted file mode 100644 index e9cf3c4ab6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; -import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java named query - */ -public class GenericJavaNamedQuery - extends AbstractJavaQuery<NamedQueryAnnotation> - implements JavaNamedQuery -{ - public GenericJavaNamedQuery(JavaQueryContainer parent, NamedQueryAnnotation queryAnnotation) { - super(parent, queryAnnotation); - } - - // ********** metadata conversion ********* - - public void convertTo(OrmQueryContainer queryContainer) { - queryContainer.addNamedQuery().convertFrom(this); - } - - public void delete() { - this.getParent().removeNamedQuery(this); - } - - // ********** validation ********** - - @Override - protected void validateQuery_(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) { - queryHelper.validate(this, this.query, this.queryAnnotation.getQueryTextRange(), 1, messages); - } - - // ********** misc ********** - - public Class<NamedQuery> getType() { - return NamedQuery.class; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java deleted file mode 100644 index b90206e45a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.core.resource.java.Annotation; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaAttributeMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; - -/** - * null mapping used when an attribute's default mapping cannot be determined - */ -public class GenericJavaNullAttributeMapping - extends AbstractJavaAttributeMapping<Annotation> -{ - public GenericJavaNullAttributeMapping(JavaPersistentAttribute parent) { - super(parent); - } - - public String getKey() { - return MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY; - } - - @Override - protected String getAnnotationName() { - return null; - } - - @Override - protected Annotation getAnnotation_() { - return null; - } - - - // ********** metamodel ********** - - @Override - public MetamodelField getMetamodelField() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToManyMapping.java deleted file mode 100644 index bf84573cf3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToManyMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOneToManyMapping; - -public class GenericJavaOneToManyMapping - extends AbstractJavaOneToManyMapping -{ - public GenericJavaOneToManyMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToOneMapping.java deleted file mode 100644 index c2f6397a6c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOneToOneMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaOneToOneMapping; - -public class GenericJavaOneToOneMapping - extends AbstractJavaOneToOneMapping -{ - public GenericJavaOneToOneMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java deleted file mode 100644 index 18d7560a64..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOrderable.java +++ /dev/null @@ -1,480 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.OrderColumnValidator; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaOrderColumn2_0; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrderColumn2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrderable2_0; -import org.eclipse.jpt.jpa.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java ordering - * <p> - * <strong>NB:</strong> Setting any flag to <code>false</code> (or setting the - * specified "order by" to <code>null</code>) can be a bit unpredictable. The - * intent is to set a flag to <code>true</code> (or set the specified "order by" - * to a non-<code>null</code> value). - * <p> - * <strong>(JPA 2.0 only) NB:</strong> If both the "order by" and the "order - * column" annotations are present (which is prohibited by the JPA spec), - * both are ignored. - */ -public class GenericJavaOrderable - extends AbstractJavaJpaContextNode - implements JavaOrderable2_0 -{ - protected String specifiedOrderBy; - protected boolean noOrdering = false; - protected boolean pkOrdering = false; - protected boolean customOrdering = false; - - // JPA 2.0 - protected final Owner owner; // this is null for JPA 1.0 mappings - protected boolean orderColumnOrdering = false; - protected final JavaOrderColumn2_0 orderColumn; - - - /** - * JPA 1.0 - */ - public GenericJavaOrderable(JavaAttributeMapping parent) { - this(parent, null); - } - - /** - * JPA 2.0 - */ - public GenericJavaOrderable(JavaAttributeMapping parent, Owner owner) { - super(parent); - this.specifiedOrderBy = this.buildSpecifiedOrderBy(); - this.noOrdering = this.buildNoOrdering(); - this.pkOrdering = this.buildPkOrdering(); - this.customOrdering = this.buildCustomOrdering(); - - this.owner = owner; - this.orderColumnOrdering = this.buildOrderColumnOrdering(); - this.orderColumn = this.buildOrderColumn(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - - this.setSpecifiedOrderBy_(this.buildSpecifiedOrderBy()); - this.setNoOrdering_(this.buildNoOrdering()); - this.setPkOrdering_(this.buildPkOrdering()); - this.setCustomOrdering_(this.buildCustomOrdering()); - - this.setOrderColumnOrdering_(this.buildOrderColumnOrdering()); - this.orderColumn.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.orderColumn.update(); - } - - - // ********** specified order by ********** - - public String getSpecifiedOrderBy() { - return this.specifiedOrderBy; - } - - public void setSpecifiedOrderBy(String orderBy) { - if (orderBy != null) { - this.removeOrderColumnAnnotation(); - this.getOrderByAnnotationForUpdate().setValue(orderBy); - - this.setSpecifiedOrderBy_(orderBy); - this.setNoOrdering_(false); - this.setPkOrdering_(false); - this.setCustomOrdering_(true); - this.setOrderColumnOrdering_(false); - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setSpecifiedOrderBy_(String orderBy) { - String old = this.specifiedOrderBy; - this.specifiedOrderBy = orderBy; - this.firePropertyChanged(SPECIFIED_ORDER_BY_PROPERTY, old, orderBy); - } - - protected String buildSpecifiedOrderBy() { - if (this.orderColumnAnnotationIsPresent()) { - return null; - } - OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation(); - return (orderByAnnotation == null) ? null : orderByAnnotation.getValue(); - } - - - // ********** no ordering ********** - - public boolean isNoOrdering() { - return this.noOrdering; - } - - public void setNoOrdering(boolean noOrdering) { - if (noOrdering) { - this.removeOrderColumnAnnotation(); - if (this.getOrderByAnnotation() != null) { - this.removeOrderByAnnotation(); - } - - this.setSpecifiedOrderBy_(null); - this.setNoOrdering_(true); - this.setPkOrdering_(false); - this.setCustomOrdering_(false); - this.setOrderColumnOrdering_(false); - } else { - this.setPkOrdering(true); // hmmm... - } - } - - protected void setNoOrdering_(boolean noOrdering) { - boolean old = this.noOrdering; - this.noOrdering = noOrdering; - this.firePropertyChanged(NO_ORDERING_PROPERTY, old, noOrdering); - } - - protected boolean buildNoOrdering() { - return this.isJpa2_0Compatible() ? this.buildNoOrdering2_0() : this.buildNoOrdering1_0(); - } - - /** - * both annotations are missing <em>or</em> both are present - */ - protected boolean buildNoOrdering2_0() { - boolean orderByMissing = (this.getOrderByAnnotation() == null); - boolean orderByPresent = ! orderByMissing; - boolean orderColumnMissing = (this.getOrderColumnAnnotation() == null); - boolean orderColumnPresent = ! orderColumnMissing; - return (orderByMissing && orderColumnMissing) || (orderByPresent && orderColumnPresent); - } - - /** - * the order-by annotation is missing - */ - protected boolean buildNoOrdering1_0() { - return this.getOrderByAnnotation() == null; - } - - - // ********** pk ordering ********** - - public boolean isPkOrdering() { - return this.pkOrdering; - } - - public void setPkOrdering(boolean pkOrdering) { - if (pkOrdering) { - this.removeOrderColumnAnnotation(); - OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation(); - if (orderByAnnotation == null) { - this.addOrderByAnnotation(); - } else { - orderByAnnotation.setValue(null); - } - - this.setSpecifiedOrderBy_(null); - this.setNoOrdering_(false); - this.setPkOrdering_(true); - this.setCustomOrdering_(false); - this.setOrderColumnOrdering_(false); - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setPkOrdering_(boolean pkOrdering) { - boolean old = this.pkOrdering; - this.pkOrdering = pkOrdering; - this.firePropertyChanged(PK_ORDERING_PROPERTY, old, pkOrdering); - } - - /** - * the order-by annotation is present but no value specified - */ - protected boolean buildPkOrdering() { - if (this.orderColumnAnnotationIsPresent()) { - return false; - } - OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation(); - return (orderByAnnotation != null) && (orderByAnnotation.getValue() == null); - } - - - // ********** custom ordering ********** - - public boolean isCustomOrdering() { - return this.customOrdering; - } - - public void setCustomOrdering(boolean customOrdering) { - if (customOrdering) { - this.setSpecifiedOrderBy(""); //$NON-NLS-1$ - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setCustomOrdering_(boolean customOrdering) { - boolean old = this.customOrdering; - this.customOrdering = customOrdering; - this.firePropertyChanged(CUSTOM_ORDERING_PROPERTY, old, customOrdering); - } - - /** - * the order-by annotation is present and it has a specified value - */ - protected boolean buildCustomOrdering() { - if (this.orderColumnAnnotationIsPresent()) { - return false; - } - OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation(); - return (orderByAnnotation != null) && (orderByAnnotation.getValue() != null); - } - - - // ********** order column ordering ********** - - public boolean isOrderColumnOrdering() { - return this.orderColumnOrdering; - } - - public void setOrderColumnOrdering(boolean orderColumnOrdering) { - if (orderColumnOrdering) { - this.removeOrderByAnnotation(); - if (this.getOrderColumnAnnotation() == null) { - this.addOrderColumnAnnotation(); - } - - this.setSpecifiedOrderBy_(null); - this.setNoOrdering_(false); - this.setPkOrdering_(false); - this.setCustomOrdering_(false); - this.setOrderColumnOrdering_(true); - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setOrderColumnOrdering_(boolean orderColumnOrdering) { - boolean old = this.orderColumnOrdering; - this.orderColumnOrdering = orderColumnOrdering; - this.firePropertyChanged(ORDER_COLUMN_ORDERING_PROPERTY, old, orderColumnOrdering); - } - - /** - * JPA 2.0 only; - * the order column annotation is present <em>and</em> - * the order-by annotation is missing - */ - protected boolean buildOrderColumnOrdering() { - return this.orderColumnAnnotationIsPresent() && - (this.getOrderByAnnotation() == null); - } - - - // ********** order column ********** - - public JavaOrderColumn2_0 getOrderColumn() { - return this.orderColumn; - } - - protected JavaOrderColumn2_0 buildOrderColumn() { - JavaReadOnlyNamedColumn.Owner columnOwner = new OrderColumnOwner(); - return this.isJpa2_0Compatible() ? - this.getJpaFactory2_0().buildJavaOrderColumn(this, columnOwner) : - new GenericJavaOrderColumn2_0(this, columnOwner); - } - - - // ********** order by annotation ********** - - protected OrderByAnnotation getOrderByAnnotation() { - return (OrderByAnnotation) this.getResourceAttribute().getAnnotation(OrderByAnnotation.ANNOTATION_NAME); - } - - protected OrderByAnnotation getOrderByAnnotationForUpdate() { - OrderByAnnotation annotation = this.getOrderByAnnotation(); - return (annotation != null) ? annotation : this.addOrderByAnnotation(); - } - - protected OrderByAnnotation addOrderByAnnotation() { - return (OrderByAnnotation) this.getResourceAttribute().addAnnotation(OrderByAnnotation.ANNOTATION_NAME); - } - - protected void removeOrderByAnnotation() { - this.getResourceAttribute().removeAnnotation(OrderByAnnotation.ANNOTATION_NAME); - } - - - // ********** order column annotation ********** - - protected OrderColumn2_0Annotation getOrderColumnAnnotation() { - return (OrderColumn2_0Annotation) this.getResourceAttribute().getAnnotation(OrderColumn2_0Annotation.ANNOTATION_NAME); - } - - /** - * NB: Only return <code>true</code> for JPA 2.0 mappings. - */ - protected boolean orderColumnAnnotationIsPresent() { - return this.isJpa2_0Compatible() && (this.getOrderColumnAnnotation() != null); - } - - protected OrderColumn2_0Annotation addOrderColumnAnnotation() { - return (OrderColumn2_0Annotation) this.getResourceAttribute().addAnnotation(OrderColumn2_0Annotation.ANNOTATION_NAME); - } - - protected void removeOrderColumnAnnotation() { - if (this.orderColumnAnnotationIsPresent()) { - this.removeOrderColumnAnnotation_(); - } - } - - protected void removeOrderColumnAnnotation_() { - this.getResourceAttribute().removeAnnotation(OrderColumn2_0Annotation.ANNOTATION_NAME); - } - - - // ********** misc ********** - - @Override - public JavaAttributeMapping getParent() { - return (JavaAttributeMapping) super.getParent(); - } - - protected JavaAttributeMapping getAttributeMapping() { - return this.getParent(); - } - - protected JavaPersistentAttribute getPersistentAttribute() { - return this.getAttributeMapping().getPersistentAttribute(); - } - - public JavaResourceAttribute getResourceAttribute() { - return this.getPersistentAttribute().getResourceAttribute(); - } - - // JPA 2.0 only - public String getDefaultTableName() { - return this.owner.getTableName(); - } - - // JPA 2.0 only - protected Table resolveDbTable(String tableName) { - return this.owner.resolveDbTable(tableName); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - - return this.orderColumn.getJavaCompletionProposals(pos, filter, astRoot); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getOrderByAnnotationTextRange(astRoot); - return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(astRoot); - } - - protected TextRange getOrderByAnnotationTextRange(CompilationUnit astRoot) { - OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation(); - return (orderByAnnotation == null) ? null : orderByAnnotation.getTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - if (this.orderColumnAnnotationIsPresent() && (this.getOrderByAnnotation() != null)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, - new String[] {this.getPersistentAttribute().getName()}, - this.getAttributeMapping(), - this.getOrderByAnnotationTextRange(astRoot) - ) - ); - } - if (this.orderColumnOrdering) { - //TODO validation message if type is not List - this.orderColumn.validate(messages, reporter, astRoot); - } - } - - - // ********** order column owner (JPA 2.0) ********** - - protected class OrderColumnOwner - implements JavaReadOnlyNamedColumn.Owner - { - public String getDefaultTableName() { - return GenericJavaOrderable.this.getDefaultTableName(); - } - - public Table resolveDbTable(String tableName) { - return GenericJavaOrderable.this.resolveDbTable(tableName); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return this.getPersistentAttribute().getName() + "_ORDER"; //$NON-NLS-1$ - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return GenericJavaOrderable.this.getValidationTextRange(astRoot); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new OrderColumnValidator(this.getPersistentAttribute(), (OrderColumn2_0) column, textRangeResolver); - } - - protected JavaPersistentAttribute getPersistentAttribute() { - return GenericJavaOrderable.this.getPersistentAttribute(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java deleted file mode 100644 index 47085a1fde..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaOverrideRelationship.java +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.MappedByRelationship; -import org.eclipse.jpt.jpa.core.context.OverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.Relationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.context.java.GenericJavaOverrideJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaOverrideJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappingRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaOverrideRelationship - extends AbstractJavaJpaContextNode - implements JavaOverrideRelationship2_0 -{ - protected JavaRelationshipStrategy strategy; - - protected final JavaJoinColumnRelationshipStrategy joinColumnStrategy; - - // JPA 2.0 - protected final JavaJoinTableRelationshipStrategy joinTableStrategy; - - - public GenericJavaOverrideRelationship(JavaAssociationOverride parent) { - super(parent); - this.joinColumnStrategy = this.buildJoinColumnStrategy(); - this.joinTableStrategy = this.buildJoinTableStrategy(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.joinColumnStrategy.synchronizeWithResourceModel(); - this.joinTableStrategy.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.setStrategy(this.buildStrategy()); - this.joinColumnStrategy.update(); - this.joinTableStrategy.update(); - } - - - // ********** strategy ********** - - public JavaRelationshipStrategy getStrategy() { - return this.strategy; - } - - protected void setStrategy(JavaRelationshipStrategy strategy) { - JavaRelationshipStrategy old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - protected JavaRelationshipStrategy buildStrategy() { - return this.isJpa2_0Compatible() ? - this.buildStrategy2_0() : - this.joinColumnStrategy; - } - - /** - * The overridden mapping determines the override's strategy. - */ - protected JavaRelationshipStrategy buildStrategy2_0() { - MappingRelationshipStrategy2_0 mappingStrategy = this.getMappingStrategy(); - return (mappingStrategy != null) ? - (JavaRelationshipStrategy) mappingStrategy.selectOverrideStrategy(this) : - this.buildMissingMappingStrategy(); - } - - /** - * Get the strategy from the overridden mapping. - */ - protected MappingRelationshipStrategy2_0 getMappingStrategy() { - RelationshipMapping mapping = this.getMapping(); - return (mapping == null) ? null : (MappingRelationshipStrategy2_0) mapping.getRelationship().getStrategy(); - } - - /** - * Return the strategy to use when the override's name does not match the - * name of an appropriate relationship mapping. - */ - protected JavaRelationshipStrategy buildMissingMappingStrategy() { - return this.joinColumnStrategy.hasSpecifiedJoinColumns() ? - this.joinColumnStrategy : - this.joinTableStrategy; - } - - - // ********** join column strategy ********** - - public JavaJoinColumnRelationshipStrategy getJoinColumnStrategy() { - return this.joinColumnStrategy; - } - - public boolean strategyIsJoinColumn() { - return this.strategy == this.joinColumnStrategy; - } - - public void setStrategyToJoinColumn() { - throw new UnsupportedOperationException(); - } - - public boolean mayHaveDefaultJoinColumn() { - // association overrides do not have defaults - return false; - } - - protected JavaJoinColumnRelationshipStrategy buildJoinColumnStrategy() { - return new GenericJavaOverrideJoinColumnRelationshipStrategy(this); - } - - - // ********** join table strategy ********** - - public JavaJoinTableRelationshipStrategy getJoinTableStrategy() { - return this.joinTableStrategy; - } - - public boolean strategyIsJoinTable() { - return this.strategy == this.joinTableStrategy; - } - - public void setStrategyToJoinTable() { - throw new UnsupportedOperationException(); - } - - public boolean mayHaveDefaultJoinTable() { - // association overrides do not have defaults - return false; - } - - protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() { - return this.isJpa2_0Compatible() ? - new GenericJavaOverrideJoinTableRelationshipStrategy2_0(this) : - new NullJavaJoinTableRelationshipStrategy(this); - } - - - // ********** conversions ********** - - public void initializeFrom(ReadOnlyRelationship oldRelationship) { - oldRelationship.initializeOn(this); - } - - public void initializeOn(Relationship newRelationship) { - newRelationship.initializeFromJoinTableRelationship(this); - newRelationship.initializeFromJoinColumnRelationship(this); - } - - public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) { - // NOP - } - - public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) { - this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy()); - } - - public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) { - this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy()); - } - - public void initializeFromVirtual(ReadOnlyOverrideRelationship virtualRelationship) { - virtualRelationship.initializeOnSpecified(this); - } - - public void initializeOnSpecified(OverrideRelationship specifiedRelationship) { - throw new UnsupportedOperationException(); - } - - public void initializeFromVirtualJoinTableRelationship(ReadOnlyJoinTableRelationship virtualRelationship) { - this.joinTableStrategy.initializeFromVirtual(virtualRelationship.getJoinTableStrategy()); - } - - public void initializeFromVirtualJoinColumnRelationship(ReadOnlyJoinColumnRelationship virtualRelationship) { - this.joinColumnStrategy.initializeFromVirtual(virtualRelationship.getJoinColumnStrategy()); - } - - - // ********** misc ********** - - @Override - public JavaAssociationOverride getParent() { - return (JavaAssociationOverride) super.getParent(); - } - - protected JavaAssociationOverride getAssociationOverride() { - return this.getParent(); - } - - protected JavaAssociationOverride2_0 getAssociationOverride2_0() { - return (JavaAssociationOverride2_0) this.getAssociationOverride(); - } - - public TypeMapping getTypeMapping() { - return this.getAssociationOverride().getTypeMapping(); - } - - public String getAttributeName() { - return this.getAssociationOverride().getName(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getAssociationOverride().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getAssociationOverride().getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return this.getAssociationOverride().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getAssociationOverride().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride().buildColumnValidator(column, owner, textRangeResolver); - } - - public AssociationOverrideAnnotation getOverrideAnnotation() { - return this.getAssociationOverride().getOverrideAnnotation(); - } - - public Entity getEntity() { - TypeMapping typeMapping = this.getTypeMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - public boolean isVirtual() { - return false; - } - - public RelationshipMapping getMapping() { - return this.getAssociationOverride().getMapping(); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - - return this.strategy.getJavaCompletionProposals(pos, filter, astRoot); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getAssociationOverride().getValidationTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.strategy.validate(messages, reporter, astRoot); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableValidator(table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java deleted file mode 100644 index a1c781c011..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.JavaResourceField; -import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.context.java.Accessor; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentAttribute; - -/** - * Generic Java persistent attribute - */ -public class GenericJavaPersistentAttribute - extends AbstractJavaPersistentAttribute -{ - - public GenericJavaPersistentAttribute(PersistentType parent, JavaResourceField resourceField) { - super(parent, resourceField); - } - - public GenericJavaPersistentAttribute(PersistentType parent, JavaResourceMethod resourceGetter, JavaResourceMethod resourceSetter) { - super(parent, resourceGetter, resourceSetter); - } - - public GenericJavaPersistentAttribute(PersistentType parent, Accessor accessor) { - super(parent, accessor); - } - - // ********** validation ********** - - @Override - protected JptValidator buildAttributeValidator(CompilationUnit astRoot) { - return getAccessor().buildAttributeValidator(this, this.buildTextRangeResolver(astRoot)); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentType.java deleted file mode 100644 index ccd859882e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentType.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.PersistentType; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType; - -/** - * JPA 1.0 Java persistent type. - * The specified access is always null. - */ -public class GenericJavaPersistentType - extends AbstractJavaPersistentType -{ - public GenericJavaPersistentType(PersistentType.Owner parent, JavaResourceType jrt) { - super(parent, jrt); - } - - - // ********** access ********** - - /** - * Return <code>null</code> - JPA 1.0 does not support a specified access. - */ - @Override - protected AccessType buildSpecifiedAccess() { - return null; - } - - /** - * JPA 1.0 does not support a specified access. - */ - @Override - public void setSpecifiedAccess(AccessType specifiedAccess) { - throw new UnsupportedOperationException("JPA 1.0 does not support a specified access type in java."); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java deleted file mode 100644 index c0cda4fe63..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.JavaPrimaryKeyJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Java primary key join column - */ -public class GenericJavaPrimaryKeyJoinColumn - extends AbstractJavaNamedColumn<PrimaryKeyJoinColumnAnnotation, JavaReadOnlyBaseJoinColumn.Owner> - implements JavaPrimaryKeyJoinColumn -{ - /** @see AbstractJavaNamedColumn#AbstractJavaNamedColumn(org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode, org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyNamedColumn.Owner, org.eclipse.jpt.jpa.core.resource.java.NamedColumnAnnotation) */ - protected /* final */ PrimaryKeyJoinColumnAnnotation columnAnnotation; // never null - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericJavaPrimaryKeyJoinColumn(JavaJpaContextNode parent, JavaReadOnlyBaseJoinColumn.Owner owner, PrimaryKeyJoinColumnAnnotation columnAnnotation) { - super(parent, owner, columnAnnotation); - this.specifiedReferencedColumnName = this.buildSpecifiedReferencedColumnName(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedReferencedColumnName_(this.buildSpecifiedReferencedColumnName()); - } - - @Override - public void update() { - super.update(); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** column annotation ********** - - @Override - public PrimaryKeyJoinColumnAnnotation getColumnAnnotation() { - return this.columnAnnotation; - } - - @Override - protected void setColumnAnnotation(PrimaryKeyJoinColumnAnnotation columnAnnotation) { - this.columnAnnotation = columnAnnotation; - } - - @Override - protected void removeColumnAnnotation() { - // we don't remove a pk join column annotation when it is empty - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - public void setSpecifiedReferencedColumnName(String name) { - if (this.valuesAreDifferent(this.specifiedReferencedColumnName, name)) { - this.columnAnnotation.setReferencedColumnName(name); - this.removeColumnAnnotationIfUnset(); - this.setSpecifiedReferencedColumnName_(name); - } - } - - protected void setSpecifiedReferencedColumnName_(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return this.columnAnnotation.getReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - // TODO not correct when we start supporting - // primary key join columns in 1-1 mappings - protected String buildDefaultReferencedColumnName() { - return this.buildDefaultName(); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** misc ********** - - @Override - public String getTable() { - return this.owner.getDefaultTableName(); - } - - - // ********** Java completion proposals ********** - - @Override - protected Iterable<String> getConnectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getConnectedJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.referencedColumnNameTouches(pos)) { - return this.getJavaCandidateReferencedColumnNames(filter); - } - return null; - } - - protected boolean referencedColumnNameTouches(int pos) { - return this.columnAnnotation.referencedColumnNameTouches(pos); - } - - protected Iterable<String> getJavaCandidateReferencedColumnNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateReferencedColumnNames(filter)); - } - - protected Iterable<String> getCandidateReferencedColumnNames(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateReferencedColumnNames(), filter); - } - - protected Iterable<String> getCandidateReferencedColumnNames() { - Table table = this.owner.getReferencedColumnDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } - - - // ********** validation ********** - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) { - return new JavaPrimaryKeyJoinColumnTextRangeResolver(this, astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getValidationTextRange(this.columnAnnotation.getReferencedColumnNameTextRange(), astRoot); - } - - - // ********** misc ********** - - @Override - public void toString(StringBuilder sb) { - super.toString(sb); - sb.append("=>"); //$NON-NLS-1$ - sb.append(this.getReferencedColumnName()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java deleted file mode 100644 index 3b77df2586..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java query container - */ -public class GenericJavaQueryContainer - extends AbstractJavaJpaContextNode - implements JavaQueryContainer -{ - protected final Owner owner; - - protected final ContextListContainer<JavaNamedQuery, NamedQueryAnnotation> namedQueryContainer; - protected final ContextListContainer<JavaNamedNativeQuery, NamedNativeQueryAnnotation> namedNativeQueryContainer; - - - public GenericJavaQueryContainer(JavaJpaContextNode parent, Owner owner) { - super(parent); - this.owner = owner; - this.namedQueryContainer = this.buildNamedQueryContainer(); - this.namedNativeQueryContainer = this.buildNamedNativeQueryContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncNamedQueries(); - this.syncNamedNativeQueries(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getNamedQueries()); - this.updateNodes(this.getNamedNativeQueries()); - } - - - // ********** queries ********** - - @SuppressWarnings("unchecked") - public Iterable<Query> getQueries() { - return new CompositeIterable<Query>(this.getNamedQueries(), this.getNamedNativeQueries()); - } - - - // ********** named queries ********** - - - public ListIterable<JavaNamedQuery> getNamedQueries() { - return this.namedQueryContainer.getContextElements(); - } - - public int getNamedQueriesSize() { - return this.namedQueryContainer.getContextElementsSize(); - } - - public JavaNamedQuery addNamedQuery() { - return this.addNamedQuery(this.getNamedQueriesSize()); - } - - public JavaNamedQuery addNamedQuery(int index) { - NamedQueryAnnotation annotation = this.addNamedQueryAnnotation(index); - return this.namedQueryContainer.addContextElement(index, annotation); - } - - protected NamedQueryAnnotation addNamedQueryAnnotation(int index) { - return (NamedQueryAnnotation) this.owner.getResourceAnnotatedElement().addAnnotation(index, NamedQueryAnnotation.ANNOTATION_NAME); - } - - public void removeNamedQuery(NamedQuery namedQuery) { - this.removeNamedQuery(this.namedQueryContainer.indexOfContextElement((JavaNamedQuery) namedQuery)); - } - - public void removeNamedQuery(int index) { - this.owner.getResourceAnnotatedElement().removeAnnotation(index, NamedQueryAnnotation.ANNOTATION_NAME); - this.namedQueryContainer.removeContextElement(index); - } - - public void moveNamedQuery(int targetIndex, int sourceIndex) { - this.owner.getResourceAnnotatedElement().moveAnnotation(targetIndex, sourceIndex, NamedQueryAnnotation.ANNOTATION_NAME); - this.namedQueryContainer.moveContextElement(targetIndex, sourceIndex); - } - - protected JavaNamedQuery buildNamedQuery(NamedQueryAnnotation namedQueryAnnotation) { - return this.getJpaFactory().buildJavaNamedQuery(this, namedQueryAnnotation); - } - - protected void syncNamedQueries() { - this.namedQueryContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<NamedQueryAnnotation> getNamedQueryAnnotations() { - return new SubListIterableWrapper<NestableAnnotation, NamedQueryAnnotation>(this.getNestableNamedQueryAnnotations_()); - } - - protected ListIterable<NestableAnnotation> getNestableNamedQueryAnnotations_() { - return this.owner.getResourceAnnotatedElement().getAnnotations(NamedQueryAnnotation.ANNOTATION_NAME); - } - - protected ContextListContainer<JavaNamedQuery, NamedQueryAnnotation> buildNamedQueryContainer() { - NamedQueryContainer container = new NamedQueryContainer(); - container.initialize(); - return container; - } - - /** - * named query container - */ - protected class NamedQueryContainer - extends ContextListContainer<JavaNamedQuery, NamedQueryAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return NAMED_QUERIES_LIST; - } - @Override - protected JavaNamedQuery buildContextElement(NamedQueryAnnotation resourceElement) { - return GenericJavaQueryContainer.this.buildNamedQuery(resourceElement); - } - @Override - protected ListIterable<NamedQueryAnnotation> getResourceElements() { - return GenericJavaQueryContainer.this.getNamedQueryAnnotations(); - } - @Override - protected NamedQueryAnnotation getResourceElement(JavaNamedQuery contextElement) { - return contextElement.getQueryAnnotation(); - } - } - - - // ********** named native queries ********** - - public ListIterable<JavaNamedNativeQuery> getNamedNativeQueries() { - return this.namedNativeQueryContainer.getContextElements(); - } - - public int getNamedNativeQueriesSize() { - return this.namedNativeQueryContainer.getContextElementsSize(); - } - - public JavaNamedNativeQuery addNamedNativeQuery() { - return this.addNamedNativeQuery(this.getNamedNativeQueriesSize()); - } - - public JavaNamedNativeQuery addNamedNativeQuery(int index) { - NamedNativeQueryAnnotation annotation = this.addNamedNativeQueryAnnotation(index); - return this.namedNativeQueryContainer.addContextElement(index, annotation); - } - - protected NamedNativeQueryAnnotation addNamedNativeQueryAnnotation(int index) { - return (NamedNativeQueryAnnotation) this.owner.getResourceAnnotatedElement().addAnnotation(index, NamedNativeQueryAnnotation.ANNOTATION_NAME); - } - - public void removeNamedNativeQuery(NamedNativeQuery namedNativeQuery) { - this.removeNamedNativeQuery(this.namedNativeQueryContainer.indexOfContextElement((JavaNamedNativeQuery) namedNativeQuery)); - } - - public void removeNamedNativeQuery(int index) { - this.owner.getResourceAnnotatedElement().removeAnnotation(index, NamedNativeQueryAnnotation.ANNOTATION_NAME); - this.namedNativeQueryContainer.removeContextElement(index); - } - - public void moveNamedNativeQuery(int targetIndex, int sourceIndex) { - this.owner.getResourceAnnotatedElement().moveAnnotation(targetIndex, sourceIndex, NamedNativeQueryAnnotation.ANNOTATION_NAME); - this.namedNativeQueryContainer.moveContextElement(targetIndex, sourceIndex); - } - - protected JavaNamedNativeQuery buildNamedNativeQuery(NamedNativeQueryAnnotation namedNativeQueryAnnotation) { - return this.getJpaFactory().buildJavaNamedNativeQuery(this, namedNativeQueryAnnotation); - } - - protected void syncNamedNativeQueries() { - this.namedNativeQueryContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<NamedNativeQueryAnnotation> getNamedNativeQueryAnnotations() { - return new SubListIterableWrapper<NestableAnnotation, NamedNativeQueryAnnotation>(this.getNestableNamedNativeQueryAnnotations_()); - } - - protected ListIterable<NestableAnnotation> getNestableNamedNativeQueryAnnotations_() { - return this.owner.getResourceAnnotatedElement().getAnnotations(NamedNativeQueryAnnotation.ANNOTATION_NAME); - } - - protected ContextListContainer<JavaNamedNativeQuery, NamedNativeQueryAnnotation> buildNamedNativeQueryContainer() { - NamedNativeQueryContainer container = new NamedNativeQueryContainer(); - container.initialize(); - return container; - } - - /** - * named query container - */ - protected class NamedNativeQueryContainer - extends ContextListContainer<JavaNamedNativeQuery, NamedNativeQueryAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return NAMED_NATIVE_QUERIES_LIST; - } - @Override - protected JavaNamedNativeQuery buildContextElement(NamedNativeQueryAnnotation resourceElement) { - return GenericJavaQueryContainer.this.buildNamedNativeQuery(resourceElement); - } - @Override - protected ListIterable<NamedNativeQueryAnnotation> getResourceElements() { - return GenericJavaQueryContainer.this.getNamedNativeQueryAnnotations(); - } - @Override - protected NamedNativeQueryAnnotation getResourceElement(JavaNamedNativeQuery contextElement) { - return contextElement.getQueryAnnotation(); - } - } - - - // ********** validation ********** - - /** - * The queries are validated in the persistence unit. - * @see org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#validateQueries(List, IReporter) - */ - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - // queries are validated in the persistence unit - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.owner.getResourceAnnotatedElement().getTextRange(astRoot); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); - } - - - // ********** misc ********** - - @Override - public JavaJpaContextNode getParent() { - return (JavaJpaContextNode) super.getParent(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java deleted file mode 100644 index 2c977b7d35..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.QueryHint; -import org.eclipse.jpt.jpa.core.context.java.JavaQuery; -import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation; - -/** - * Java query hing - */ -public class GenericJavaQueryHint - extends AbstractJavaJpaContextNode - implements JavaQueryHint -{ - protected final QueryHintAnnotation queryHintAnnotation; - - protected String name; - protected String value; - - - public GenericJavaQueryHint(JavaQuery parent, QueryHintAnnotation queryHintAnnotation) { - super(parent); - this.queryHintAnnotation = queryHintAnnotation; - this.name = queryHintAnnotation.getName(); - this.value = queryHintAnnotation.getValue(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setName_(this.queryHintAnnotation.getName()); - this.setValue_(this.queryHintAnnotation.getValue()); - } - - - // ********** name ********** - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.queryHintAnnotation.setName(name); - this.setName_(name); - } - - protected void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - - // ********** value ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.queryHintAnnotation.setValue(value); - this.setValue_(value); - } - - protected void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.queryHintAnnotation.getTextRange(astRoot); - return (textRange != null) ? textRange : this.getQuery().getValidationTextRange(astRoot); - } - - public boolean isEquivalentTo(QueryHint hint) { - return StringTools.stringsAreEqual(this.getName(), hint.getName()) && - StringTools.stringsAreEqual(this.getValue(), hint.getValue()) ; - } - - // ********** misc ********** - - @Override - public JavaQuery getParent() { - return (JavaQuery) super.getParent(); - } - - protected JavaQuery getQuery() { - return this.getParent(); - } - - public QueryHintAnnotation getQueryHintAnnotation() { - return this.queryHintAnnotation; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } -} 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 deleted file mode 100644 index fe0ead9f0e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaReferenceTable.java +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyReferenceTable; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaReferenceTable; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaTable; -import org.eclipse.jpt.jpa.core.internal.resource.java.NullJoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.ReferenceTableAnnotation; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java join table or collection table - */ -public abstract class GenericJavaReferenceTable<A extends ReferenceTableAnnotation> - extends AbstractJavaTable<A> - implements JavaReferenceTable -{ - protected final ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> specifiedJoinColumnContainer; - protected final JavaReadOnlyJoinColumn.Owner joinColumnOwner; - - protected JavaJoinColumn defaultJoinColumn; - - - protected GenericJavaReferenceTable(JavaJpaContextNode parent, Owner owner) { - super(parent, owner); - this.joinColumnOwner = this.buildJoinColumnOwner(); - this.specifiedJoinColumnContainer = this.buildSpecifiedJoinColumnContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedJoinColumns(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedJoinColumns()); - this.updateDefaultJoinColumn(); - } - - - // ********** join columns ********** - - public ListIterable<JavaJoinColumn> getJoinColumns() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns(); - } - - public int getJoinColumnsSize() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize(); - } - - public void convertDefaultJoinColumnToSpecified() { - MappingTools.convertReferenceTableDefaultToSpecifiedJoinColumn(this); - } - - - // ********** specified join columns ********** - - public ListIterable<JavaJoinColumn> getSpecifiedJoinColumns() { - return this.specifiedJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedJoinColumnsSize() { - return this.specifiedJoinColumnContainer.getContextElementsSize(); - } - - public boolean hasSpecifiedJoinColumns() { - return this.getSpecifiedJoinColumnsSize() != 0; - } - - public JavaJoinColumn getSpecifiedJoinColumn(int index) { - return this.specifiedJoinColumnContainer.getContextElement(index); - } - - public JavaJoinColumn addSpecifiedJoinColumn() { - return this.addSpecifiedJoinColumn(this.getSpecifiedJoinColumnsSize()); - } - - public JavaJoinColumn addSpecifiedJoinColumn(int index) { - JoinColumnAnnotation annotation = this.getTableAnnotation().addJoinColumn(index); - return this.specifiedJoinColumnContainer.addContextElement(index, annotation); - } - - public void removeSpecifiedJoinColumn(JoinColumn joinColumn) { - this.removeSpecifiedJoinColumn(this.specifiedJoinColumnContainer.indexOfContextElement((JavaJoinColumn) joinColumn)); - } - - public void removeSpecifiedJoinColumn(int index) { - this.getTableAnnotation().removeJoinColumn(index); - this.removeTableAnnotationIfUnset(); - this.specifiedJoinColumnContainer.removeContextElement(index); - } - - public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) { - this.getTableAnnotation().moveJoinColumn(targetIndex, sourceIndex); - this.specifiedJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - } - - protected void syncSpecifiedJoinColumns() { - this.specifiedJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<JoinColumnAnnotation> getJoinColumnAnnotations() { - return this.getTableAnnotation().getJoinColumns(); - } - - - /** - * join column container - */ - protected class SpecifiedJoinColumnContainer - extends ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_JOIN_COLUMNS_LIST; - } - @Override - protected JavaJoinColumn buildContextElement(JoinColumnAnnotation resourceElement) { - return GenericJavaReferenceTable.this.buildJoinColumn(resourceElement); - } - @Override - protected ListIterable<JoinColumnAnnotation> getResourceElements() { - return GenericJavaReferenceTable.this.getJoinColumnAnnotations(); - } - @Override - protected JoinColumnAnnotation getResourceElement(JavaJoinColumn contextElement) { - return (JoinColumnAnnotation) contextElement.getColumnAnnotation(); - } - } - - protected abstract JavaReadOnlyJoinColumn.Owner buildJoinColumnOwner(); - - protected ContextListContainer<JavaJoinColumn, JoinColumnAnnotation> buildSpecifiedJoinColumnContainer(){ - SpecifiedJoinColumnContainer container = new SpecifiedJoinColumnContainer(); - container.initialize(); - return container; - } - - // ********** default join column ********** - - public JavaJoinColumn getDefaultJoinColumn() { - return this.defaultJoinColumn; - } - - protected void setDefaultJoinColumn(JavaJoinColumn joinColumn) { - JavaJoinColumn old = this.defaultJoinColumn; - this.defaultJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn); - } - - protected ListIterable<JavaJoinColumn> getDefaultJoinColumns() { - return (this.defaultJoinColumn != null) ? - new SingleElementListIterable<JavaJoinColumn>(this.defaultJoinColumn) : - EmptyListIterable.<JavaJoinColumn>instance(); - } - - protected int getDefaultJoinColumnsSize() { - return (this.defaultJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultJoinColumn() { - if (this.buildsDefaultJoinColumn()) { - if (this.defaultJoinColumn == null) { - this.setDefaultJoinColumn(this.buildJoinColumn(new NullJoinColumnAnnotation(this.getTableAnnotation()))); - } else { - this.defaultJoinColumn.update(); - } - } else { - this.setDefaultJoinColumn(null); - } - } - - protected boolean buildsDefaultJoinColumn() { - return ! this.hasSpecifiedJoinColumns(); - } - - - // ********** misc ********** - - protected void initializeFrom(ReadOnlyReferenceTable oldTable) { - super.initializeFrom(oldTable); - for (ReadOnlyJoinColumn joinColumn : oldTable.getSpecifiedJoinColumns()) { - this.addSpecifiedJoinColumn().initializeFrom(joinColumn); - } - } - - protected void initializeFromVirtual(ReadOnlyReferenceTable virtualTable) { - super.initializeFromVirtual(virtualTable); - for (ReadOnlyJoinColumn joinColumn : virtualTable.getJoinColumns()) { - this.addSpecifiedJoinColumn().initializeFromVirtual(joinColumn); - } - } - - protected JavaJoinColumn buildJoinColumn(JoinColumnAnnotation joinColumnAnnotation) { - return this.buildJoinColumn(this.joinColumnOwner, joinColumnAnnotation); - } - - protected JavaJoinColumn buildJoinColumn(JavaReadOnlyJoinColumn.Owner jcOwner, JoinColumnAnnotation joinColumnAnnotation) { - return this.getJpaFactory().buildJavaJoinColumn(this, jcOwner, joinColumnAnnotation); - } - - @Override - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - for (JavaJoinColumn column : this.getJoinColumns()) { - result = column.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - boolean continueValidating = this.buildTableValidator(astRoot).validate(messages, reporter); - - //join column validation will handle the check for whether to validate against the database - //some validation messages are not database specific. If the database validation for the - //table fails we will stop there and not validate the join columns at all - if (continueValidating) { - this.validateJoinColumns(messages, reporter, astRoot); - } - } - - protected void validateJoinColumns(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - this.validateNodes(this.getJoinColumns(), messages, reporter, astRoot); - } -} - 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 deleted file mode 100644 index 3fafa6103e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSecondaryTable.java +++ /dev/null @@ -1,355 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaTable; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.SecondaryTablePrimaryKeyJoinColumnValidator; -import org.eclipse.jpt.jpa.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Java secondary table - */ -public class GenericJavaSecondaryTable - extends AbstractJavaTable<SecondaryTableAnnotation> - implements JavaSecondaryTable -{ - /** @see AbstractJavaTable#AbstractJavaTable(org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode, org.eclipse.jpt.jpa.core.context.Table.Owner, org.eclipse.jpt.jpa.core.resource.java.BaseTableAnnotation) */ - protected /* final */ SecondaryTableAnnotation tableAnnotation; - - protected final ContextListContainer<JavaPrimaryKeyJoinColumn, PrimaryKeyJoinColumnAnnotation> specifiedPrimaryKeyJoinColumnContainer; - protected final JavaReadOnlyBaseJoinColumn.Owner primaryKeyJoinColumnOwner; - - protected JavaPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn; - - - public GenericJavaSecondaryTable(JavaEntity parent, Owner owner, SecondaryTableAnnotation tableAnnotation) { - super(parent, owner, tableAnnotation); - this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner(); - this.specifiedPrimaryKeyJoinColumnContainer = this.buildSpecifiedPrimaryKeyJoinColumnContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedPrimaryKeyJoinColumns(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedPrimaryKeyJoinColumns()); - this.updateDefaultPrimaryKeyJoinColumn(); - } - - - // ********** table annotation ********** - - @Override - public SecondaryTableAnnotation getTableAnnotation() { - return this.tableAnnotation; - } - - /** - * @see AbstractJavaTable - */ - @Override - protected void setTableAnnotation(SecondaryTableAnnotation tableAnnotation) { - this.tableAnnotation = tableAnnotation; - } - - @Override - protected void removeTableAnnotation() { - // even though its name is required, we don't remove a secondary table' - // annotation when it is empty since it is part of a list and it's not - // obvious whether this would be very user-helpful... - } - - protected String getAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - - - // ********** primary key join columns ********** - - public ListIterable<JavaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() { - return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumns() : this.getDefaultPrimaryKeyJoinColumns(); - } - - public int getPrimaryKeyJoinColumnsSize() { - return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumnsSize() : this.getDefaultPrimaryKeyJoinColumnsSize(); - } - - - // ********** specified primary key join columns ********** - - - public ListIterable<JavaPrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns() { - return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedPrimaryKeyJoinColumnsSize() { - return this.specifiedPrimaryKeyJoinColumnContainer.getContextElementsSize(); - } - - protected boolean hasSpecifiedPrimaryKeyJoinColumns() { - return this.getSpecifiedPrimaryKeyJoinColumnsSize() != 0; - } - - public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn() { - return this.addSpecifiedPrimaryKeyJoinColumn(this.getSpecifiedPrimaryKeyJoinColumnsSize()); - } - - public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) { - PrimaryKeyJoinColumnAnnotation annotation = this.tableAnnotation.addPkJoinColumn(index); - return this.specifiedPrimaryKeyJoinColumnContainer.addContextElement(index, annotation); - } - - public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn joinColumn) { - this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumnContainer.indexOfContextElement((JavaPrimaryKeyJoinColumn) joinColumn)); - } - - public void removeSpecifiedPrimaryKeyJoinColumn(int index) { - this.tableAnnotation.removePkJoinColumn(index); - this.removeTableAnnotationIfUnset(); - this.specifiedPrimaryKeyJoinColumnContainer.removeContextElement(index); - } - - public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) { - this.tableAnnotation.movePkJoinColumn(targetIndex, sourceIndex); - this.specifiedPrimaryKeyJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - } - - protected void syncSpecifiedPrimaryKeyJoinColumns() { - this.specifiedPrimaryKeyJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<PrimaryKeyJoinColumnAnnotation> getPrimaryKeyJoinColumnAnnotations() { - return this.tableAnnotation.getPkJoinColumns(); - } - - /** - * specified primary key join column container - */ - protected class SpecifiedPrimaryKeyJoinColumnContainer - extends ContextListContainer<JavaPrimaryKeyJoinColumn, PrimaryKeyJoinColumnAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST; - } - @Override - protected JavaPrimaryKeyJoinColumn buildContextElement(PrimaryKeyJoinColumnAnnotation resourceElement) { - return GenericJavaSecondaryTable.this.buildPrimaryKeyJoinColumn(resourceElement); - } - @Override - protected ListIterable<PrimaryKeyJoinColumnAnnotation> getResourceElements() { - return GenericJavaSecondaryTable.this.getPrimaryKeyJoinColumnAnnotations(); - } - @Override - protected PrimaryKeyJoinColumnAnnotation getResourceElement(JavaPrimaryKeyJoinColumn contextElement) { - return contextElement.getColumnAnnotation(); - } - } - - protected JavaReadOnlyBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() { - return new PrimaryKeyJoinColumnOwner(); - } - - protected ContextListContainer<JavaPrimaryKeyJoinColumn, PrimaryKeyJoinColumnAnnotation> buildSpecifiedPrimaryKeyJoinColumnContainer() { - SpecifiedPrimaryKeyJoinColumnContainer container = new SpecifiedPrimaryKeyJoinColumnContainer(); - container.initialize(); - return container; - } - - // ********** default primary key join column ********** - - public JavaPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() { - return this.defaultPrimaryKeyJoinColumn; - } - - protected void setDefaultPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn joinColumn) { - JavaPrimaryKeyJoinColumn old = this.defaultPrimaryKeyJoinColumn; - this.defaultPrimaryKeyJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, old, joinColumn); - } - - protected ListIterable<JavaPrimaryKeyJoinColumn> getDefaultPrimaryKeyJoinColumns() { - return (this.defaultPrimaryKeyJoinColumn != null) ? - new SingleElementListIterable<JavaPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn) : - EmptyListIterable.<JavaPrimaryKeyJoinColumn>instance(); - } - - protected int getDefaultPrimaryKeyJoinColumnsSize() { - return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultPrimaryKeyJoinColumn() { - if (this.buildsDefaultPrimaryKeyJoinColumn()) { - if (this.defaultPrimaryKeyJoinColumn == null) { - this.setDefaultPrimaryKeyJoinColumn(this.buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.tableAnnotation))); - } else { - this.defaultPrimaryKeyJoinColumn.update(); - } - } else { - this.setDefaultPrimaryKeyJoinColumn(null); - } - } - - protected boolean buildsDefaultPrimaryKeyJoinColumn() { - return ! this.hasSpecifiedPrimaryKeyJoinColumns(); - } - - - // ********** misc ********** - - @Override - public JavaEntity getParent() { - return (JavaEntity) super.getParent(); - } - - protected JavaEntity getEntity() { - return this.getParent(); - } - - public boolean isVirtual() { - return false; - } - - protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(PrimaryKeyJoinColumnAnnotation pkJoinColumnAnnotation) { - return this.getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, pkJoinColumnAnnotation); - } - - - // ********** defaults ********** - - /** - * a secondary table doesn't have a default name - */ - @Override - protected String buildDefaultName() { - return null; - } - - @Override - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** code completion ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - for (JavaPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) { - result = column.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - boolean continueValidating = this.buildTableValidator(astRoot).validate(messages, reporter); - - //join column validation will handle the check for whether to validate against the database - //some validation messages are not database specific. If the database validation for the - //table fails we will stop there and not validate the join columns at all - if (continueValidating) { - for (JavaPrimaryKeyJoinColumn pkJoinColumn : this.getPrimaryKeyJoinColumns()) { - pkJoinColumn.validate(messages, reporter, astRoot); - } - } - } - - public boolean validatesAgainstDatabase() { - return this.connectionProfileIsActive(); - } - - - // ********** primary key join column owner adapter ********** - - protected class PrimaryKeyJoinColumnOwner - implements JavaReadOnlyBaseJoinColumn.Owner - { - protected JavaEntity getEntity() { - return GenericJavaSecondaryTable.this.getEntity(); - } - - public String getDefaultTableName() { - return GenericJavaSecondaryTable.this.getName(); - } - - public Table resolveDbTable(String tableName) { - return GenericJavaSecondaryTable.this.getDbTable(); - } - - public Table getReferencedColumnDbTable() { - return this.getEntity().getPrimaryDbTable(); - } - - public int getJoinColumnsSize() { - return GenericJavaSecondaryTable.this.getPrimaryKeyJoinColumnsSize(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - if (this.getJoinColumnsSize() != 1) { - return null; - } - return this.getEntity().getPrimaryKeyColumnName(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return GenericJavaSecondaryTable.this.getValidationTextRange(astRoot); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new SecondaryTablePrimaryKeyJoinColumnValidator(GenericJavaSecondaryTable.this, (ReadOnlyBaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSequenceGenerator.java deleted file mode 100644 index 5b45320174..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaSequenceGenerator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaSequenceGenerator; -import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation; - -/** - * Java sequence generator - */ -public class GenericJavaSequenceGenerator - extends AbstractJavaSequenceGenerator<SequenceGeneratorAnnotation> -{ - public GenericJavaSequenceGenerator(JavaGeneratorContainer parent, SequenceGeneratorAnnotation generatorAnnotation) { - super(parent, generatorAnnotation); - } - - - // ********** database stuff ********** - - /** - * The JPA 1.0 spec does not allow a sequence to specify a catalog. - */ - @Override - protected String getCatalog() { - return this.getContextDefaultCatalog(); - } - - /** - * The JPA 1.0 spec does not allow a sequence to specify a schema. - */ - @Override - protected String getSchema() { - return this.getContextDefaultSchema(); - } - - // ********** validation ********** - - @Override - protected boolean isEquivalentTo(SequenceGenerator generator) { - return super.isEquivalentTo(generator) && - Tools.valuesAreEqual(this.getDbSchema(), generator.getDbSchema()) && - Tools.valuesAreEqual(this.getDbCatalog(), generator.getDbCatalog()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTable.java deleted file mode 100644 index a0990dd1b9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTable.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.jpa.core.context.java.JavaEntity; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaTable; -import org.eclipse.jpt.jpa.core.resource.java.TableAnnotation; - -/** - * Java table - */ -public class GenericJavaTable - extends AbstractJavaTable<TableAnnotation> -{ - public GenericJavaTable(JavaEntity parent, Owner owner) { - super(parent, owner); - } - - - // ********** table annotation ********** - - @Override - public TableAnnotation getTableAnnotation() { - // TODO get the NullTableAnnotation from the resource model or build it here in the context model?? - return (TableAnnotation) this.getJavaResourceType().getNonNullAnnotation(this.getAnnotationName()); - } - - @Override - protected void removeTableAnnotation() { - this.getJavaResourceType().removeAnnotation(this.getAnnotationName()); - } - - protected String getAnnotationName() { - return TableAnnotation.ANNOTATION_NAME; - } - - protected JavaResourceType getJavaResourceType() { - return this.getEntity().getPersistentType().getJavaResourceType(); - } - - - // ********** defaults ********** - - @Override - protected String buildDefaultName() { - return this.getEntity().getDefaultTableName(); - } - - /** - * Just to remember:<ol> - * <li>{@link org.eclipse.jpt.jpa.core.context.Entity#getDefaultSchema()}<br> - * check inheritance; get default schema from root - * <li>{@link org.eclipse.jpt.jpa.core.context.orm.EntityMappings#getSchema()}<br> - * check for specified schema - * <li>{@link org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit#getDefaultSchema()}<br> - * {@link org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitDefaults#getSchema()} - * <li>{@link org.eclipse.jpt.jpa.core.JpaProject#getDefaultSchema()}<br> - * check for user override project setting - * <li>{@link org.eclipse.jpt.jpa.db.Catalog#getDefaultSchema()}<br> - * or {@link org.eclipse.jpt.jpa.db.Database#getDefaultSchema()} - * </ol> - */ - @Override - protected String buildDefaultSchema() { - return this.getEntity().getDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getEntity().getDefaultCatalog(); - } - - - // ********** validation ********** - - public boolean validatesAgainstDatabase() { - return this.connectionProfileIsActive(); - } - - - // ********** misc ********** - - /** - * covariant override - */ - @Override - public JavaEntity getParent() { - return (JavaEntity) super.getParent(); - } - - protected JavaEntity getEntity() { - return this.getParent(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java deleted file mode 100644 index 4ed1b078bd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java +++ /dev/null @@ -1,596 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.core.context.UniqueConstraint; -import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaTableGenerator; -import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaGenerator; -import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.jpa.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Java table generator - */ -public class GenericJavaTableGenerator - extends AbstractJavaGenerator<TableGeneratorAnnotation> - implements JavaTableGenerator, UniqueConstraint.Owner -{ - protected String specifiedTable; - protected String defaultTable; - - protected String specifiedSchema; - protected String defaultSchema; - - protected String specifiedCatalog; - protected String defaultCatalog; - - protected String specifiedPkColumnName; - protected String defaultPkColumnName; - - protected String specifiedValueColumnName; - protected String defaultValueColumnName; - - protected String specifiedPkColumnValue; - protected String defaultPkColumnValue; - - protected final ContextListContainer<JavaUniqueConstraint, UniqueConstraintAnnotation> uniqueConstraintContainer; - - - // ********** constructor ********** - - public GenericJavaTableGenerator(JavaGeneratorContainer parent, TableGeneratorAnnotation generatorAnnotation) { - super(parent, generatorAnnotation); - this.specifiedTable = generatorAnnotation.getTable(); - this.specifiedSchema = generatorAnnotation.getSchema(); - this.specifiedCatalog = generatorAnnotation.getCatalog(); - this.specifiedPkColumnName = generatorAnnotation.getPkColumnName(); - this.specifiedValueColumnName = generatorAnnotation.getValueColumnName(); - this.specifiedPkColumnValue = generatorAnnotation.getPkColumnValue(); - this.uniqueConstraintContainer = this.buildUniqueConstraintContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedTable_(this.generatorAnnotation.getTable()); - this.setSpecifiedSchema_(this.generatorAnnotation.getSchema()); - this.setSpecifiedCatalog_(this.generatorAnnotation.getCatalog()); - this.setSpecifiedPkColumnName_(this.generatorAnnotation.getPkColumnName()); - this.setSpecifiedValueColumnName_(this.generatorAnnotation.getValueColumnName()); - this.setSpecifiedPkColumnValue_(this.generatorAnnotation.getPkColumnValue()); - this.syncUniqueConstraints(); - } - - @Override - public void update() { - super.update(); - this.setDefaultTable(this.buildDefaultTable()); - this.setDefaultSchema(this.buildDefaultSchema()); - this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setDefaultPkColumnName(this.buildDefaultPkColumnName()); - this.setDefaultValueColumnName(this.buildDefaultValueColumnName()); - this.setDefaultPkColumnValue(this.buildDefaultPkColumnValue()); - this.updateNodes(this.getUniqueConstraints()); - } - - - // ********** initial value ********** - - @Override - protected int buildDefaultInitialValue() { - return DEFAULT_INITIAL_VALUE; - } - - - // ********** table ********** - - public String getTable() { - return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable; - } - - public String getSpecifiedTable() { - return this.specifiedTable; - } - - public void setSpecifiedTable(String table) { - this.generatorAnnotation.setTable(table); - this.setSpecifiedTable_(table); - } - - protected void setSpecifiedTable_(String table) { - String old = this.specifiedTable; - this.specifiedTable = table; - this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table); - } - - public String getDefaultTable() { - return this.defaultTable; - } - - protected void setDefaultTable(String table) { - String old = this.defaultTable; - this.defaultTable = table; - this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table); - } - - protected String buildDefaultTable() { - return null; // TODO the default table is determined by the runtime provider... - } - - public Table getDbTable() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema == null) ? null : dbSchema.getTableForIdentifier(this.getTable()); - } - - - // ********** schema ********** - - @Override - public String getSchema() { - return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema; - } - - public String getSpecifiedSchema() { - return this.specifiedSchema; - } - - public void setSpecifiedSchema(String schema) { - this.generatorAnnotation.setSchema(schema); - this.setSpecifiedSchema_(schema); - } - - protected void setSpecifiedSchema_(String schema) { - String old = this.specifiedSchema; - this.specifiedSchema = schema; - this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema); - } - - public String getDefaultSchema() { - return this.defaultSchema; - } - - protected void setDefaultSchema(String schema) { - String old = this.defaultSchema; - this.defaultSchema = schema; - this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema); - } - - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - - // ********** catalog ********** - - @Override - public String getCatalog() { - return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog; - } - - public String getSpecifiedCatalog() { - return this.specifiedCatalog; - } - - public void setSpecifiedCatalog(String catalog) { - this.generatorAnnotation.setCatalog(catalog); - this.setSpecifiedCatalog_(catalog); - } - - protected void setSpecifiedCatalog_(String catalog) { - String old = this.specifiedCatalog; - this.specifiedCatalog = catalog; - this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog); - } - - public String getDefaultCatalog() { - return this.defaultCatalog; - } - - protected void setDefaultCatalog(String catalog) { - String old = this.defaultCatalog; - this.defaultCatalog = catalog; - this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog); - } - - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** primary key column name ********** - - public String getPkColumnName() { - return (this.specifiedPkColumnName != null) ? this.specifiedPkColumnName : this.defaultPkColumnName; - } - - public String getSpecifiedPkColumnName() { - return this.specifiedPkColumnName; - } - - public void setSpecifiedPkColumnName(String name) { - this.generatorAnnotation.setPkColumnName(name); - this.setSpecifiedPkColumnName_(name); - } - - protected void setSpecifiedPkColumnName_(String name) { - String old = this.specifiedPkColumnName; - this.specifiedPkColumnName = name; - this.firePropertyChanged(SPECIFIED_PK_COLUMN_NAME_PROPERTY, old, name); - } - - public String getDefaultPkColumnName() { - return this.defaultPkColumnName; - } - - protected void setDefaultPkColumnName(String name) { - String old = this.defaultPkColumnName; - this.defaultPkColumnName = name; - this.firePropertyChanged(DEFAULT_PK_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultPkColumnName() { - return null; // TODO the default pk column name is determined by the runtime provider... - } - - - // ********** value column name ********** - - public String getValueColumnName() { - return (this.specifiedValueColumnName != null) ? this.specifiedValueColumnName : this.defaultValueColumnName; - } - - public String getSpecifiedValueColumnName() { - return this.specifiedValueColumnName; - } - - public void setSpecifiedValueColumnName(String name) { - this.generatorAnnotation.setValueColumnName(name); - this.setSpecifiedValueColumnName_(name); - } - - protected void setSpecifiedValueColumnName_(String name) { - String old = this.specifiedValueColumnName; - this.specifiedValueColumnName = name; - this.firePropertyChanged(SPECIFIED_VALUE_COLUMN_NAME_PROPERTY, old, name); - } - - public String getDefaultValueColumnName() { - return this.defaultValueColumnName; - } - - protected void setDefaultValueColumnName(String name) { - String old = this.defaultValueColumnName; - this.defaultValueColumnName = name; - this.firePropertyChanged(DEFAULT_VALUE_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultValueColumnName() { - return null; // TODO the default value column name is determined by the runtime provider... - } - - - // ********** primary key column value ********** - - public String getPkColumnValue() { - return (this.specifiedPkColumnValue != null) ? this.specifiedPkColumnValue : this.defaultPkColumnValue; - } - - public String getSpecifiedPkColumnValue() { - return this.specifiedPkColumnValue; - } - - public void setSpecifiedPkColumnValue(String value) { - this.generatorAnnotation.setPkColumnValue(value); - this.setSpecifiedPkColumnValue_(value); - } - - protected void setSpecifiedPkColumnValue_(String value) { - String old = this.specifiedPkColumnValue; - this.specifiedPkColumnValue = value; - this.firePropertyChanged(SPECIFIED_PK_COLUMN_VALUE_PROPERTY, old, value); - } - - public String getDefaultPkColumnValue() { - return this.defaultPkColumnValue; - } - - protected void setDefaultPkColumnValue(String value) { - String old = this.defaultPkColumnValue; - this.defaultPkColumnValue = value; - this.firePropertyChanged(DEFAULT_PK_COLUMN_VALUE_PROPERTY, old, value); - } - - protected String buildDefaultPkColumnValue() { - return null; // TODO the default pk column value is determined by the runtime provider... - } - - - // ********** unique constraints ********** - public ListIterable<JavaUniqueConstraint> getUniqueConstraints() { - return this.uniqueConstraintContainer.getContextElements(); - } - - public int getUniqueConstraintsSize() { - return this.uniqueConstraintContainer.getContextElementsSize(); - } - - public JavaUniqueConstraint getUniqueConstraint(int index) { - return this.uniqueConstraintContainer.getContextElement(index); - } - - public JavaUniqueConstraint addUniqueConstraint() { - return this.addUniqueConstraint(this.getUniqueConstraintsSize()); - } - - public JavaUniqueConstraint addUniqueConstraint(int index) { - UniqueConstraintAnnotation annotation = this.getGeneratorAnnotation().addUniqueConstraint(index); - return this.uniqueConstraintContainer.addContextElement(index, annotation); - } - - public void removeUniqueConstraint(int index) { - this.getGeneratorAnnotation().removeUniqueConstraint(index); - this.uniqueConstraintContainer.removeContextElement(index); - } - - public void removeUniqueConstraint(UniqueConstraint uniqueConstraint) { - this.removeUniqueConstraint(this.uniqueConstraintContainer.indexOfContextElement((JavaUniqueConstraint) uniqueConstraint)); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - this.getGeneratorAnnotation().moveUniqueConstraint(targetIndex, sourceIndex); - this.uniqueConstraintContainer.moveContextElement(targetIndex, sourceIndex); - } - - protected void syncUniqueConstraints() { - this.uniqueConstraintContainer.synchronizeWithResourceModel(); - } - - protected void updateUniqueConstraints() { - this.uniqueConstraintContainer.synchronizeWithResourceModel(); - } - - protected JavaUniqueConstraint buildUniqueConstraint(UniqueConstraintAnnotation constraintAnnotation) { - return this.getJpaFactory().buildJavaUniqueConstraint(this, this, constraintAnnotation); - } - - protected ListIterable<UniqueConstraintAnnotation> getUniqueConstraintAnnotations() { - return this.getGeneratorAnnotation().getUniqueConstraints(); - } - - protected ContextListContainer<JavaUniqueConstraint, UniqueConstraintAnnotation> buildUniqueConstraintContainer() { - UniqueConstraintContainer container = new UniqueConstraintContainer(); - container.initialize(); - return container; - } - - /** - * unique constraint container - */ - protected class UniqueConstraintContainer - extends ContextListContainer<JavaUniqueConstraint, UniqueConstraintAnnotation> - { - @Override - protected String getContextElementsPropertyName() { - return UNIQUE_CONSTRAINTS_LIST; - } - @Override - protected JavaUniqueConstraint buildContextElement(UniqueConstraintAnnotation resourceElement) { - return GenericJavaTableGenerator.this.buildUniqueConstraint(resourceElement); - } - @Override - protected ListIterable<UniqueConstraintAnnotation> getResourceElements() { - return GenericJavaTableGenerator.this.getUniqueConstraintAnnotations(); - } - @Override - protected UniqueConstraintAnnotation getResourceElement(JavaUniqueConstraint contextElement) { - return contextElement.getUniqueConstraintAnnotation(); - } - } - - - // ********** UniqueConstraint.Owner implementation ********** - - public Iterable<String> getCandidateUniqueConstraintColumnNames() { - org.eclipse.jpt.jpa.db.Table dbTable = this.getDbTable(); - return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String>instance(); - } - - - // ********** Java completion proposals ********** - - @Override - public Iterable<String> getJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - for (JavaUniqueConstraint constraint : this.getUniqueConstraints()) { - result = constraint.getJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - /** - * called if the database is connected: - * table, schema, catalog, pkColumnName, valueColumnName - */ - @Override - protected Iterable<String> getConnectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getConnectedJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.tableTouches(pos)) { - return this.getJavaCandidateTables(filter); - } - if (this.schemaTouches(pos)) { - return this.getJavaCandidateSchemata(filter); - } - if (this.pkColumnNameTouches(pos)) { - return this.getJavaCandidateColumnNames(filter); - } - if (this.valueColumnNameTouches(pos)) { - return this.getJavaCandidateColumnNames(filter); - } - return null; - } - - // ********** code assist: table - - protected boolean tableTouches(int pos) { - return this.generatorAnnotation.tableTouches(pos); - } - - protected Iterable<String> getJavaCandidateTables(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateTables(filter)); - } - - protected Iterable<String> getCandidateTables(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateTables(), filter); - } - - protected Iterable<String> getCandidateTables() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** code assist: schema - - protected boolean schemaTouches(int pos) { - return this.generatorAnnotation.schemaTouches(pos); - } - - protected Iterable<String> getJavaCandidateSchemata(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateSchemata(filter)); - } - - protected Iterable<String> getCandidateSchemata(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateSchemata(), filter); - } - - protected Iterable<String> getCandidateSchemata() { - SchemaContainer schemaContainer = this.getDbSchemaContainer(); - return (schemaContainer != null) ? schemaContainer.getSortedSchemaIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** code assist: catalog - - protected boolean catalogTouches(int pos) { - return this.generatorAnnotation.catalogTouches(pos); - } - - protected Iterable<String> getJavaCandidateCatalogs(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateCatalogs(filter)); - } - - protected Iterable<String> getCandidateCatalogs(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateCatalogs(), filter); - } - - protected Iterable<String> getCandidateCatalogs() { - Database db = this.getDatabase(); - return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** code assist: pkColumnName - - protected boolean pkColumnNameTouches(int pos) { - return this.generatorAnnotation.pkColumnNameTouches(pos); - } - - protected Iterable<String> getJavaCandidateColumnNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateColumnNames(filter)); - } - - protected Iterable<String> getCandidateColumnNames(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateColumnNames(), filter); - } - - protected Iterable<String> getCandidateColumnNames() { - Table table = this.getDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** code assist: valueColumnName - - protected boolean valueColumnNameTouches(int pos) { - return this.generatorAnnotation.valueColumnNameTouches(pos); - } - - // ********** metadata conversion ********** - - public void convertTo(EntityMappings entityMappings) { - entityMappings.addTableGenerator().convertFrom(this); - } - - public void delete() { - this.getParent().removeTableGenerator(); - } - - // ********** misc ********** - - public Class<TableGenerator> getType() { - return TableGenerator.class; - } - - // ********** validation ********** - - @Override - public boolean isEquivalentTo(JpaNamedContextNode node) { - return super.isEquivalentTo(node) - && this.isEquivalentTo((TableGenerator) node); - } - - protected boolean isEquivalentTo(TableGenerator generator) { - return super.isEquivalentTo(generator) && - Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) && - Tools.valuesAreEqual(this.specifiedSchema, generator.getSpecifiedSchema()) && - Tools.valuesAreEqual(this.specifiedCatalog, generator.getSpecifiedCatalog()) && - Tools.valuesAreEqual(this.specifiedPkColumnName, generator.getSpecifiedPkColumnName()) && - Tools.valuesAreEqual(this.specifiedPkColumnValue, generator.getSpecifiedPkColumnValue()) && - Tools.valuesAreEqual(this.specifiedValueColumnName, generator.getSpecifiedValueColumnName()) && - uniqueConstrainsAreEquivalentTo(generator); - } - - protected boolean uniqueConstrainsAreEquivalentTo(TableGenerator generator) { - if (this.getUniqueConstraintsSize() != generator.getUniqueConstraintsSize()) { - return false; - } - - for (int i=0; i<this.getUniqueConstraintsSize(); i++) { - if (! this.uniqueConstraintContainer.get(i).isEquivalentTo(generator.getUniqueConstraint(i))) { - return false; - } - } - return true; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTransientMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTransientMapping.java deleted file mode 100644 index 37e46c1c56..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTransientMapping.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaAttributeMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation; - -/** - * Java transient mapping - */ -public class GenericJavaTransientMapping - extends AbstractJavaAttributeMapping<TransientAnnotation> - implements JavaTransientMapping -{ - public GenericJavaTransientMapping(JavaPersistentAttribute parent) { - super(parent); - } - - public String getKey() { - return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; - } - - @Override - protected String getAnnotationName() { - return TransientAnnotation.ANNOTATION_NAME; - } - - - // ********** metamodel ********** - - @Override - public MetamodelField getMetamodelField() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java deleted file mode 100644 index cdcb4e0959..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.Filter; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.UniqueConstraint; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.resource.java.UniqueConstraintAnnotation; - -public class GenericJavaUniqueConstraint - extends AbstractJavaReadOnlyUniqueConstraint - implements JavaUniqueConstraint -{ - protected Owner owner; - protected final UniqueConstraintAnnotation uniqueConstraintAnnotation; - - - public GenericJavaUniqueConstraint(JavaJpaContextNode parent, Owner owner, UniqueConstraintAnnotation uniqueConstraintAnnotation) { - super(parent); - this.owner = owner; - this.uniqueConstraintAnnotation = uniqueConstraintAnnotation; - this.initializeColumnNames(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncColumnNames(); - } - - - // ********** column names ********** - - public void addColumnName(String columnName) { - this.addColumnName(this.columnNames.size(), columnName); - } - - public void addColumnName(int index, String columnName) { - this.uniqueConstraintAnnotation.addColumnName(index, columnName); - this.addItemToList(index, columnName, this.columnNames, COLUMN_NAMES_LIST); - } - - public void removeColumnName(String columnName) { - this.removeColumnName(this.columnNames.indexOf(columnName)); - } - - public void removeColumnName(int index) { - this.uniqueConstraintAnnotation.removeColumnName(index); - this.removeItemFromList(index, this.columnNames, COLUMN_NAMES_LIST); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - this.uniqueConstraintAnnotation.moveColumnName(targetIndex, sourceIndex); - this.moveItemInList(targetIndex, sourceIndex, this.columnNames, COLUMN_NAMES_LIST); - } - - protected void initializeColumnNames() { - for (String columnName : this.getResourceColumnNames()) { - this.columnNames.add(columnName); - } - } - - @Override - protected Iterable<String> getResourceColumnNames() { - return this.uniqueConstraintAnnotation.getColumnNames(); - } - - // ********** Java completion proposals ********** - - @Override - protected Iterable<String> getConnectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterable<String> result = super.getConnectedJavaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.columnNamesTouches(pos)) { - return this.javaCandidateColumnNames(filter); - } - return null; - } - - protected boolean columnNamesTouches(int pos) { - return this.uniqueConstraintAnnotation.columnNamesTouches(pos); - } - - protected Iterable<String> javaCandidateColumnNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.getCandidateColumnNames(filter)); - } - - protected Iterable<String> getCandidateColumnNames(Filter<String> filter) { - return new FilteringIterable<String>(this.getCandidateColumnNames(), filter); - } - - protected Iterable<String> getCandidateColumnNames() { - return this.owner.getCandidateUniqueConstraintColumnNames(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.uniqueConstraintAnnotation.getTextRange(astRoot); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); - } - - public boolean isEquivalentTo(UniqueConstraint uniqueConstraint) { - return columnNamesAreEquivalent(uniqueConstraint); - } - - protected boolean columnNamesAreEquivalent(UniqueConstraint uniqueConstraint) { - if (this.getColumnNamesSize() != uniqueConstraint.getColumnNamesSize()) { - return false; - } - - for (int i=0; i<this.getColumnNamesSize(); i++) { - if (! Tools.valuesAreEqual(this.columnNames.get(i), uniqueConstraint.getColumnName(i))) { - return false; - } - } - return true; - } - - // ********** misc ********** - - public UniqueConstraintAnnotation getUniqueConstraintAnnotation() { - return this.uniqueConstraintAnnotation; - } - - public void initializeFrom(ReadOnlyUniqueConstraint oldUniqueConstraint) { - for (String columnName : oldUniqueConstraint.getColumnNames()) { - this.addColumnName(columnName); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVersionMapping.java deleted file mode 100644 index 9d66e365f5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVersionMapping.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaVersionMapping; - -public class GenericJavaVersionMapping - extends AbstractJavaVersionMapping -{ - public GenericJavaVersionMapping(JavaPersistentAttribute parent) { - super(parent); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAssociationOverride.java deleted file mode 100644 index d7f6b3b98d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAssociationOverride.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualOverrideRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaVirtualOverride; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaVirtualAssociationOverride2_0; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Virtual Java association override - */ -public class GenericJavaVirtualAssociationOverride - extends AbstractJavaVirtualOverride<JavaAssociationOverrideContainer> - implements JavaVirtualAssociationOverride2_0 -{ - protected final JavaVirtualOverrideRelationship relationship; - - - public GenericJavaVirtualAssociationOverride(JavaAssociationOverrideContainer parent, String name) { - super(parent, name); - this.relationship = this.buildRelationship(); - } - - @Override - public void update() { - super.update(); - this.relationship.update(); - } - - @Override - public JavaAssociationOverride convertToSpecified() { - return (JavaAssociationOverride) super.convertToSpecified(); - } - - public RelationshipMapping getMapping() { - return this.getContainer().getRelationshipMapping(this.name); - } - - protected JavaAssociationOverrideContainer2_0 getContainer2_0() { - return (JavaAssociationOverrideContainer2_0) this.getContainer(); - } - - - // ********** relationship ********** - - public JavaVirtualOverrideRelationship getRelationship() { - return this.relationship; - } - - /** - * The relationship should be available (since its presence precipitated the - * creation of the virtual override). - */ - protected JavaVirtualOverrideRelationship buildRelationship() { - return this.getJpaFactory().buildJavaVirtualOverrideRelationship(this); - } - - public ReadOnlyRelationship resolveOverriddenRelationship() { - return this.getContainer().resolveOverriddenRelationship(this.name); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.relationship.validate(messages, reporter, astRoot); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableValidator(this, table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableJoinColumnValidator(this, column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableInverseJoinColumnValidator(this, column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAttributeOverride.java deleted file mode 100644 index a4c5705f52..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualAttributeOverride.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualColumn; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaVirtualOverride; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Virtual Java attribute override - */ -public class GenericJavaVirtualAttributeOverride - extends AbstractJavaVirtualOverride<JavaAttributeOverrideContainer> - implements JavaVirtualAttributeOverride, JavaVirtualColumn.Owner -{ - protected final JavaVirtualColumn column; - - - public GenericJavaVirtualAttributeOverride(JavaAttributeOverrideContainer parent, String name) { - super(parent, name); - this.column = this.buildColumn(); - } - - @Override - public void update() { - super.update(); - this.column.update(); - } - - @Override - public JavaAttributeOverride convertToSpecified() { - return (JavaAttributeOverride) super.convertToSpecified(); - } - - - // ********** column ********** - - public JavaVirtualColumn getColumn() { - return this.column; - } - - /** - * The original column should be available (since the presence of its - * attribute is what precipitated the creation of the virtual override). - */ - protected JavaVirtualColumn buildColumn() { - return this.getJpaFactory().buildJavaVirtualColumn(this, this); - } - - - // ********** column owner implementation ********** - - @Override - public String getDefaultTableName() { - String overriddenColumnTable = this.getOverriddenColumnTable(); - return (overriddenColumnTable != null) ? overriddenColumnTable : super.getDefaultTableName(); - } - - protected String getOverriddenColumnTable() { - ReadOnlyColumn overriddenColumn = this.resolveOverriddenColumn(); - // pretty sure this is the *specified* table... - return (overriddenColumn == null) ? null : overriddenColumn.getSpecifiedTable(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - String overriddenColumnName = this.getOverriddenColumnName(); - return (overriddenColumnName != null) ? overriddenColumnName : this.name; - } - - protected String getOverriddenColumnName() { - ReadOnlyColumn overriddenColumn = this.resolveOverriddenColumn(); - return (overriddenColumn == null) ? null : overriddenColumn.getName(); - } - - public ReadOnlyColumn resolveOverriddenColumn() { - return this.getContainer().resolveOverriddenColumn(this.name); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, (ReadOnlyBaseColumn) col, this, (TableColumnTextRangeResolver) textRangeResolver); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.column.validate(messages, reporter, astRoot); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualColumn.java deleted file mode 100644 index 342eec168b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualColumn.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaVirtualBaseColumn; - -/** - * Java virtual column - */ -public class GenericJavaVirtualColumn - extends AbstractJavaVirtualBaseColumn<JavaVirtualColumn.Owner, ReadOnlyColumn> - implements JavaVirtualColumn -{ - protected Integer specifiedLength; - protected int defaultLength; - - protected Integer specifiedPrecision; - protected int defaultPrecision; - - protected Integer specifiedScale; - protected int defaultScale; - - - public GenericJavaVirtualColumn(JavaJpaContextNode parent, JavaVirtualColumn.Owner owner) { - super(parent, owner); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - - this.setSpecifiedLength(this.buildSpecifiedLength()); - this.setDefaultLength(this.buildDefaultLength()); - - this.setSpecifiedPrecision(this.buildSpecifiedPrecision()); - this.setDefaultPrecision(this.buildDefaultPrecision()); - - this.setSpecifiedScale(this.buildSpecifiedScale()); - this.setDefaultScale(this.buildDefaultScale()); - } - - - // ********** column ********** - - @Override - public ReadOnlyColumn getOverriddenColumn() { - return this.owner.resolveOverriddenColumn(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength; - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - protected void setSpecifiedLength(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - return this.getOverriddenColumn().getSpecifiedLength(); - } - - public int getDefaultLength() { - return this.defaultLength; - } - - protected void setDefaultLength(int length) { - int old = this.defaultLength; - this.defaultLength = length; - this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, length); - } - - protected int buildDefaultLength() { - return DEFAULT_LENGTH; - } - - - // ********** precision ********** - - public int getPrecision() { - return (this.specifiedPrecision != null) ? this.specifiedPrecision.intValue() : this.defaultPrecision; - } - - public Integer getSpecifiedPrecision() { - return this.specifiedPrecision; - } - - protected void setSpecifiedPrecision(Integer precision) { - Integer old = this.specifiedPrecision; - this.specifiedPrecision = precision; - this.firePropertyChanged(SPECIFIED_PRECISION_PROPERTY, old, precision); - } - - protected Integer buildSpecifiedPrecision() { - return this.getOverriddenColumn().getSpecifiedPrecision(); - } - - public int getDefaultPrecision() { - return this.defaultPrecision; - } - - protected void setDefaultPrecision(int precision) { - int old = this.defaultPrecision; - this.defaultPrecision = precision; - this.firePropertyChanged(DEFAULT_PRECISION_PROPERTY, old, precision); - } - - protected int buildDefaultPrecision() { - return DEFAULT_PRECISION; - } - - - // ********** scale ********** - - public int getScale() { - return (this.specifiedScale != null) ? this.specifiedScale.intValue() : this.defaultScale; - } - - public Integer getSpecifiedScale() { - return this.specifiedScale; - } - - protected void setSpecifiedScale(Integer scale) { - Integer old = this.specifiedScale; - this.specifiedScale = scale; - this.firePropertyChanged(SPECIFIED_SCALE_PROPERTY, old, scale); - } - - protected Integer buildSpecifiedScale() { - return this.getOverriddenColumn().getSpecifiedScale(); - } - - public int getDefaultScale() { - return this.defaultScale; - } - - protected void setDefaultScale(int scale) { - int old = this.defaultScale; - this.defaultScale = scale; - this.firePropertyChanged(DEFAULT_SCALE_PROPERTY, old, scale); - } - - protected int buildDefaultScale() { - return DEFAULT_SCALE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualJoinColumn.java deleted file mode 100644 index 61d73f863a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualJoinColumn.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaVirtualBaseColumn; -import org.eclipse.jpt.jpa.core.internal.context.java.JavaJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Java virtual join column - */ -public class GenericJavaVirtualJoinColumn - extends AbstractJavaVirtualBaseColumn<JavaReadOnlyJoinColumn.Owner, ReadOnlyJoinColumn> - implements JavaVirtualJoinColumn -{ - protected final ReadOnlyJoinColumn overriddenColumn; - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericJavaVirtualJoinColumn(JavaJpaContextNode parent, JavaReadOnlyJoinColumn.Owner owner, ReadOnlyJoinColumn overriddenColumn) { - super(parent, owner); - this.overriddenColumn = overriddenColumn; - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - - this.setSpecifiedReferencedColumnName(this.buildSpecifiedReferencedColumnName()); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** column ********** - - @Override - public ReadOnlyJoinColumn getOverriddenColumn() { - return this.overriddenColumn; - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - protected void setSpecifiedReferencedColumnName(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return this.getOverriddenColumn().getSpecifiedReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultReferencedColumnName() { - return MappingTools.buildJoinColumnDefaultReferencedColumnName(this.owner); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** validation ********** - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) { - return new JavaJoinColumnTextRangeResolver(this, astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getValidationTextRange(astRoot); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java deleted file mode 100644 index 71ef4b44d9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java +++ /dev/null @@ -1,370 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SuperListIterableWrapper; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualOverrideRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaVirtualOverrideJoinColumnRelationshipStrategy - extends AbstractJavaJpaContextNode - implements JavaVirtualJoinColumnRelationshipStrategy -{ - protected final ContextListContainer<JavaVirtualJoinColumn, ReadOnlyJoinColumn> specifiedJoinColumnContainer; - protected final JavaReadOnlyJoinColumn.Owner joinColumnOwner; - - protected JavaVirtualJoinColumn defaultJoinColumn; - - - public GenericJavaVirtualOverrideJoinColumnRelationshipStrategy(JavaVirtualOverrideRelationship parent) { - super(parent); - this.joinColumnOwner = this.buildJoinColumnOwner(); - this.specifiedJoinColumnContainer = this.buildSpecifiedJoinColumnContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.updateSpecifiedJoinColumns(); - this.updateDefaultJoinColumn(); - } - - - // ********** join columns ********** - - public ListIterable<JavaVirtualJoinColumn> getJoinColumns() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns(); - } - - public int getJoinColumnsSize() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize(); - } - - - // ********** specified join columns ********** - - public ListIterable<JavaVirtualJoinColumn> getSpecifiedJoinColumns() { - return this.specifiedJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedJoinColumnsSize() { - return this.specifiedJoinColumnContainer.getContextElementsSize(); - } - - public boolean hasSpecifiedJoinColumns() { - return this.getSpecifiedJoinColumnsSize() != 0; - } - - public JavaVirtualJoinColumn getSpecifiedJoinColumn(int index) { - return this.specifiedJoinColumnContainer.getContextElement(index); - } - - protected void updateSpecifiedJoinColumns() { - this.specifiedJoinColumnContainer.update(); - } - - protected ListIterable<ReadOnlyJoinColumn> getOverriddenSpecifiedJoinColumns() { - ReadOnlyJoinColumnRelationshipStrategy overriddenStrategy = this.getOverriddenStrategy(); - return (overriddenStrategy == null) ? - EmptyListIterable.<ReadOnlyJoinColumn>instance() : - new SuperListIterableWrapper<ReadOnlyJoinColumn>(overriddenStrategy.getSpecifiedJoinColumns()); - } - - /** - * specified join column container - */ - protected class SpecifiedJoinColumnContainer - extends ContextListContainer<JavaVirtualJoinColumn, ReadOnlyJoinColumn> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_JOIN_COLUMNS_LIST; - } - @Override - protected JavaVirtualJoinColumn buildContextElement(ReadOnlyJoinColumn resourceElement) { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.buildJoinColumn(resourceElement); - } - @Override - protected ListIterable<ReadOnlyJoinColumn> getResourceElements() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getOverriddenSpecifiedJoinColumns(); - } - @Override - protected ReadOnlyJoinColumn getResourceElement(JavaVirtualJoinColumn contextElement) { - return contextElement.getOverriddenColumn(); - } - } - - protected JavaReadOnlyJoinColumn.Owner buildJoinColumnOwner() { - return new JoinColumnOwner(); - } - - protected ContextListContainer<JavaVirtualJoinColumn, ReadOnlyJoinColumn> buildSpecifiedJoinColumnContainer(){ - return new SpecifiedJoinColumnContainer(); - } - - - // ********** default join column ********** - - public JavaVirtualJoinColumn getDefaultJoinColumn() { - return this.defaultJoinColumn; - } - - protected void setDefaultJoinColumn(JavaVirtualJoinColumn joinColumn) { - JavaVirtualJoinColumn old = this.defaultJoinColumn; - this.defaultJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn); - } - - protected ListIterable<JavaVirtualJoinColumn> getDefaultJoinColumns() { - return (this.defaultJoinColumn != null) ? - new SingleElementListIterable<JavaVirtualJoinColumn>(this.defaultJoinColumn) : - EmptyListIterable.<JavaVirtualJoinColumn>instance(); - } - - protected int getDefaultJoinColumnsSize() { - return (this.defaultJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultJoinColumn() { - ReadOnlyJoinColumn overriddenDefaultJoinColumn = this.getOverriddenDefaultJoinColumn(); - if (overriddenDefaultJoinColumn == null) { - if (this.defaultJoinColumn != null) { - this.setDefaultJoinColumn(null); - } - } else { - if ((this.defaultJoinColumn != null) && (this.defaultJoinColumn.getOverriddenColumn() == overriddenDefaultJoinColumn)) { - this.defaultJoinColumn.update(); - } else { - this.setDefaultJoinColumn(this.buildJoinColumn(overriddenDefaultJoinColumn)); - } - } - } - - protected ReadOnlyJoinColumn getOverriddenDefaultJoinColumn() { - ReadOnlyJoinColumnRelationshipStrategy overriddenStrategy = this.getOverriddenStrategy(); - return (overriddenStrategy == null) ? null : overriddenStrategy.getDefaultJoinColumn(); - } - - - // ********** misc ********** - - @Override - public JavaVirtualOverrideRelationship getParent() { - return (JavaVirtualOverrideRelationship) super.getParent(); - } - - public JavaVirtualOverrideRelationship getRelationship() { - return this.getParent(); - } - - protected ReadOnlyJoinColumnRelationshipStrategy getOverriddenStrategy() { - ReadOnlyJoinColumnRelationship relationship = this.getOverriddenJoinColumnRelationship(); - return (relationship == null) ? null : relationship.getJoinColumnStrategy(); - } - - protected ReadOnlyJoinColumnRelationship getOverriddenJoinColumnRelationship() { - ReadOnlyRelationship relationship = this.resolveOverriddenRelationship(); - return (relationship instanceof ReadOnlyJoinColumnRelationship) ? (ReadOnlyJoinColumnRelationship) relationship : null; - } - - protected ReadOnlyRelationship resolveOverriddenRelationship() { - return this.getRelationship().resolveOverriddenRelationship(); - } - - public boolean isTargetForeignKey() { - RelationshipMapping relationshipMapping = this.getRelationshipMapping(); - return (relationshipMapping != null) && - relationshipMapping.getRelationship().isTargetForeignKey(); - } - - public TypeMapping getRelationshipSource() { - return this.isTargetForeignKey() ? - // relationship mapping is not null - this.getRelationshipMapping().getResolvedTargetEntity() : - this.getRelationship().getTypeMapping(); - } - - public TypeMapping getRelationshipTarget() { - return this.isTargetForeignKey() ? - this.getRelationship().getTypeMapping() : - // relationship mapping may still be null - this.getRelationshipMappingTargetEntity(); - } - - protected TypeMapping getRelationshipMappingTargetEntity() { - RelationshipMapping mapping = this.getRelationshipMapping(); - return (mapping == null) ? null : mapping.getResolvedTargetEntity(); - } - - protected Entity getRelationshipTargetEntity() { - TypeMapping target = this.getRelationshipTarget(); - return (target instanceof Entity) ? (Entity) target : null; - } - - protected RelationshipMapping getRelationshipMapping() { - return this.getRelationship().getMapping(); - } - - public String getTableName() { - return this.isTargetForeignKey() ? - this.getTargetDefaultTableName() : - this.getRelationship().getDefaultTableName(); - } - - protected String getTargetDefaultTableName() { - TypeMapping typeMapping = this.getRelationshipMapping().getResolvedTargetEntity(); - return (typeMapping == null) ? null : typeMapping.getPrimaryTableName(); - } - - protected Table resolveDbTable(String tableName) { - return this.isTargetForeignKey() ? - this.resolveTargetDbTable(tableName) : - this.getRelationship().resolveDbTable(tableName); - } - - protected Table resolveTargetDbTable(String tableName) { - TypeMapping typeMapping = this.getRelationshipMapping().getResolvedTargetEntity(); - return (typeMapping == null) ? null : typeMapping.resolveDbTable(tableName); - } - - protected boolean tableNameIsInvalid(String tableName) { - return this.isTargetForeignKey() ? - this.targetTableNameIsInvalid(tableName) : - this.getRelationship().tableNameIsInvalid(tableName); - } - - protected boolean targetTableNameIsInvalid(String tableName) { - TypeMapping typeMapping = this.getRelationshipMapping().getResolvedTargetEntity(); - return (typeMapping != null) && typeMapping.tableNameIsInvalid(tableName); - } - - protected Table getReferencedColumnDbTable() { - TypeMapping relationshipTarget = this.getRelationshipTarget(); - return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable(); - } - - protected Iterable<String> getCandidateTableNames() { - return this.isTargetForeignKey() ? - this.getTargetCandidateTableNames() : - this.getRelationship().getCandidateTableNames(); - } - - protected Iterable<String> getTargetCandidateTableNames() { - TypeMapping typeMapping = this.getRelationshipMapping().getResolvedTargetEntity(); - return (typeMapping != null) ? typeMapping.getAllAssociatedTableNames() : EmptyIterable.<String>instance(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getRelationship().getValidationTextRange(astRoot); - } - - protected String getAttributeName() { - return this.getRelationship().getAttributeName(); - } - - protected JavaVirtualJoinColumn buildJoinColumn(ReadOnlyJoinColumn overriddenJoinColumn) { - return this.getJpaFactory().buildJavaVirtualJoinColumn(this, this.joinColumnOwner, overriddenJoinColumn); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - for (JavaVirtualJoinColumn joinColumn : this.getJoinColumns()) { - joinColumn.validate(messages, reporter, astRoot); - } - } - - - // ********** join column owner ********** - - protected class JoinColumnOwner - implements JavaReadOnlyJoinColumn.Owner - { - protected JoinColumnOwner() { - super(); - } - - public String getDefaultTableName() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getTableName(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return MappingTools.buildJoinColumnDefaultName((ReadOnlyJoinColumn) column, this); - } - - public String getAttributeName() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getAttributeName(); - } - - public Entity getRelationshipTarget() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity(); - } - - public boolean tableNameIsInvalid(String tableName) { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.resolveDbTable(tableName); - } - - public Table getReferencedColumnDbTable() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getReferencedColumnDbTable(); - } - - public int getJoinColumnsSize() { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getJoinColumnsSize(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getValidationTextRange(astRoot); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.this.getRelationship().buildColumnValidator((ReadOnlyBaseColumn) column, this, (TableColumnTextRangeResolver) textRangeResolver); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java deleted file mode 100644 index 073d0ca591..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.OverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.Relationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappingRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaVirtualOverrideRelationship2_0; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaVirtualOverrideRelationship - extends AbstractJavaJpaContextNode - implements JavaVirtualOverrideRelationship2_0 -{ - protected JavaVirtualRelationshipStrategy strategy; - - protected final JavaVirtualJoinColumnRelationshipStrategy joinColumnStrategy; - - // JPA 2.0 - protected final JavaVirtualJoinTableRelationshipStrategy joinTableStrategy; - - - public GenericJavaVirtualOverrideRelationship(JavaVirtualAssociationOverride parent) { - super(parent); - this.joinColumnStrategy = this.buildJoinColumnStrategy(); - this.joinTableStrategy = this.buildJoinTableStrategy(); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.setStrategy(this.buildStrategy()); - this.joinColumnStrategy.update(); - this.joinTableStrategy.update(); - } - - - // ********** strategy ********** - - public JavaVirtualRelationshipStrategy getStrategy() { - return this.strategy; - } - - protected void setStrategy(JavaVirtualRelationshipStrategy strategy) { - JavaVirtualRelationshipStrategy old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - protected JavaVirtualRelationshipStrategy buildStrategy() { - return this.isJpa2_0Compatible() ? - this.buildStrategy2_0() : - this.joinColumnStrategy; - } - - /** - * The overridden mapping determines the override's strategy. - */ - protected JavaVirtualRelationshipStrategy buildStrategy2_0() { - MappingRelationshipStrategy2_0 mappingStrategy = this.getMappingStrategy(); - return (mappingStrategy != null) ? - (JavaVirtualRelationshipStrategy) mappingStrategy.selectOverrideStrategy(this) : - this.buildMissingMappingStrategy(); - } - - /** - * Get the strategy from the overridden mapping. - */ - protected MappingRelationshipStrategy2_0 getMappingStrategy() { - RelationshipMapping mapping = this.getMapping(); - return (mapping == null) ? null : (MappingRelationshipStrategy2_0) mapping.getRelationship().getStrategy(); - } - - /** - * Return the strategy to use when the override's name does not match the - * name of an appropriate relationship mapping. - */ - protected JavaVirtualRelationshipStrategy buildMissingMappingStrategy() { - return this.joinColumnStrategy.hasSpecifiedJoinColumns() ? - this.joinColumnStrategy : - this.joinTableStrategy; - } - - - // ********** join column strategy ********** - - public JavaVirtualJoinColumnRelationshipStrategy getJoinColumnStrategy() { - return this.joinColumnStrategy; - } - - public boolean strategyIsJoinColumn() { - return this.strategy == this.joinColumnStrategy; - } - - public boolean mayHaveDefaultJoinColumn() { - // association overrides do not have defaults - return false; - } - - protected JavaVirtualJoinColumnRelationshipStrategy buildJoinColumnStrategy() { - return new GenericJavaVirtualOverrideJoinColumnRelationshipStrategy(this); - } - - - // ********** join table strategy ********** - - public JavaVirtualJoinTableRelationshipStrategy getJoinTableStrategy() { - return this.joinTableStrategy; - } - - public boolean strategyIsJoinTable() { - return this.strategy == this.joinTableStrategy; - } - - public boolean mayHaveDefaultJoinTable() { - // association overrides do not have defaults - return false; - } - - protected JavaVirtualJoinTableRelationshipStrategy buildJoinTableStrategy() { - return new GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0(this); - } - - - // ********** conversions ********** - - public void initializeOn(Relationship newRelationship) { - newRelationship.initializeFromJoinTableRelationship(this); - newRelationship.initializeFromJoinColumnRelationship(this); - } - - public void initializeOnSpecified(OverrideRelationship specifiedRelationship) { - specifiedRelationship.initializeFromVirtualJoinColumnRelationship(this); - specifiedRelationship.initializeFromVirtualJoinTableRelationship(this); - } - - - // ********** misc ********** - - @Override - public JavaVirtualAssociationOverride getParent() { - return (JavaVirtualAssociationOverride) super.getParent(); - } - - protected JavaVirtualAssociationOverride getAssociationOverride() { - return this.getParent(); - } - - protected ReadOnlyAssociationOverride2_0 getAssociationOverride2_0() { - return (ReadOnlyAssociationOverride2_0) this.getAssociationOverride(); - } - - public TypeMapping getTypeMapping() { - return this.getAssociationOverride().getTypeMapping(); - } - - public String getAttributeName() { - return this.getAssociationOverride().getName(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getAssociationOverride().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getAssociationOverride().getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return this.getAssociationOverride().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getAssociationOverride().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride().buildColumnValidator(column, owner, textRangeResolver); - } - - public Entity getEntity() { - TypeMapping typeMapping = this.getTypeMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - public boolean isVirtual() { - return true; - } - - public RelationshipMapping getMapping() { - return this.getAssociationOverride().getMapping(); - } - - public ReadOnlyRelationship resolveOverriddenRelationship() { - return this.getAssociationOverride().resolveOverriddenRelationship(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getAssociationOverride().getValidationTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.strategy.validate(messages, reporter, astRoot); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableValidator(table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java deleted file mode 100644 index 0b5c080248..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaVirtualUniqueConstraint; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaReadOnlyUniqueConstraint; - -public class GenericJavaVirtualUniqueConstraint - extends AbstractJavaReadOnlyUniqueConstraint - implements JavaVirtualUniqueConstraint -{ - protected final ReadOnlyUniqueConstraint overriddenUniqueConstraint; - - - public GenericJavaVirtualUniqueConstraint(JavaJpaContextNode parent, ReadOnlyUniqueConstraint overriddenUniqueConstraint) { - super(parent); - this.overriddenUniqueConstraint = overriddenUniqueConstraint; - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.syncColumnNames(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getParent().getValidationTextRange(astRoot); - } - - - // ********** misc ********** - - public ReadOnlyUniqueConstraint getOverriddenUniqueConstraint() { - return this.overriddenUniqueConstraint; - } - - @Override - protected Iterable<String> getResourceColumnNames() { - return this.overriddenUniqueConstraint.getColumnNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaElementCollectionTemporalConverterValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaElementCollectionTemporalConverterValidator.java deleted file mode 100644 index 981ebaf258..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaElementCollectionTemporalConverterValidator.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.BaseTemporalConverter; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AbstractTemporalConverterValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.ConverterTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0; - -public class JavaElementCollectionTemporalConverterValidator extends AbstractTemporalConverterValidator -{ - - public JavaElementCollectionTemporalConverterValidator(BaseTemporalConverter converter, ConverterTextRangeResolver textRangeResolver) { - super(converter, textRangeResolver); - } - - @Override - protected JavaElementCollectionMapping2_0 getAttributeMapping() { - return (JavaElementCollectionMapping2_0) super.getAttributeMapping(); - } - @Override - protected String getTypeName() { - return this.getAttributeMapping().getFullyQualifiedTargetClass(); - } - - @Override - protected String getInvalidTemporalMappingType() { - return JpaValidationMessages.PERSISTENT_ATTRIBUTE_ELEMENT_COLLECTION_INVALID_VALUE_TYPE; - } - - @Override - protected String getVirtualAttributeInvalidTemporalMappingType() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_INVALID_VALUE_TYPE; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaTemporalConverterValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaTemporalConverterValidator.java deleted file mode 100644 index fa5ddd6626..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/JavaTemporalConverterValidator.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jpt.jpa.core.context.BaseTemporalConverter; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AbstractTemporalConverterValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.ConverterTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; - -public class JavaTemporalConverterValidator extends AbstractTemporalConverterValidator -{ - - public JavaTemporalConverterValidator(BaseTemporalConverter converter, ConverterTextRangeResolver textRangeResolver) { - super(converter, textRangeResolver); - } - - @Override - protected String getTypeName() { - return this.getPersistentAttribute().getTypeName(); - } - - @Override - protected String getInvalidTemporalMappingType() { - return JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_TEMPORAL_MAPPING_TYPE; - } - - @Override - protected String getVirtualAttributeInvalidTemporalMappingType() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_INVALID_TEMPORAL_MAPPING_TYPE; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java deleted file mode 100644 index 90d1ba4ff9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.resource.java.Annotation; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaConverter; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; - -public class NullJavaConverter - extends AbstractJavaJpaContextNode - implements JavaConverter -{ - public NullJavaConverter(JavaAttributeMapping parent) { - super(parent); - } - - @Override - public JavaAttributeMapping getParent() { - return (JavaAttributeMapping) super.getParent(); - } - - public Class<? extends Converter> getType() { - return null; - } - - public Annotation getConverterAnnotation() { - return null; - } - - public void dispose() { - // NOP - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getParent().getValidationTextRange(astRoot); - } -} 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 deleted file mode 100644 index df7fd609dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaMappingJoinColumnRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Used by - * {@link org.eclipse.jpt.jpa.core.internal.context.java.GenericJavaOneToManyRelationship#buildJoinColumnStrategy()} - * in a JPA 1.0 project. - */ -public class NullJavaJoinColumnRelationshipStrategy - extends AbstractJavaJpaContextNode - implements JavaMappingJoinColumnRelationshipStrategy2_0 -{ - public NullJavaJoinColumnRelationshipStrategy(JavaJoinColumnRelationship parent) { - super(parent); - } - - - // ********** join columns ********** - - public ListIterable<JavaJoinColumn> getJoinColumns() { - return EmptyListIterable.<JavaJoinColumn>instance(); - } - - public int getJoinColumnsSize() { - return 0; - } - - - // ********** specified join columns ********** - - public ListIterable<JavaJoinColumn> getSpecifiedJoinColumns() { - return EmptyListIterable.<JavaJoinColumn>instance(); - } - - public int getSpecifiedJoinColumnsSize() { - return 0; - } - - public boolean hasSpecifiedJoinColumns() { - return false; - } - - public JavaJoinColumn getSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public JavaJoinColumn addSpecifiedJoinColumn() { - throw new UnsupportedOperationException(); - } - - public JavaJoinColumn addSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void removeSpecifiedJoinColumn(JoinColumn joinColumn) { - throw new UnsupportedOperationException(); - } - - public void removeSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - - // ********** default join column ********** - - public JavaJoinColumn getDefaultJoinColumn() { - return null; - } - - - // ********** misc ********** - - @Override - public JavaJoinColumnRelationship getParent() { - return (JavaJoinColumnRelationship) super.getParent(); - } - - public JavaJoinColumnRelationship getRelationship() { - return this.getParent(); - } - - protected RelationshipMapping getRelationshipMapping() { - return this.getRelationship().getMapping(); - } - - public String getTableName() { - return null; - } - - public TypeMapping getRelationshipSource() { - return this.getRelationshipMapping().getTypeMapping(); - } - - public TypeMapping getRelationshipTarget() { - return null; - } - - public boolean isTargetForeignKey() { - return false; - } - - public void initializeFrom(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) { - // NOP - } - - public void initializeFromVirtual(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) { - // NOP - } - - public ReadOnlyRelationshipStrategy selectOverrideStrategy(ReadOnlyOverrideRelationship2_0 overrideRelationship) { - return null; - } - - public void addStrategy() { - // NOP - } - - public void removeStrategy() { - // NOP - } - - public boolean isOverridable() { - return false; - } - - public boolean tableNameIsInvalid(String tableName) { - return true; - } - - public Table resolveDbTable(String tableName) { - return null; - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getRelationship().getValidationTextRange(astRoot); - } - - public String getColumnTableNotValidDescription() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java deleted file mode 100644 index 547a93fa4c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable; -import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaMappingJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.jpa.db.Table; - -public class NullJavaJoinTableRelationshipStrategy - extends AbstractJavaJpaContextNode - implements JavaMappingJoinTableRelationshipStrategy2_0 -{ - public NullJavaJoinTableRelationshipStrategy(JavaJoinTableRelationship parent) { - super(parent); - } - - - // ********** join table ********** - - public JavaJoinTable getJoinTable() { - return null; - } - - public JoinTableAnnotation getJoinTableAnnotation() { - return null; - } - - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getRelationship().getValidationTextRange(astRoot); - } - - - // ********** misc ********** - - @Override - public JavaJoinTableRelationship getParent() { - return (JavaJoinTableRelationship) super.getParent(); - } - - public JavaJoinTableRelationship getRelationship() { - return this.getParent(); - } - - public void initializeFrom(ReadOnlyJoinTableRelationshipStrategy oldStrategy) { - // NOP - } - - public void initializeFromVirtual(ReadOnlyJoinTableRelationshipStrategy virtualStrategy) { - // NOP - } - - public String getTableName() { - return null; - } - - public Table resolveDbTable(String tableName) { - return null; - } - - public boolean tableNameIsInvalid(String tableName) { - return true; - } - - public String getColumnTableNotValidDescription() { - return null; - } - - public String getJoinTableDefaultName() { - return null; - } - - public ReadOnlyRelationshipStrategy selectOverrideStrategy(ReadOnlyOverrideRelationship2_0 overrideRelationship) { - return null; - } - - public void addStrategy() { - // NOP - } - - public void removeStrategy() { - // NOP - } - - public boolean isOverridable() { - return false; - } - - public boolean validatesAgainstDatabase() { - return false; - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException(); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java deleted file mode 100644 index d4457f3730..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmConverter; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.ConverterTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public abstract class AbstractOrmConverter - extends AbstractOrmXmlContextNode - implements OrmConverter -{ - protected final OrmConverter.Owner owner; - - protected AbstractOrmConverter(OrmAttributeMapping parent, OrmConverter.Owner owner) { - super(parent); - this.owner = owner; - } - - protected OrmConverter.Owner getOwner() { - return this.owner; - } - - // ********** misc ********** - - @Override - public OrmAttributeMapping getParent() { - return (OrmAttributeMapping) super.getParent(); - } - - protected OrmAttributeMapping getAttributeMapping() { - return this.getParent(); - } - - protected XmlAttributeMapping getXmlAttributeMapping() { - return this.getAttributeMapping().getXmlAttributeMapping(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.owner.buildValidator(this, this.buildConverterTextRangeResolver()).validate(messages, reporter); - } - - - protected ConverterTextRangeResolver buildConverterTextRangeResolver() { - return new ConverterTextRangeResolver() { - public TextRange getConverterTextRange() { - return getValidationTextRange(); - } - }; - } - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlValidationTextRange(); - return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(); - } - - protected abstract TextRange getXmlValidationTextRange(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedIdMapping.java deleted file mode 100644 index e022e8d385..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedIdMapping.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.io.Serializable; -import java.util.List; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jpt.common.core.internal.utility.JDTTools; -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBaseEmbeddedMapping; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.EmbeddedIdMapping2_0; -import org.eclipse.jpt.jpa.core.resource.orm.Attributes; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddedId; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> embedded ID mapping - */ -public abstract class AbstractOrmEmbeddedIdMapping<X extends XmlEmbeddedId> - extends AbstractOrmBaseEmbeddedMapping<X> - implements EmbeddedIdMapping2_0, OrmEmbeddedIdMapping -{ - /* JPA 2.0 - the embedded id may be derived from a relationship */ - protected boolean derived; - - - protected AbstractOrmEmbeddedIdMapping(OrmPersistentAttribute parent, X xmlMapping) { - super(parent, xmlMapping); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.setMappedByRelationship(this.buildDerived()); - } - - - // ********** derived ********** - - public boolean isDerived() { - return this.derived; - } - - protected void setMappedByRelationship(boolean derived) { - boolean old = this.derived; - this.derived = derived; - this.firePropertyChanged(DERIVED_PROPERTY, old, derived); - } - - protected boolean buildDerived() { - return this.isJpa2_0Compatible() && this.buildDerived_(); - } - - protected boolean buildDerived_() { - return this.getTypeMapping().attributeIsDerivedId(this.name); - } - - - // ********** misc ********** - - public String getKey() { - return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY; - } - - public int getXmlSequence() { - return 10; - } - - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmEmbeddedIdMapping(this); - } - - public void addXmlAttributeMappingTo(Attributes xmlAttributes) { - xmlAttributes.getEmbeddedIds().add(this.xmlAttributeMapping); - } - - public void removeXmlAttributeMappingFrom(Attributes xmlAttributes) { - xmlAttributes.getEmbeddedIds().remove(this.xmlAttributeMapping); - } - - @Override - protected Iterable<String> getEmbeddableOverridableAttributeMappingNames() { - return this.derived ? - EmptyIterable.<String>instance() : - super.getEmbeddableOverridableAttributeMappingNames(); - } - - @Override - protected OrmAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() { - return new AttributeOverrideContainerOwner(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - validateMappedByRelationshipAndAttributeOverridesSpecified(messages, reporter); - } - - @Override - protected boolean validateTargetEmbeddable(List<IMessage> messages) { - boolean continueValidating = super.validateTargetEmbeddable(messages); - if (continueValidating) { //targetEmbeddable != null - if (this.getTargetEmbeddable().getJavaResourceType() != null) { - this.validateTargetEmbeddableClass(messages); - } - this.validateNoRelationshipMappingsOnTargetEmbeddable(messages); - } - return true; - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - * {@link #getTargetEmbeddable#getJavaResourceType()} is not null - */ - protected void validateTargetEmbeddableClass(List<IMessage> messages) { - this.validateTargetEmbeddableImplementsEqualsAndHashcode(messages); - this.validateTargetEmbeddableIsPublic(messages); - this.validateTargetEmbeddableImplementsSerializable(messages); - this.validateTargetEmbeddableImplementsNoArgConstructor(messages); - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - */ - protected void validateNoRelationshipMappingsOnTargetEmbeddable(List<IMessage> messages) { - TypeMapping targetEmbeddableTypeMapping = this.getTargetEmbeddable().getPersistentType().getMapping(); - if (targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY).iterator().hasNext() - || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY).iterator().hasNext() - || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY).iterator().hasNext() - || targetEmbeddableTypeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY).iterator().hasNext()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_CLASS_SHOULD_NOT_CONTAIN_RELATIONSHIP_MAPPINGS, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - * {@link #getTargetEmbeddable#getJavaResourceType()} is not null - */ - protected void validateTargetEmbeddableImplementsSerializable(List<IMessage> messages) { - String targetEmbeddableClassName = this.getTargetEmbeddable().getPersistentType().getName(); - IJavaProject javaProject = getJpaProject().getJavaProject(); - if (!JDTTools.typeIsSubType(javaProject, targetEmbeddableClassName, Serializable.class.getName())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_SERIALIZABLE, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - * {@link #getTargetEmbeddable#getJavaResourceType()} is not null - */ - protected void validateTargetEmbeddableIsPublic(List<IMessage> messages) { - if (!this.getTargetEmbeddable().getJavaResourceType().isPublic()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_CLASS_SHOULD_BE_PUBLIC, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - * {@link #getTargetEmbeddable#getJavaResourceType()} is not null - */ - protected void validateTargetEmbeddableImplementsEqualsAndHashcode(List<IMessage> messages) { - JavaResourceType resourceType = this.getTargetEmbeddable().getJavaResourceType(); - if (!resourceType.hasHashCodeMethod() || !resourceType.hasEqualsMethod()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_EQUALS_HASHCODE, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } - - /** - * preconditions: - * {@link #getTargetEmbeddable()} is not null - * {@link #getTargetEmbeddable#getJavaResourceType()} is not null - */ - protected void validateTargetEmbeddableImplementsNoArgConstructor(List<IMessage> messages) { - String targetEmbeddableClassName = this.getTargetEmbeddable().getPersistentType().getName(); - IJavaProject javaProject = getJpaProject().getJavaProject(); - if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, targetEmbeddableClassName)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_CLASS_SHOULD_IMPLEMENT_NO_ARG_CONSTRUCTOR, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } - - protected void validateMappedByRelationshipAndAttributeOverridesSpecified(List<IMessage> messages, IReporter reporter) { - // [JPA 2.0] if the embedded id is mapped by a relationship, then any specified - // attribute overrides are in error - // (in JPA 1.0, this will obviously never be reached) - if (this.derived - && (this.attributeOverrideContainer.getSpecifiedOverridesSize() > 0)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.EMBEDDED_ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_ATTRIBUTE_OVERRIDES_SPECIFIED, - EMPTY_STRING_ARRAY, - this.attributeOverrideContainer, - this.attributeOverrideContainer.getValidationTextRange() - ) - ); - } - } - - - // ********** attribute override container owner ********* - - protected class AttributeOverrideContainerOwner - extends AbstractOrmBaseEmbeddedMapping<XmlEmbeddedId>.AttributeOverrideContainerOwner - { - @Override - public Iterable<String> getAllOverridableNames() { - return AbstractOrmEmbeddedIdMapping.this.isDerived() ? - EmptyIterable.<String>instance() : - super.getAllOverridableNames(); - } - - /** - * pre-condition: type mapping is not <code>null</code> - */ - @Override - protected Iterable<String> getAllOverridableAttributeNames_(TypeMapping overriddenTypeMapping) { - return new FilteringIterable<String>(super.getAllOverridableAttributeNames_(overriddenTypeMapping)) { - @Override - protected boolean accept(String attributeName) { - return ! AttributeOverrideContainerOwner.this.getTypeMapping().attributeIsDerivedId(attributeName); - } - }; - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java deleted file mode 100644 index a1cb23f604..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmEmbeddedMapping.java +++ /dev/null @@ -1,325 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper; -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.AssociationOverride; -import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.AttributeMapping; -import org.eclipse.jpt.jpa.core.context.OverrideContainer; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.Relationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBaseEmbeddedMapping; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinTableValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideValidator; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmEmbeddedMapping2_0; -import org.eclipse.jpt.jpa.core.resource.orm.Attributes; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbedded; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> embedded mapping - */ -public abstract class AbstractOrmEmbeddedMapping<X extends XmlEmbedded> - extends AbstractOrmBaseEmbeddedMapping<X> - implements OrmEmbeddedMapping2_0 -{ - protected final OrmAssociationOverrideContainer associationOverrideContainer; - - - protected AbstractOrmEmbeddedMapping(OrmPersistentAttribute parent, X xmlMapping) { - super(parent, xmlMapping); - this.associationOverrideContainer = this.buildAssociationOverrideContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.associationOverrideContainer.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.associationOverrideContainer.update(); - } - - - // ********** association override container ********** - - public OrmAssociationOverrideContainer getAssociationOverrideContainer() { - return this.associationOverrideContainer; - } - - protected OrmAssociationOverrideContainer buildAssociationOverrideContainer() { - return this.isOrmXml2_0Compatible() ? - this.getContextNodeFactory2_0().buildOrmAssociationOverrideContainer(this, this.buildAssociationOverrideContainerOwner()) : - new GenericOrmAssociationOverrideContainer(this, null); - } - - protected OrmAssociationOverrideContainer2_0.Owner buildAssociationOverrideContainerOwner() { - return new AssociationOverrideContainerOwner(); - } - - - // ********** embedded mappings ********** - - /** - * This is only to build the choices for a "mapped by" setting in a - * relationship mapping. JPA 2.0 does not support relationship mappings - * in an embedded ID class; so we only put this logic here. - */ - @Override - @SuppressWarnings("unchecked") - public Iterable<String> getAllMappingNames() { - return this.isJpa2_0Compatible() ? - new CompositeIterable<String>(super.getAllMappingNames(), this.getAllEmbeddableAttributeMappingNames()) : - super.getAllMappingNames(); - } - - protected Iterable<String> getAllEmbeddableAttributeMappingNames() { - return this.getQualifiedEmbeddableOverridableMappingNames(AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER); - } - - protected Iterable<RelationshipMapping> allOverridableAssociations() { - return (this.targetEmbeddable != null) ? - new SubIterableWrapper<AttributeMapping, RelationshipMapping>(this.getAllOverridableAssociations_()) : - EmptyIterable.<RelationshipMapping>instance(); - } - - protected Iterable<AttributeMapping> getAllOverridableAssociations_() { - return new FilteringIterable<AttributeMapping>(this.targetEmbeddable.getAttributeMappings()) { - @Override - protected boolean accept(AttributeMapping attributeMapping) { - return attributeMapping.isOverridableAssociationMapping(); - } - }; - } - - @Override - public AttributeMapping resolveAttributeMapping(String attributeName) { - AttributeMapping resolvedMapping = super.resolveAttributeMapping(attributeName); - if (resolvedMapping != null) { - return resolvedMapping; - } - return this.isJpa2_0Compatible() ? this.resolveAttributeMapping_(attributeName) : null; - } - - protected AttributeMapping resolveAttributeMapping_(String attributeName) { - attributeName = this.unqualify(attributeName); - if (attributeName == null) { - return null; - } - // recurse into the embeddable mappings - for (AttributeMapping mapping : this.getEmbeddableAttributeMappings()) { - AttributeMapping resolvedMapping = mapping.resolveAttributeMapping(attributeName); - if (resolvedMapping != null) { - return resolvedMapping; - } - } - return null; - } - - - // ********** misc ********** - - public String getKey() { - return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; - } - - public int getXmlSequence() { - return 80; - } - - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmEmbeddedMapping(this); - } - - public void addXmlAttributeMappingTo(Attributes xmlAttributes) { - xmlAttributes.getEmbeddeds().add(this.xmlAttributeMapping); - } - - public void removeXmlAttributeMappingFrom(Attributes xmlAttributes) { - xmlAttributes.getEmbeddeds().remove(this.xmlAttributeMapping); - } - - @Override - public Relationship resolveOverriddenRelationship(String attributeName) { - return this.isJpa2_0Compatible() ? this.resolveOverriddenRelationship_(attributeName) : null; - } - - protected Relationship resolveOverriddenRelationship_(String attributeName) { - attributeName = this.unqualify(attributeName); - if (attributeName == null) { - return null; - } - AssociationOverride override = this.associationOverrideContainer.getSpecifiedOverrideNamed(attributeName); - // recurse into the target embeddable if necessary - return (override != null) ? override.getRelationship() : this.resolveOverriddenRelationshipInTargetEmbeddable(attributeName); - } - - protected Relationship resolveOverriddenRelationshipInTargetEmbeddable(String attributeName) { - return (this.targetEmbeddable == null) ? null : this.targetEmbeddable.resolveOverriddenRelationship(attributeName); - } - - @Override - protected OrmAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() { - return new AttributeOverrideContainerOwner(); - } - - - // ********** validation ********** - - @Override - protected void validateOverrides(List<IMessage> messages, IReporter reporter) { - super.validateOverrides(messages, reporter); - this.associationOverrideContainer.validate(messages, reporter); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.associationOverrideContainer.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } - - // ********** attribute override container owner ********* - - protected class AttributeOverrideContainerOwner - extends AbstractOrmBaseEmbeddedMapping<XmlEmbedded>.AttributeOverrideContainerOwner - { - // nothing yet - } - - - // ********** association override container owner ********** - - protected class AssociationOverrideContainerOwner - implements OrmAssociationOverrideContainer2_0.Owner - { - protected String getMappingName() { - return AbstractOrmEmbeddedMapping.this.getName(); - } - - public OrmTypeMapping getTypeMapping() { - return AbstractOrmEmbeddedMapping.this.getTypeMapping(); - } - - public TypeMapping getOverridableTypeMapping() { - return AbstractOrmEmbeddedMapping.this.getTargetEmbeddable(); - } - - public Iterable<String> getAllOverridableNames() { - TypeMapping typeMapping = this.getOverridableTypeMapping(); - return (typeMapping != null) ? typeMapping.getAllOverridableAssociationNames() : EmptyIterable.<String>instance(); - } - - public Iterable<String> getJavaOverrideNames() { - return null; - } - - public EList<XmlAssociationOverride> getXmlOverrides() { - return AbstractOrmEmbeddedMapping.this.getXmlAttributeMapping().getAssociationOverrides(); - } - - public Relationship resolveOverriddenRelationship(String attributeName) { - return MappingTools.resolveOverriddenRelationship(this.getOverridableTypeMapping(), attributeName); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getTypeMapping().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getTypeMapping().getAllAssociatedTableNames(); - } - - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - return this.getTypeMapping().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getTypeMapping().getPrimaryTableName(); - } - - public TextRange getValidationTextRange() { - return AbstractOrmEmbeddedMapping.this.getValidationTextRange(); - } - - public JptValidator buildOverrideValidator(ReadOnlyOverride override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) { - return new AssociationOverrideValidator(this.getPersistentAttribute(), (ReadOnlyAssociationOverride) override, (AssociationOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(ReadOnlyOverride override, ReadOnlyBaseColumn column, ReadOnlyBaseColumn.Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinColumnValidator(this.getPersistentAttribute(), (ReadOnlyAssociationOverride) override, (ReadOnlyJoinColumn) column, (ReadOnlyJoinColumn.Owner) owner, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider()); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinColumnValidator(this.getPersistentAttribute(), override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideInverseJoinColumnValidator(this.getPersistentAttribute(), override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableValidator(ReadOnlyAssociationOverride override, ReadOnlyTable table, TableTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinTableValidator(this.getPersistentAttribute(), override, (ReadOnlyJoinTable) table, textRangeResolver); - } - - protected OrmPersistentAttribute getPersistentAttribute() { - return AbstractOrmEmbeddedMapping.this.getPersistentAttribute(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmNamedDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmNamedDiscriminatorColumn.java deleted file mode 100644 index 62f184befa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmNamedDiscriminatorColumn.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.DiscriminatorType; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmNamedDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyNamedDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmNamedColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlBaseDiscriminatorColumn; - -/** - * <code>orm.xml</code> named discriminator column - */ -public abstract class AbstractOrmNamedDiscriminatorColumn<X extends XmlBaseDiscriminatorColumn, O extends OrmReadOnlyNamedDiscriminatorColumn.Owner> - extends AbstractOrmNamedColumn<X, O> - implements OrmNamedDiscriminatorColumn -{ - protected DiscriminatorType specifiedDiscriminatorType; - protected DiscriminatorType defaultDiscriminatorType; - - protected Integer specifiedLength; - protected int defaultLength; - - - protected AbstractOrmNamedDiscriminatorColumn(XmlContextNode parent, O owner) { - this(parent, owner, null); - } - - protected AbstractOrmNamedDiscriminatorColumn(XmlContextNode parent, O owner, X xmlColumn) { - super(parent, owner, xmlColumn); - this.specifiedDiscriminatorType = this.buildSpecifiedDiscriminatorType(); - this.specifiedLength = this.buildSpecifiedLength(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedDiscriminatorType_(this.buildSpecifiedDiscriminatorType()); - this.setSpecifiedLength_(this.buildSpecifiedLength()); - } - - @Override - public void update() { - super.update(); - this.setDefaultDiscriminatorType(this.buildDefaultDiscriminatorType()); - this.setDefaultLength(this.buildDefaultLength()); - } - - - // ********** discriminator type ********** - - public DiscriminatorType getDiscriminatorType() { - return (this.specifiedDiscriminatorType != null) ? this.specifiedDiscriminatorType : this.defaultDiscriminatorType; - } - - public DiscriminatorType getSpecifiedDiscriminatorType() { - return this.specifiedDiscriminatorType; - } - - public void setSpecifiedDiscriminatorType(DiscriminatorType discriminatorType) { - if (this.valuesAreDifferent(this.specifiedDiscriminatorType, discriminatorType)) { - X xmlColumn = this.getXmlColumnForUpdate(); - this.setSpecifiedDiscriminatorType_(discriminatorType); - xmlColumn.setDiscriminatorType(DiscriminatorType.toOrmResourceModel(discriminatorType)); - this.removeXmlColumnIfUnset(); - } - } - - protected void setSpecifiedDiscriminatorType_(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.specifiedDiscriminatorType; - this.specifiedDiscriminatorType = discriminatorType; - this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - protected DiscriminatorType buildSpecifiedDiscriminatorType() { - X xmlColumn = this.getXmlColumn(); - return (xmlColumn == null) ? null : DiscriminatorType.fromOrmResourceModel(xmlColumn.getDiscriminatorType()); - } - - public DiscriminatorType getDefaultDiscriminatorType() { - return this.defaultDiscriminatorType; - } - - protected void setDefaultDiscriminatorType(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.defaultDiscriminatorType; - this.defaultDiscriminatorType = discriminatorType; - this.firePropertyChanged(DEFAULT_DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - protected DiscriminatorType buildDefaultDiscriminatorType() { - return this.owner.getDefaultDiscriminatorType(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength; - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - public void setSpecifiedLength(Integer length) { - if (this.valuesAreDifferent(this.specifiedLength, length)) { - X xmlColumn = this.getXmlColumnForUpdate(); - this.setSpecifiedLength_(length); - xmlColumn.setLength(length); - this.removeXmlColumnIfUnset(); - } - } - - protected void setSpecifiedLength_(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - X xmlColumn = this.getXmlColumn(); - return (xmlColumn == null) ? null : xmlColumn.getLength(); - } - - public int getDefaultLength() { - return this.defaultLength; - } - - protected void setDefaultLength(int defaultLength) { - int old = this.defaultLength; - this.defaultLength = defaultLength; - this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, defaultLength); - } - - protected int buildDefaultLength() { - return this.owner.getDefaultLength(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java deleted file mode 100644 index 93c19b4866..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverride; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOverride; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Specified <code>orm.xml</code> override - */ -public abstract class AbstractOrmOverride<C extends OrmOverrideContainer, X extends XmlOverride> - extends AbstractOrmXmlContextNode - implements OrmOverride -{ - protected final X xmlOverride; - - protected String name; - - - protected AbstractOrmOverride(C parent, X xmlOverride) { - super(parent); - this.xmlOverride = xmlOverride; - this.name = xmlOverride.getName(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setName_(this.xmlOverride.getName()); - } - - - // ********** name ********** - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.setName_(name); - this.xmlOverride.setName(name); - } - - protected void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - - // ********** specified/virtual ********** - - public boolean isVirtual() { - return false; - } - - public OrmVirtualOverride convertToVirtual() { - return this.getContainer().convertOverrideToVirtual(this); - } - - - // ********** misc ********** - - @Override - @SuppressWarnings("unchecked") - public C getParent() { - return (C) super.getParent(); - } - - protected C getContainer() { - return this.getParent(); - } - - public X getXmlOverride() { - return this.xmlOverride; - } - - protected void initializeFrom(ReadOnlyOverride oldOverride) { - this.setName(oldOverride.getName()); - } - - protected void initializeFromVirtual(ReadOnlyOverride virtualOverride) { - this.setName(virtualOverride.getName()); - } - - public TypeMapping getTypeMapping() { - return this.getContainer().getTypeMapping(); - } - - public Table resolveDbTable(String tableName) { - return this.getContainer().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getContainer().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, column, owner, textRangeResolver); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.buildValidator().validate(messages, reporter); - } - - protected JptValidator buildValidator() { - return this.getContainer().buildOverrideValidator(this, this.buildTextRangeResolver()); - } - - protected OverrideTextRangeResolver buildTextRangeResolver() { - return new OrmOverrideTextRangeResolver(this); - } - - /** - * @see AbstractOrmOverrideContainer#getValidationTextRange() - */ - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlOverride.getValidationTextRange(); - // skip the container since it really doesn't have a text range - // (also, this prevents a stack overflow) - return (textRange != null) ? textRange : this.getContainer().getParent().getValidationTextRange(); - } - - public TextRange getNameTextRange() { - return this.getValidationTextRange(this.xmlOverride.getNameTextRange()); - } - - - public boolean tableNameIsInvalid(String tableName) { - return this.getContainer().tableNameIsInvalid(tableName); - } - - - public Iterable<String> getCandidateTableNames() { - return this.getContainer().getCandidateTableNames(); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.nameTouches(pos)) { - return this.getCandidateNames(); - } - return null; - } - - protected boolean nameTouches(int pos) { - return this.xmlOverride.nameTouches(pos); - } - - protected Iterable<String> getCandidateNames() { - return this.getContainer().getAllOverridableNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java deleted file mode 100644 index 038e1f2e30..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java +++ /dev/null @@ -1,491 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import java.util.Vector; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.jpa.core.context.Override_; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.VirtualOverride; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverride; -import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOverride; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> override container - */ -public abstract class AbstractOrmOverrideContainer< - O extends OrmOverrideContainer.Owner, - R extends OrmReadOnlyOverride, - S extends OrmOverride, - V extends OrmVirtualOverride, - X extends XmlOverride - > - extends AbstractOrmXmlContextNode - implements OrmOverrideContainer -{ - // this can be null if the container is "read-only" (i.e. a "null" container) - protected final O owner; - - protected final Vector<S> specifiedOverrides = new Vector<S>(); - protected final SpecifiedOverrideContainerAdapter specifiedOverrideContainerAdapter = new SpecifiedOverrideContainerAdapter(); - - protected final Vector<V> virtualOverrides = new Vector<V>(); - protected final VirtualOverrideContainerAdapter virtualOverrideContainerAdapter = new VirtualOverrideContainerAdapter(); - - - protected AbstractOrmOverrideContainer(XmlContextNode parent, O owner) { - super(parent); - this.owner = owner; - this.initializeSpecifiedOverrides(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedOverrides(); - // the virtual overrides do not need a sync - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedOverrides()); - this.updateVirtualOverrides(); - } - - - // ********** overrides ********** - - @SuppressWarnings("unchecked") - public ListIterable<R> getOverrides() { - return new CompositeListIterable<R>(this.getReadOnlySpecifiedOverrides(), this.getReadOnlyVirtualOverrides()); - } - - public int getOverridesSize() { - return this.specifiedOverrides.size() + this.virtualOverrides.size(); - } - - public R getOverrideNamed(String name) { - return this.selectOverrideNamed(this.getOverrides(), name); - } - - - // ********** override conversions ********** - - /** - * <em>Silently</em> add the new virtual override before removing the - * specified override, or the <em>update</em> will discover the missing - * virtual override and add it preemptively. - */ - public V convertOverrideToVirtual(Override_ override) { - if (override.isVirtual()) { - throw new IllegalArgumentException("Override is already virtual: " + override); //$NON-NLS-1$ - } - - @SuppressWarnings("unchecked") - S specifiedOverride = (S) override; - int virtualIndex = this.virtualOverrides.size(); - String overrideName = specifiedOverride.getName(); - V virtualOverride = null; - // make sure the specified override actually overrides something before building the virtual override - if (this.overrideWillBeVirtual(overrideName, specifiedOverride)) { - virtualOverride = this.buildVirtualOverride(overrideName); - this.virtualOverrides.add(virtualIndex, virtualOverride); - } - - this.removeSpecifiedOverride(specifiedOverride); // trigger update - - if (virtualOverride != null) { - this.fireItemAdded(VIRTUAL_OVERRIDES_LIST, virtualIndex, virtualOverride); - } - return virtualOverride; - } - - /** - * Return whether the specified override name will be a - * <em>virtual</em> override when the specified specified override is - * removed from the container. The override name must be among the - * valid override names and it must not correspond to any of the - * remaining specified overrides. - */ - protected boolean overrideWillBeVirtual(String overrideName, S specifiedOverrideToBeRemoved) { - return CollectionTools.contains(this.getPossibleVirtualOverrideNames(), overrideName) && - (this.getSpecifiedOverrideNamed(overrideName, specifiedOverrideToBeRemoved) == null); - } - - /** - * <em>Silently</em> remove the virtual override and add the new specified - * override before naming the specified override, or the <em>update</em> - * will discover the dangling virtual override and remove it preemptively. - */ - public S convertOverrideToSpecified(VirtualOverride override) { - if ( ! override.isVirtual()) { - throw new IllegalArgumentException("Override is already specified: " + override); //$NON-NLS-1$ - } - - @SuppressWarnings("unchecked") - V virtualOverride = (V) override; - int virtualIndex = this.virtualOverrides.indexOf(virtualOverride); - this.virtualOverrides.remove(virtualIndex); - - int specifiedIndex = this.specifiedOverrides.size(); - X xmlOverride = this.buildXmlOverride(); - S specifiedOverride = this.buildSpecifiedOverride(xmlOverride); - this.specifiedOverrides.add(specifiedIndex, specifiedOverride); - this.owner.getXmlOverrides().add(specifiedIndex, xmlOverride); - - this.initializeSpecifiedOverride(specifiedOverride, virtualOverride); // trigger update - - this.fireItemRemoved(VIRTUAL_OVERRIDES_LIST, virtualIndex, virtualOverride); - this.fireItemAdded(SPECIFIED_OVERRIDES_LIST, specifiedIndex, specifiedOverride); - return specifiedOverride; - } - - protected abstract void initializeSpecifiedOverride(S specifiedOverride, V virtualOverride); - - - // ********** specified overrides ********** - - public ListIterable<S> getSpecifiedOverrides() { - return new LiveCloneListIterable<S>(this.specifiedOverrides); - } - - @SuppressWarnings("unchecked") - protected ListIterable<R> getReadOnlySpecifiedOverrides() { - // S should always be a subtype of R, but we can't enforce that in the - // class declaration... - return (ListIterable<R>) this.getSpecifiedOverrides(); - } - - public int getSpecifiedOverridesSize() { - return this.specifiedOverrides.size(); - } - - public S getSpecifiedOverride(int index) { - return this.specifiedOverrides.get(index); - } - - public S getSpecifiedOverrideNamed(String name) { - return this.getSpecifiedOverrideNamed(name, null); - } - - @SuppressWarnings("unchecked") - protected S getSpecifiedOverrideNamed(String name, S exclude) { - return (S) this.selectOverrideNamed(this.getReadOnlySpecifiedOverrides(), name, exclude); - } - - protected S addSpecifiedOverride() { - return this.addSpecifiedOverride(this.specifiedOverrides.size()); - } - - protected S addSpecifiedOverride(int index) { - X xmlOverride = this.buildXmlOverride(); - S override = this.addSpecifiedOverride_(index, xmlOverride); - this.owner.getXmlOverrides().add(index, xmlOverride); - return override; - } - - protected abstract X buildXmlOverride(); - - protected void removeSpecifiedOverride(S override) { - this.removeSpecifiedOverride(this.specifiedOverrides.indexOf(override)); - } - - protected void removeSpecifiedOverride(int index) { - this.removeSpecifiedOverride_(index); - this.owner.getXmlOverrides().remove(index); - } - - protected void removeSpecifiedOverride_(int index) { - this.removeItemFromList(index, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - } - - public void moveSpecifiedOverride(int targetIndex, int sourceIndex) { - this.moveItemInList(targetIndex, sourceIndex, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - this.owner.getXmlOverrides().move(targetIndex, sourceIndex); - } - - protected void initializeSpecifiedOverrides() { - for (X xmlOverride : this.getXmlOverrides()) { - this.specifiedOverrides.add(this.buildSpecifiedOverride(xmlOverride)); - } - } - - protected abstract S buildSpecifiedOverride(X xmlOverride); - - protected void syncSpecifiedOverrides() { - ContextContainerTools.synchronizeWithResourceModel(this.specifiedOverrideContainerAdapter); - } - - protected Iterable<X> getXmlOverrides() { - return (this.owner == null) ? EmptyIterable.<X>instance() : this.getXmlOverrides_(); - } - - /** - * pre-condition: {@link #owner} is not <code>null</code> - */ - protected abstract Iterable<X> getXmlOverrides_(); - - protected void moveSpecifiedOverride_(int index, S override) { - this.moveItemInList(index, override, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - } - - protected S addSpecifiedOverride_(int index, X xmlOverride) { - S override = this.buildSpecifiedOverride(xmlOverride); - this.addItemToList(index, override, this.specifiedOverrides, SPECIFIED_OVERRIDES_LIST); - return override; - } - - protected void removeSpecifiedOverride_(S override) { - this.removeSpecifiedOverride_(this.specifiedOverrides.indexOf(override)); - } - - /** - * specified override container adapter - */ - protected class SpecifiedOverrideContainerAdapter - implements ContextContainerTools.Adapter<S, X> - { - public Iterable<S> getContextElements() { - return AbstractOrmOverrideContainer.this.getSpecifiedOverrides(); - } - public Iterable<X> getResourceElements() { - return AbstractOrmOverrideContainer.this.getXmlOverrides(); - } - @SuppressWarnings("unchecked") - public X getResourceElement(S contextElement) { - return (X) contextElement.getXmlOverride(); - } - public void moveContextElement(int index, S element) { - AbstractOrmOverrideContainer.this.moveSpecifiedOverride_(index, element); - } - public void addContextElement(int index, X resourceElement) { - AbstractOrmOverrideContainer.this.addSpecifiedOverride_(index, resourceElement); - } - public void removeContextElement(S element) { - AbstractOrmOverrideContainer.this.removeSpecifiedOverride_(element); - } - } - - - // ********** virtual overrides ********** - - public ListIterable<V> getVirtualOverrides() { - return new LiveCloneListIterable<V>(this.virtualOverrides); - } - - @SuppressWarnings("unchecked") - protected ListIterable<R> getReadOnlyVirtualOverrides() { - // V should always be a subtype of R, but we can't enforce that in the - // class declaration... - return (ListIterable<R>) this.getVirtualOverrides(); - } - - public int getVirtualOverridesSize() { - return this.virtualOverrides.size(); - } - - protected void updateVirtualOverrides() { - ContextContainerTools.update(this.virtualOverrideContainerAdapter); - } - - /** - * Return the overridable names that are not already in the list of - * specified overrides. - */ - protected Iterable<String> getVirtualOverrideNames() { - return new FilteringIterable<String>(this.getPossibleVirtualOverrideNames()) { - @Override - protected boolean accept(String name) { - return AbstractOrmOverrideContainer.this.overrideIsVirtual(name); - } - }; - } - - protected boolean overrideIsVirtual(String name) { - return this.getSpecifiedOverrideNamed(name) == null; - } - - protected void moveVirtualOverride(int index, V override) { - this.moveItemInList(index, override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - } - - protected V addVirtualOverride(int index, String name) { - V override = this.buildVirtualOverride(name); - this.addItemToList(index, override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - return override; - } - - protected abstract V buildVirtualOverride(String name); - - protected void removeVirtualOverride(V override) { - this.removeItemFromList(override, this.virtualOverrides, VIRTUAL_OVERRIDES_LIST); - } - - /** - * virtual override container adapter - * NB: the context override is matched with a resource override by name - */ - protected class VirtualOverrideContainerAdapter - implements ContextContainerTools.Adapter<V, String> - { - public Iterable<V> getContextElements() { - return AbstractOrmOverrideContainer.this.getVirtualOverrides(); - } - public Iterable<String> getResourceElements() { - return AbstractOrmOverrideContainer.this.getVirtualOverrideNames(); - } - public String getResourceElement(V contextElement) { - return contextElement.getName(); - } - public void moveContextElement(int index, V element) { - AbstractOrmOverrideContainer.this.moveVirtualOverride(index, element); - } - public void addContextElement(int index, String resourceElement) { - AbstractOrmOverrideContainer.this.addVirtualOverride(index, resourceElement); - } - public void removeContextElement(V element) { - AbstractOrmOverrideContainer.this.removeVirtualOverride(element); - } - } - - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } - - public TypeMapping getOverridableTypeMapping() { - return this.owner.getOverridableTypeMapping(); - } - - public TypeMapping getTypeMapping() { - return this.owner.getTypeMapping(); - } - - /** - * Return all the possible virtual override names. If we have a - * corresponding Java entity, take the override names from it. This allows - * us to include any Java specified overrides that are invalid (and - * generate the appropriate error messages). If we don't have a - * corresponding Java entity, take the override names directly from the - * type. - */ - protected Iterable<String> getPossibleVirtualOverrideNames() { - if (this.owner == null) { - return EmptyIterable.instance(); - } - Iterable<String> javaNames = this.owner.getJavaOverrideNames(); - return (javaNames != null) ? javaNames : this.owner.getAllOverridableNames(); - } - - public Iterable<String> getAllOverridableNames() { - return (this.owner != null) ? this.owner.getAllOverridableNames() : EmptyIterable.<String>instance(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.owner.tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.owner.getCandidateTableNames(); - } - - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - return this.owner.resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.owner.getDefaultTableName(); - } - - public JptValidator buildOverrideValidator(ReadOnlyOverride override, OverrideTextRangeResolver textRangeResolver) { - return this.owner.buildOverrideValidator(override, this, textRangeResolver); - } - - public JptValidator buildColumnValidator(ReadOnlyOverride override, ReadOnlyBaseColumn column, ReadOnlyBaseColumn.Owner columnOwner, TableColumnTextRangeResolver textRangeResolver) { - return this.owner.buildColumnValidator(override, column, columnOwner, textRangeResolver); - } - - protected R selectOverrideNamed(Iterable<R> overrides, String name) { - return this.selectOverrideNamed(overrides, name, null); - } - - protected R selectOverrideNamed(Iterable<R> overrides, String name, S exclude) { - for (R override : overrides) { - if (override == exclude) { - continue; // skip - } - if (this.valuesAreEqual(override.getName(), name)) { - return override; - } - } - return null; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - for (R override : this.getOverrides()) { - override.validate(messages, reporter); - } - } - - public TextRange getValidationTextRange() { - return (this.specifiedOverrides.size() > 0) ? - this.specifiedOverrides.get(0).getValidationTextRange() : - this.owner.getValidationTextRange(); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - for (R override : this.getOverrides()) { - result = override.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java deleted file mode 100644 index 0e7ab51c70..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitDefaults.java +++ /dev/null @@ -1,397 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistenceUnitDefaults2_0; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitDefaults; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.db.Catalog; -import org.eclipse.jpt.jpa.db.Database; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.SchemaContainer; - -/** - * <code>orm.xml</code> file - * <br> - * <code>persistence-unit-defaults</code> element - */ -public abstract class AbstractOrmPersistenceUnitDefaults - extends AbstractOrmXmlContextNode - implements OrmPersistenceUnitDefaults2_0 -{ - protected AccessType specifiedAccess; - - protected String specifiedCatalog; - protected String defaultCatalog; - - protected String specifiedSchema; - protected String defaultSchema; - - protected boolean cascadePersist; - - protected boolean delimitedIdentifiers; - - - // ********** constructor/initialization ********** - - protected AbstractOrmPersistenceUnitDefaults(OrmPersistenceUnitMetadata parent) { - super(parent); - this.specifiedAccess = this.buildSpecifiedAccess(); - this.specifiedCatalog = this.buildSpecifiedCatalog(); - this.specifiedSchema = this.buildSpecifiedSchema(); - this.cascadePersist = this.buildCascadePersist(); - this.delimitedIdentifiers = this.buildDelimitedIdentifiers(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedAccess_(this.buildSpecifiedAccess()); - this.setSpecifiedCatalog_(this.buildSpecifiedCatalog()); - this.setSpecifiedSchema_(this.buildSpecifiedSchema()); - this.setCascadePersist_(this.buildCascadePersist()); - this.setDelimitedIdentifiers_(this.buildDelimitedIdentifiers()); - } - - @Override - public void update() { - super.update(); - this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setDefaultSchema(this.buildDefaultSchema()); - } - - - // ********** access ********** - - public AccessType getAccess() { - return this.getSpecifiedAccess(); - } - - public AccessType getDefaultAccess() { - return null; - } - - public AccessType getSpecifiedAccess() { - return this.specifiedAccess; - } - - public void setSpecifiedAccess(AccessType access) { - if (this.valuesAreDifferent(this.specifiedAccess, access)) { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaultsForUpdate(); - this.setSpecifiedAccess_(access); - xmlDefaults.setAccess(AccessType.toOrmResourceModel(access)); - this.removeXmlDefaultsIfUnset(); - } - } - - protected void setSpecifiedAccess_(AccessType access) { - AccessType old = this.specifiedAccess; - this.specifiedAccess = access; - this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, access); - } - - protected AccessType buildSpecifiedAccess() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? null : AccessType.fromOrmResourceModel(xmlDefaults.getAccess(), this.getJpaPlatform(), this.getResourceType()); - } - - - // ********** schema container ********** - - /** - * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog), - * then the database probably does not support catalogs; and we need to - * get the schema directly from the database. - */ - public SchemaContainer getDbSchemaContainer() { - String catalog = this.getCatalog(); - return (catalog != null) ? this.resolveDbCatalog(catalog) : this.getDatabase(); - } - - - // ********** catalog ********** - - public String getCatalog() { - return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog; - } - - public String getSpecifiedCatalog() { - return this.specifiedCatalog; - } - - public void setSpecifiedCatalog(String catalog) { - if (this.valuesAreDifferent(this.specifiedCatalog, catalog)) { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaultsForUpdate(); - this.setSpecifiedCatalog_(catalog); - xmlDefaults.setCatalog(catalog); - this.removeXmlDefaultsIfUnset(); - } - } - - protected void setSpecifiedCatalog_(String catalog) { - String old = this.specifiedCatalog; - this.specifiedCatalog = catalog; - this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog); - } - - protected String buildSpecifiedCatalog() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? null : xmlDefaults.getCatalog(); - } - - public String getDefaultCatalog() { - return this.defaultCatalog; - } - - protected void setDefaultCatalog(String catalog) { - String old = this.defaultCatalog; - this.defaultCatalog = catalog; - this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog); - } - - protected String buildDefaultCatalog() { - return this.getJpaProject().getDefaultCatalog(); - } - - /** - * If we don't have a catalog (i.e. we don't even have a <em>default</em> - * catalog), then the database probably does not support catalogs. - */ - public Catalog getDbCatalog() { - String catalog = this.getCatalog(); - return (catalog == null) ? null : this.resolveDbCatalog(catalog); - } - - - // ********** schema ********** - - public String getSchema() { - return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema; - } - - public String getSpecifiedSchema() { - return this.specifiedSchema; - } - - public void setSpecifiedSchema(String schema) { - if (this.valuesAreDifferent(this.specifiedSchema, schema)) { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaultsForUpdate(); - this.setSpecifiedSchema_(schema); - xmlDefaults.setSchema(schema); - this.removeXmlDefaultsIfUnset(); - } - } - - protected void setSpecifiedSchema_(String schema) { - String old = this.specifiedSchema; - this.specifiedSchema = schema; - this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema); - } - - protected String buildSpecifiedSchema() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? null : xmlDefaults.getSchema(); - } - - public String getDefaultSchema() { - return this.defaultSchema; - } - - protected void setDefaultSchema(String schema) { - String old = this.defaultSchema; - this.defaultSchema = schema; - this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema); - } - - protected String buildDefaultSchema() { - return this.getJpaProject().getDefaultSchema(); - } - - public Schema getDbSchema() { - SchemaContainer dbSchemaContainer = this.getDbSchemaContainer(); - return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema()); - } - - - // ********** cascade persist ********** - - public boolean isCascadePersist() { - return this.cascadePersist; - } - - public void setCascadePersist(boolean cascadePersist) { - if (this.cascadePersist != cascadePersist) { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaultsForUpdate(); - this.setCascadePersist_(cascadePersist); - xmlDefaults.setCascadePersist(cascadePersist); - this.removeXmlDefaultsIfUnset(); - } - } - - protected void setCascadePersist_(boolean cascadePersist) { - boolean old = this.cascadePersist; - this.cascadePersist = cascadePersist; - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, cascadePersist); - } - - protected boolean buildCascadePersist() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? false : xmlDefaults.isCascadePersist(); - } - - - // ********** delimited identifiers ********** - - public boolean isDelimitedIdentifiers() { - return this.delimitedIdentifiers; - } - - public void setDelimitedIdentifiers(boolean delimitedIdentifiers) { - if (this.delimitedIdentifiers != delimitedIdentifiers) { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaultsForUpdate(); - this.setDelimitedIdentifiers_(delimitedIdentifiers); - xmlDefaults.setDelimitedIdentifiers(delimitedIdentifiers); - this.removeXmlDefaultsIfUnset(); - } - } - - protected void setDelimitedIdentifiers_(boolean di) { - boolean old = this.delimitedIdentifiers; - this.delimitedIdentifiers = di; - this.firePropertyChanged(DELIMITED_IDENTIFIERS_PROPERTY, old, di); - } - - protected boolean buildDelimitedIdentifiers() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? false : xmlDefaults.isDelimitedIdentifiers(); - } - - - // ********** XML defaults ********** - - /** - * Return <code>null</code> if the XML defaults does not exist. - */ - protected XmlPersistenceUnitDefaults getXmlDefaults() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata == null) ? null : xmlMetadata.getPersistenceUnitDefaults(); - } - - protected XmlPersistenceUnitMetadata getXmlPersistenceUnitMetadata() { - return this.getPersistenceUnitMetadata().getXmlPersistenceUnitMetadata(); - } - - /** - * Build the XML defaults (and XML metadata if necessary) if it does not exist. - */ - protected XmlPersistenceUnitDefaults getXmlDefaultsForUpdate() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadataForUpdate(); - XmlPersistenceUnitDefaults xmlDefaults = xmlMetadata.getPersistenceUnitDefaults(); - return (xmlDefaults != null) ? xmlDefaults : this.buildXmlDefaults(xmlMetadata); - } - - protected XmlPersistenceUnitMetadata getXmlPersistenceUnitMetadataForUpdate() { - return this.getPersistenceUnitMetadata().getXmlPersistenceUnitMetadataForUpdate(); - } - - protected XmlPersistenceUnitDefaults buildXmlDefaults(XmlPersistenceUnitMetadata xmlMetadata) { - XmlPersistenceUnitDefaults xmlDefaults = this.buildXmlPersistenceUnitDefaults(); - xmlMetadata.setPersistenceUnitDefaults(xmlDefaults); - return xmlDefaults; - } - - protected abstract XmlPersistenceUnitDefaults buildXmlPersistenceUnitDefaults(); - - /** - * clear the XML defaults (and the XML metadata) if appropriate - */ - protected void removeXmlDefaultsIfUnset() { - if (this.getXmlDefaults().isUnset()) { - this.getXmlPersistenceUnitMetadata().setPersistenceUnitDefaults(null); - this.removeXmlPersistenceUnitMetadataIfUnset(); - } - } - - protected void removeXmlPersistenceUnitMetadataIfUnset() { - this.getPersistenceUnitMetadata().removeXmlPersistenceUnitMetadataIfUnset(); - } - - - // ********** misc ********** - - @Override - public OrmPersistenceUnitMetadata getParent() { - return (OrmPersistenceUnitMetadata) super.getParent(); - } - - public OrmPersistenceUnitMetadata getPersistenceUnitMetadata() { - return this.getParent(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlTextRange(); - return (textRange != null) ? textRange : this.getPersistenceUnitMetadata().getValidationTextRange(); - } - - protected TextRange getXmlTextRange() { - XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults == null) ? null : xmlDefaults.getValidationTextRange(); - } - - // ********** completion proposals ********* - - @Override - protected Iterable<String> getConnectedXmlCompletionProposals(int pos) { - Iterable<String> result = super.getConnectedXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.schemaTouches(pos)) { - return this.getCandidateSchemata(); - } - if (this.catalogTouches(pos)) { - return this.getCandidateCatalogs(); - } - return null; - } - - // ********** content assist: schema - - protected boolean schemaTouches(int pos) { - return (this.getXmlDefaults() != null) && this.getXmlDefaults().schemaTouches(pos); - } - - protected Iterable<String> getCandidateSchemata() { - SchemaContainer schemaContainer = this.getDbSchemaContainer(); - return (schemaContainer != null) ? schemaContainer.getSortedSchemaIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** content assist: catalog - - protected boolean catalogTouches(int pos) { - return (this.getXmlDefaults() != null) && this.getXmlDefaults().catalogTouches(pos); - } - - protected Iterable<String> getCandidateCatalogs() { - Database db = this.getDatabase(); - return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java deleted file mode 100644 index a7bd86e6ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmPersistenceUnitMetadata.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitDefaults; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistenceUnitMetadata2_0; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitMetadata; - -/** - * <code>orm.xml</code> file - * <br> - * <code>persistence-unit-metadata</code> element - */ -public abstract class AbstractOrmPersistenceUnitMetadata - extends AbstractOrmXmlContextNode - implements OrmPersistenceUnitMetadata2_0 -{ - protected boolean xmlMappingMetadataComplete; - - protected String description; - - // never null - protected final OrmPersistenceUnitDefaults persistenceUnitDefaults; - - - protected AbstractOrmPersistenceUnitMetadata(EntityMappings parent) { - super(parent); - this.xmlMappingMetadataComplete = this.buildXmlMappingMetadataComplete(); - this.description = this.buildDescription(); - this.persistenceUnitDefaults = this.buildPersistenceUnitDefaults(); - } - - protected OrmPersistenceUnitDefaults buildPersistenceUnitDefaults() { - return this.getContextNodeFactory().buildOrmPersistenceUnitDefaults(this); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setXmlMappingMetadataComplete_(this.buildXmlMappingMetadataComplete()); - this.setDescription_(this.buildDescription()); - this.persistenceUnitDefaults.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.persistenceUnitDefaults.update(); - } - - - // ********** XML metadata ********** - - /** - * Return <code>null</code> if the XML metadata does not exist. - */ - public XmlPersistenceUnitMetadata getXmlPersistenceUnitMetadata() { - return this.getXmlEntityMappings().getPersistenceUnitMetadata(); - } - - /** - * Build the XML metadata if it does not exist. - */ - public XmlPersistenceUnitMetadata getXmlPersistenceUnitMetadataForUpdate() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata != null) ? xmlMetadata : this.buildXmlPersistenceUnitMetadata(); - } - - protected XmlPersistenceUnitMetadata buildXmlPersistenceUnitMetadata() { - XmlPersistenceUnitMetadata xmlMetadata = this.buildXmlPersistenceUnitMetadata_(); - this.getXmlEntityMappings().setPersistenceUnitMetadata(xmlMetadata); - return xmlMetadata; - } - - protected abstract XmlPersistenceUnitMetadata buildXmlPersistenceUnitMetadata_(); - - public void removeXmlPersistenceUnitMetadataIfUnset() { - if (this.getXmlPersistenceUnitMetadata().isUnset()) { - this.getXmlEntityMappings().setPersistenceUnitMetadata(null); - } - } - - - // ********** XML mapping metadata complete ********** - - public boolean isXmlMappingMetadataComplete() { - return this.xmlMappingMetadataComplete; - } - - public void setXmlMappingMetadataComplete(boolean xmlMappingMetadataComplete) { - if (this.xmlMappingMetadataComplete != xmlMappingMetadataComplete) { - XmlPersistenceUnitMetadata xmlPersistenceUnitMetadata = this.getXmlPersistenceUnitMetadataForUpdate(); - this.setXmlMappingMetadataComplete_(xmlMappingMetadataComplete); - xmlPersistenceUnitMetadata.setXmlMappingMetadataComplete(xmlMappingMetadataComplete); - this.removeXmlPersistenceUnitMetadataIfUnset(); - } - } - - protected void setXmlMappingMetadataComplete_(boolean xmlMappingMetadataComplete) { - boolean old = this.xmlMappingMetadataComplete; - this.xmlMappingMetadataComplete = xmlMappingMetadataComplete; - this.firePropertyChanged(XML_MAPPING_METADATA_COMPLETE_PROPERTY, old, xmlMappingMetadataComplete); - } - - protected boolean buildXmlMappingMetadataComplete() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata != null) ? xmlMetadata.isXmlMappingMetadataComplete() : false; - } - - - // ********** description ********** - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - if (this.valuesAreDifferent(this.description, description)) { - XmlPersistenceUnitMetadata xmlPersistenceUnitMetadata = this.getXmlPersistenceUnitMetadataForUpdate(); - this.setDescription_(description); - xmlPersistenceUnitMetadata.setDescription(description); - this.removeXmlPersistenceUnitMetadataIfUnset(); - } - } - - protected void setDescription_(String description) { - String old = this.description; - this.description = description; - this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description); - } - - protected String buildDescription() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata == null) ? null : xmlMetadata.getDescription(); - } - - - // ********** persistence unit defaults ********** - - public OrmPersistenceUnitDefaults getPersistenceUnitDefaults() { - return this.persistenceUnitDefaults; - } - - - // ********** misc ********** - - @Override - public EntityMappings getParent() { - return (EntityMappings) super.getParent(); - } - - protected EntityMappings getEntityMappings() { - return this.getParent(); - } - - public XmlEntityMappings getXmlEntityMappings() { - return this.getEntityMappings().getXmlEntityMappings(); - } - - public boolean resourceExists() { - return this.getXmlPersistenceUnitMetadata() != null; - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlTextRange(); - return (textRange != null) ? textRange : this.getEntityMappings().getValidationTextRange(); - } - - protected TextRange getXmlTextRange() { - XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata == null) ? null : xmlMetadata.getValidationTextRange(); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.persistenceUnitDefaults.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java deleted file mode 100644 index 2a46f57e60..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverride; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOverrideTextRangeResolver; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Virtual <code>orm.xml</code> override - */ -public abstract class AbstractOrmVirtualOverride<C extends OrmOverrideContainer> - extends AbstractOrmXmlContextNode - implements OrmVirtualOverride -{ - protected final String name; // never null - - - protected AbstractOrmVirtualOverride(C parent, String name) { - super(parent); - this.name = name; - } - - public String getName() { - return this.name; - } - - public boolean isVirtual() { - return true; - } - - public OrmOverride convertToSpecified() { - return this.getContainer().convertOverrideToSpecified(this); - } - - @Override - @SuppressWarnings("unchecked") - public C getParent() { - return (C) super.getParent(); - } - - protected C getContainer() { - return this.getParent(); - } - - public TypeMapping getTypeMapping() { - return this.getContainer().getTypeMapping(); - } - - public Table resolveDbTable(String tableName) { - return this.getContainer().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getContainer().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, column, owner, textRangeResolver); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.buildValidator().validate(messages, reporter); - } - - protected JptValidator buildValidator() { - return this.getContainer().buildOverrideValidator(this, this.buildTextRangeResolver()); - } - - protected OverrideTextRangeResolver buildTextRangeResolver() { - return new OrmOverrideTextRangeResolver(this); - } - - public TextRange getValidationTextRange() { - return this.getContainer().getValidationTextRange(); - } - - public TextRange getNameTextRange() { - return this.getValidationTextRange(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getContainer().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getContainer().getCandidateTableNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericEntityMappings.java deleted file mode 100644 index a6ae9ee62b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericEntityMappings.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractEntityMappings; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings; - -/** - * <code>orm.xml</code> file - * <br> - * <code>entity-mappings</code> element - */ -public class GenericEntityMappings - extends AbstractEntityMappings -{ - public GenericEntityMappings(OrmXml parent, XmlEntityMappings resource) { - super(parent, resource); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java deleted file mode 100644 index af85f006d0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverride.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideRelationship; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Specified <code>orm.xml</code> association override - */ -public class GenericOrmAssociationOverride - extends AbstractOrmOverride<OrmAssociationOverrideContainer, XmlAssociationOverride> - implements OrmAssociationOverride2_0 -{ - protected final OrmOverrideRelationship relationship; - - - public GenericOrmAssociationOverride(OrmAssociationOverrideContainer parent, XmlAssociationOverride xmlOverride) { - super(parent, xmlOverride); - this.relationship = this.buildRelationship(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.relationship.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.relationship.update(); - } - - - // ********** specified/virtual ********** - - @Override - public OrmVirtualAssociationOverride convertToVirtual() { - return (OrmVirtualAssociationOverride) super.convertToVirtual(); - } - - - // ********** relationship ********** - - public OrmOverrideRelationship getRelationship() { - return this.relationship; - } - - protected OrmOverrideRelationship buildRelationship() { - return this.getContextNodeFactory().buildOrmOverrideRelationship(this); - } - - - // ********** misc ********** - - protected OrmAssociationOverrideContainer2_0 getContainer2_0() { - return (OrmAssociationOverrideContainer2_0) this.getContainer(); - } - - public RelationshipMapping getMapping() { - return this.getContainer().getRelationshipMapping(this.name); - } - - public void initializeFrom(ReadOnlyAssociationOverride oldOverride) { - super.initializeFrom(oldOverride); - this.relationship.initializeFrom(oldOverride.getRelationship()); - } - - public void initializeFromVirtual(ReadOnlyAssociationOverride virtualOverride) { - super.initializeFromVirtual(virtualOverride); - this.relationship.initializeFromVirtual(virtualOverride.getRelationship()); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.relationship.validate(messages, reporter); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableValidator(this, table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableJoinColumnValidator(this, column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableInverseJoinColumnValidator(this, column, owner, textRangeResolver); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.relationship.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverrideContainer.java deleted file mode 100644 index f0d01182d3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAssociationOverrideContainer.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTable; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyAssociationOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride; - -/** - * <code>orm.xml</code> association override container - */ -public class GenericOrmAssociationOverrideContainer - extends AbstractOrmOverrideContainer< - OrmAssociationOverrideContainer.Owner, - OrmReadOnlyAssociationOverride, - OrmAssociationOverride, - OrmVirtualAssociationOverride, - XmlAssociationOverride - > - implements OrmAssociationOverrideContainer2_0 -{ - public GenericOrmAssociationOverrideContainer(XmlContextNode parent, OrmAssociationOverrideContainer.Owner owner) { - super(parent, owner); - } - - - public RelationshipMapping getRelationshipMapping(String attributeName) { - return MappingTools.getRelationshipMapping(attributeName, this.owner.getOverridableTypeMapping()); - } - - public ReadOnlyRelationship resolveOverriddenRelationship(String associationOverrideName) { - return this.owner.resolveOverriddenRelationship(associationOverrideName); - } - - protected OrmAssociationOverrideContainer2_0.Owner getOwner2_0() { - return (OrmAssociationOverrideContainer2_0.Owner) this.owner; - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner columnOwner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableJoinColumnValidator(override, column, columnOwner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyAssociationOverride override, ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner columnOwner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableInverseJoinColumnValidator(override, column, columnOwner, textRangeResolver); - } - - public JptValidator buildJoinTableValidator(ReadOnlyAssociationOverride override, ReadOnlyTable table, TableTextRangeResolver textRangeResolver) { - return this.getOwner2_0().buildJoinTableValidator(override, table, textRangeResolver); - } - - @Override - protected Iterable<XmlAssociationOverride> getXmlOverrides_() { - // clone to reduce chance of concurrency problems - return new LiveCloneIterable<XmlAssociationOverride>(this.owner.getXmlOverrides()); - } - - @Override - protected XmlAssociationOverride buildXmlOverride() { - return OrmFactory.eINSTANCE.createXmlAssociationOverride(); - } - - @Override - protected OrmAssociationOverride buildSpecifiedOverride(XmlAssociationOverride xmlOverride) { - return this.getContextNodeFactory().buildOrmAssociationOverride(this, xmlOverride); - } - - @Override - protected void initializeSpecifiedOverride(OrmAssociationOverride specifiedOverride, OrmVirtualAssociationOverride virtualOverride) { - specifiedOverride.initializeFromVirtual(virtualOverride); - } - - @Override - protected OrmVirtualAssociationOverride buildVirtualOverride(String name) { - return this.getContextNodeFactory().buildOrmVirtualAssociationOverride(this, name); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java deleted file mode 100644 index 22ea7a8b00..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverride.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Specified <code>orm.xml</code> attribute override - */ -public class GenericOrmAttributeOverride - extends AbstractOrmOverride<OrmAttributeOverrideContainer, XmlAttributeOverride> - implements OrmAttributeOverride, OrmColumn.Owner -{ - protected final OrmColumn column; - - - public GenericOrmAttributeOverride(OrmAttributeOverrideContainer parent, XmlAttributeOverride xmlOverride) { - super(parent, xmlOverride); - this.column = this.buildColumn(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.column.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.column.update(); - } - - - // ********** specified/virtual ********** - - @Override - public OrmVirtualAttributeOverride convertToVirtual() { - return (OrmVirtualAttributeOverride) super.convertToVirtual(); - } - - - // ********** column ********** - - public OrmColumn getColumn() { - return this.column; - } - - protected OrmColumn buildColumn() { - return this.getContextNodeFactory().buildOrmColumn(this, this); - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyAttributeOverride oldOverride) { - super.initializeFrom(oldOverride); - this.column.initializeFrom(oldOverride.getColumn()); - } - - public void initializeFromVirtual(ReadOnlyAttributeOverride oldOverride) { - super.initializeFromVirtual(oldOverride); - this.column.initializeFromVirtual(oldOverride.getColumn()); - } - - - // ********** column owner implementation ********** - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return this.name; - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, (ReadOnlyBaseColumn) col, this, (TableColumnTextRangeResolver) textRangeResolver); - } - - public XmlColumn getXmlColumn() { - return this.getXmlOverride().getColumn(); - } - - public XmlColumn buildXmlColumn() { - XmlColumn xmlColumn = OrmFactory.eINSTANCE.createXmlColumn(); - this.getXmlOverride().setColumn(xmlColumn); - return xmlColumn; - } - - public void removeXmlColumn() { - this.getXmlOverride().setColumn(null); - } - - - // ********** mapped by relationship ********** - - protected boolean attributeIsDerivedId() { - return this.getTypeMapping().attributeIsDerivedId(this.name); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - - if (this.attributeIsDerivedId()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ATTRIBUTE_OVERRIDE_DERIVED_AND_SPECIFIED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - - // validate the column if it is specified - if (this.xmlColumnIsSpecified()) { - this.column.validate(messages, reporter); - } - } else { - this.column.validate(messages, reporter); - } - } - - protected boolean xmlColumnIsSpecified() { - return this.getXmlColumn() != null; - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.column.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java deleted file mode 100644 index 6b56484f04..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmAttributeOverrideContainer.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyAttributeOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride; - -/** - * <code>orm.xml</code> attribute override container - */ -public class GenericOrmAttributeOverrideContainer - extends AbstractOrmOverrideContainer< - OrmAttributeOverrideContainer.Owner, - OrmReadOnlyAttributeOverride, - OrmAttributeOverride, - OrmVirtualAttributeOverride, - XmlAttributeOverride - > - implements OrmAttributeOverrideContainer -{ - public GenericOrmAttributeOverrideContainer(XmlContextNode parent, OrmAttributeOverrideContainer.Owner owner) { - super(parent, owner); - } - - - public ReadOnlyColumn resolveOverriddenColumn(String attributeName) { - return (attributeName == null) ? null : this.owner.resolveOverriddenColumn(attributeName); - } - - @Override - protected Iterable<XmlAttributeOverride> getXmlOverrides_() { - // clone to reduce chance of concurrency problems - return new LiveCloneIterable<XmlAttributeOverride>(this.owner.getXmlOverrides()); - } - - @Override - protected XmlAttributeOverride buildXmlOverride() { - return OrmFactory.eINSTANCE.createXmlAttributeOverride(); - } - - @Override - protected OrmAttributeOverride buildSpecifiedOverride(XmlAttributeOverride xmlOverride) { - return this.getContextNodeFactory().buildOrmAttributeOverride(this, xmlOverride); - } - - public void initializeFrom(OrmAttributeOverrideContainer oldContainer) { - for (OrmAttributeOverride oldOverride : oldContainer.getSpecifiedOverrides()) { - this.addSpecifiedOverride().initializeFrom(oldOverride); - } - } - - @Override - protected void initializeSpecifiedOverride(OrmAttributeOverride specifiedOverride, OrmVirtualAttributeOverride virtualOverride) { - specifiedOverride.initializeFromVirtual(virtualOverride); - } - - @Override - protected OrmVirtualAttributeOverride buildVirtualOverride(String name) { - return this.getContextNodeFactory().buildOrmVirtualAttributeOverride(this, name); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseEnumeratedConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseEnumeratedConverter.java deleted file mode 100644 index 915c56d91b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseEnumeratedConverter.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.BaseEnumeratedConverter; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.EnumType; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmBaseEnumeratedConverter; - -public class GenericOrmBaseEnumeratedConverter - extends AbstractOrmConverter - implements OrmBaseEnumeratedConverter -{ - protected EnumType specifiedEnumType; - protected EnumType defaultEnumType; - - - public GenericOrmBaseEnumeratedConverter(OrmAttributeMapping parent, OrmBaseEnumeratedConverter.Owner owner) { - super(parent, owner); - this.specifiedEnumType = this.buildSpecifiedEnumType(); - } - - @Override - protected OrmBaseEnumeratedConverter.Owner getOwner() { - return (OrmBaseEnumeratedConverter.Owner) super.getOwner(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedEnumType_(this.buildSpecifiedEnumType()); - } - - @Override - public void update() { - super.update(); - this.setDefaultEnumType(this.buildDefaultEnumType()); - } - - - // ********** enum type ********** - - public EnumType getEnumType() { - return (this.specifiedEnumType != null) ? this.specifiedEnumType : this.getDefaultEnumType(); - } - - public EnumType getSpecifiedEnumType() { - return this.specifiedEnumType; - } - - public void setSpecifiedEnumType(EnumType enumType) { - this.setSpecifiedEnumType_(enumType); - this.setXmlEnumerated(enumType); - } - - protected void setSpecifiedEnumType_(EnumType enumType) { - EnumType old = this.specifiedEnumType; - this.specifiedEnumType = enumType; - this.firePropertyChanged(SPECIFIED_ENUM_TYPE_PROPERTY, old, enumType); - } - - protected void setXmlEnumerated(EnumType enumType) { - this.getOwner().setXmlEnumType(EnumType.toOrmResourceModel(enumType)); - } - - protected EnumType buildSpecifiedEnumType() { - return EnumType.fromOrmResourceModel(this.getOwner().getXmlEnumType()); - } - - public EnumType getDefaultEnumType() { - return this.defaultEnumType; - } - - protected void setDefaultEnumType(EnumType enumType) { - EnumType old = this.defaultEnumType; - this.defaultEnumType = enumType; - this.firePropertyChanged(DEFAULT_ENUM_TYPE_PROPERTY, old, enumType); - } - - /** - * There is no default enum type in XML. - * If you specify the enumerated element, you must - * specify either {@link EnumType#ORDINAL} or - * {@link EnumType#STRING}. - */ - protected EnumType buildDefaultEnumType() { - return null; - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return BaseEnumeratedConverter.class; - } - - public void initialize() { - this.specifiedEnumType = DEFAULT_ENUM_TYPE; - this.setXmlEnumerated(this.specifiedEnumType); - } - - - // ********** validation ********** - - @Override - protected TextRange getXmlValidationTextRange() { - return this.getOwner().getEnumTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseTemporalConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseTemporalConverter.java deleted file mode 100644 index eeb2a12a30..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBaseTemporalConverter.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.BaseTemporalConverter; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.TemporalType; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmBaseTemporalConverter; -import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter; - -public class GenericOrmBaseTemporalConverter - extends AbstractOrmConverter - implements OrmBaseTemporalConverter -{ - protected TemporalType temporalType; - - public GenericOrmBaseTemporalConverter(OrmAttributeMapping parent, OrmTemporalConverter.Owner owner) { - super(parent, owner); - this.temporalType = this.buildTemporalType(); - } - - @Override - protected OrmTemporalConverter.Owner getOwner() { - return (OrmTemporalConverter.Owner) super.getOwner(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setTemporalType_(this.buildTemporalType()); - } - - - // ********** temporal type ********** - - public TemporalType getTemporalType() { - return this.temporalType; - } - - public void setTemporalType(TemporalType temporalType) { - this.setTemporalType_(temporalType); - this.setXmlTemporal(temporalType); - } - - protected void setTemporalType_(TemporalType temporalType) { - TemporalType old = this.temporalType; - this.temporalType = temporalType; - this.firePropertyChanged(TEMPORAL_TYPE_PROPERTY, old, temporalType); - } - - protected void setXmlTemporal(TemporalType temporalType) { - this.getOwner().setXmlTemporalType(TemporalType.toOrmResourceModel(temporalType)); - } - - protected TemporalType buildTemporalType() { - return TemporalType.fromOrmResourceModel(this.getOwner().getXmlTemporalType()); - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return BaseTemporalConverter.class; - } - - public void initialize() { - // start with DATE(?) - this.temporalType = TemporalType.DATE; - this.setXmlTemporal(this.temporalType); - } - - - // ********** validation ********** - - @Override - protected TextRange getXmlValidationTextRange() { - return this.getOwner().getTemporalTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBasicMapping.java deleted file mode 100644 index 99f763d272..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmBasicMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBasicMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlBasic; - -/** - * <code>orm.xml</code> basic mapping - */ -public class GenericOrmBasicMapping - extends AbstractOrmBasicMapping<XmlBasic> -{ - public GenericOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java deleted file mode 100644 index 76cba3a5c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Cascade; -import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipMapping; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmRelationshipMapping; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.Cascade2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCascade2_0; -import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlRelationshipMapping; -import org.eclipse.jpt.jpa.core.resource.orm.CascadeType; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; - -public class GenericOrmCascade - extends AbstractOrmXmlContextNode - implements OrmCascade2_0 -{ - protected boolean all; - - protected boolean persist; - - protected boolean merge; - - protected boolean remove; - - protected boolean refresh; - - /* JPA 2.0 */ - protected boolean detach; - - - /** - * This is built directly by the mapping implementation; as opposed to via - * a platform-specific factory. - * @see AbstractOrmRelationshipMapping#buildCascade() - */ - public GenericOrmCascade(OrmRelationshipMapping parent) { - super(parent); - this.all = this.buildAll(); - this.persist = this.buildPersist(); - this.merge = this.buildMerge(); - this.remove = this.buildRemove(); - this.refresh = this.buildRefresh(); - this.detach = this.buildDetach(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setAll_(this.buildAll()); - this.setPersist_(this.buildPersist()); - this.setMerge_(this.buildMerge()); - this.setRemove_(this.buildRemove()); - this.setRefresh_(this.buildRefresh()); - this.setDetach_(this.buildDetach()); - } - - - // ********** all ********** - - public boolean isAll() { - return this.all; - } - - public void setAll(boolean all) { - if (this.all != all) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setAll_(all); - xmlCascade.setCascadeAll(all); - this.removeXmlCascadeIfUnset(); - } - } - - protected void setAll_(boolean all) { - boolean old = this.all; - this.all = all; - this.firePropertyChanged(ALL_PROPERTY, old, all); - } - - protected boolean buildAll() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadeAll(); - } - - - // ********** persist ********** - - public boolean isPersist() { - return this.persist; - } - - public void setPersist(boolean persist) { - if (this.persist != persist) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setPersist_(persist); - xmlCascade.setCascadePersist(persist); - this.removeXmlCascadeIfUnset(); - } - } - - protected boolean setPersist_(boolean persist) { - boolean old = this.persist; - this.persist = persist; - return this.firePropertyChanged(PERSIST_PROPERTY, old, persist); - } - - protected boolean buildPersist() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadePersist(); - } - - - // ********** merge ********** - - public boolean isMerge() { - return this.merge; - } - - public void setMerge(boolean merge) { - if (this.merge != merge) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setMerge_(merge); - xmlCascade.setCascadeMerge(merge); - this.removeXmlCascadeIfUnset(); - } - } - - protected boolean setMerge_(boolean merge) { - boolean old = this.merge; - this.merge = merge; - return this.firePropertyChanged(MERGE_PROPERTY, old, merge); - } - - protected boolean buildMerge() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadeMerge(); - } - - - // ********** remove ********** - - public boolean isRemove() { - return this.remove; - } - - public void setRemove(boolean remove) { - if (this.remove != remove) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setRemove_(remove); - xmlCascade.setCascadeRemove(remove); - this.removeXmlCascadeIfUnset(); - } - } - - protected boolean setRemove_(boolean remove) { - boolean old = this.remove; - this.remove = remove; - return this.firePropertyChanged(REMOVE_PROPERTY, old, remove); - } - - protected boolean buildRemove() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadeRemove(); - } - - - // ********** refresh ********** - - public boolean isRefresh() { - return this.refresh; - } - - public void setRefresh(boolean refresh) { - if (this.refresh != refresh) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setRefresh_(refresh); - xmlCascade.setCascadeRefresh(refresh); - this.removeXmlCascadeIfUnset(); - } - } - - protected boolean setRefresh_(boolean refresh) { - boolean old = this.refresh; - this.refresh = refresh; - return this.firePropertyChanged(REFRESH_PROPERTY, old, refresh); - } - - protected boolean buildRefresh() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadeRefresh(); - } - - - // ********** detach ********** - - public boolean isDetach() { - return this.detach; - } - - public void setDetach(boolean detach) { - if (this.detach != detach) { - CascadeType xmlCascade = this.getXmlCascadeForUpdate(); - this.setDetach_(detach); - xmlCascade.setCascadeDetach(detach); - this.removeXmlCascadeIfUnset(); - } - } - - protected boolean setDetach_(boolean detach) { - boolean old = this.detach; - this.detach = detach; - return this.firePropertyChanged(DETACH_PROPERTY, old, detach); - } - - protected boolean buildDetach() { - return this.isJpa2_0Compatible() && this.buildDetach_(); - } - - protected boolean buildDetach_() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) && xmlCascade.isCascadeDetach(); - } - - - // ********** XML cascade ********** - - /** - * Return <code>null</code> if XML cascade does not exists. - */ - protected CascadeType getXmlCascade() { - return this.getXmlRelationshipMapping().getCascade(); - } - - /** - * Build the XML cascade if it does not exist. - */ - protected CascadeType getXmlCascadeForUpdate() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) ? xmlCascade : this.buildXmlCascade(); - } - - protected CascadeType buildXmlCascade() { - CascadeType xmlCascade = OrmFactory.eINSTANCE.createCascadeType(); - this.getXmlRelationshipMapping().setCascade(xmlCascade); - return xmlCascade; - } - - protected void removeXmlCascadeIfUnset() { - if (this.getXmlCascade().isUnset()) { - this.removeXmlCascade(); - } - } - - protected void removeXmlCascade() { - this.getXmlRelationshipMapping().setCascade(null); - } - - - // ********** misc ********** - - @Override - public OrmRelationshipMapping getParent() { - return (OrmRelationshipMapping) super.getParent(); - } - - protected OrmRelationshipMapping getRelationshipMapping() { - return this.getParent(); - } - - protected AbstractXmlRelationshipMapping getXmlRelationshipMapping() { - return this.getRelationshipMapping().getXmlAttributeMapping(); - } - - public void initializeFrom(Cascade oldCascade) { - this.setAll(oldCascade.isAll()); - this.setPersist(oldCascade.isPersist()); - this.setMerge(oldCascade.isMerge()); - this.setRemove(oldCascade.isRemove()); - this.setRefresh(oldCascade.isRefresh()); - if (this.isJpa2_0Compatible()) { - this.setDetach(((Cascade2_0) oldCascade).isDetach()); - } - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlTextRange(); - return (textRange != null) ? textRange : this.getRelationshipMapping().getValidationTextRange(); - } - - protected TextRange getXmlTextRange() { - CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade == null) ? null : xmlCascade.getValidationTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmColumn.java deleted file mode 100644 index 6e254476eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmColumn.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0, which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBaseColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn; - -/** - * <code>orm.xml</code> column - */ -public class GenericOrmColumn - extends AbstractOrmBaseColumn<XmlColumn, OrmColumn.Owner> - implements OrmColumn -{ - // TODO defaults from java for all of these settings - protected Integer specifiedLength; - - protected Integer specifiedPrecision; - - protected Integer specifiedScale; - - - public GenericOrmColumn(XmlContextNode parent, OrmColumn.Owner owner) { - super(parent, owner); - this.specifiedLength = this.buildSpecifiedLength(); - this.specifiedPrecision = this.buildSpecifiedPrecision(); - this.specifiedScale = this.buildSpecifiedScale(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedLength_(this.buildSpecifiedLength()); - this.setSpecifiedPrecision_(this.buildSpecifiedPrecision()); - this.setSpecifiedScale_(this.buildSpecifiedScale()); - } - - - // ********** XML column ********** - - @Override - public XmlColumn getXmlColumn() { - return this.owner.getXmlColumn(); - } - - @Override - protected XmlColumn buildXmlColumn() { - return this.owner.buildXmlColumn(); - } - - @Override - protected void removeXmlColumn() { - this.owner.removeXmlColumn(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.getDefaultLength(); - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - public void setSpecifiedLength(Integer length) { - if (this.valuesAreDifferent(this.specifiedLength, length)) { - XmlColumn xmlColumn = this.getXmlColumnForUpdate(); - this.setSpecifiedLength_(length); - xmlColumn.setLength(length); - this.removeXmlColumnIfUnset(); - } - } - - protected void setSpecifiedLength_(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - XmlColumn xmlColumn = this.getXmlColumn(); - return (xmlColumn == null) ? null : xmlColumn.getLength(); - } - - public int getDefaultLength() { - return DEFAULT_LENGTH; - } - - - // ********** precision ********** - - public int getPrecision() { - return (this.specifiedPrecision != null) ? this.specifiedPrecision.intValue() : this.getDefaultPrecision(); - } - - public Integer getSpecifiedPrecision() { - return this.specifiedPrecision; - } - - public void setSpecifiedPrecision(Integer precision) { - if (this.valuesAreDifferent(this.specifiedPrecision, precision)) { - XmlColumn xmlColumn = this.getXmlColumnForUpdate(); - this.setSpecifiedPrecision_(precision); - xmlColumn.setPrecision(precision); - this.removeXmlColumnIfUnset(); - } - } - - protected void setSpecifiedPrecision_(Integer precision) { - Integer old = this.specifiedPrecision; - this.specifiedPrecision = precision; - this.firePropertyChanged(SPECIFIED_PRECISION_PROPERTY, old, precision); - } - - protected Integer buildSpecifiedPrecision() { - XmlColumn xmlColumn = this.getXmlColumn(); - return (xmlColumn == null) ? null : xmlColumn.getPrecision(); - } - - public int getDefaultPrecision() { - return DEFAULT_PRECISION; - } - - - // ********** scale ********** - - public int getScale() { - return (this.specifiedScale != null) ? this.specifiedScale.intValue() : this.getDefaultScale(); - } - - public Integer getSpecifiedScale() { - return this.specifiedScale; - } - - public void setSpecifiedScale(Integer scale) { - if (this.valuesAreDifferent(this.specifiedScale, scale)) { - XmlColumn xmlColumn = this.getXmlColumnForUpdate(); - this.setSpecifiedScale_(scale); - xmlColumn.setScale(scale); - this.removeXmlColumnIfUnset(); - } - } - - protected void setSpecifiedScale_(Integer scale) { - Integer old = this.specifiedScale; - this.specifiedScale = scale; - this.firePropertyChanged(SPECIFIED_SCALE_PROPERTY, old, scale); - } - - protected Integer buildSpecifiedScale() { - XmlColumn xmlColumn = this.getXmlColumn(); - return (xmlColumn == null) ? null : xmlColumn.getScale(); - } - - public int getDefaultScale() { - return DEFAULT_SCALE; - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyColumn oldColumn) { - super.initializeFrom(oldColumn); - this.setSpecifiedLength(oldColumn.getSpecifiedLength()); - this.setSpecifiedPrecision(oldColumn.getSpecifiedPrecision()); - this.setSpecifiedScale(oldColumn.getSpecifiedScale()); - } - - public void initializeFromVirtual(ReadOnlyColumn virtualColumn) { - super.initializeFromVirtual(virtualColumn); - // ignore other settings? - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java deleted file mode 100644 index 0424412001..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmDiscriminatorColumn.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmDiscriminatorColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlDiscriminatorColumn; - -/** - * <code>orm.xml</code> discriminator column - */ -public class GenericOrmDiscriminatorColumn - extends AbstractOrmNamedDiscriminatorColumn<XmlDiscriminatorColumn, OrmDiscriminatorColumn.Owner> - implements OrmDiscriminatorColumn -{ - - public GenericOrmDiscriminatorColumn(XmlContextNode parent, OrmDiscriminatorColumn.Owner owner) { - super(parent, owner); - } - - - // ********** XML column ********** - - @Override - public XmlDiscriminatorColumn getXmlColumn() { - return this.owner.getXmlColumn(); - } - - @Override - protected XmlDiscriminatorColumn buildXmlColumn() { - return this.owner.buildXmlColumn(); - } - - @Override - protected void removeXmlColumn() { - this.owner.removeXmlColumn(); - } - - // ********** validation ********** - - @Override - public boolean isVirtual() { - return this.getXmlColumn() == null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddable.java deleted file mode 100644 index 9ecf827277..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddable.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: Oracle. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.utility.internal.ArrayTools; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmEmbeddable; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaEmbeddable; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddable; - -/** - * <code>orm.xml</code> embeddable type mapping - */ -public class GenericOrmEmbeddable - extends AbstractOrmEmbeddable<XmlEmbeddable> -{ - public GenericOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping) { - super(parent, resourceMapping); - } - - @Override - public boolean attributeMappingKeyAllowed(String attributeMappingKey) { - return ArrayTools.contains(GenericJavaEmbeddable.ALLOWED_ATTRIBUTE_MAPPING_KEYS, attributeMappingKey); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedIdMapping.java deleted file mode 100644 index ffa8df64d6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedIdMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddedId; - -/** - * <code>orm.xml</code> embedded ID mapping - */ -public class GenericOrmEmbeddedIdMapping - extends AbstractOrmEmbeddedIdMapping<XmlEmbeddedId> -{ - - public GenericOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java deleted file mode 100644 index 3266c65927..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbedded; - -/** - * <code>orm.xml</code> embedded mapping - */ -public class GenericOrmEmbeddedMapping - extends AbstractOrmEmbeddedMapping<XmlEmbedded> -{ - public GenericOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEntity.java deleted file mode 100644 index 839ccc846d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEntity.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmEntity; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.NullOrmCacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.Cacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.CacheableHolder2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCacheable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity; -import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlCacheable_2_0; - -public class GenericOrmEntity - extends AbstractOrmEntity<XmlEntity> -{ - // EclipseLink holds its cacheable in its caching - protected final OrmCacheable2_0 cacheable; - - - public GenericOrmEntity(OrmPersistentType parent, XmlEntity xmlEntity) { - super(parent, xmlEntity); - this.cacheable = this.buildCacheable(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.cacheable.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.cacheable.update(); - } - - - // ********** cacheable ********** - - public OrmCacheable2_0 getCacheable() { - return this.cacheable; - } - - protected OrmCacheable2_0 buildCacheable() { - return this.isOrmXml2_0Compatible() ? - this.getContextNodeFactory2_0().buildOrmCacheable(this) : - new NullOrmCacheable2_0(this); - } - - public boolean calculateDefaultCacheable() { - CacheableHolder2_0 javaEntity = (CacheableHolder2_0) this.getJavaTypeMappingForDefaults(); - if (javaEntity != null) { - return javaEntity.getCacheable().isCacheable(); - } - - Cacheable2_0 parentCacheable = this.getParentCacheable(); - return (parentCacheable != null) ? - parentCacheable.isCacheable() : - ((PersistenceUnit2_0) this.getPersistenceUnit()).calculateDefaultCacheable(); - } - - protected Cacheable2_0 getParentCacheable() { - CacheableHolder2_0 parentEntity = (CacheableHolder2_0) this.getParentEntity(); - return (parentEntity == null) ? null : parentEntity.getCacheable(); - } - - public XmlCacheable_2_0 getXmlCacheable() { - return this.getXmlTypeMapping(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java deleted file mode 100644 index 049ec7fcbb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java +++ /dev/null @@ -1,214 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.GenerationType; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratedValue; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratedValue; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> generated value - */ -public class GenericOrmGeneratedValue - extends AbstractOrmXmlContextNode - implements OrmGeneratedValue -{ - protected final XmlGeneratedValue xmlGeneratedValue; - - protected GenerationType specifiedStrategy; - protected GenerationType defaultStrategy; - - protected String specifiedGenerator; - protected String defaultGenerator; - - - public GenericOrmGeneratedValue(XmlContextNode parent, XmlGeneratedValue xmlGeneratedValue) { - super(parent); - this.xmlGeneratedValue = xmlGeneratedValue; - this.specifiedStrategy = this.buildSpecifiedStrategy(); - this.specifiedGenerator = xmlGeneratedValue.getGenerator(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedStrategy_(this.buildSpecifiedStrategy()); - this.setSpecifiedGenerator_(this.xmlGeneratedValue.getGenerator()); - } - - @Override - public void update() { - super.update(); - this.setDefaultStrategy(this.buildDefaultStrategy()); - this.setDefaultGenerator(this.buildDefaultGenerator()); - } - - - // ********** strategy ********** - - public GenerationType getStrategy() { - return (this.specifiedStrategy != null) ? this.specifiedStrategy : this.defaultStrategy; - } - - public GenerationType getSpecifiedStrategy() { - return this.specifiedStrategy; - } - - public void setSpecifiedStrategy(GenerationType strategy) { - this.setSpecifiedStrategy_(strategy); - this.xmlGeneratedValue.setStrategy(GenerationType.toOrmResourceModel(strategy)); - } - - protected void setSpecifiedStrategy_(GenerationType strategy) { - GenerationType old = this.specifiedStrategy; - this.specifiedStrategy = strategy; - this.firePropertyChanged(SPECIFIED_STRATEGY_PROPERTY, old, strategy); - } - - protected GenerationType buildSpecifiedStrategy() { - return GenerationType.fromOrmResourceModel(this.xmlGeneratedValue.getStrategy()); - } - - public GenerationType getDefaultStrategy() { - return this.defaultStrategy; - } - - protected void setDefaultStrategy(GenerationType strategy) { - GenerationType old = this.defaultStrategy; - this.defaultStrategy = strategy; - this.firePropertyChanged(DEFAULT_STRATEGY_PROPERTY, old, strategy); - } - - // TODO - protected GenerationType buildDefaultStrategy() { - return DEFAULT_STRATEGY; - } - - - // ********** generator ********** - - public String getGenerator() { - return (this.specifiedGenerator != null) ? this.specifiedGenerator : this.defaultGenerator; - } - - public String getSpecifiedGenerator() { - return this.specifiedGenerator; - } - - public void setSpecifiedGenerator(String generator) { - this.setSpecifiedGenerator_(generator); - this.xmlGeneratedValue.setGenerator(generator); - } - - protected void setSpecifiedGenerator_(String generator) { - String old = this.specifiedGenerator; - this.specifiedGenerator = generator; - this.firePropertyChanged(SPECIFIED_GENERATOR_PROPERTY, old, generator); - } - - public String getDefaultGenerator() { - return this.defaultGenerator; - } - - protected void setDefaultGenerator(String generator) { - String old = this.defaultGenerator; - this.defaultGenerator = generator; - this.firePropertyChanged(DEFAULT_GENERATOR_PROPERTY, old, generator); - } - - // TODO - protected String buildDefaultGenerator() { - return null; - } - - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } - - public XmlGeneratedValue getXmlGeneratedValue() { - return this.xmlGeneratedValue; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - - String generator = this.getGenerator(); - if (generator == null) { - return; - } - - for (Generator next : this.getPersistenceUnit().getGenerators()) { - if (generator.equals(next.getName())) { - return; - } - } - - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, - new String[] {generator}, - this.getParent(), - this.getGeneratorTextRange() - ) - ); - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlGeneratedValue.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - - public TextRange getGeneratorTextRange() { - return this.getValidationTextRange(this.xmlGeneratedValue.getGeneratorTextRange()); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.generatorTouches(pos)) { - return this.getCandidateGeneratorNames(); - } - return null; - } - - protected boolean generatorTouches(int pos) { - return this.xmlGeneratedValue.generatorTouches(pos); - } - - protected Iterable<String> getCandidateGeneratorNames() { - return this.getPersistenceUnit().getUniqueGeneratorNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java deleted file mode 100644 index 0cf8af22e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.NotNullFilter; -import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; -import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator; -import org.eclipse.jpt.jpa.core.context.orm.OrmTableGenerator; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratorContainer; -import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator; -import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmGeneratorContainer - extends AbstractOrmXmlContextNode - implements OrmGeneratorContainer -{ - protected final XmlGeneratorContainer xmlGeneratorContainer; - - protected OrmSequenceGenerator sequenceGenerator; - - protected OrmTableGenerator tableGenerator; - - - public GenericOrmGeneratorContainer(XmlContextNode parent, XmlGeneratorContainer xmlGeneratorContainer) { - super(parent); - this.xmlGeneratorContainer = xmlGeneratorContainer; - this.sequenceGenerator = this.buildSequenceGenerator(); - this.tableGenerator = this.buildTableGenerator(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSequenceGenerator(); - this.syncTableGenerator(); - } - - @Override - public void update() { - super.update(); - if (this.sequenceGenerator != null) { - this.sequenceGenerator.update(); - } - if (this.tableGenerator != null) { - this.tableGenerator.update(); - } - } - - - // ********** sequence generator ********** - - public OrmSequenceGenerator getSequenceGenerator() { - return this.sequenceGenerator; - } - - public OrmSequenceGenerator addSequenceGenerator() { - if (this.sequenceGenerator != null) { - throw new IllegalStateException("sequence generator already exists: " + this.sequenceGenerator); //$NON-NLS-1$ - } - XmlSequenceGenerator xmlGenerator = this.buildXmlSequenceGenerator(); - OrmSequenceGenerator generator = this.buildSequenceGenerator(xmlGenerator); - this.setSequenceGenerator_(generator); - this.xmlGeneratorContainer.setSequenceGenerator(xmlGenerator); - return generator; - } - - protected XmlSequenceGenerator buildXmlSequenceGenerator() { - return OrmFactory.eINSTANCE.createXmlSequenceGenerator(); - } - - public void removeSequenceGenerator() { - if (this.sequenceGenerator == null) { - throw new IllegalStateException("sequence generator does not exist"); //$NON-NLS-1$ - } - this.setSequenceGenerator_(null); - this.xmlGeneratorContainer.setSequenceGenerator(null); - } - - protected OrmSequenceGenerator buildSequenceGenerator() { - XmlSequenceGenerator xmlGenerator = this.getXmlSequenceGenerator(); - return (xmlGenerator == null) ? null : this.buildSequenceGenerator(xmlGenerator); - } - - protected XmlSequenceGenerator getXmlSequenceGenerator() { - return this.xmlGeneratorContainer.getSequenceGenerator(); - } - - protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator xmlSequenceGenerator) { - return this.getContextNodeFactory().buildOrmSequenceGenerator(this, xmlSequenceGenerator); - } - - protected void syncSequenceGenerator() { - XmlSequenceGenerator xmlGenerator = this.getXmlSequenceGenerator(); - if (xmlGenerator == null) { - if (this.sequenceGenerator != null) { - this.setSequenceGenerator_(null); - } - } else { - if ((this.sequenceGenerator != null) && (this.sequenceGenerator.getXmlGenerator() == xmlGenerator)) { - this.sequenceGenerator.synchronizeWithResourceModel(); - } else { - this.setSequenceGenerator_(this.buildSequenceGenerator(xmlGenerator)); - } - } - } - - protected void setSequenceGenerator_(OrmSequenceGenerator sequenceGenerator) { - OrmSequenceGenerator old = this.sequenceGenerator; - this.sequenceGenerator = sequenceGenerator; - this.firePropertyChanged(SEQUENCE_GENERATOR_PROPERTY, old, sequenceGenerator); - } - - - // ********** table generator ********** - - public OrmTableGenerator getTableGenerator() { - return this.tableGenerator; - } - - public OrmTableGenerator addTableGenerator() { - if (this.tableGenerator != null) { - throw new IllegalStateException("table generator already exists: " + this.tableGenerator); //$NON-NLS-1$ - } - XmlTableGenerator xmlGenerator = this.buildXmlTableGenerator(); - OrmTableGenerator generator = this.buildTableGenerator(xmlGenerator); - this.setTableGenerator_(generator); - this.xmlGeneratorContainer.setTableGenerator(xmlGenerator); - return generator; - } - - protected XmlTableGenerator buildXmlTableGenerator() { - return OrmFactory.eINSTANCE.createXmlTableGenerator(); - } - - public void removeTableGenerator() { - if (this.tableGenerator == null) { - throw new IllegalStateException("table generator does not exist"); //$NON-NLS-1$ - } - this.setTableGenerator_(null); - this.xmlGeneratorContainer.setTableGenerator(null); - } - - protected OrmTableGenerator buildTableGenerator() { - XmlTableGenerator xmlGenerator = this.getXmlTableGenerator(); - return (xmlGenerator == null) ? null : this.buildTableGenerator(xmlGenerator); - } - - protected XmlTableGenerator getXmlTableGenerator() { - return this.xmlGeneratorContainer.getTableGenerator(); - } - - protected OrmTableGenerator buildTableGenerator(XmlTableGenerator xmlTableGenerator) { - return this.getContextNodeFactory().buildOrmTableGenerator(this, xmlTableGenerator); - } - - protected void syncTableGenerator() { - XmlTableGenerator xmlGenerator = this.getXmlTableGenerator(); - if (xmlGenerator == null) { - if (this.tableGenerator != null) { - this.setTableGenerator_(null); - } - } else { - if ((this.tableGenerator != null) && (this.tableGenerator.getXmlGenerator() == xmlGenerator)) { - this.tableGenerator.synchronizeWithResourceModel(); - } else { - this.setTableGenerator_(this.buildTableGenerator(xmlGenerator)); - } - } - } - - protected void setTableGenerator_(OrmTableGenerator tableGenerator) { - OrmTableGenerator old = this.tableGenerator; - this.tableGenerator = tableGenerator; - this.firePropertyChanged(TABLE_GENERATOR_PROPERTY, old, tableGenerator); - } - - - // ********** validation ********** - - /** - * The generators are validated in the persistence unit. - * @see org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#validateGenerators(List, IReporter) - */ - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - // generators are validated in the persistence unit - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlGeneratorContainer.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.tableGenerator != null) { - result = this.tableGenerator.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - if (this.sequenceGenerator != null) { - result = this.sequenceGenerator.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } - - public Iterable<Generator> getGenerators() { - return new FilteringIterable<Generator>(this.getGenerators_(), NotNullFilter.<Generator>instance()); - } - - protected Iterable<Generator> getGenerators_() { - return new ArrayIterable<Generator>(this.sequenceGenerator, this.tableGenerator); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmIdMapping.java deleted file mode 100644 index 958b87ddf5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmIdMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmIdMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlId; - -/** - * <code>orm.xml</code> ID mapping - */ -public class GenericOrmIdMapping - extends AbstractOrmIdMapping<XmlId> -{ - public GenericOrmIdMapping(OrmPersistentAttribute parent, XmlId xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java deleted file mode 100644 index 82c9b8b39a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmBaseColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * <code>orm.xml</code> join column - */ -public class GenericOrmJoinColumn - extends AbstractOrmBaseColumn<XmlJoinColumn, OrmReadOnlyJoinColumn.Owner> - implements OrmJoinColumn -{ - /** @see org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmNamedColumn#AbstractOrmNamedColumn(XmlContextNode, org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyNamedColumn.Owner, org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlNamedColumn) */ - protected /* final */ XmlJoinColumn xmlColumn; // null for default join columns - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericOrmJoinColumn(XmlContextNode parent, OrmReadOnlyJoinColumn.Owner owner) { - this(parent, owner, null); - } - - public GenericOrmJoinColumn(XmlContextNode parent, OrmReadOnlyJoinColumn.Owner owner, XmlJoinColumn xmlColumn) { - super(parent, owner, xmlColumn); - this.specifiedReferencedColumnName = this.buildSpecifiedReferencedColumnName(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedReferencedColumnName_(this.buildSpecifiedReferencedColumnName()); - } - - @Override - public void update() { - super.update(); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** XML column ********** - - @Override - public XmlJoinColumn getXmlColumn() { - return this.xmlColumn; - } - - @Override - protected void setXmlColumn(XmlJoinColumn xmlColumn) { - this.xmlColumn = xmlColumn; - } - - /** - * join columns are part of a collection; - * the 'join-column' element will be removed/added - * when the XML join column is removed from/added to - * the owner's collection - */ - @Override - protected XmlJoinColumn buildXmlColumn() { - throw new IllegalStateException("XML join column is missing"); //$NON-NLS-1$ - } - - /** - * @see #buildXmlColumn() - */ - @Override - protected void removeXmlColumn() { - // do nothing - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - public void setSpecifiedReferencedColumnName(String name) { - this.setSpecifiedReferencedColumnName_(name); - this.getXmlColumn().setReferencedColumnName(name); - } - - protected void setSpecifiedReferencedColumnName_(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - XmlJoinColumn joinColumn = this.getXmlColumn(); - return (joinColumn == null) ? null : joinColumn.getReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultReferencedColumnName() { - return MappingTools.buildJoinColumnDefaultReferencedColumnName(this.owner); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyJoinColumn oldColumn) { - super.initializeFrom(oldColumn); - this.setSpecifiedReferencedColumnName(oldColumn.getSpecifiedReferencedColumnName()); - } - - public void initializeFromVirtual(ReadOnlyJoinColumn virtualColumn) { - super.initializeFromVirtual(virtualColumn); - this.setSpecifiedReferencedColumnName(virtualColumn.getReferencedColumnName()); - } - - - // ********** validation ********** - - public TextRange getReferencedColumnNameTextRange() { - return this.getValidationTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); - } - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver() { - return new OrmJoinColumnTextRangeResolver(this); - } - - // ********** completion proposals ********** - - @Override - protected Iterable<String> getConnectedXmlCompletionProposals(int pos) { - Iterable<String> result = super.getConnectedXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.referencedColumnNameTouches(pos)) { - return this.getCandidateReferencedColumnNames(); - } - return null; - } - - protected boolean referencedColumnNameTouches(int pos) { - XmlJoinColumn joinColumn = this.getXmlColumn(); - return (joinColumn != null) && (joinColumn.referencedColumnNameTouches(pos)); - } - - protected Iterable<String> getCandidateReferencedColumnNames() { - Table table = this.owner.getReferencedColumnDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java deleted file mode 100644 index 6a69301767..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java +++ /dev/null @@ -1,473 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.PersistentAttribute; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinTable; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> join table - */ -public class GenericOrmJoinTable - extends GenericOrmReferenceTable<XmlJoinTable> - implements OrmJoinTable -{ - protected final ContextListContainer<OrmJoinColumn, XmlJoinColumn> specifiedInverseJoinColumnContainer; - protected final OrmReadOnlyJoinColumn.Owner inverseJoinColumnOwner; - - protected OrmJoinColumn defaultInverseJoinColumn; - - - public GenericOrmJoinTable(OrmJoinTableRelationshipStrategy parent, Owner owner) { - super(parent, owner); - this.inverseJoinColumnOwner = this.buildInverseJoinColumnOwner(); - this.specifiedInverseJoinColumnContainer = this.buildSpecifiedInverseJoinColumnContainer(); - } - - @Override - protected OrmReadOnlyJoinColumn.Owner buildJoinColumnOwner() { - return new JoinColumnOwner(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedInverseJoinColumns(); - if (this.defaultInverseJoinColumn != null) { - this.defaultInverseJoinColumn.synchronizeWithResourceModel(); - } - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedInverseJoinColumns()); - this.updateDefaultInverseJoinColumn(); - } - - - // ********** XML table ********** - - @Override - protected XmlJoinTable getXmlTable() { - return this.getRelationshipStrategy().getXmlJoinTable(); - } - - @Override - protected XmlJoinTable buildXmlTable() { - return this.getRelationshipStrategy().buildXmlJoinTable(); - } - - @Override - protected void removeXmlTable() { - this.getRelationshipStrategy().removeXmlJoinTable(); - } - - - // ********** inverse join columns ********** - - public ListIterable<OrmJoinColumn> getInverseJoinColumns() { - return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumns() : this.getDefaultInverseJoinColumns(); - } - - public int getInverseJoinColumnsSize() { - return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumnsSize() : this.getDefaultInverseJoinColumnsSize(); - } - - public void convertDefaultInverseJoinColumnToSpecified() { - MappingTools.convertJoinTableDefaultToSpecifiedInverseJoinColumn(this); - } - - - // ********** specified inverse join columns ********** - - public ListIterable<OrmJoinColumn> getSpecifiedInverseJoinColumns() { - return this.specifiedInverseJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedInverseJoinColumnsSize() { - return this.specifiedInverseJoinColumnContainer.getContextElementsSize(); - } - - public boolean hasSpecifiedInverseJoinColumns() { - return this.getSpecifiedInverseJoinColumnsSize() != 0; - } - - public OrmJoinColumn getSpecifiedInverseJoinColumn(int index) { - return this.specifiedInverseJoinColumnContainer.getContextElement(index); - } - - public OrmJoinColumn addSpecifiedInverseJoinColumn() { - return this.addSpecifiedInverseJoinColumn(this.getSpecifiedInverseJoinColumnsSize()); - } - - public OrmJoinColumn addSpecifiedInverseJoinColumn(int index) { - XmlJoinTable xmlTable = this.getXmlTableForUpdate(); - XmlJoinColumn xmlJoinColumn = this.buildXmlJoinColumn(); - OrmJoinColumn joinColumn = this.specifiedInverseJoinColumnContainer.addContextElement(index, xmlJoinColumn); - xmlTable.getInverseJoinColumns().add(index, xmlJoinColumn); - return joinColumn; - } - - public void removeSpecifiedInverseJoinColumn(JoinColumn joinColumn) { - this.removeSpecifiedInverseJoinColumn(this.specifiedInverseJoinColumnContainer.indexOfContextElement((OrmJoinColumn) joinColumn)); - } - - public void removeSpecifiedInverseJoinColumn(int index) { - this.specifiedInverseJoinColumnContainer.removeContextElement(index); - this.getXmlTable().getInverseJoinColumns().remove(index); - this.removeXmlTableIfUnset(); - } - - public void moveSpecifiedInverseJoinColumn(int targetIndex, int sourceIndex) { - this.specifiedInverseJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - this.getXmlTable().getInverseJoinColumns().move(targetIndex, sourceIndex); - } - - public void clearSpecifiedInverseJoinColumns() { - this.specifiedInverseJoinColumnContainer.clearContextList(); - this.getXmlTable().getInverseJoinColumns().clear(); - } - - protected void syncSpecifiedInverseJoinColumns() { - this.specifiedInverseJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlJoinColumn> getXmlInverseJoinColumns() { - XmlJoinTable xmlTable = this.getXmlTable(); - return (xmlTable == null) ? - EmptyListIterable.<XmlJoinColumn>instance() : - // clone to reduce chance of concurrency problems - new LiveCloneListIterable<XmlJoinColumn>(xmlTable.getInverseJoinColumns()); - } - - protected ContextListContainer<OrmJoinColumn, XmlJoinColumn> buildSpecifiedInverseJoinColumnContainer() { - SpecifiedInverseJoinColumnContainer container = new SpecifiedInverseJoinColumnContainer(); - container.initialize(); - return container; - } - - /** - * specified inverse join column container - */ - protected class SpecifiedInverseJoinColumnContainer - extends ContextListContainer<OrmJoinColumn, XmlJoinColumn> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_INVERSE_JOIN_COLUMNS_LIST; - } - @Override - protected OrmJoinColumn buildContextElement(XmlJoinColumn resourceElement) { - return GenericOrmJoinTable.this.buildInverseJoinColumn(resourceElement); - } - @Override - protected ListIterable<XmlJoinColumn> getResourceElements() { - return GenericOrmJoinTable.this.getXmlInverseJoinColumns(); - } - @Override - protected XmlJoinColumn getResourceElement(OrmJoinColumn contextElement) { - return contextElement.getXmlColumn(); - } - } - - protected OrmReadOnlyJoinColumn.Owner buildInverseJoinColumnOwner() { - return new InverseJoinColumnOwner(); - } - - - // ********** default inverse join column ********** - - public OrmJoinColumn getDefaultInverseJoinColumn() { - return this.defaultInverseJoinColumn; - } - - protected void setDefaultInverseJoinColumn(OrmJoinColumn joinColumn) { - OrmJoinColumn old = this.defaultInverseJoinColumn; - this.defaultInverseJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_INVERSE_JOIN_COLUMN, old, joinColumn); - } - - protected ListIterable<OrmJoinColumn> getDefaultInverseJoinColumns() { - return (this.defaultInverseJoinColumn != null) ? - new SingleElementListIterable<OrmJoinColumn>(this.defaultInverseJoinColumn) : - EmptyListIterable.<OrmJoinColumn>instance(); - } - - protected int getDefaultInverseJoinColumnsSize() { - return (this.defaultInverseJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultInverseJoinColumn() { - if (this.buildsDefaultInverseJoinColumn()) { - if (this.defaultInverseJoinColumn == null) { - this.setDefaultInverseJoinColumn(this.buildInverseJoinColumn(null)); - } else { - this.defaultInverseJoinColumn.update(); - } - } else { - this.setDefaultInverseJoinColumn(null); - } - } - - protected boolean buildsDefaultInverseJoinColumn() { - return ! this.hasSpecifiedInverseJoinColumns(); - } - - - // ********** misc ********** - - @Override - public OrmJoinTableRelationshipStrategy getParent() { - return (OrmJoinTableRelationshipStrategy) super.getParent(); - } - - protected OrmJoinTableRelationshipStrategy getRelationshipStrategy() { - return this.getParent(); - } - - @Override - protected String buildDefaultName() { - return this.getRelationshipStrategy().getJoinTableDefaultName(); - } - - public void initializeFrom(ReadOnlyJoinTable oldTable) { - super.initializeFrom(oldTable); - for (ReadOnlyJoinColumn joinColumn : oldTable.getSpecifiedInverseJoinColumns()) { - this.addSpecifiedInverseJoinColumn().initializeFrom(joinColumn); - } - } - - public void initializeFromVirtual(ReadOnlyJoinTable virtualTable) { - super.initializeFromVirtual(virtualTable); - for (ReadOnlyJoinColumn joinColumn : virtualTable.getInverseJoinColumns()) { - this.addSpecifiedInverseJoinColumn().initializeFromVirtual(joinColumn); - } - } - - protected OrmJoinColumn buildInverseJoinColumn(XmlJoinColumn xmlJoinColumn) { - return this.getContextNodeFactory().buildOrmJoinColumn(this, this.inverseJoinColumnOwner, xmlJoinColumn); - } - - public RelationshipMapping getRelationshipMapping() { - return this.getRelationshipStrategy().getRelationship().getMapping(); - } - - public PersistentAttribute getPersistentAttribute() { - return this.getRelationshipMapping().getPersistentAttribute(); - } - - - // ********** validation ********** - - @Override - protected void validateJoinColumns(List<IMessage> messages, IReporter reporter) { - super.validateJoinColumns(messages, reporter); - this.validateNodes(this.getInverseJoinColumns(), messages, reporter); - } - - public boolean validatesAgainstDatabase() { - return this.getRelationshipStrategy().validatesAgainstDatabase(); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - for (OrmJoinColumn column : this.getInverseJoinColumns()) { - result = column.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } - - // ********** join column owners ********** - - /** - * just a little common behavior - */ - protected abstract class AbstractJoinColumnOwner - implements OrmReadOnlyJoinColumn.Owner - { - protected AbstractJoinColumnOwner() { - super(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return MappingTools.buildJoinColumnDefaultName((ReadOnlyJoinColumn) column, this); - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. The table is always the join table. - */ - public boolean tableNameIsInvalid(String tableName) { - return Tools.valuesAreDifferent(this.getDefaultTableName(), tableName); - } - - /** - * the join column can only be on the join table itself - */ - public Iterable<String> getCandidateTableNames() { - return EmptyIterable.instance(); - } - - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - return Tools.valuesAreEqual(GenericOrmJoinTable.this.getName(), tableName) ? - GenericOrmJoinTable.this.getDbTable() : - null; - } - - /** - * by default, the join column is, obviously, in the join table; - * not sure whether it can be anywhere else... - */ - public String getDefaultTableName() { - return GenericOrmJoinTable.this.getName(); - } - - public TextRange getValidationTextRange() { - return GenericOrmJoinTable.this.getValidationTextRange(); - } - - protected OrmRelationship getRelationship() { - return this.getRelationshipStrategy().getRelationship(); - } - - protected OrmJoinTableRelationshipStrategy getRelationshipStrategy() { - return GenericOrmJoinTable.this.getRelationshipStrategy(); - } - } - - - /** - * owner for "back-pointer" join columns; - * these point at the source/owning entity - */ - protected class JoinColumnOwner - extends AbstractJoinColumnOwner - { - protected JoinColumnOwner() { - super(); - } - - public Entity getRelationshipTarget() { - return this.getRelationship().getEntity(); - } - - public String getAttributeName() { - return MappingTools.getTargetAttributeName(GenericOrmJoinTable.this.getRelationshipMapping()); - } - - @Override - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - org.eclipse.jpt.jpa.db.Table dbTable = super.resolveDbTable(tableName); - return (dbTable != null) ? dbTable : this.getTypeMapping().resolveDbTable(tableName); - } - - public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() { - return this.getTypeMapping().getPrimaryDbTable(); - } - - protected TypeMapping getTypeMapping() { - return this.getRelationship().getTypeMapping(); - } - - public int getJoinColumnsSize() { - return GenericOrmJoinTable.this.getJoinColumnsSize(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return this.getRelationshipStrategy().buildJoinTableJoinColumnValidator((ReadOnlyJoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver); - } - } - - - /** - * owner for "forward-pointer" join columns; - * these point at the target/inverse entity - */ - protected class InverseJoinColumnOwner - extends AbstractJoinColumnOwner - { - protected InverseJoinColumnOwner() { - super(); - } - - public Entity getRelationshipTarget() { - RelationshipMapping relationshipMapping = GenericOrmJoinTable.this.getRelationshipMapping(); - return (relationshipMapping == null) ? null : relationshipMapping.getResolvedTargetEntity(); - } - - public String getAttributeName() { - RelationshipMapping relationshipMapping = GenericOrmJoinTable.this.getRelationshipMapping(); - return (relationshipMapping == null) ? null : relationshipMapping.getName(); - } - - @Override - public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - org.eclipse.jpt.jpa.db.Table dbTable = super.resolveDbTable(tableName); - if (dbTable != null) { - return dbTable; - } - Entity relationshipTarget = this.getRelationshipTarget(); - return (relationshipTarget == null) ? null : relationshipTarget.resolveDbTable(tableName); - } - - public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() { - Entity relationshipTarget = this.getRelationshipTarget(); - return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable(); - } - - public int getJoinColumnsSize() { - return GenericOrmJoinTable.this.getInverseJoinColumnsSize(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return this.getRelationshipStrategy().buildJoinTableInverseJoinColumnValidator((ReadOnlyJoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java deleted file mode 100644 index 411ec159ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.LobConverter; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmConverter; -import org.eclipse.jpt.jpa.core.context.orm.OrmLobConverter; -import org.eclipse.jpt.jpa.core.resource.orm.XmlConvertibleMapping; - -public class GenericOrmLobConverter - extends AbstractOrmConverter - implements OrmLobConverter -{ - public GenericOrmLobConverter(OrmAttributeMapping parent, OrmConverter.Owner owner) { - super(parent, owner); - } - - protected XmlConvertibleMapping getXmlConvertibleMapping() { - return (XmlConvertibleMapping) this.getXmlAttributeMapping(); - } - - - // ********** misc ********** - - public Class<? extends Converter> getType() { - return LobConverter.class; - } - - public void initialize() { - this.getXmlConvertibleMapping().setLob(true); - } - - - // ********** validation ********** - - @Override - protected TextRange getXmlValidationTextRange() { - return this.getXmlConvertibleMapping().getLobTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToManyMapping.java deleted file mode 100644 index 6a002b3d2e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToManyMapping.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmManyToManyMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany; - -public class GenericOrmManyToManyMapping - extends AbstractOrmManyToManyMapping<XmlManyToMany> -{ - public GenericOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToOneMapping.java deleted file mode 100644 index 740c4e01e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmManyToOneMapping.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmManyToOneMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne; - -public class GenericOrmManyToOneMapping - extends AbstractOrmManyToOneMapping<XmlManyToOne> -{ - public GenericOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmMappedSuperclass.java deleted file mode 100644 index 45014549d5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmMappedSuperclass.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmMappedSuperclass; -import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedSuperclass; - -/** - * <code>orm.xml</code> mapped superclass - */ -public class GenericOrmMappedSuperclass - extends AbstractOrmMappedSuperclass<XmlMappedSuperclass> -{ - public GenericOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) { - super(parent, resourceMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java deleted file mode 100644 index 6c0ebef097..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery; -import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedNativeQuery; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> named native query - */ -public class GenericOrmNamedNativeQuery - extends AbstractOrmQuery<XmlNamedNativeQuery> - implements OrmNamedNativeQuery -{ - protected String resultClass; - protected String fullyQualifiedResultClass; - - protected String resultSetMapping; - - - public GenericOrmNamedNativeQuery(XmlContextNode parent, XmlNamedNativeQuery xmlNamedNativeQuery) { - super(parent, xmlNamedNativeQuery); - this.resultClass = xmlNamedNativeQuery.getResultClass(); - this.resultSetMapping = xmlNamedNativeQuery.getResultSetMapping(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setResultClass_(this.xmlQuery.getResultClass()); - this.setResultSetMapping_(this.xmlQuery.getResultSetMapping()); - } - @Override - public void update() { - super.update(); - this.setFullyQualifiedResultClass(this.buildFullyQualifiedResultClass()); - } - - - // ********** result class ********** - - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - this.setResultClass_(resultClass); - this.xmlQuery.setResultClass(resultClass); - } - - protected void setResultClass_(String resultClass) { - String old = this.resultClass; - this.resultClass = resultClass; - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); - } - - public String getFullyQualifiedResultClass() { - return this.fullyQualifiedResultClass; - } - - protected void setFullyQualifiedResultClass(String resultClass) { - String old = this.fullyQualifiedResultClass; - this.fullyQualifiedResultClass = resultClass; - this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_PROPERTY, old, resultClass); - } - - protected String buildFullyQualifiedResultClass() { - return this.getMappingFileRoot().getFullyQualifiedName(this.resultClass); - } - - public char getResultClassEnclosingTypeSeparator() { - return '$'; - } - - - // ********** result set mapping ********** - - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - this.setResultSetMapping_(resultSetMapping); - this.xmlQuery.setResultSetMapping(resultSetMapping); - } - - protected void setResultSetMapping_(String resultSetMapping) { - String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); - } - - // ********** metadata conversion ********** - - public void convertFrom(JavaNamedNativeQuery javaQuery) { - super.convertFrom(javaQuery); - this.setResultClass(javaQuery.getResultClass()); - this.setResultSetMapping(javaQuery.getResultSetMapping()); - } - - // ********** validation ********** - - @Override - protected void validateQuery_(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) { - // nothing yet - } - - @Override - public boolean isEquivalentTo(JpaNamedContextNode node) { - return super.isEquivalentTo(node) - && this.isEquivalentTo((NamedNativeQuery) node); - } - - protected boolean isEquivalentTo(NamedNativeQuery nnQuery) { - return Tools.valuesAreEqual(this.resultClass, nnQuery.getResultClass()) && - Tools.valuesAreEqual(this.resultSetMapping, nnQuery.getResultSetMapping()); - } - - // ********** misc ********** - - public Class<NamedNativeQuery> getType() { - return NamedNativeQuery.class; - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java deleted file mode 100644 index 2447464860..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; -import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery; -import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery; -import org.eclipse.persistence.jpa.jpql.ExpressionTools; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> named query - */ -public class GenericOrmNamedQuery - extends AbstractOrmQuery<XmlNamedQuery> - implements OrmNamedQuery -{ - public GenericOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) { - super(parent, resourceNamedQuery); - } - - - // ********** validation ********** - - @Override - protected void validateQuery_(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) { - - // Convert the literal escape characters into actual escape characters - String jpqlQuery = ExpressionTools.unescape(this.query, new int[1]); - - queryHelper.validate(this, jpqlQuery, this.getQueryTextRange(), 0, messages); - } - - // ********** misc ********** - - public Class<NamedQuery> getType() { - return NamedQuery.class; - } - - public void convertFrom(JavaNamedQuery javaQuery) { - super.convertFrom(javaQuery); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNullAttributeMapping.java deleted file mode 100644 index 374f84e338..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNullAttributeMapping.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.jpa.core.resource.orm.Attributes; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNullAttributeMapping; - -/** - * <code>orm.xml</code> null attribute mapping - */ -public class GenericOrmNullAttributeMapping - extends AbstractOrmAttributeMapping<XmlNullAttributeMapping> -{ - public GenericOrmNullAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping xmlMapping) { - super(parent, xmlMapping); - } - - public String getKey() { - return null; - } - - public int getXmlSequence() { - return -1; - } - - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmAttributeMapping(this); - } - - public void addXmlAttributeMappingTo(Attributes resourceAttributes) { - throw new UnsupportedOperationException(); - } - - public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) { - throw new UnsupportedOperationException(); - } - - // ********** metamodel ********** - - @Override - public MetamodelField getMetamodelField() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToManyMapping.java deleted file mode 100644 index 4fdad7ce7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToManyMapping.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmOneToManyMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany; - -public class GenericOrmOneToManyMapping - extends AbstractOrmOneToManyMapping<XmlOneToMany> -{ - public GenericOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToOneMapping.java deleted file mode 100644 index e89cef7e89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOneToOneMapping.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmOneToOneMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne; - -/** - * <code>orm.xml</code> 1:1 mapping - */ -public class GenericOrmOneToOneMapping - extends AbstractOrmOneToOneMapping<XmlOneToOne> -{ - public GenericOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java deleted file mode 100644 index 9f1dc107fe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOrderable.java +++ /dev/null @@ -1,459 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.OrderColumnValidator; -import org.eclipse.jpt.jpa.core.jpa2.context.OrderColumn2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrderColumn2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrderable2_0; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOrderColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlOrderable; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> ordering - * <p> - * <strong>NB:</strong> Setting any flag to <code>false</code> (or setting the - * specified "order by" to <code>null</code>) can be a bit unpredictable. The - * intent is to set a flag to <code>true</code> (or set the specified "order by" - * to a non-<code>null</code> value). - * <p> - * <strong>(JPA 2.0 only) NB:</strong> If both the "order-by" and the - * "order-column" elements are present (which is prohibited by the JPA spec), - * both are ignored. - */ -public class GenericOrmOrderable - extends AbstractOrmXmlContextNode - implements OrmOrderable2_0 -{ - protected String specifiedOrderBy; - protected boolean noOrdering = false; - protected boolean pkOrdering = false; - protected boolean customOrdering = false; - - // JPA 2.0 - protected final Owner owner; // this is null for JPA 1.0 mappings - protected boolean orderColumnOrdering = false; - protected final OrmOrderColumn2_0 orderColumn; // this is null for JPA 1.0 mappings - - - /** - * JPA 1.0 - */ - public GenericOrmOrderable(OrmAttributeMapping parent) { - this(parent, null); - } - - /** - * JPA 2.0 - */ - public GenericOrmOrderable(OrmAttributeMapping parent, Owner owner) { - super(parent); - - this.specifiedOrderBy = this.buildSpecifiedOrderBy(); - this.noOrdering = this.buildNoOrdering(); - this.pkOrdering = this.buildPkOrdering(); - this.customOrdering = this.buildCustomOrdering(); - - this.owner = owner; - this.orderColumnOrdering = this.buildOrderColumnOrdering(); - this.orderColumn = this.buildOrderColumn(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - - this.setSpecifiedOrderBy_(this.buildSpecifiedOrderBy()); - this.setNoOrdering_(this.buildNoOrdering()); - this.setPkOrdering_(this.buildPkOrdering()); - this.setCustomOrdering_(this.buildCustomOrdering()); - - this.setOrderColumnOrdering_(this.buildOrderColumnOrdering()); - if (this.orderColumn != null) { - this.orderColumn.synchronizeWithResourceModel(); - } - } - - @Override - public void update() { - super.update(); - if (this.orderColumn != null) { - this.orderColumn.update(); - } - } - - - // ********** specified order by ********** - - public String getSpecifiedOrderBy() { - return this.specifiedOrderBy; - } - - public void setSpecifiedOrderBy(String orderBy) { - if (orderBy != null) { - this.setSpecifiedOrderBy_(orderBy); - this.setNoOrdering_(false); - this.setPkOrdering_(orderBy.length() == 0); - this.setCustomOrdering_(orderBy.length() != 0); - this.setOrderColumnOrdering_(false); - - this.removeXmlOrderColumn(); - this.getXmlOrderable().setOrderBy(orderBy); - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setSpecifiedOrderBy_(String orderBy) { - String old = this.specifiedOrderBy; - this.specifiedOrderBy = orderBy; - this.firePropertyChanged(SPECIFIED_ORDER_BY_PROPERTY, old, orderBy); - } - - protected String buildSpecifiedOrderBy() { - if (this.xmlOrderColumnIsPresent()) { - return null; - } - return this.getXmlOrderBy(); - } - - - // ********** no ordering ********** - - public boolean isNoOrdering() { - return this.noOrdering; - } - - public void setNoOrdering(boolean noOrdering) { - if (noOrdering) { - this.setSpecifiedOrderBy_(null); - this.setNoOrdering_(true); - this.setPkOrdering_(false); - this.setCustomOrdering_(false); - this.setOrderColumnOrdering_(false); - - this.removeXmlOrderColumn(); - this.getXmlOrderable().setOrderBy(null); - } else { - this.setPkOrdering(true); // hmmm... - } - } - - protected void setNoOrdering_(boolean noOrdering) { - boolean old = this.noOrdering; - this.noOrdering = noOrdering; - this.firePropertyChanged(NO_ORDERING_PROPERTY, old, noOrdering); - } - - protected boolean buildNoOrdering() { - return this.isJpa2_0Compatible() ? this.buildNoOrdering2_0() : this.buildNoOrdering1_0(); - } - - /** - * both elements are missing <em>or</em> both are present - */ - protected boolean buildNoOrdering2_0() { - boolean orderByMissing = (this.getXmlOrderBy() == null); - boolean orderByPresent = ! orderByMissing; - boolean orderColumnMissing = (this.getXmlOrderColumn() == null); - boolean orderColumnPresent = ! orderColumnMissing; - return (orderByMissing && orderColumnMissing) || (orderByPresent && orderColumnPresent); - } - - /** - * the order-by element is missing - */ - protected boolean buildNoOrdering1_0() { - return this.getXmlOrderBy() == null; - } - - - // ********** pk ordering ********** - - public boolean isPkOrdering() { - return this.pkOrdering; - } - - public void setPkOrdering(boolean pkOrdering) { - if (pkOrdering) { - this.setSpecifiedOrderBy(""); //$NON-NLS-1$ - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setPkOrdering_(boolean pkOrdering) { - boolean old = this.pkOrdering; - this.pkOrdering = pkOrdering; - this.firePropertyChanged(PK_ORDERING_PROPERTY, old, pkOrdering); - } - - /** - * the order-by element is present but no value specified - */ - protected boolean buildPkOrdering() { - if (this.xmlOrderColumnIsPresent()) { - return false; - } - String xmlOrderBy = this.getXmlOrderBy(); - return (xmlOrderBy != null) && (xmlOrderBy.length() == 0); - } - - - // ********** custom ordering ********** - - public boolean isCustomOrdering() { - return this.customOrdering; - } - - /** - * Unfortunately, setting the "custom ordering" flag directly is a bit hacky: - * The "specified order-by" is initially set to an empty string, which is - * the same as a "primary key ordering" state.... - */ - public void setCustomOrdering(boolean customOrdering) { - if (customOrdering) { - this.setSpecifiedOrderBy_(""); // hmmm... //$NON-NLS-1$ - this.setNoOrdering_(false); - this.setPkOrdering_(false); - this.setCustomOrdering_(true); - this.setOrderColumnOrdering_(false); - - this.removeXmlOrderColumn(); - this.getXmlOrderable().setOrderBy(""); //$NON-NLS-1$ - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setCustomOrdering_(boolean customOrdering) { - boolean old = this.customOrdering; - this.customOrdering = customOrdering; - this.firePropertyChanged(CUSTOM_ORDERING_PROPERTY, old, customOrdering); - } - - /** - * the order-by element is present and it has a specified value - */ - protected boolean buildCustomOrdering() { - if (this.xmlOrderColumnIsPresent()) { - return false; - } - String xmlOrderBy = this.getXmlOrderBy(); - return (xmlOrderBy != null) && (xmlOrderBy.length() != 0); - } - - - // ********** order column ordering ********** - - public boolean isOrderColumnOrdering() { - return this.orderColumnOrdering; - } - - public void setOrderColumnOrdering(boolean orderColumnOrdering) { - if (orderColumnOrdering) { - this.setSpecifiedOrderBy_(null); - this.setNoOrdering_(false); - this.setPkOrdering_(false); - this.setCustomOrdering_(false); - this.setOrderColumnOrdering_(true); - - this.getXmlOrderable().setOrderBy(null); - this.buildXmlOrderColumn(); - } else { - this.setNoOrdering(true); // hmmm... - } - } - - protected void setOrderColumnOrdering_(boolean orderColumnOrdering) { - boolean old = this.orderColumnOrdering; - this.orderColumnOrdering = orderColumnOrdering; - this.firePropertyChanged(ORDER_COLUMN_ORDERING_PROPERTY, old, orderColumnOrdering); - } - - /** - * JPA 2.0 only; - * the <code>order-column</code> element is present <em>and</em> - * the <code>order-by</code> element is missing - */ - protected boolean buildOrderColumnOrdering() { - return this.xmlOrderColumnIsPresent() && - (this.getXmlOrderBy() == null); - } - - - // ********** order column ********** - - public OrmOrderColumn2_0 getOrderColumn() { - return this.orderColumn; - } - - /** - * JPA 2.0 only - */ - protected OrmOrderColumn2_0 buildOrderColumn() { - return this.isOrmXml2_0Compatible() ? - this.getContextNodeFactory2_0().buildOrmOrderColumn(this, new OrderColumnOwner()) : - null; - } - - - // ********** xml order by ********** - - protected String getXmlOrderBy() { - return this.getXmlOrderable().getOrderBy(); - } - - - // ********** xml order column ********** - - protected XmlOrderColumn getXmlOrderColumn() { - return this.getXmlOrderable().getOrderColumn(); - } - - /** - * NB: Only return <code>true</code> for JPA 2.0 mappings. - */ - protected boolean xmlOrderColumnIsPresent() { - return this.isJpa2_0Compatible() && (this.getXmlOrderColumn() != null); - } - - protected XmlOrderColumn buildXmlOrderColumn() { - XmlOrderColumn xmlColumn = OrmFactory.eINSTANCE.createXmlOrderColumn(); - GenericOrmOrderable.this.getXmlOrderable().setOrderColumn(xmlColumn); - return xmlColumn; - } - - protected void removeXmlOrderColumn() { - if (this.xmlOrderColumnIsPresent()) { - this.getXmlOrderable().setOrderColumn(null); - } - } - - - // ********** misc ********** - - @Override - public OrmAttributeMapping getParent() { - return (OrmAttributeMapping) super.getParent(); - } - - protected OrmAttributeMapping getAttributeMapping() { - return this.getParent(); - } - - protected OrmPersistentAttribute getPersistentAttribute() { - return this.getAttributeMapping().getPersistentAttribute(); - } - - protected XmlOrderable getXmlOrderable() { - return (XmlOrderable) this.getAttributeMapping().getXmlAttributeMapping(); - } - - // JPA 2.0 - public String getDefaultTableName() { - return this.owner.getTableName(); - } - - // JPA 2.0 - protected Table resolveDbTable(String tableName) { - return this.owner.resolveDbTable(tableName); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlOrderable().getValidationTextRange(); - return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - // order-column and order-by both specified is handled with schema validation - if (this.orderColumnOrdering) { - // TODO validation message if type is not List - this.orderColumn.validate(messages, reporter); - } - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.orderColumn.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } - - // ********** order column owner (JPA 2.0) ********** - - protected class OrderColumnOwner - implements OrmOrderColumn2_0.Owner - { - public String getDefaultTableName() { - return GenericOrmOrderable.this.getDefaultTableName(); - } - - public Table resolveDbTable(String tableName) { - return GenericOrmOrderable.this.resolveDbTable(tableName); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - return this.getPersistentAttribute().getName() + "_ORDER"; //$NON-NLS-1$ - } - - public TextRange getValidationTextRange() { - return GenericOrmOrderable.this.getValidationTextRange(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new OrderColumnValidator(this.getPersistentAttribute(), (OrderColumn2_0) column, textRangeResolver); - } - - public XmlOrderColumn getXmlColumn() { - return GenericOrmOrderable.this.getXmlOrderColumn(); - } - - public XmlOrderColumn buildXmlColumn() { - return GenericOrmOrderable.this.buildXmlOrderColumn(); - } - - public void removeXmlColumn() { - GenericOrmOrderable.this.removeXmlOrderColumn(); - } - - protected OrmPersistentAttribute getPersistentAttribute() { - return GenericOrmOrderable.this.getPersistentAttribute(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java deleted file mode 100644 index 0f010df5af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmOverrideRelationship.java +++ /dev/null @@ -1,323 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.MappedByRelationship; -import org.eclipse.jpt.jpa.core.context.OverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyOverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.Relationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmOverrideJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.context.orm.NullOrmJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmOverrideJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappingRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmOverrideRelationship - extends AbstractOrmXmlContextNode - implements OrmOverrideRelationship2_0 -{ - protected OrmRelationshipStrategy strategy; - - protected final OrmJoinColumnRelationshipStrategy joinColumnStrategy; - - // JPA 2.0 - protected final OrmJoinTableRelationshipStrategy joinTableStrategy; - - - public GenericOrmOverrideRelationship(OrmAssociationOverride parent) { - super(parent); - this.joinColumnStrategy = this.buildJoinColumnStrategy(); - this.joinTableStrategy = this.buildJoinTableStrategy(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.joinColumnStrategy.synchronizeWithResourceModel(); - this.joinTableStrategy.synchronizeWithResourceModel(); - } - - @Override - public void update() { - super.update(); - this.setStrategy(this.buildStrategy()); - this.joinColumnStrategy.update(); - this.joinTableStrategy.update(); - } - - - // ********** strategy ********** - - public OrmRelationshipStrategy getStrategy() { - return this.strategy; - } - - protected void setStrategy(OrmRelationshipStrategy strategy) { - OrmRelationshipStrategy old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - protected OrmRelationshipStrategy buildStrategy() { - return this.isJpa2_0Compatible() ? - this.buildStrategy2_0() : - this.joinColumnStrategy; - } - - /** - * The overridden mapping determines the override's strategy. - */ - protected OrmRelationshipStrategy buildStrategy2_0() { - MappingRelationshipStrategy2_0 mappingStrategy = this.getMappingStrategy(); - return (mappingStrategy != null) ? - (OrmRelationshipStrategy) mappingStrategy.selectOverrideStrategy(this) : - this.buildMissingMappingStrategy(); - } - - /** - * Get the strategy from the overridden mapping. - */ - protected MappingRelationshipStrategy2_0 getMappingStrategy() { - RelationshipMapping mapping = this.getMapping(); - return (mapping == null) ? null : (MappingRelationshipStrategy2_0) mapping.getRelationship().getStrategy(); - } - - /** - * Return the strategy to use when the override's name does not match the - * name of an appropriate relationship mapping. - */ - protected OrmRelationshipStrategy buildMissingMappingStrategy() { - return this.joinColumnStrategy.hasSpecifiedJoinColumns() ? - this.joinColumnStrategy : - this.joinTableStrategy; - } - - - // ********** join column strategy ********** - - public OrmJoinColumnRelationshipStrategy getJoinColumnStrategy() { - return this.joinColumnStrategy; - } - - public boolean strategyIsJoinColumn() { - return this.strategy == this.joinColumnStrategy; - } - - public void setStrategyToJoinColumn() { - this.joinColumnStrategy.addStrategy(); - this.joinTableStrategy.removeStrategy(); - } - - public boolean mayHaveDefaultJoinColumn() { - // association overrides do not have defaults - return false; - } - - protected OrmJoinColumnRelationshipStrategy buildJoinColumnStrategy() { - return new GenericOrmOverrideJoinColumnRelationshipStrategy(this); - } - - - // ********** join table strategy ********** - - public OrmJoinTableRelationshipStrategy getJoinTableStrategy() { - return this.joinTableStrategy; - } - - public boolean strategyIsJoinTable() { - return this.strategy == this.joinTableStrategy; - } - - public void setStrategyToJoinTable() { - this.joinTableStrategy.addStrategy(); - this.joinColumnStrategy.removeStrategy(); - } - - public boolean mayHaveDefaultJoinTable() { - // association overrides do not have defaults - return false; - } - - protected OrmJoinTableRelationshipStrategy buildJoinTableStrategy() { - return this.isJpa2_0Compatible() ? - new GenericOrmOverrideJoinTableRelationshipStrategy2_0(this) : - new NullOrmJoinTableRelationshipStrategy(this); - } - - - // ********** conversions ********** - - public void initializeFrom(ReadOnlyRelationship oldRelationship) { - oldRelationship.initializeOn(this); - } - - public void initializeOn(Relationship newRelationship) { - newRelationship.initializeFromJoinTableRelationship(this); - newRelationship.initializeFromJoinColumnRelationship(this); - } - - public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) { - // NOP - } - - public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) { - this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy()); - } - - public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) { - this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy()); - } - - public void initializeFromVirtual(ReadOnlyOverrideRelationship virtualRelationship) { - virtualRelationship.initializeOnSpecified(this); - } - - public void initializeOnSpecified(OverrideRelationship specifiedRelationship) { - throw new UnsupportedOperationException(); - } - - public void initializeFromVirtualJoinTableRelationship(ReadOnlyJoinTableRelationship virtualRelationship) { - this.joinTableStrategy.initializeFromVirtual(virtualRelationship.getJoinTableStrategy()); - } - - public void initializeFromVirtualJoinColumnRelationship(ReadOnlyJoinColumnRelationship virtualRelationship) { - this.joinColumnStrategy.initializeFromVirtual(virtualRelationship.getJoinColumnStrategy()); - } - - - // ********** misc ********** - - @Override - public OrmAssociationOverride getParent() { - return (OrmAssociationOverride) super.getParent(); - } - - protected OrmAssociationOverride getAssociationOverride() { - return this.getParent(); - } - - protected OrmAssociationOverride2_0 getAssociationOverride2_0() { - return (OrmAssociationOverride2_0) this.getAssociationOverride(); - } - - public XmlAssociationOverride getXmlContainer() { - return this.getAssociationOverride().getXmlOverride(); - } - - public TypeMapping getTypeMapping() { - return this.getAssociationOverride().getTypeMapping(); - } - - public String getAttributeName() { - return this.getAssociationOverride().getName(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getAssociationOverride().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getAssociationOverride().getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return this.getAssociationOverride().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getAssociationOverride().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride().buildColumnValidator(column, owner, textRangeResolver); - } - - public Entity getEntity() { - TypeMapping typeMapping = this.getTypeMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - public boolean isVirtual() { - return false; - } - - public RelationshipMapping getMapping() { - return this.getAssociationOverride().getMapping(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - return this.getAssociationOverride().getValidationTextRange(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.strategy.validate(messages, reporter); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableValidator(table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - result = this.strategy.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java deleted file mode 100644 index 3b24185b6b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitDefaults; - -/** - * <code>orm.xml</code> file - * <br> - * <code>persistence-unit-defaults</code> element - */ -public class GenericOrmPersistenceUnitDefaults - extends AbstractOrmPersistenceUnitDefaults -{ - - - // ********** constructor/initialization ********** - - public GenericOrmPersistenceUnitDefaults(OrmPersistenceUnitMetadata parent) { - super(parent); - } - - @Override - protected XmlPersistenceUnitDefaults buildXmlPersistenceUnitDefaults() { - return OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java deleted file mode 100644 index 4a4b5d79c3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPersistenceUnitMetadata; -import org.eclipse.jpt.jpa.core.resource.xml.EmfTools; - -/** - * <code>orm.xml</code> file - * <br> - * <code>persistence-unit-metadata</code> element - */ -public class GenericOrmPersistenceUnitMetadata - extends AbstractOrmPersistenceUnitMetadata -{ - - public GenericOrmPersistenceUnitMetadata(EntityMappings parent) { - super(parent); - } - - @Override - protected XmlPersistenceUnitMetadata buildXmlPersistenceUnitMetadata_() { - return EmfTools.create( - this.getResourceNodeFactory(), - OrmPackage.eINSTANCE.getXmlPersistenceUnitMetadata(), - XmlPersistenceUnitMetadata.class - ); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java deleted file mode 100644 index 83ce2991a7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.orm.SpecifiedOrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> persistent attribute - */ -public class GenericOrmPersistentAttribute - extends SpecifiedOrmPersistentAttribute -{ - public GenericOrmPersistentAttribute(OrmPersistentType parent, XmlAttributeMapping xmlMapping) { - super(parent, xmlMapping); - } - - - // ********** validation ********** - - @Override - protected void validateAttribute(List<IMessage> messages, IReporter reporter) { - super.validateAttribute(messages, reporter); - if (this.javaPersistentAttribute != null) { - JavaPersistentType javaPersistentType = this.getOwningPersistentType().getJavaPersistentType(); - if ((javaPersistentType != null) && (javaPersistentType.getAttributeNamed(this.javaPersistentAttribute.getName()) == null)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.NORMAL_SEVERITY, - JpaValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED, - new String[] { - this.getName(), - this.getOwningPersistentType().getMapping().getClass_() - }, - this.mapping, - this.mapping.getNameTextRange() - ) - ); - } - } - } - - @Override - protected JptValidator buildAttibuteValidator() { - return this.getJavaPersistentAttribute().getAccessor().buildAttributeValidator(this, buildTextRangeResolver()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java deleted file mode 100644 index 750bfb8d7e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.internal.context.orm.SpecifiedOrmPersistentType; -import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping; - -/** - * <code>orm.xml</code> persistent type:<ul> - * <li>mapping - * <li>access - * <li>attributes - * <li>super persistent type - * <li>Java persistent type - * </ul> - */ -public class GenericOrmPersistentType - extends SpecifiedOrmPersistentType -{ - - public GenericOrmPersistentType(EntityMappings parent, XmlTypeMapping xmlTypeMapping) { - super(parent, xmlTypeMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java deleted file mode 100644 index 26c08d3df7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmPrimaryKeyJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * <code>orm.xml</code> primary key join column - */ -public class GenericOrmPrimaryKeyJoinColumn - extends AbstractOrmNamedColumn<XmlPrimaryKeyJoinColumn, OrmReadOnlyBaseJoinColumn.Owner> - implements OrmPrimaryKeyJoinColumn -{ - /** @see org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmNamedColumn#AbstractOrmNamedColumn(XmlContextNode, org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyNamedColumn.Owner, org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlNamedColumn) */ - protected /* final */ XmlPrimaryKeyJoinColumn xmlColumn; // null for default pk join columns - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericOrmPrimaryKeyJoinColumn(XmlContextNode parent, OrmReadOnlyBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn xmlColumn) { - super(parent, owner, xmlColumn); - this.specifiedReferencedColumnName = this.buildSpecifiedReferencedColumnName(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedReferencedColumnName_(this.buildSpecifiedReferencedColumnName()); - } - - @Override - public void update() { - super.update(); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** XML column ********** - - @Override - public XmlPrimaryKeyJoinColumn getXmlColumn() { - return this.xmlColumn; - } - - @Override - protected void setXmlColumn(XmlPrimaryKeyJoinColumn xmlColumn) { - this.xmlColumn = xmlColumn; - } - - /** - * primary key join columns are part of a collection; - * the 'primary-key-join-column' element will be removed/added - * when the XML join column is removed from/added to - * the owner's collection - */ - @Override - protected XmlPrimaryKeyJoinColumn buildXmlColumn() { - throw new IllegalStateException("XML primary key join column is missing"); //$NON-NLS-1$ - } - - /** - * @see #buildXmlColumn() - */ - @Override - protected void removeXmlColumn() { - // do nothing - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - public void setSpecifiedReferencedColumnName(String name) { - this.setSpecifiedReferencedColumnName_(name); - this.xmlColumn.setReferencedColumnName(name); - } - - protected void setSpecifiedReferencedColumnName_(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return (this.xmlColumn == null) ? null : this.xmlColumn.getReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - // TODO not correct when we start supporting - // primary key join columns in 1-1 mappings - protected String buildDefaultReferencedColumnName() { - return this.buildDefaultName(); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** misc ********** - - public void initializeFrom(ReadOnlyPrimaryKeyJoinColumn oldColumn) { - super.initializeFrom(oldColumn); - this.setSpecifiedReferencedColumnName(oldColumn.getSpecifiedReferencedColumnName()); - } - - @Override - public String getTable() { - return this.owner.getDefaultTableName(); - } - - - // ********** validation ********** - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver() { - return new OrmPrimaryKeyJoinColumnTextRangeResolver(this); - } - - public TextRange getReferencedColumnNameTextRange() { - return this.getValidationTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); - } - - // ********** completion proposals ********** - - @Override - protected Iterable<String> getConnectedXmlCompletionProposals(int pos) { - Iterable<String> result = super.getConnectedXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.referencedColumnNameTouches(pos)) { - return this.getCandidateReferencedColumnNames(); - } - return null; - } - - public boolean referencedColumnNameTouches(int pos) { - XmlPrimaryKeyJoinColumn column = this.getXmlColumn(); - return (column != null) && (column.referencedColumnNameTouches(pos)); - } - - protected Iterable<String> getCandidateReferencedColumnNames() { - Table table = this.owner.getReferencedColumnDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java deleted file mode 100644 index 2a18873415..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.jpa.core.context.NamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.NamedQuery; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery; -import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery; -import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedNativeQuery; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery; -import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryContainer; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> query container - */ -public class GenericOrmQueryContainer - extends AbstractOrmXmlContextNode - implements OrmQueryContainer -{ - protected final XmlQueryContainer xmlQueryContainer; - - protected final ContextListContainer<OrmNamedQuery, XmlNamedQuery> namedQueryContainer; - protected final ContextListContainer<OrmNamedNativeQuery, XmlNamedNativeQuery> namedNativeQueryContainer; - - - public GenericOrmQueryContainer(XmlContextNode parent, XmlQueryContainer xmlQueryContainer) { - super(parent); - this.xmlQueryContainer = xmlQueryContainer; - this.namedQueryContainer = this.buildNamedQueryContainer(); - this.namedNativeQueryContainer = this.buildNamedNativeQueryContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncNamedQueries(); - this.syncNamedNativeQueries(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getNamedQueries()); - this.updateNodes(this.getNamedNativeQueries()); - } - - - // ********** queries ********** - - @SuppressWarnings("unchecked") - public Iterable<Query> getQueries() { - return new CompositeIterable<Query>(this.getNamedQueries(), this.getNamedNativeQueries()); - } - - - // ********** named queries ********** - - public ListIterable<OrmNamedQuery> getNamedQueries() { - return this.namedQueryContainer.getContextElements(); - } - - public int getNamedQueriesSize() { - return this.namedQueryContainer.getContextElementsSize(); - } - - public OrmNamedQuery addNamedQuery() { - return this.addNamedQuery(this.getNamedQueriesSize()); - } - - public OrmNamedQuery addNamedQuery(int index) { - XmlNamedQuery xmlQuery = this.buildXmlNamedQuery(); - OrmNamedQuery query = this.namedQueryContainer.addContextElement(index, xmlQuery); - this.xmlQueryContainer.getNamedQueries().add(index, xmlQuery); - return query; - } - - protected XmlNamedQuery buildXmlNamedQuery() { - return OrmFactory.eINSTANCE.createXmlNamedQuery(); - } - - public void removeNamedQuery(NamedQuery namedQuery) { - this.removeNamedQuery(this.namedQueryContainer.indexOfContextElement((OrmNamedQuery) namedQuery)); - } - - public void removeNamedQuery(int index) { - this.namedQueryContainer.removeContextElement(index); - this.xmlQueryContainer.getNamedQueries().remove(index); - } - - public void moveNamedQuery(int targetIndex, int sourceIndex) { - this.namedQueryContainer.moveContextElement(targetIndex, sourceIndex); - this.xmlQueryContainer.getNamedQueries().move(targetIndex, sourceIndex); - } - - protected OrmNamedQuery buildNamedQuery(XmlNamedQuery xmlNamedQuery) { - return this.getContextNodeFactory().buildOrmNamedQuery(this, xmlNamedQuery); - } - - protected void syncNamedQueries() { - this.namedQueryContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlNamedQuery> getXmlNamedQueries() { - // clone to reduce chance of concurrency problems - return new LiveCloneListIterable<XmlNamedQuery>(this.xmlQueryContainer.getNamedQueries()); - } - - protected ContextListContainer<OrmNamedQuery, XmlNamedQuery> buildNamedQueryContainer() { - NamedQueryContainer container = new NamedQueryContainer(); - container.initialize(); - return container; - } - - /** - * named query container - */ - protected class NamedQueryContainer - extends ContextListContainer<OrmNamedQuery, XmlNamedQuery> - { - @Override - protected String getContextElementsPropertyName() { - return NAMED_QUERIES_LIST; - } - @Override - protected OrmNamedQuery buildContextElement(XmlNamedQuery resourceElement) { - return GenericOrmQueryContainer.this.buildNamedQuery(resourceElement); - } - @Override - protected ListIterable<XmlNamedQuery> getResourceElements() { - return GenericOrmQueryContainer.this.getXmlNamedQueries(); - } - @Override - protected XmlNamedQuery getResourceElement(OrmNamedQuery contextElement) { - return contextElement.getXmlQuery(); - } - } - - // ********** named native queries ********** - - public ListIterable<OrmNamedNativeQuery> getNamedNativeQueries() { - return this.namedNativeQueryContainer.getContextElements(); - } - - public int getNamedNativeQueriesSize() { - return this.namedNativeQueryContainer.getContextElementsSize(); - } - - public OrmNamedNativeQuery addNamedNativeQuery() { - return this.addNamedNativeQuery(this.getNamedNativeQueriesSize()); - } - - public OrmNamedNativeQuery addNamedNativeQuery(int index) { - XmlNamedNativeQuery xmlQuery = this.buildXmlNamedNativeQuery(); - OrmNamedNativeQuery query = this.namedNativeQueryContainer.addContextElement(index, xmlQuery); - this.xmlQueryContainer.getNamedNativeQueries().add(index, xmlQuery); - return query; - } - - protected XmlNamedNativeQuery buildXmlNamedNativeQuery() { - return OrmFactory.eINSTANCE.createXmlNamedNativeQuery(); - } - - public void removeNamedNativeQuery(NamedNativeQuery namedNativeQuery) { - this.removeNamedNativeQuery(this.namedNativeQueryContainer.indexOfContextElement((OrmNamedNativeQuery) namedNativeQuery)); - } - - public void removeNamedNativeQuery(int index) { - this.namedNativeQueryContainer.removeContextElement(index); - this.xmlQueryContainer.getNamedNativeQueries().remove(index); - } - - public void moveNamedNativeQuery(int targetIndex, int sourceIndex) { - this.namedNativeQueryContainer.moveContextElement(targetIndex, sourceIndex); - this.xmlQueryContainer.getNamedNativeQueries().move(targetIndex, sourceIndex); - } - - protected OrmNamedNativeQuery buildNamedNativeQuery(XmlNamedNativeQuery xmlNamedNativeQuery) { - return this.getContextNodeFactory().buildOrmNamedNativeQuery(this, xmlNamedNativeQuery); - } - - protected void syncNamedNativeQueries() { - this.namedNativeQueryContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlNamedNativeQuery> getXmlNamedNativeQueries() { - // clone to reduce chance of concurrency problems - return new LiveCloneListIterable<XmlNamedNativeQuery>(this.xmlQueryContainer.getNamedNativeQueries()); - } - - protected ContextListContainer<OrmNamedNativeQuery, XmlNamedNativeQuery> buildNamedNativeQueryContainer() { - NamedNativeQueryContainer container = new NamedNativeQueryContainer(); - container.initialize(); - return container; - } - - /** - * named query container - */ - protected class NamedNativeQueryContainer - extends ContextListContainer<OrmNamedNativeQuery, XmlNamedNativeQuery> - { - @Override - protected String getContextElementsPropertyName() { - return NAMED_NATIVE_QUERIES_LIST; - } - @Override - protected OrmNamedNativeQuery buildContextElement(XmlNamedNativeQuery resourceElement) { - return GenericOrmQueryContainer.this.buildNamedNativeQuery(resourceElement); - } - @Override - protected ListIterable<XmlNamedNativeQuery> getResourceElements() { - return GenericOrmQueryContainer.this.getXmlNamedNativeQueries(); - } - @Override - protected XmlNamedNativeQuery getResourceElement(OrmNamedNativeQuery contextElement) { - return contextElement.getXmlQuery(); - } - } - - - // ********** validation ********** - - /** - * The queries are validated in the persistence unit. - * @see org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#validateQueries(List, IReporter) - */ - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - // queries are validated in the persistence unit - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlQueryContainer.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java deleted file mode 100644 index 3bf4a14837..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.QueryHint; -import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint; -import org.eclipse.jpt.jpa.core.context.orm.OrmQuery; -import org.eclipse.jpt.jpa.core.context.orm.OrmQueryHint; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryHint; - -/** - * <code>orm.xml</code> query hint - */ -public class GenericOrmQueryHint - extends AbstractOrmXmlContextNode - implements OrmQueryHint -{ - protected final XmlQueryHint xmlQueryHint; - - protected String name; - protected String value; - - - public GenericOrmQueryHint(OrmQuery parent, XmlQueryHint xmlQueryHint) { - super(parent); - this.xmlQueryHint = xmlQueryHint; - this.name = xmlQueryHint.getName(); - this.value = xmlQueryHint.getValue(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setName_(this.xmlQueryHint.getName()); - this.setValue_(this.xmlQueryHint.getValue()); - } - - - // ********** name ********** - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.setName_(name); - this.xmlQueryHint.setName(name); - } - - protected void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - - // ********** value ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.setValue_(value); - this.xmlQueryHint.setValue(value); - } - - protected void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - // ********** metadata conversion ********** - - public void convertFrom(JavaQueryHint javaHint) { - this.setName(javaHint.getName()); - this.setValue(javaHint.getValue()); - } - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlQueryHint.getValidationTextRange(); - return (textRange != null) ? textRange : this.getQuery().getValidationTextRange(); - } - - public boolean isEquivalentTo(QueryHint hint) { - return StringTools.stringsAreEqual(this.getName(), hint.getName()) && - StringTools.stringsAreEqual(this.getValue(), hint.getValue()) ; - } - - // ********** misc ********** - - @Override - public OrmQuery getParent() { - return (OrmQuery) super.getParent(); - } - - protected OrmQuery getQuery() { - return this.getParent(); - } - - public XmlQueryHint getXmlQueryHint() { - return this.xmlQueryHint; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } -} 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 deleted file mode 100644 index 0c1005835b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmReferenceTable.java +++ /dev/null @@ -1,281 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyReferenceTable; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReferenceTable; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmTable; -import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlReferenceTable; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumn; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> join table or collection table - */ -public abstract class GenericOrmReferenceTable<X extends AbstractXmlReferenceTable> - extends AbstractOrmTable<X> - implements OrmReferenceTable -{ - protected final ContextListContainer<OrmJoinColumn, XmlJoinColumn> specifiedJoinColumnContainer; - protected final OrmReadOnlyJoinColumn.Owner joinColumnOwner; - - protected OrmJoinColumn defaultJoinColumn; - - - protected GenericOrmReferenceTable(XmlContextNode parent, Owner owner) { - super(parent, owner); - this.joinColumnOwner = this.buildJoinColumnOwner(); - this.specifiedJoinColumnContainer = this.buildSpecifiedJoinColumnContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedJoinColumns(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedJoinColumns()); - this.updateDefaultJoinColumn(); - } - - - // ********** join columns ********** - - public ListIterable<OrmJoinColumn> getJoinColumns() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns(); - } - - public int getJoinColumnsSize() { - return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize(); - } - - public void convertDefaultJoinColumnToSpecified() { - MappingTools.convertReferenceTableDefaultToSpecifiedJoinColumn(this); - } - - - // ********** specified join columns ********** - - public ListIterable<OrmJoinColumn> getSpecifiedJoinColumns() { - return this.specifiedJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedJoinColumnsSize() { - return this.specifiedJoinColumnContainer.getContextElementsSize(); - } - - public boolean hasSpecifiedJoinColumns() { - return this.getSpecifiedJoinColumnsSize() != 0; - } - - public OrmJoinColumn getSpecifiedJoinColumn(int index) { - return this.specifiedJoinColumnContainer.getContextElement(index); - } - - public OrmJoinColumn addSpecifiedJoinColumn() { - return this.addSpecifiedJoinColumn(this.getSpecifiedJoinColumnsSize()); - } - - public OrmJoinColumn addSpecifiedJoinColumn(int index) { - X xmlTable = this.getXmlTableForUpdate(); - XmlJoinColumn xmlJoinColumn = this.buildXmlJoinColumn(); - OrmJoinColumn joinColumn = this.specifiedJoinColumnContainer.addContextElement(index, xmlJoinColumn); - xmlTable.getJoinColumns().add(index, xmlJoinColumn); - return joinColumn; - } - - protected XmlJoinColumn buildXmlJoinColumn() { - return OrmFactory.eINSTANCE.createXmlJoinColumn(); - } - - public void removeSpecifiedJoinColumn(JoinColumn joinColumn) { - this.removeSpecifiedJoinColumn(this.specifiedJoinColumnContainer.indexOfContextElement((OrmJoinColumn) joinColumn)); - } - - public void removeSpecifiedJoinColumn(int index) { - this.specifiedJoinColumnContainer.removeContextElement(index); - this.getXmlTable().getJoinColumns().remove(index); - this.removeXmlTableIfUnset(); - } - - public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) { - this.specifiedJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - this.getXmlTable().getJoinColumns().move(targetIndex, sourceIndex); - } - - protected void syncSpecifiedJoinColumns() { - this.specifiedJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlJoinColumn> getXmlJoinColumns() { - X xmlTable = this.getXmlTable(); - return (xmlTable == null) ? - EmptyListIterable.<XmlJoinColumn>instance() : - // clone to reduce chance of concurrency problems - new LiveCloneListIterable<XmlJoinColumn>(xmlTable.getJoinColumns()); - } - - protected ContextListContainer<OrmJoinColumn, XmlJoinColumn> buildSpecifiedJoinColumnContainer() { - SpecifiedJoinColumnContainer container = new SpecifiedJoinColumnContainer(); - container.initialize(); - return container; - } - - /** - * specified join column container - */ - protected class SpecifiedJoinColumnContainer - extends ContextListContainer<OrmJoinColumn, XmlJoinColumn> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_JOIN_COLUMNS_LIST; - } - @Override - protected OrmJoinColumn buildContextElement(XmlJoinColumn resourceElement) { - return GenericOrmReferenceTable.this.buildJoinColumn(resourceElement); - } - @Override - protected ListIterable<XmlJoinColumn> getResourceElements() { - return GenericOrmReferenceTable.this.getXmlJoinColumns(); - } - @Override - protected XmlJoinColumn getResourceElement(OrmJoinColumn contextElement) { - return contextElement.getXmlColumn(); - } - } - - protected abstract OrmReadOnlyJoinColumn.Owner buildJoinColumnOwner(); - - - // ********** default join column ********** - - public OrmJoinColumn getDefaultJoinColumn() { - return this.defaultJoinColumn; - } - - protected void setDefaultJoinColumn(OrmJoinColumn joinColumn) { - OrmJoinColumn old = this.defaultJoinColumn; - this.defaultJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn); - } - - protected ListIterable<OrmJoinColumn> getDefaultJoinColumns() { - return (this.defaultJoinColumn != null) ? - new SingleElementListIterable<OrmJoinColumn>(this.defaultJoinColumn) : - EmptyListIterable.<OrmJoinColumn>instance(); - } - - protected int getDefaultJoinColumnsSize() { - return (this.defaultJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultJoinColumn() { - if (this.buildsDefaultJoinColumn()) { - if (this.defaultJoinColumn == null) { - this.setDefaultJoinColumn(this.buildJoinColumn(null)); - } else { - this.defaultJoinColumn.update(); - } - } else { - this.setDefaultJoinColumn(null); - } - } - - protected boolean buildsDefaultJoinColumn() { - return ! this.hasSpecifiedJoinColumns(); - } - - - // ********** misc ********** - - protected void initializeFrom(ReadOnlyReferenceTable oldTable) { - super.initializeFrom(oldTable); - for (ReadOnlyJoinColumn joinColumn : oldTable.getSpecifiedJoinColumns()) { - this.addSpecifiedJoinColumn().initializeFrom(joinColumn); - } - } - - protected void initializeFromVirtual(ReadOnlyReferenceTable virtualTable) { - super.initializeFromVirtual(virtualTable); - for (ReadOnlyJoinColumn joinColumn : virtualTable.getJoinColumns()) { - this.addSpecifiedJoinColumn().initializeFromVirtual(joinColumn); - } - } - - protected OrmJoinColumn buildJoinColumn(XmlJoinColumn xmlJoinColumn) { - return this.getContextNodeFactory().buildOrmJoinColumn(this, this.joinColumnOwner, xmlJoinColumn); - } - - @Override - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - boolean continueValidating = this.buildTableValidator().validate(messages, reporter); - - //join column validation will handle the check for whether to validate against the database - //some validation messages are not database specific. If the database validation for the - //table fails we will stop there and not validate the join columns at all - if (continueValidating) { - this.validateJoinColumns(messages, reporter); - } - } - - protected void validateJoinColumns(List<IMessage> messages, IReporter reporter) { - this.validateNodes(this.getJoinColumns(), messages, reporter); - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - for (OrmJoinColumn column : this.getJoinColumns()) { - result = column.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } -} 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 deleted file mode 100644 index f91546bee1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java +++ /dev/null @@ -1,380 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable; -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmSecondaryTable; -import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmTable; -import org.eclipse.jpt.jpa.core.internal.jpa1.context.SecondaryTablePrimaryKeyJoinColumnValidator; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.resource.orm.XmlSecondaryTable; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>orm.xml</code> secondary table - */ -public class GenericOrmSecondaryTable - extends AbstractOrmTable<XmlSecondaryTable> - implements OrmSecondaryTable -{ - /** @see AbstractOrmTable#AbstractOrmTable(org.eclipse.jpt.jpa.core.context.XmlContextNode, org.eclipse.jpt.jpa.core.context.Table.Owner, org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlTable) */ - protected /* final */ XmlSecondaryTable xmlSecondaryTable; - - protected final ContextListContainer<OrmPrimaryKeyJoinColumn, XmlPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumnContainer; - protected final OrmReadOnlyBaseJoinColumn.Owner primaryKeyJoinColumnOwner; - - protected OrmPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn; - - - public GenericOrmSecondaryTable(OrmEntity parent, Owner owner, XmlSecondaryTable xmlSecondaryTable) { - super(parent, owner, xmlSecondaryTable); - this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner(); - this.specifiedPrimaryKeyJoinColumnContainer = this.buildSpecifiedPrimaryKeyJoinColumnContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncSpecifiedPrimaryKeyJoinColumns(); - if (this.defaultPrimaryKeyJoinColumn != null) { - this.defaultPrimaryKeyJoinColumn.synchronizeWithResourceModel(); - } - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getSpecifiedPrimaryKeyJoinColumns()); - this.updateDefaultPrimaryKeyJoinColumn(); - } - - - // ********** XML table ********** - - @Override - public XmlSecondaryTable getXmlTable() { - return this.xmlSecondaryTable; - } - - /** - * @see AbstractOrmTable - */ - @Override - protected void setXmlTable(XmlSecondaryTable xmlTable) { - this.xmlSecondaryTable = xmlTable; - } - - /** - * secondary tables are part of a collection; - * the 'secondary-table' element will be removed from/added - * when the XML secondary table is removed/added to - * the XML entity's collection - */ - @Override - protected XmlSecondaryTable buildXmlTable() { - throw new IllegalStateException("XML secondary table is missing"); //$NON-NLS-1$ - } - - /** - * @see #buildXmlTable() - */ - @Override - protected void removeXmlTable() { - // do nothing - } - - - // ********** primary key join columns ********** - - public ListIterable<OrmPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() { - return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumns() : this.getDefaultPrimaryKeyJoinColumns(); - } - - public int getPrimaryKeyJoinColumnsSize() { - return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumnsSize() : this.getDefaultPrimaryKeyJoinColumnsSize(); - } - - - // ********** specified primary key join columns ********** - - public ListIterable<OrmPrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns() { - return this.specifiedPrimaryKeyJoinColumnContainer.getContextElements(); - } - - public int getSpecifiedPrimaryKeyJoinColumnsSize() { - return this.specifiedPrimaryKeyJoinColumnContainer.getContextElementsSize(); - } - - protected boolean hasSpecifiedPrimaryKeyJoinColumns() { - return this.getSpecifiedPrimaryKeyJoinColumnsSize() != 0; - } - - public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn() { - return this.addSpecifiedPrimaryKeyJoinColumn(this.getSpecifiedPrimaryKeyJoinColumnsSize()); - } - - public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) { - XmlPrimaryKeyJoinColumn xmlJoinColumn = this.buildXmlPrimaryKeyJoinColumn(); - OrmPrimaryKeyJoinColumn joinColumn = this.specifiedPrimaryKeyJoinColumnContainer.addContextElement(index, xmlJoinColumn); - this.xmlSecondaryTable.getPrimaryKeyJoinColumns().add(index, xmlJoinColumn); - return joinColumn; - } - - protected XmlPrimaryKeyJoinColumn buildXmlPrimaryKeyJoinColumn() { - return OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn(); - } - - public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn joinColumn) { - this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumnContainer.indexOfContextElement((OrmPrimaryKeyJoinColumn) joinColumn)); - } - - public void removeSpecifiedPrimaryKeyJoinColumn(int index) { - this.specifiedPrimaryKeyJoinColumnContainer.removeContextElement(index); - this.xmlSecondaryTable.getPrimaryKeyJoinColumns().remove(index); - } - - public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) { - this.specifiedPrimaryKeyJoinColumnContainer.moveContextElement(targetIndex, sourceIndex); - this.xmlSecondaryTable.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex); - } - - protected void syncSpecifiedPrimaryKeyJoinColumns() { - this.specifiedPrimaryKeyJoinColumnContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlPrimaryKeyJoinColumn> getXmlPrimaryKeyJoinColumns() { - // clone to reduce chance of concurrency problems - return new LiveCloneListIterable<XmlPrimaryKeyJoinColumn>(this.xmlSecondaryTable.getPrimaryKeyJoinColumns()); - } - - protected ContextListContainer<OrmPrimaryKeyJoinColumn, XmlPrimaryKeyJoinColumn> buildSpecifiedPrimaryKeyJoinColumnContainer() { - SpecifiedPrimaryKeyJoinColumnContainer container = new SpecifiedPrimaryKeyJoinColumnContainer(); - container.initialize(); - return container; - } - - /** - * specified primary key join column container - */ - protected class SpecifiedPrimaryKeyJoinColumnContainer - extends ContextListContainer<OrmPrimaryKeyJoinColumn, XmlPrimaryKeyJoinColumn> - { - @Override - protected String getContextElementsPropertyName() { - return SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST; - } - @Override - protected OrmPrimaryKeyJoinColumn buildContextElement(XmlPrimaryKeyJoinColumn resourceElement) { - return GenericOrmSecondaryTable.this.buildPrimaryKeyJoinColumn(resourceElement); - } - @Override - protected ListIterable<XmlPrimaryKeyJoinColumn> getResourceElements() { - return GenericOrmSecondaryTable.this.getXmlPrimaryKeyJoinColumns(); - } - @Override - protected XmlPrimaryKeyJoinColumn getResourceElement(OrmPrimaryKeyJoinColumn contextElement) { - return contextElement.getXmlColumn(); - } - } - - protected OrmReadOnlyBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() { - return new PrimaryKeyJoinColumnOwner(); - } - - - // ********** default primary key join column ********** - - public OrmPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() { - return this.defaultPrimaryKeyJoinColumn; - } - - protected void setDefaultPrimaryKeyJoinColumn(OrmPrimaryKeyJoinColumn joinColumn) { - OrmPrimaryKeyJoinColumn old = this.defaultPrimaryKeyJoinColumn; - this.defaultPrimaryKeyJoinColumn = joinColumn; - this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, old, joinColumn); - } - - protected ListIterable<OrmPrimaryKeyJoinColumn> getDefaultPrimaryKeyJoinColumns() { - return (this.defaultPrimaryKeyJoinColumn != null) ? - new SingleElementListIterable<OrmPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn) : - EmptyListIterable.<OrmPrimaryKeyJoinColumn>instance(); - } - - protected int getDefaultPrimaryKeyJoinColumnsSize() { - return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1; - } - - protected void updateDefaultPrimaryKeyJoinColumn() { - if (this.buildsDefaultPrimaryKeyJoinColumn()) { - if (this.defaultPrimaryKeyJoinColumn == null) { - this.setDefaultPrimaryKeyJoinColumn(this.buildPrimaryKeyJoinColumn(null)); - } else { - this.defaultPrimaryKeyJoinColumn.update(); - } - } else { - this.setDefaultPrimaryKeyJoinColumn(null); - } - } - - protected boolean buildsDefaultPrimaryKeyJoinColumn() { - return ! this.hasSpecifiedPrimaryKeyJoinColumns(); - } - - - // ********** misc ********** - - @Override - public OrmEntity getParent() { - return (OrmEntity) super.getParent(); - } - - protected OrmEntity getEntity() { - return this.getParent(); - } - - public boolean isVirtual() { - return false; - } - - public void initializeFrom(ReadOnlySecondaryTable oldSecondaryTable) { - super.initializeFrom(oldSecondaryTable); - for (ReadOnlyPrimaryKeyJoinColumn pkJoinColumn : oldSecondaryTable.getSpecifiedPrimaryKeyJoinColumns()) { - this.addSpecifiedPrimaryKeyJoinColumn().initializeFrom(pkJoinColumn); - } - } - - protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn xmlJoinColumn) { - return this.getContextNodeFactory().buildOrmPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, xmlJoinColumn); - } - - - // ********** defaults ********** - - /** - * a secondary table doesn't have a default name - */ - @Override - protected String buildDefaultName() { - return null; - } - - @Override - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** validation ********** - - public boolean validatesAgainstDatabase() { - return this.connectionProfileIsActive(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - boolean continueValidating = this.buildTableValidator().validate(messages, reporter); - - //join column validation will handle the check for whether to validate against the database - //some validation messages are not database specific. If the database validation for the - //table fails we will stop there and not validate the join columns at all - if (continueValidating) { - this.validateNodes(this.getPrimaryKeyJoinColumns(), messages, reporter); - } - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - for (OrmPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) { - result = column.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } - - // ********** primary key join column owner adapter ********** - - protected class PrimaryKeyJoinColumnOwner - implements OrmReadOnlyBaseJoinColumn.Owner - { - protected OrmEntity getEntity() { - return GenericOrmSecondaryTable.this.getEntity(); - } - - public String getDefaultTableName() { - return GenericOrmSecondaryTable.this.getName(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - if (this.getJoinColumnsSize() != 1) { - return null; - } - Entity parentEntity = this.getEntity().getParentEntity(); - return (parentEntity != null) ? - parentEntity.getPrimaryKeyColumnName() : - this.getEntity().getPrimaryKeyColumnName(); - } - - public Table resolveDbTable(String tableName) { - return GenericOrmSecondaryTable.this.getDbTable(); - } - - public int getJoinColumnsSize() { - return GenericOrmSecondaryTable.this.getPrimaryKeyJoinColumnsSize(); - } - - public Table getReferencedColumnDbTable() { - return this.getEntity().getPrimaryDbTable(); - } - - public TextRange getValidationTextRange() { - return GenericOrmSecondaryTable.this.getValidationTextRange(); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new SecondaryTablePrimaryKeyJoinColumnValidator(GenericOrmSecondaryTable.this, (ReadOnlyBaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSequenceGenerator.java deleted file mode 100644 index 24ade86bd7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSequenceGenerator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.context.SequenceGenerator; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmSequenceGenerator; -import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator; - -/** - * <code>orm.xml</code> sequence generator - */ -public class GenericOrmSequenceGenerator - extends AbstractOrmSequenceGenerator -{ - public GenericOrmSequenceGenerator(XmlContextNode parent, XmlSequenceGenerator xmlSequenceGenerator) { - super(parent, xmlSequenceGenerator); - } - - // ********** database stuff ********** - - /** - * The JPA 1.0 spec does not allow a sequence to specify a catalog. - */ - @Override - protected String getCatalog() { - return this.getContextDefaultCatalog(); - } - - /** - * The JPA 1.0 spec does not allow a sequence to specify a schema. - */ - @Override - protected String getSchema() { - return this.getContextDefaultSchema(); - } - - // ********** validation ********** - - @Override - protected boolean isEquivalentTo(SequenceGenerator generator) { - return super.isEquivalentTo(generator) && - Tools.valuesAreEqual(this.getDbSchema(), generator.getDbSchema()) && - Tools.valuesAreEqual(this.getDbCatalog(), generator.getDbCatalog()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTable.java deleted file mode 100644 index 0832952ada..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTable.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmTable; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity; -import org.eclipse.jpt.jpa.core.resource.orm.XmlTable; - -/** - * <code>orm.xml</code> table - */ -public class GenericOrmTable - extends AbstractOrmTable<XmlTable> -{ - public GenericOrmTable(OrmEntity parent, Owner owner) { - super(parent, owner); - } - - - // ********** XML table ********** - - @Override - protected XmlTable getXmlTable() { - return this.getXmlEntity().getTable(); - } - - @Override - protected XmlTable buildXmlTable() { - XmlTable xmlTable = OrmFactory.eINSTANCE.createXmlTable(); - this.getXmlEntity().setTable(xmlTable); - return xmlTable; - } - - @Override - protected void removeXmlTable() { - this.getXmlEntity().setTable(null); - } - - protected XmlEntity getXmlEntity() { - return this.getEntity().getXmlTypeMapping(); - } - - - // ********** defaults ********** - - @Override - protected String buildDefaultName() { - return this.getEntity().getDefaultTableName(); - } - - @Override - protected String buildDefaultSchema() { - return this.getEntity().getDefaultSchema(); - } - - @Override - protected String buildDefaultCatalog() { - return this.getEntity().getDefaultCatalog(); - } - - - // ********** validation ********** - - public boolean validatesAgainstDatabase() { - return this.connectionProfileIsActive(); - } - - - // ********** misc ********** - - @Override - public OrmEntity getParent() { - return (OrmEntity) super.getParent(); - } - - protected OrmEntity getEntity() { - return this.getParent(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java deleted file mode 100644 index 6ce0ac56e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java +++ /dev/null @@ -1,544 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable; -import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode; -import org.eclipse.jpt.jpa.core.context.TableGenerator; -import org.eclipse.jpt.jpa.core.context.UniqueConstraint; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaTableGenerator; -import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.orm.OrmTableGenerator; -import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmGenerator; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; -import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator; -import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint; -import org.eclipse.jpt.jpa.db.Schema; -import org.eclipse.jpt.jpa.db.Table; - -/** - * <code>orm.xml</code> table generator - */ -public class GenericOrmTableGenerator - extends AbstractOrmGenerator<XmlTableGenerator> - implements OrmTableGenerator, UniqueConstraint.Owner -{ - protected String specifiedTable; - protected String defaultTable; - - protected String specifiedSchema; - protected String defaultSchema; - - protected String specifiedCatalog; - protected String defaultCatalog; - - protected String specifiedPkColumnName; - protected String defaultPkColumnName; - - protected String specifiedValueColumnName; - protected String defaultValueColumnName; - - protected String specifiedPkColumnValue; - protected String defaultPkColumnValue; - - protected final ContextListContainer<OrmUniqueConstraint, XmlUniqueConstraint> uniqueConstraintContainer; - - - // ********** constructor ********** - - public GenericOrmTableGenerator(XmlContextNode parent, XmlTableGenerator xmlTableGenerator) { - super(parent, xmlTableGenerator); - this.specifiedTable = xmlTableGenerator.getTable(); - this.specifiedSchema = xmlTableGenerator.getSchema(); - this.specifiedCatalog = xmlTableGenerator.getCatalog(); - this.specifiedPkColumnName = xmlTableGenerator.getPkColumnName(); - this.specifiedValueColumnName = xmlTableGenerator.getValueColumnName(); - this.specifiedPkColumnValue = xmlTableGenerator.getPkColumnValue(); - this.uniqueConstraintContainer = this.buildUniqueConstraintContainer(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setSpecifiedTable_(this.xmlGenerator.getTable()); - this.setSpecifiedSchema_(this.xmlGenerator.getSchema()); - this.setSpecifiedCatalog_(this.xmlGenerator.getCatalog()); - this.setSpecifiedPkColumnName_(this.xmlGenerator.getPkColumnName()); - this.setSpecifiedValueColumnName_(this.xmlGenerator.getValueColumnName()); - this.setSpecifiedPkColumnValue_(this.xmlGenerator.getPkColumnValue()); - this.syncUniqueConstraints(); - } - - @Override - public void update() { - super.update(); - this.setDefaultTable(this.buildDefaultTable()); - this.setDefaultSchema(this.buildDefaultSchema()); - this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setDefaultPkColumnName(this.buildDefaultPkColumnName()); - this.setDefaultValueColumnName(this.buildDefaultValueColumnName()); - this.setDefaultPkColumnValue(this.buildDefaultPkColumnValue()); - this.updateNodes(this.getUniqueConstraints()); - } - - - // ********** initial value ********** - - @Override - protected int buildDefaultInitialValue() { - return DEFAULT_INITIAL_VALUE; - } - - - // ********** table ********** - - public String getTable() { - return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable; - } - - public String getSpecifiedTable() { - return this.specifiedTable; - } - - public void setSpecifiedTable(String table) { - this.setSpecifiedTable_(table); - this.xmlGenerator.setTable(table); - } - - protected void setSpecifiedTable_(String table) { - String old = this.specifiedTable; - this.specifiedTable = table; - this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table); - } - - public String getDefaultTable() { - return this.defaultTable; - } - - protected void setDefaultTable(String table) { - String old = this.defaultTable; - this.defaultTable = table; - this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table); - } - - protected String buildDefaultTable() { - return null; // TODO the default table is determined by the runtime provider... - } - - public Table getDbTable() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema == null) ? null : dbSchema.getTableForIdentifier(this.getTable()); - } - - - // ********** schema ********** - - @Override - public String getSchema() { - return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema; - } - - public String getSpecifiedSchema() { - return this.specifiedSchema; - } - - public void setSpecifiedSchema(String schema) { - this.setSpecifiedSchema_(schema); - this.xmlGenerator.setSchema(schema); - } - - protected void setSpecifiedSchema_(String schema) { - String old = this.specifiedSchema; - this.specifiedSchema = schema; - this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema); - } - - public String getDefaultSchema() { - return this.defaultSchema; - } - - protected void setDefaultSchema(String schema) { - String old = this.defaultSchema; - this.defaultSchema = schema; - this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema); - } - - protected String buildDefaultSchema() { - return this.getContextDefaultSchema(); - } - - - // ********** catalog ********** - - @Override - public String getCatalog() { - return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog; - } - - public String getSpecifiedCatalog() { - return this.specifiedCatalog; - } - - public void setSpecifiedCatalog(String catalog) { - this.setSpecifiedCatalog_(catalog); - this.xmlGenerator.setCatalog(catalog); - } - - protected void setSpecifiedCatalog_(String catalog) { - String old = this.specifiedCatalog; - this.specifiedCatalog = catalog; - this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog); - } - - public String getDefaultCatalog() { - return this.defaultCatalog; - } - - protected void setDefaultCatalog(String catalog) { - String old = this.defaultCatalog; - this.defaultCatalog = catalog; - this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog); - } - - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - - // ********** primary key column name ********** - - public String getPkColumnName() { - return (this.specifiedPkColumnName != null) ? this.specifiedPkColumnName : this.defaultPkColumnName; - } - - public String getSpecifiedPkColumnName() { - return this.specifiedPkColumnName; - } - - public void setSpecifiedPkColumnName(String name) { - this.setSpecifiedPkColumnName_(name); - this.xmlGenerator.setPkColumnName(name); - } - - protected void setSpecifiedPkColumnName_(String name) { - String old = this.specifiedPkColumnName; - this.specifiedPkColumnName = name; - this.firePropertyChanged(SPECIFIED_PK_COLUMN_NAME_PROPERTY, old, name); - } - - public String getDefaultPkColumnName() { - return this.defaultPkColumnName; - } - - protected void setDefaultPkColumnName(String name) { - String old = this.defaultPkColumnName; - this.defaultPkColumnName = name; - this.firePropertyChanged(DEFAULT_PK_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultPkColumnName() { - return null; // TODO the default pk column name is determined by the runtime provider... - } - - - // ********** value column name ********** - - public String getValueColumnName() { - return (this.specifiedValueColumnName != null) ? this.specifiedValueColumnName : this.defaultValueColumnName; - } - - public String getSpecifiedValueColumnName() { - return this.specifiedValueColumnName; - } - - public void setSpecifiedValueColumnName(String name) { - this.setSpecifiedValueColumnName_(name); - this.xmlGenerator.setValueColumnName(name); - } - - protected void setSpecifiedValueColumnName_(String name) { - String old = this.specifiedValueColumnName; - this.specifiedValueColumnName = name; - this.firePropertyChanged(SPECIFIED_VALUE_COLUMN_NAME_PROPERTY, old, name); - } - - public String getDefaultValueColumnName() { - return this.defaultValueColumnName; - } - - protected void setDefaultValueColumnName(String name) { - String old = this.defaultValueColumnName; - this.defaultValueColumnName = name; - this.firePropertyChanged(DEFAULT_VALUE_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultValueColumnName() { - return null; // TODO the default value column name is determined by the runtime provider... - } - - - // ********** primary key column value ********** - - public String getPkColumnValue() { - return (this.specifiedPkColumnValue != null) ? this.specifiedPkColumnValue : this.defaultPkColumnValue; - } - - public String getSpecifiedPkColumnValue() { - return this.specifiedPkColumnValue; - } - - public void setSpecifiedPkColumnValue(String value) { - this.setSpecifiedPkColumnValue_(value); - this.xmlGenerator.setPkColumnValue(value); - } - - protected void setSpecifiedPkColumnValue_(String value) { - String old = this.specifiedPkColumnValue; - this.specifiedPkColumnValue = value; - this.firePropertyChanged(SPECIFIED_PK_COLUMN_VALUE_PROPERTY, old, value); - } - - public String getDefaultPkColumnValue() { - return this.defaultPkColumnValue; - } - - protected void setDefaultPkColumnValue(String value) { - String old = this.defaultPkColumnValue; - this.defaultPkColumnValue = value; - this.firePropertyChanged(DEFAULT_PK_COLUMN_VALUE_PROPERTY, old, value); - } - - protected String buildDefaultPkColumnValue() { - return null; // TODO the default pk column value is determined by the runtime provider... - } - - - // ********** unique constraints ********** - - public ListIterable<OrmUniqueConstraint> getUniqueConstraints() { - return this.uniqueConstraintContainer.getContextElements(); - } - - public int getUniqueConstraintsSize() { - return this.uniqueConstraintContainer.getContextElementsSize(); - } - - public OrmUniqueConstraint getUniqueConstraint(int index) { - return this.uniqueConstraintContainer.getContextElement(index); - } - - public OrmUniqueConstraint addUniqueConstraint() { - return this.addUniqueConstraint(this.getUniqueConstraintsSize()); - } - - public OrmUniqueConstraint addUniqueConstraint(int index) { - XmlUniqueConstraint xmlConstraint = this.buildXmlUniqueConstraint(); - OrmUniqueConstraint constraint = this.uniqueConstraintContainer.addContextElement(index, xmlConstraint); - this.xmlGenerator.getUniqueConstraints().add(index, xmlConstraint); - return constraint; - } - - protected XmlUniqueConstraint buildXmlUniqueConstraint() { - return OrmFactory.eINSTANCE.createXmlUniqueConstraint(); - } - - public void removeUniqueConstraint(UniqueConstraint uniqueConstraint) { - this.removeUniqueConstraint(this.uniqueConstraintContainer.indexOfContextElement((OrmUniqueConstraint) uniqueConstraint)); - } - - public void removeUniqueConstraint(int index) { - this.uniqueConstraintContainer.removeContextElement(index); - this.xmlGenerator.getUniqueConstraints().remove(index); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - this.uniqueConstraintContainer.moveContextElement(targetIndex, sourceIndex); - this.xmlGenerator.getUniqueConstraints().move(targetIndex, sourceIndex); - } - - protected OrmUniqueConstraint buildUniqueConstraint(XmlUniqueConstraint resourceUniqueConstraint) { - return this.getContextNodeFactory().buildOrmUniqueConstraint(this, this, resourceUniqueConstraint); - } - - protected void syncUniqueConstraints() { - this.uniqueConstraintContainer.synchronizeWithResourceModel(); - } - - protected ListIterable<XmlUniqueConstraint> getXmlUniqueConstraints() { - // clone to reduce chance of concurrency problems - return new LiveCloneListIterable<XmlUniqueConstraint>(this.xmlGenerator.getUniqueConstraints()); - } - - protected ContextListContainer<OrmUniqueConstraint, XmlUniqueConstraint> buildUniqueConstraintContainer() { - UniqueConstraintContainer container = new UniqueConstraintContainer(); - container.initialize(); - return container; - } - - /** - * unique constraint container - */ - protected class UniqueConstraintContainer - extends ContextListContainer<OrmUniqueConstraint, XmlUniqueConstraint> - { - @Override - protected String getContextElementsPropertyName() { - return UNIQUE_CONSTRAINTS_LIST; - } - @Override - protected OrmUniqueConstraint buildContextElement(XmlUniqueConstraint resourceElement) { - return GenericOrmTableGenerator.this.buildUniqueConstraint(resourceElement); - } - @Override - protected ListIterable<XmlUniqueConstraint> getResourceElements() { - return GenericOrmTableGenerator.this.getXmlUniqueConstraints(); - } - @Override - protected XmlUniqueConstraint getResourceElement(OrmUniqueConstraint contextElement) { - return contextElement.getXmlUniqueConstraint(); - } - } - - - // ********** UniqueConstraint.Owner implementation ********** - - public Iterable<String> getCandidateUniqueConstraintColumnNames() { - org.eclipse.jpt.jpa.db.Table dbTable = this.getDbTable(); - return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String>instance(); - } - - // ********** misc ********** - - public Class<TableGenerator> getType() { - return TableGenerator.class; - } - - // ********** validation ********** - - @Override - public boolean isEquivalentTo(JpaNamedContextNode node) { - return super.isEquivalentTo(node) - && this.isEquivalentTo((TableGenerator) node); - } - - protected boolean isEquivalentTo(TableGenerator generator) { - return super.isEquivalentTo(generator) && - Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) && - Tools.valuesAreEqual(this.specifiedSchema, generator.getSpecifiedSchema()) && - Tools.valuesAreEqual(this.specifiedCatalog, generator.getSpecifiedCatalog()) && - Tools.valuesAreEqual(this.specifiedPkColumnName, generator.getSpecifiedPkColumnName()) && - Tools.valuesAreEqual(this.specifiedValueColumnName, generator.getSpecifiedValueColumnName()) && - Tools.valuesAreEqual(this.specifiedPkColumnValue, generator.getSpecifiedPkColumnValue()) && - uniqueConstrainsAreEquivalentTo(generator); - } - - protected boolean uniqueConstrainsAreEquivalentTo(TableGenerator generator) { - if (this.getUniqueConstraintsSize() != generator.getUniqueConstraintsSize()) { - return false; - } - - for (int i=0; i<this.getUniqueConstraintsSize(); i++) { - if (! this.uniqueConstraintContainer.get(i).isEquivalentTo(generator.getUniqueConstraint(i))) { - return false; - } - } - return true; - } - - // ********** metadata conversion ********** - - public void convertFrom(JavaTableGenerator javaTableGenerator) { - super.convertFrom(javaTableGenerator); - this.setSpecifiedTable(javaTableGenerator.getSpecifiedTable()); - this.setSpecifiedSchema(javaTableGenerator.getSpecifiedSchema()); - this.setSpecifiedCatalog(javaTableGenerator.getSpecifiedCatalog()); - this.setSpecifiedPkColumnName(javaTableGenerator.getSpecifiedPkColumnName()); - this.setSpecifiedValueColumnName(javaTableGenerator.getSpecifiedValueColumnName()); - this.setSpecifiedPkColumnValue(javaTableGenerator.getSpecifiedPkColumnValue()); - for (JavaUniqueConstraint javaUniqueConstraint : javaTableGenerator.getUniqueConstraints()) { - this.addUniqueConstraint().convertFrom(javaUniqueConstraint); - } - } - - // ********** completion proposals ********** - - @Override - public Iterable<String> getXmlCompletionProposals(int pos) { - Iterable<String> result = super.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - for (OrmUniqueConstraint constraint : this.getUniqueConstraints()) { - result = constraint.getXmlCompletionProposals(pos); - if (result != null) { - return result; - } - } - return null; - } - - /** - * called if the database is connected: - * table, schema, catalog, pkColumnName, valueColumnName - */ - @Override - protected Iterable<String> getConnectedXmlCompletionProposals(int pos) { - Iterable<String> result = super.getConnectedXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.tableTouches(pos)) { - return this.getCandidateTables(); - } - if (this.pkColumnNameTouches(pos)) { - return this.getCandidateColumnNames(); - } - if (this.valueColumnNameTouches(pos)) { - return this.getCandidateColumnNames(); - } - return null; - } - - // ********** content assist: table - - protected boolean tableTouches(int pos) { - return this.xmlGenerator.tableTouches(pos); - } - - protected Iterable<String> getCandidateTables() { - Schema dbSchema = this.getDbSchema(); - return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** content assist: pkColumnName - - protected boolean pkColumnNameTouches(int pos) { - return this.xmlGenerator.pkColumnNameTouches(pos); - } - - protected Iterable<String> getCandidateColumnNames() { - Table table = this.getDbTable(); - return (table != null) ? table.getSortedColumnIdentifiers() : EmptyIterable.<String> instance(); - } - - // ********** content assist: valueColumnName - - protected boolean valueColumnNameTouches(int pos) { - return this.xmlGenerator.valueColumnNameTouches(pos); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTransientMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTransientMapping.java deleted file mode 100644 index fdd0cbbe07..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTransientMapping.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.jpa.core.resource.orm.Attributes; -import org.eclipse.jpt.jpa.core.resource.orm.XmlTransient; - -/** - * <code>orm.xml</code> transient mapping - */ -public class GenericOrmTransientMapping - extends AbstractOrmAttributeMapping<XmlTransient> - implements OrmTransientMapping -{ - public GenericOrmTransientMapping(OrmPersistentAttribute parent, XmlTransient xmlMapping) { - super(parent, xmlMapping); - } - - public String getKey() { - return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; - } - - public int getXmlSequence() { - return 90; - } - - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmTransientMapping(this); - } - - public void addXmlAttributeMappingTo(Attributes resourceAttributes) { - resourceAttributes.getTransients().add(this.xmlAttributeMapping); - } - - public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) { - resourceAttributes.getTransients().remove(this.xmlAttributeMapping); - } - - // ********** metamodel ********** - - @Override - public MetamodelField getMetamodelField() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java deleted file mode 100644 index 04c89c27dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.UniqueConstraint; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint; - -public class GenericOrmUniqueConstraint - extends AbstractOrmReadOnlyUniqueConstraint - implements OrmUniqueConstraint -{ - protected Owner owner; - protected final XmlUniqueConstraint xmlUniqueConstraint; - - - public GenericOrmUniqueConstraint(XmlContextNode parent, Owner owner, XmlUniqueConstraint xmlUniqueConstraint) { - super(parent); - this.owner = owner; - this.xmlUniqueConstraint = xmlUniqueConstraint; - this.initializeColumnNames(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncColumnNames(); - } - - - // ********** column names ********** - - public void addColumnName(String columnName) { - this.addColumnName(this.columnNames.size(), columnName); - } - - public void addColumnName(int index, String columnName) { - this.addItemToList(index, columnName, this.columnNames, COLUMN_NAMES_LIST); - this.xmlUniqueConstraint.getColumnNames().add(index, columnName); - } - - public void removeColumnName(String columnName) { - this.removeColumnName(this.columnNames.indexOf(columnName)); - } - - public void removeColumnName(int index) { - this.removeItemFromList(index, this.columnNames, COLUMN_NAMES_LIST); - this.xmlUniqueConstraint.getColumnNames().remove(index); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - this.moveItemInList(targetIndex, sourceIndex, this.columnNames, COLUMN_NAMES_LIST); - this.xmlUniqueConstraint.getColumnNames().move(targetIndex, sourceIndex); - } - - protected void initializeColumnNames() { - for (String xmlColumnName : this.xmlUniqueConstraint.getColumnNames()) { - this.columnNames.add(xmlColumnName); - } - } - - @Override - protected Iterable<String> getResourceColumnNames() { - return this.xmlUniqueConstraint.getColumnNames(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlUniqueConstraint.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - - public boolean isEquivalentTo(UniqueConstraint uniqueConstraint) { - return columnNamesAreEquivalent(uniqueConstraint); - } - - protected boolean columnNamesAreEquivalent(UniqueConstraint uniqueConstraint) { - if (this.getColumnNamesSize() != uniqueConstraint.getColumnNamesSize()) { - return false; - } - - for (int i=0; i<this.getColumnNamesSize(); i++) { - if (! Tools.valuesAreEqual(this.columnNames.get(i), uniqueConstraint.getColumnName(i))) { - return false; - } - } - return true; - } - - // ********** completion proposals ********** - - @Override - protected Iterable<String> getConnectedXmlCompletionProposals(int pos) { - Iterable<String> result = super.getConnectedXmlCompletionProposals(pos); - if (result != null) { - return result; - } - if (this.columnNamesTouches(pos)) { - return this.getCandidateColumnNames(); - } - return null; - } - - protected boolean columnNamesTouches(int pos) { - return this.xmlUniqueConstraint.columnNamesTouches(pos); - } - - protected Iterable<String> getCandidateColumnNames() { - return this.owner.getCandidateUniqueConstraintColumnNames(); - } - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } - - public XmlUniqueConstraint getXmlUniqueConstraint() { - return this.xmlUniqueConstraint; - } - - public void initializeFrom(ReadOnlyUniqueConstraint oldUniqueConstraint) { - for (String columnName : oldUniqueConstraint.getColumnNames()) { - this.addColumnName(columnName); - } - } - - public void convertFrom(JavaUniqueConstraint javaUniqueConstraint) { - this.initializeFrom(javaUniqueConstraint); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVersionMapping.java deleted file mode 100644 index 5cd6602686..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVersionMapping.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVersionMapping; -import org.eclipse.jpt.jpa.core.resource.orm.XmlVersion; - - -public class GenericOrmVersionMapping - extends AbstractOrmVersionMapping<XmlVersion> -{ - public GenericOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion xmlMapping) { - super(parent, xmlMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAssociationOverride.java deleted file mode 100644 index 4618e9f0cc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAssociationOverride.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverrideRelationship; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmAssociationOverrideContainer2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmVirtualAssociationOverride2_0; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Virtual <code>orm.xml</code> association override - */ -public class GenericOrmVirtualAssociationOverride - extends AbstractOrmVirtualOverride<OrmAssociationOverrideContainer> - implements OrmVirtualAssociationOverride2_0 -{ - protected final OrmVirtualOverrideRelationship relationship; - - - public GenericOrmVirtualAssociationOverride(OrmAssociationOverrideContainer parent, String name) { - super(parent, name); - this.relationship = this.buildRelationship(); - } - - @Override - public void update() { - super.update(); - this.relationship.update(); - } - - @Override - public OrmAssociationOverride convertToSpecified() { - return (OrmAssociationOverride) super.convertToSpecified(); - } - - public RelationshipMapping getMapping() { - return this.getContainer().getRelationshipMapping(this.name); - } - - protected OrmAssociationOverrideContainer2_0 getContainer2_0() { - return (OrmAssociationOverrideContainer2_0) this.getContainer(); - } - - - // ********** relationship ********** - - public OrmVirtualOverrideRelationship getRelationship() { - return this.relationship; - } - - /** - * The relationship should be available (since its presence precipitated the - * creation of the virtual override). - */ - protected OrmVirtualOverrideRelationship buildRelationship() { - return this.getContextNodeFactory().buildOrmVirtualOverrideRelationship(this); - } - - public ReadOnlyRelationship resolveOverriddenRelationship() { - return this.getContainer().resolveOverriddenRelationship(this.name); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.relationship.validate(messages, reporter); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableValidator(this, table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableJoinColumnValidator(this, column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getContainer2_0().buildJoinTableInverseJoinColumnValidator(this, column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAttributeOverride.java deleted file mode 100644 index ca5d64aba2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualAttributeOverride.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualColumn; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Virtual <code>orm.xml</code> attribute override - */ -public class GenericOrmVirtualAttributeOverride - extends AbstractOrmVirtualOverride<OrmAttributeOverrideContainer> - implements OrmVirtualAttributeOverride, OrmVirtualColumn.Owner -{ - protected final OrmVirtualColumn column; - - - public GenericOrmVirtualAttributeOverride(OrmAttributeOverrideContainer parent, String name) { - super(parent, name); - this.column = this.buildColumn(); - } - - @Override - public void update() { - super.update(); - this.column.update(); - } - - @Override - public OrmAttributeOverride convertToSpecified() { - return (OrmAttributeOverride) super.convertToSpecified(); - } - - - // ********** column ********** - - public OrmVirtualColumn getColumn() { - return this.column; - } - - /** - * The original column should be available (since the presence of its - * attribute is what precipitated the creation of the virtual override). - */ - protected OrmVirtualColumn buildColumn() { - return this.getContextNodeFactory().buildOrmVirtualColumn(this, this); - } - - - // ********** column owner implementation ********** - - @Override - public String getDefaultTableName() { - String overriddenColumnTable = this.getOverriddenColumnTable(); - return (overriddenColumnTable != null) ? overriddenColumnTable : super.getDefaultTableName(); - } - - protected String getOverriddenColumnTable() { - ReadOnlyColumn overriddenColumn = this.resolveOverriddenColumn(); - // pretty sure this is the *specified* table... - return (overriddenColumn == null) ? null : overriddenColumn.getSpecifiedTable(); - } - - public String getDefaultColumnName(ReadOnlyNamedColumn column) { - String overriddenColumnName = this.getOverriddenColumnName(); - return (overriddenColumnName != null) ? overriddenColumnName : this.name; - } - - protected String getOverriddenColumnName() { - ReadOnlyColumn overriddenColumn = this.resolveOverriddenColumn(); - return (overriddenColumn == null) ? null : overriddenColumn.getName(); - } - - public ReadOnlyColumn resolveOverriddenColumn() { - return this.getContainer().resolveOverriddenColumn(this.name); - } - - public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { - return this.getContainer().buildColumnValidator(this, (ReadOnlyBaseColumn) col, this, (TableColumnTextRangeResolver) textRangeResolver); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.column.validate(messages, reporter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java deleted file mode 100644 index 8797fb7aa9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.ReadOnlyColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVirtualBaseColumn; - -/** - * <code>orm.xml</code> virtual column - */ -public class GenericOrmVirtualColumn - extends AbstractOrmVirtualBaseColumn<OrmVirtualColumn.Owner, ReadOnlyColumn> - implements OrmVirtualColumn -{ - protected Integer specifiedLength; - protected int defaultLength; - - protected Integer specifiedPrecision; - protected int defaultPrecision; - - protected Integer specifiedScale; - protected int defaultScale; - - - public GenericOrmVirtualColumn(XmlContextNode parent, OrmVirtualColumn.Owner owner) { - super(parent, owner); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - - this.setSpecifiedLength(this.buildSpecifiedLength()); - this.setDefaultLength(this.buildDefaultLength()); - - this.setSpecifiedPrecision(this.buildSpecifiedPrecision()); - this.setDefaultPrecision(this.buildDefaultPrecision()); - - this.setSpecifiedScale(this.buildSpecifiedScale()); - this.setDefaultScale(this.buildDefaultScale()); - } - - - // ********** column ********** - - @Override - public ReadOnlyColumn getOverriddenColumn() { - return this.owner.resolveOverriddenColumn(); - } - - - // ********** length ********** - - public int getLength() { - return (this.specifiedLength != null) ? this.specifiedLength.intValue() : this.defaultLength; - } - - public Integer getSpecifiedLength() { - return this.specifiedLength; - } - - protected void setSpecifiedLength(Integer length) { - Integer old = this.specifiedLength; - this.specifiedLength = length; - this.firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, old, length); - } - - protected Integer buildSpecifiedLength() { - return this.getOverriddenColumn().getSpecifiedLength(); - } - - public int getDefaultLength() { - return this.defaultLength; - } - - protected void setDefaultLength(int length) { - int old = this.defaultLength; - this.defaultLength = length; - this.firePropertyChanged(DEFAULT_LENGTH_PROPERTY, old, length); - } - - protected int buildDefaultLength() { - return DEFAULT_LENGTH; - } - - - // ********** precision ********** - - public int getPrecision() { - return (this.specifiedPrecision != null) ? this.specifiedPrecision.intValue() : this.defaultPrecision; - } - - public Integer getSpecifiedPrecision() { - return this.specifiedPrecision; - } - - protected void setSpecifiedPrecision(Integer precision) { - Integer old = this.specifiedPrecision; - this.specifiedPrecision = precision; - this.firePropertyChanged(SPECIFIED_PRECISION_PROPERTY, old, precision); - } - - protected Integer buildSpecifiedPrecision() { - return this.getOverriddenColumn().getSpecifiedPrecision(); - } - - public int getDefaultPrecision() { - return this.defaultPrecision; - } - - protected void setDefaultPrecision(int precision) { - int old = this.defaultPrecision; - this.defaultPrecision = precision; - this.firePropertyChanged(DEFAULT_PRECISION_PROPERTY, old, precision); - } - - protected int buildDefaultPrecision() { - return DEFAULT_PRECISION; - } - - - // ********** scale ********** - - public int getScale() { - return (this.specifiedScale != null) ? this.specifiedScale.intValue() : this.defaultScale; - } - - public Integer getSpecifiedScale() { - return this.specifiedScale; - } - - protected void setSpecifiedScale(Integer scale) { - Integer old = this.specifiedScale; - this.specifiedScale = scale; - this.firePropertyChanged(SPECIFIED_SCALE_PROPERTY, old, scale); - } - - protected Integer buildSpecifiedScale() { - return this.getOverriddenColumn().getSpecifiedScale(); - } - - public int getDefaultScale() { - return this.defaultScale; - } - - protected void setDefaultScale(int scale) { - int old = this.defaultScale; - this.defaultScale = scale; - this.firePropertyChanged(DEFAULT_SCALE_PROPERTY, old, scale); - } - - protected int buildDefaultScale() { - return DEFAULT_SCALE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java deleted file mode 100644 index 25909adac9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.MappingTools; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVirtualBaseColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * <code>orm.xml</code> virtual join column - */ -public class GenericOrmVirtualJoinColumn - extends AbstractOrmVirtualBaseColumn<OrmReadOnlyJoinColumn.Owner, ReadOnlyJoinColumn> - implements OrmVirtualJoinColumn -{ - protected final ReadOnlyJoinColumn overriddenColumn; - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericOrmVirtualJoinColumn(XmlContextNode parent, OrmReadOnlyJoinColumn.Owner owner, ReadOnlyJoinColumn overriddenColumn) { - super(parent, owner); - this.overriddenColumn = overriddenColumn; - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - - this.setSpecifiedReferencedColumnName(this.buildSpecifiedReferencedColumnName()); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** column ********** - - @Override - public ReadOnlyJoinColumn getOverriddenColumn() { - return this.overriddenColumn; - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - protected void setSpecifiedReferencedColumnName(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return this.getOverriddenColumn().getSpecifiedReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultReferencedColumnName() { - return MappingTools.buildJoinColumnDefaultReferencedColumnName(this.owner); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** validation ********** - - public TextRange getReferencedColumnNameTextRange() { - return this.getValidationTextRange(); - } - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver() { - return new OrmJoinColumnTextRangeResolver(this); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java deleted file mode 100644 index e77e69ed0c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Entity; -import org.eclipse.jpt.jpa.core.context.OverrideRelationship; -import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyTableColumn.Owner; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship; -import org.eclipse.jpt.jpa.core.context.Relationship; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAssociationOverride; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinTableRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.context.TableColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.JptValidator; -import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmVirtualOverrideJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.MappingRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyAssociationOverride2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmVirtualOverrideRelationship2_0; -import org.eclipse.jpt.jpa.db.Table; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmVirtualOverrideRelationship - extends AbstractOrmXmlContextNode - implements OrmVirtualOverrideRelationship2_0 -{ - protected OrmVirtualRelationshipStrategy strategy; - - protected final OrmVirtualJoinColumnRelationshipStrategy joinColumnStrategy; - - // JPA 2.0 - protected final OrmVirtualJoinTableRelationshipStrategy joinTableStrategy; - - - public GenericOrmVirtualOverrideRelationship(OrmVirtualAssociationOverride parent) { - super(parent); - this.joinColumnStrategy = this.buildJoinColumnStrategy(); - this.joinTableStrategy = this.buildJoinTableStrategy(); - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.setStrategy(this.buildStrategy()); - this.joinColumnStrategy.update(); - this.joinTableStrategy.update(); - } - - - // ********** strategy ********** - - public OrmVirtualRelationshipStrategy getStrategy() { - return this.strategy; - } - - protected void setStrategy(OrmVirtualRelationshipStrategy strategy) { - OrmVirtualRelationshipStrategy old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - protected OrmVirtualRelationshipStrategy buildStrategy() { - return this.isJpa2_0Compatible() ? - this.buildStrategy2_0() : - this.joinColumnStrategy; - } - - /** - * The overridden mapping determines the override's strategy. - */ - protected OrmVirtualRelationshipStrategy buildStrategy2_0() { - MappingRelationshipStrategy2_0 mappingStrategy = this.getMappingStrategy(); - return (mappingStrategy != null) ? - (OrmVirtualRelationshipStrategy) mappingStrategy.selectOverrideStrategy(this) : - this.buildMissingMappingStrategy(); - } - - /** - * Get the strategy from the overridden mapping. - */ - protected MappingRelationshipStrategy2_0 getMappingStrategy() { - RelationshipMapping mapping = this.getMapping(); - return (mapping == null) ? null : (MappingRelationshipStrategy2_0) mapping.getRelationship().getStrategy(); - } - - /** - * Return the strategy to use when the override's name does not match the - * name of an appropriate relationship mapping. - */ - protected OrmVirtualRelationshipStrategy buildMissingMappingStrategy() { - return this.joinColumnStrategy.hasSpecifiedJoinColumns() ? - this.joinColumnStrategy : - this.joinTableStrategy; - } - - - // ********** join column strategy ********** - - public OrmVirtualJoinColumnRelationshipStrategy getJoinColumnStrategy() { - return this.joinColumnStrategy; - } - - public boolean strategyIsJoinColumn() { - return this.strategy == this.joinColumnStrategy; - } - - public boolean mayHaveDefaultJoinColumn() { - // association overrides do not have defaults - return false; - } - - protected OrmVirtualJoinColumnRelationshipStrategy buildJoinColumnStrategy() { - return new GenericOrmVirtualOverrideJoinColumnRelationshipStrategy(this); - } - - - // ********** join table strategy ********** - - public OrmVirtualJoinTableRelationshipStrategy getJoinTableStrategy() { - return this.joinTableStrategy; - } - - public boolean strategyIsJoinTable() { - return this.strategy == this.joinTableStrategy; - } - - public boolean mayHaveDefaultJoinTable() { - // association overrides do not have defaults - return false; - } - - protected OrmVirtualJoinTableRelationshipStrategy buildJoinTableStrategy() { - return new GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0(this); - } - - - // ********** conversions ********** - - public void initializeOn(Relationship newRelationship) { - newRelationship.initializeFromJoinTableRelationship(this); - newRelationship.initializeFromJoinColumnRelationship(this); - } - - public void initializeOnSpecified(OverrideRelationship specifiedRelationship) { - specifiedRelationship.initializeFromVirtualJoinColumnRelationship(this); - specifiedRelationship.initializeFromVirtualJoinTableRelationship(this); - } - - - // ********** misc ********** - - @Override - public OrmVirtualAssociationOverride getParent() { - return (OrmVirtualAssociationOverride) super.getParent(); - } - - protected OrmVirtualAssociationOverride getAssociationOverride() { - return this.getParent(); - } - - protected ReadOnlyAssociationOverride2_0 getAssociationOverride2_0() { - return (ReadOnlyAssociationOverride2_0) this.getAssociationOverride(); - } - - public TypeMapping getTypeMapping() { - return this.getAssociationOverride().getTypeMapping(); - } - - public String getAttributeName() { - return this.getAssociationOverride().getName(); - } - - public boolean tableNameIsInvalid(String tableName) { - return this.getAssociationOverride().tableNameIsInvalid(tableName); - } - - public Iterable<String> getCandidateTableNames() { - return this.getAssociationOverride().getCandidateTableNames(); - } - - public Table resolveDbTable(String tableName) { - return this.getAssociationOverride().resolveDbTable(tableName); - } - - public String getDefaultTableName() { - return this.getAssociationOverride().getDefaultTableName(); - } - - public JptValidator buildColumnValidator(ReadOnlyBaseColumn column, Owner owner, TableColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride().buildColumnValidator(column, owner, textRangeResolver); - } - - public Entity getEntity() { - TypeMapping typeMapping = this.getTypeMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - public boolean isVirtual() { - return true; - } - - public RelationshipMapping getMapping() { - return this.getAssociationOverride().getMapping(); - } - - public ReadOnlyRelationship resolveOverriddenRelationship() { - return this.getAssociationOverride().resolveOverriddenRelationship(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - return this.getAssociationOverride().getValidationTextRange(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.strategy.validate(messages, reporter); - } - - public JptValidator buildJoinTableValidator(ReadOnlyJoinTable table, TableTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableValidator(table, textRangeResolver); - } - - public JptValidator buildJoinTableJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(ReadOnlyJoinColumn column, ReadOnlyJoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return this.getAssociationOverride2_0().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualPrimaryKeyJoinColumn.java deleted file mode 100644 index 03c99592bb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualPrimaryKeyJoinColumn.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyBaseJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualPrimaryKeyJoinColumn; -import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVirtualNamedColumn; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmPrimaryKeyJoinColumnTextRangeResolver; -import org.eclipse.jpt.jpa.db.Column; -import org.eclipse.jpt.jpa.db.Table; - -/** - * <code>orm.xml</code> virtual primary key join column - */ -public class GenericOrmVirtualPrimaryKeyJoinColumn - extends AbstractOrmVirtualNamedColumn<OrmReadOnlyBaseJoinColumn.Owner, JavaPrimaryKeyJoinColumn> - implements OrmVirtualPrimaryKeyJoinColumn -{ - protected final JavaPrimaryKeyJoinColumn javaColumn; - - protected String specifiedReferencedColumnName; - protected String defaultReferencedColumnName; - - - public GenericOrmVirtualPrimaryKeyJoinColumn(XmlContextNode parent, OrmReadOnlyBaseJoinColumn.Owner owner, JavaPrimaryKeyJoinColumn javaColumn) { - super(parent, owner); - this.javaColumn = javaColumn; - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - - this.setSpecifiedReferencedColumnName(this.buildSpecifiedReferencedColumnName()); - this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName()); - } - - - // ********** column ********** - - @Override - public JavaPrimaryKeyJoinColumn getOverriddenColumn() { - return this.javaColumn; - } - - - // ********** referenced column name ********** - - public String getReferencedColumnName() { - return (this.specifiedReferencedColumnName != null) ? this.specifiedReferencedColumnName : this.defaultReferencedColumnName; - } - - public String getSpecifiedReferencedColumnName() { - return this.specifiedReferencedColumnName; - } - - protected void setSpecifiedReferencedColumnName(String name) { - String old = this.specifiedReferencedColumnName; - this.specifiedReferencedColumnName = name; - this.firePropertyChanged(SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildSpecifiedReferencedColumnName() { - return this.getOverriddenColumn().getSpecifiedReferencedColumnName(); - } - - public String getDefaultReferencedColumnName() { - return this.defaultReferencedColumnName; - } - - protected void setDefaultReferencedColumnName(String name) { - String old = this.defaultReferencedColumnName; - this.defaultReferencedColumnName = name; - this.firePropertyChanged(DEFAULT_REFERENCED_COLUMN_NAME_PROPERTY, old, name); - } - - protected String buildDefaultReferencedColumnName() { - return this.buildDefaultName(); - } - - - // ********** database stuff ********** - - public Table getReferencedColumnDbTable() { - return this.owner.getReferencedColumnDbTable(); - } - - protected Column getReferencedDbColumn() { - Table table = this.getReferencedColumnDbTable(); - return (table == null) ? null : table.getColumnForIdentifier(this.getReferencedColumnName()); - } - - public boolean referencedColumnIsResolved() { - return this.getReferencedDbColumn() != null; - } - - - // ********** misc ********** - - public String getTable() { - return this.owner.getDefaultTableName(); - } - - - // ********** validation ********** - - @Override - protected NamedColumnTextRangeResolver buildTextRangeResolver() { - return new OrmPrimaryKeyJoinColumnTextRangeResolver(this); - } - - public TextRange getReferencedColumnNameTextRange() { - return this.getValidationTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java deleted file mode 100644 index 3b2c7d8298..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint; -import org.eclipse.jpt.jpa.core.context.XmlContextNode; -import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualUniqueConstraint; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmReadOnlyUniqueConstraint; - -public class GenericOrmVirtualUniqueConstraint - extends AbstractOrmReadOnlyUniqueConstraint - implements OrmVirtualUniqueConstraint -{ - protected final ReadOnlyUniqueConstraint overriddenUniqueConstraint; - - - public GenericOrmVirtualUniqueConstraint(XmlContextNode parent, ReadOnlyUniqueConstraint overriddenUniqueConstraint) { - super(parent); - this.overriddenUniqueConstraint = overriddenUniqueConstraint; - } - - - // ********** synchronize/update ********** - - @Override - public void update() { - super.update(); - this.syncColumnNames(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - return this.getParent().getValidationTextRange(); - } - - - // ********** misc ********** - - @Override - public XmlContextNode getParent() { - return (XmlContextNode) super.getParent(); - } - - public ReadOnlyUniqueConstraint getOverriddenUniqueConstraint() { - return this.overriddenUniqueConstraint; - } - - @Override - protected Iterable<String> getResourceColumnNames() { - return this.overriddenUniqueConstraint.getColumnNames(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java deleted file mode 100644 index 92a2f1d3ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java +++ /dev/null @@ -1,324 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.List; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.Generator; -import org.eclipse.jpt.jpa.core.context.Query; -import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.jpa.core.context.orm.OrmXml; -import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.ReplaceEdit; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * JPA <code>orm.xml</code> file. - */ -public class GenericOrmXml - extends AbstractOrmXmlContextNode - implements OrmXml -{ - /** - * If the XML resource's content type changes, the mapping file - * ref will throw out its current mapping file. - */ - protected final JpaXmlResource xmlResource; // never null - - /** - * The resource type will only change if the XML file's version changes - * (since, if the content type changes, we get garbage-collected). - */ - protected JptResourceType resourceType; - - /** - * Cache the <code>orm.xml</code> definition alongside the resource type. - * (The definition is determined by the resource type.) - */ - protected OrmXmlDefinition definition; - - /** - * The root element of the <code>orm.xml</code> file. - */ - protected EntityMappings root; - - - public GenericOrmXml(MappingFileRef parent, JpaXmlResource xmlResource) { - super(parent); - this.checkXmlResource(xmlResource); - this.xmlResource = xmlResource; - this.resourceType = xmlResource.getResourceType(); - this.definition = this.buildDefinition(); - - XmlEntityMappings xmlEntityMappings = (XmlEntityMappings) xmlResource.getRootObject(); - if (xmlEntityMappings != null) { - this.root = this.buildRoot(xmlEntityMappings); - } - } - - - // ********** synchronize/update ********** - - /** - * @see org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml#synchronizeWithResourceModel() - */ - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - XmlEntityMappings oldXmlEntityMappings = (this.root == null) ? null : this.root.getXmlEntityMappings(); - XmlEntityMappings newXmlEntityMappings = (XmlEntityMappings) this.xmlResource.getRootObject(); - JptResourceType newResourceType = this.xmlResource.getResourceType(); - - // If the old and new XML entity mappings are different instances, - // we scrap the old context entity mappings and rebuild. - // (This can happen when the resource model changes drastically, - // such as a CVS checkout or an edit reversion.) - if ((oldXmlEntityMappings != newXmlEntityMappings) || - (newXmlEntityMappings == null) || - this.valuesAreDifferent(this.resourceType, newResourceType) - ) { - if (this.root != null) { - this.unregisterRootStructureNode(); - this.root.dispose(); - this.setRoot(null); - } - } - - this.resourceType = newResourceType; - this.definition = this.buildDefinition(); - - if (newXmlEntityMappings != null) { - if (this.root == null) { - this.setRoot(this.buildRoot(newXmlEntityMappings)); - } else { - // the context entity mappings already holds the XML entity mappings - this.root.synchronizeWithResourceModel(); - } - } - } - - @Override - public void update() { - super.update(); - if (this.root != null) { - this.root.update(); - // this will happen redundantly - need to hold JpaFile? - this.registerRootStructureNode(); - } - } - - - // ********** resource type/definition ********** - - @Override - public JptResourceType getResourceType() { - return this.resourceType; - } - - @Override - public OrmXmlDefinition getMappingFileDefinition() { - return this.definition; - } - - protected OrmXmlDefinition buildDefinition() { - return (OrmXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.resourceType); - } - - - // ********** root ********** - - public EntityMappings getRoot() { - return this.root; - } - - protected void setRoot(EntityMappings root) { - EntityMappings old = this.root; - this.root = root; - this.firePropertyChanged(ROOT_PROPERTY, old, root); - } - - protected EntityMappings buildRoot(XmlEntityMappings xmlEntityMappings) { - return this.getContextNodeFactory().buildEntityMappings(this, xmlEntityMappings); - } - - - // ********** queries/generators ********** - - public Iterable<Query> getMappingFileQueries() { - return (this.root != null) ? this.root.getMappingFileQueries() : EmptyIterable.<Query>instance(); - } - - public Iterable<Generator> getMappingFileGenerators() { - return (this.root != null) ? this.root.getMappingFileGenerators() : EmptyIterable.<Generator>instance(); - } - - - // ********** misc ********** - - protected void checkXmlResource(JpaXmlResource resource) { - if (resource == null) { - throw new NullPointerException(); - } - if ( ! resource.getContentType().isKindOf(JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE)) { - throw new IllegalArgumentException("Content type is not 'mapping file': " + resource); //$NON-NLS-1$ - } - } - - @Override - public MappingFileRef getParent() { - return (MappingFileRef) super.getParent(); - } - - @Override - public IResource getResource() { - return this.xmlResource.getFile(); - } - - protected JpaFile getJpaFile() { - return this.getJpaFile(this.xmlResource.getFile()); - } - - public boolean isLatestSupportedVersion() { - return XmlFile_.isLatestSupportedVersion(this); - } - - public boolean isIn(IFolder folder) { - IResource member = folder.findMember(this.xmlResource.getFile().getName()); - IFile file = this.xmlResource.getFile(); - return Tools.valuesAreEqual(member, file); - } - - - // ********** JpaStructureNode implementation ********** - - public ContextType getContextType() { - return new ContextType(this); - } - - public Class<OrmXml> getType() { - return OrmXml.class; - } - - public JpaStructureNode getStructureNode(int textOffset) { - if ((this.root != null) && this.root.containsOffset(textOffset)) { - return this.root.getStructureNode(textOffset); - } - return this; - } - - // never actually selected - public TextRange getSelectionTextRange() { - return TextRange.Empty.instance(); - } - - public void dispose() { - if (this.root != null) { - JpaFile jpaFile = this.getJpaFile(); - if (jpaFile != null) { - this.unregisterRootStructureNode(); - } - this.root.dispose(); - } - } - - // TODO hold the JpaFile? - protected void registerRootStructureNode() { - this.getJpaFile().addRootStructureNode(this.xmlResource, this.root); - } - - protected void unregisterRootStructureNode() { - this.getJpaFile().removeRootStructureNode(this.xmlResource, this.root); - } - - - // ********** MappingFile implementation ********** - - public JpaXmlResource getXmlResource() { - return this.xmlResource; - } - - public OrmPersistentType getPersistentType(String name) { - return (this.root == null) ? null : this.root.getPersistentType(name); - } - - - // ********** PersistentTypeContainer implementation ********** - - /** - * All <code>orm.xml</code> mapping files must be able to generate a static metamodel - * because 1.0 <code>orm.xml</code> files can be referenced from 2.0 - * <code>persistence.xml</code> - * files. - */ - public Iterable<OrmPersistentType> getPersistentTypes() { - return (this.root != null) ? this.root.getPersistentTypes() : EmptyIterable.<OrmPersistentType>instance(); - } - - - // ********** refactoring ********** - - public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) { - return (this.root != null) ? - this.root.createDeleteTypeEdits(type) : - EmptyIterable.<DeleteEdit>instance(); - } - - public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) { - return (this.root != null) ? - this.root.createRenameTypeEdits(originalType, newName) : - EmptyIterable.<ReplaceEdit>instance(); - } - - public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - return (this.root != null) ? - this.root.createMoveTypeEdits(originalType, newPackage) : - EmptyIterable.<ReplaceEdit>instance(); - } - - public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) { - return (this.root != null) ? - this.root.createRenamePackageEdits(originalPackage, newName) : - EmptyIterable.<ReplaceEdit>instance(); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - if (this.root != null) { - this.root.validate(messages, reporter); - } - } - - public TextRange getValidationTextRange() { - // since this is the entire file, point to the top of the file - return TextRange.Empty.instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXmlDefinition.java deleted file mode 100644 index af8d7cc6c7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXmlDefinition.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import java.util.ArrayList; -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.utility.internal.CollectionTools; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.orm.NullOrmAttributeMappingDefinition; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition; -import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory; -import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition; -import org.eclipse.jpt.jpa.core.internal.GenericJpaPlatformProvider; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmXmlContextNodeFactory; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmBasicMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmEmbeddedIdMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmEmbeddedMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmIdMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmManyToManyMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmManyToOneMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOneToManyMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOneToOneMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmTransientMappingDefinition; -import org.eclipse.jpt.jpa.core.internal.context.orm.OrmVersionMappingDefinition; -import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory; - -public class GenericOrmXmlDefinition - extends AbstractOrmXmlDefinition -{ - // singleton - private static final OrmXmlDefinition INSTANCE = new GenericOrmXmlDefinition(); - - /** - * Return the singleton - */ - public static OrmXmlDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private GenericOrmXmlDefinition() { - super(); - } - - public JptResourceType getResourceType() { - return JptJpaCorePlugin.ORM_XML_1_0_RESOURCE_TYPE; - } - - public EFactory getResourceNodeFactory() { - return OrmFactory.eINSTANCE; - } - - @Override - protected OrmXmlContextNodeFactory buildContextNodeFactory() { - return new GenericOrmXmlContextNodeFactory(); - } - - @Override - protected void addAttributeMappingDefinitionsTo(ArrayList<OrmAttributeMappingDefinition> definitions) { - CollectionTools.addAll(definitions, ATTRIBUTE_MAPPING_DEFINITIONS); - } - - /** - * Order should not matter here; but we'll use the same order as for Java. - * @see GenericJpaPlatformProvider - */ - protected static final OrmAttributeMappingDefinition[] ATTRIBUTE_MAPPING_DEFINITIONS = new OrmAttributeMappingDefinition[] { - OrmTransientMappingDefinition.instance(), - OrmIdMappingDefinition.instance(), - OrmVersionMappingDefinition.instance(), - OrmBasicMappingDefinition.instance(), - OrmEmbeddedMappingDefinition.instance(), - OrmEmbeddedIdMappingDefinition.instance(), - OrmManyToManyMappingDefinition.instance(), - OrmManyToOneMappingDefinition.instance(), - OrmOneToManyMappingDefinition.instance(), - OrmOneToOneMappingDefinition.instance(), - NullOrmAttributeMappingDefinition.instance() - }; -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java deleted file mode 100644 index 8ea7e1a03d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmConverter; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; - -public class NullOrmConverter - extends AbstractOrmXmlContextNode - implements OrmConverter -{ - public NullOrmConverter(OrmAttributeMapping parent) { - super(parent); - } - - @Override - public OrmAttributeMapping getParent() { - return (OrmAttributeMapping) super.getParent(); - } - - public void initialize() { - // NOP - } - - public Class<? extends Converter> getType() { - return null; - } - - public TextRange getValidationTextRange() { - return this.getParent().getValidationTextRange(); - } -} 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 deleted file mode 100644 index 5cd0538991..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationshipStrategy; -import org.eclipse.jpt.jpa.core.context.RelationshipMapping; -import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationship; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.jpa.core.jpa2.context.ReadOnlyOverrideRelationship2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmMappingJoinColumnRelationshipStrategy2_0; -import org.eclipse.jpt.jpa.db.Table; - -/** - * Used by - * {@link org.eclipse.jpt.jpa.core.internal.context.orm.GenericOrmOneToManyRelationship#buildJoinColumnStrategy()} - * in a JPA 1.0 project. - */ -public class NullOrmJoinColumnRelationshipStrategy - extends AbstractOrmXmlContextNode - implements OrmMappingJoinColumnRelationshipStrategy2_0 -{ - public NullOrmJoinColumnRelationshipStrategy(OrmJoinColumnRelationship parent) { - super(parent); - } - - - // ********** join columns ********** - - public ListIterable<OrmJoinColumn> getJoinColumns() { - return EmptyListIterable.<OrmJoinColumn>instance(); - } - - public int getJoinColumnsSize() { - return 0; - } - - - // ********** specified join columns ********** - - public ListIterable<OrmJoinColumn> getSpecifiedJoinColumns() { - return EmptyListIterable.<OrmJoinColumn>instance(); - } - - public int getSpecifiedJoinColumnsSize() { - return 0; - } - - public boolean hasSpecifiedJoinColumns() { - return false; - } - - public OrmJoinColumn getSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public OrmJoinColumn addSpecifiedJoinColumn() { - throw new UnsupportedOperationException(); - } - - public OrmJoinColumn addSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void removeSpecifiedJoinColumn(JoinColumn joinColumn) { - throw new UnsupportedOperationException(); - } - - public void removeSpecifiedJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - - // ********** default join column ********** - - public OrmJoinColumn getDefaultJoinColumn() { - return null; - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - return this.getRelationship().getValidationTextRange(); - } - - public String getColumnTableNotValidDescription() { - return null; - } - - - // ********** misc ********** - - @Override - public OrmJoinColumnRelationship getParent() { - return (OrmJoinColumnRelationship) super.getParent(); - } - - public OrmJoinColumnRelationship getRelationship() { - return this.getParent(); - } - - public void initializeFrom(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) { - // NOP - } - - public void initializeFromVirtual(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) { - // NOP - } - - public ReadOnlyRelationshipStrategy selectOverrideStrategy(ReadOnlyOverrideRelationship2_0 overrideRelationship) { - return null; - } - - public void addStrategy() { - // NOP - } - - public void removeStrategy() { - // NOP - } - - public boolean isTargetForeignKey() { - return false; - } - - public TypeMapping getRelationshipTarget() { - return null; - } - - public String getTableName() { - return null; - } - - public boolean isOverridable() { - return false; - } - - public boolean tableNameIsInvalid(String tableName) { - return true; - } - - public Table resolveDbTable(String tableName) { - return null; - } - - public TypeMapping getRelationshipSource() { - return this.getRelationshipMapping().getTypeMapping(); - } - - protected RelationshipMapping getRelationshipMapping() { - return this.getRelationship().getMapping(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/UnsupportedOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/UnsupportedOrmAttributeMapping.java deleted file mode 100644 index 1cba7cb9d6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/UnsupportedOrmAttributeMapping.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; - -import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.jpa.core.resource.orm.Attributes; -import org.eclipse.jpt.jpa.core.resource.orm.XmlNullAttributeMapping; - -/** - * This will be used in cases where Java-supported attribute mapping types - * are not supported by the particular version of the <code>orm.xml</code> - * file. For example, EclipseLink supports variable 1:1 mappings, but the - * generic <code>orm.xml</code> file does not. - */ -public class UnsupportedOrmAttributeMapping - extends AbstractOrmAttributeMapping<XmlNullAttributeMapping> -{ - public UnsupportedOrmAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping xmlMapping) { - super(parent, xmlMapping); - } - - public String getKey() { - //this ends up returning the java attribute mapping key - return this.xmlAttributeMapping.getMappingKey(); - } - - public int getXmlSequence() { - return -1; - } - - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmAttributeMapping(this); - } - - public void addXmlAttributeMappingTo(Attributes xmlAttributes) { - throw new UnsupportedOperationException(); - } - - public void removeXmlAttributeMappingFrom(Attributes xmlAttributes) { - throw new UnsupportedOperationException(); - } - - - // ********** metamodel ********** - - @Override - public MetamodelField getMetamodelField() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java deleted file mode 100644 index 5ad77e09a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java +++ /dev/null @@ -1,386 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import java.util.List; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind; -import org.eclipse.jpt.common.core.resource.java.JavaResourceType; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.AccessType; -import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; -import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; -import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.ReplaceEdit; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>persistence.xml</code> file - * <br> - * <code>class</code> element - */ -public class GenericClassRef - extends AbstractPersistenceXmlContextNode - implements ClassRef -{ - /** - * This is <code>null</code> for a <em>virtual</em> class ref. - */ - protected final XmlJavaClassRef xmlJavaClassRef; - - protected String className; - - /** - * The Java persistent type corresponding to the ref's class name; - * this can be <code>null</code> if the className is invalid or - * refers to an enum instead of a class or interface. - */ - protected JavaPersistentType javaPersistentType; - - - // ********** constructors ********** - - /** - * Construct a <em>specified</em> class ref; i.e. a class ref with - * an explicit entry in the <code>persistence.xml</code>. - */ - public GenericClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef) { - this(parent, xmlJavaClassRef, xmlJavaClassRef.getJavaClass()); - } - - /** - * Construct an <em>virtual</em> class ref; i.e. a class ref without - * an explicit entry in the <code>persistence.xml</code>. - */ - public GenericClassRef(PersistenceUnit parent, String className) { - this(parent, null, className); - } - - protected GenericClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef, String className) { - super(parent); - this.xmlJavaClassRef = xmlJavaClassRef; - this.className = className; - // 'javaPersistentType' is resolved in the update - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - // virtual class refs are matched by name in the persistence unit - // so no need to sync it here (also, 'xmlJavaClassRef' is null...) - if (this.isNotVirtual()) { - // the name probably never changes... - this.setClassName_(this.xmlJavaClassRef.getJavaClass()); - } - if (this.javaPersistentType != null) { - this.javaPersistentType.synchronizeWithResourceModel(); - } - } - - @Override - public void update() { - super.update(); - this.updateJavaPersistentType(); - } - - - // ********** class name ********** - - public String getClassName() { - return this.className; - } - - public void setClassName(String className) { - if (this.isVirtual()) { - throw new IllegalStateException("The name of a virtual class ref cannot be changed: " + this); //$NON-NLS-1$ - } - this.setClassName_(className); - this.xmlJavaClassRef.setJavaClass(className); - } - - protected void setClassName_(String className) { - String old = this.className; - this.className = className; - this.firePropertyChanged(CLASS_NAME_PROPERTY, old, className); - } - - /** - * Nested classes will be qualified with a '$'; the Java name is qualified - * with a '.'. Like <code>className</code>, this can be <code>null</code>. - */ - protected String getJavaClassName() { - return StringTools.stringIsEmpty(this.className) ? null : this.className.replace('$', '.'); - } - - - // ********** java persistent type ********** - - public JavaPersistentType getJavaPersistentType() { - return this.javaPersistentType; - } - - protected void setJavaPersistentType(JavaPersistentType javaPersistentType) { - JavaPersistentType old = this.javaPersistentType; - this.javaPersistentType = javaPersistentType; - this.firePropertyChanged(JAVA_PERSISTENT_TYPE_PROPERTY, old, javaPersistentType); - } - - protected void updateJavaPersistentType() { - JavaResourceType resourceType = this.resolveJavaResourceType(); - if (resourceType == null) { - if (this.javaPersistentType != null) { - this.javaPersistentType.dispose(); - this.setJavaPersistentType(null); - } - } else { - if (this.javaPersistentType == null) { - this.setJavaPersistentType(this.buildJavaPersistentType(resourceType)); - } else { - if (this.javaPersistentType.getJavaResourceType() == resourceType) { - this.javaPersistentType.update(); - } else { - this.javaPersistentType.dispose(); - this.setJavaPersistentType(this.buildJavaPersistentType(resourceType)); - } - } - } - } - - protected JavaResourceType resolveJavaResourceType() { - String javaClassName = this.getJavaClassName(); - return (javaClassName == null) ? null : (JavaResourceType) this.getJpaProject().getJavaResourceType(javaClassName, Kind.TYPE); - } - - protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrpt) { - return this.getJpaFactory().buildJavaPersistentType(this, jrpt); - } - - - // ********** misc ********** - - @Override - public PersistenceUnit getParent() { - return (PersistenceUnit) super.getParent(); - } - - public XmlJavaClassRef getXmlClassRef() { - return this.xmlJavaClassRef; - } - - protected boolean isFor(IType type) { - return this.isFor(type.getFullyQualifiedName('.')); - } - - public boolean isFor(String typeName) { - return Tools.valuesAreEqual(typeName, this.getJavaClassName()); - } - - protected boolean isInPackage(IPackageFragment packageFragment) { - return Tools.valuesAreEqual(this.getPackageName(), packageFragment.getElementName()); - } - - protected String getPackageName() { - int lastPeriod = this.className.lastIndexOf('.'); - return (lastPeriod == -1) ? null : this.className.substring(0, lastPeriod); - } - - public boolean isVirtual() { - return this.xmlJavaClassRef == null; - } - - protected boolean isNotVirtual() { - return ! this.isVirtual(); - } - - public boolean containsOffset(int textOffset) { - return this.isNotVirtual() && this.xmlJavaClassRef.containsOffset(textOffset); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getJavaClassName()); - } - - - // ********** JpaStructureNode implementation ********** - - public ContextType getContextType() { - return new ContextType(this); - } - - public Class<ClassRef> getType() { - return ClassRef.class; - } - - public JpaStructureNode getStructureNode(int textOffset) { - return this; - } - - public TextRange getSelectionTextRange() { - return this.isVirtual() ? null : this.xmlJavaClassRef.getSelectionTextRange(); - } - - public void dispose() { - if (this.javaPersistentType != null) { - this.javaPersistentType.dispose(); - } - } - - - // ********** PersistentType.Owner implementation ********** - - public AccessType getOverridePersistentTypeAccess() { - // no access type at this level overrides any local access type specification - return null; - } - - public AccessType getDefaultPersistentTypeAccess() { - return this.getPersistenceUnit().getDefaultAccess(); - } - - - //*********** refactoring *********** - - public Iterable<DeleteEdit> createDeleteTypeEdits(final IType type) { - if (this.isVirtual()) { - throw new IllegalStateException(); - } - return this.isFor(type) ? - new SingleElementIterable<DeleteEdit>(this.createDeleteEdit()) : - EmptyIterable.<DeleteEdit>instance(); - } - - protected DeleteEdit createDeleteEdit() { - return this.xmlJavaClassRef.createDeleteEdit(); - } - - public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) { - if (this.isVirtual()) { - throw new IllegalStateException(); - } - return this.isFor(originalType) ? - new SingleElementIterable<ReplaceEdit>(this.createReplaceEdit(originalType, newName)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createReplaceEdit(IType originalType, String newName) { - return this.xmlJavaClassRef.createRenameEdit(originalType, newName); - } - - public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - if (this.isVirtual()) { - throw new IllegalStateException(); - } - return this.isFor(originalType) ? - new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName())) : - EmptyIterable.<ReplaceEdit>instance(); - } - - public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) { - if (this.isVirtual()) { - throw new IllegalStateException(); - } - return this.isInPackage(originalPackage) ? - new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createRenamePackageEdit(String newName) { - return this.xmlJavaClassRef.createRenamePackageEdit(newName); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - - if (StringTools.stringIsEmpty(this.className)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS, - this, - this.getValidationTextRange() - ) - ); - return; - } - - if (this.javaPersistentType == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS, - new String[] {this.getJavaClassName()}, - this, - this.getValidationTextRange() - ) - ); - return; - } - - // 190062 validate Java class only if this is the only reference to it - // i.e. the persistence.xml ref is the only ref - none of the mapping - // files reference the same class - boolean validateJavaPersistentType = true; - for (MappingFileRef mappingFileRef : this.getPersistenceUnit().getMappingFileRefsContaining(this.getJavaClassName())) { - validateJavaPersistentType = false; - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.LOW_SEVERITY, - JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS, - new String[] {this.getJavaClassName(), mappingFileRef.getFileName()}, - this, - this.getValidationTextRange() - ) - ); - } - - if (validateJavaPersistentType) { - this.validateJavaPersistentType(messages, reporter); - } - } - - protected void validateJavaPersistentType(List<IMessage> messages, IReporter reporter) { - try { - this.javaPersistentType.validate(messages, reporter); - } catch (Throwable t) { - JptJpaCorePlugin.log(t); - } - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlValidationTextRange(); - return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); - } - - public TextRange getXmlValidationTextRange() { - return this.isVirtual() ? null : this.xmlJavaClassRef.getValidationTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericJarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericJarFileRef.java deleted file mode 100644 index eec257e95c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericJarFileRef.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractJarFileRef; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlJarFileRef; - -/** - * Context JAR file reference (from the persistence unit) - */ -public class GenericJarFileRef - extends AbstractJarFileRef -{ - public GenericJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) { - super(parent, xmlJarFileRef); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java deleted file mode 100644 index 5d5b555a53..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.common.core.resource.ProjectResourceLocator; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractMappingFileRef; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.ReplaceEdit; - -/** - * <code>persistence.xml</code> file - * <br> - * <code>mapping-file</code> element - */ -public class GenericMappingFileRef - extends AbstractMappingFileRef -{ - protected final XmlMappingFileRef xmlMappingFileRef; - - - public GenericMappingFileRef(PersistenceUnit parent, XmlMappingFileRef xmlMappingFileRef) { - super(parent, xmlMappingFileRef.getFileName()); - this.xmlMappingFileRef = xmlMappingFileRef; - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - // set the file name *before* calling super - this.setFileName_(this.xmlMappingFileRef.getFileName()); - super.synchronizeWithResourceModel(); - } - - - // ********** file name ********** - - public void setFileName(String fileName) { - this.setFileName_(fileName); - this.xmlMappingFileRef.setFileName(fileName); - } - - protected void setFileName_(String xmlFileName) { - String old = this.fileName; - this.fileName = xmlFileName; - if (this.firePropertyChanged(FILE_NAME_PROPERTY, old, xmlFileName)) { - if (this.mappingFile != null) { - this.mappingFile.dispose(); - this.setMappingFile(null); - } - } - } - - - // ********** misc ********** - - public XmlMappingFileRef getXmlMappingFileRef() { - return this.xmlMappingFileRef; - } - - public boolean isImplied() { - return false; - } - - public boolean containsOffset(int textOffset) { - return this.xmlMappingFileRef.containsOffset(textOffset); - } - - - // ********** JpaStructureNode implementation ********** - - public TextRange getSelectionTextRange() { - return this.xmlMappingFileRef.getSelectionTextRange(); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.getXmlValidationTextRange(); - return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); - } - - protected TextRange getXmlValidationTextRange() { - return this.xmlMappingFileRef.getValidationTextRange(); - } - - - // ********** refactoring ********** - - public Iterable<DeleteEdit> createDeleteMappingFileEdits(IFile file) { - return this.isFor(file) ? - new SingleElementIterable<DeleteEdit>(this.createDeleteEdit()) : - EmptyIterable.<DeleteEdit>instance(); - } - - protected DeleteEdit createDeleteEdit() { - return this.xmlMappingFileRef.createDeleteEdit(); - } - - @Override - protected ReplaceEdit createRenameEdit(IFile originalFile, String newName) { - return this.xmlMappingFileRef.createRenameEdit(originalFile, newName); - } - - public Iterable<ReplaceEdit> createRenameFolderEdits(IFolder originalFolder, String newName) { - return this.isIn(originalFolder) ? - new SingleElementIterable<ReplaceEdit>(this.createRenameFolderEdit(originalFolder, newName)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createRenameFolderEdit(IFolder originalFolder, String newName) { - return this.xmlMappingFileRef.createRenameFolderEdit(originalFolder, newName); - } - - @Override - protected ReplaceEdit createMoveEdit(IFile originalFile, IPath runtineDestination) { - return this.xmlMappingFileRef.createMoveEdit(originalFile, runtineDestination); - } - - public Iterable<ReplaceEdit> createMoveFolderEdits(IFolder originalFolder, IPath runtimeDestination) { - return this.isIn(originalFolder) ? - new SingleElementIterable<ReplaceEdit>(this.createMoveEdit(originalFolder, runtimeDestination)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createMoveEdit(IFolder originalFolder, IPath runtimeDestination) { - IProject project = originalFolder.getProject(); - IPath fullPath = originalFolder.getFullPath(); - ProjectResourceLocator locator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class); - IPath originalLocation = locator.getRuntimePath(fullPath); - return this.createMoveEdit(originalLocation, runtimeDestination); - } - - protected ReplaceEdit createMoveEdit(IPath originalLocation, IPath runtineDestination) { - return this.xmlMappingFileRef.createMoveEdit(originalLocation, runtineDestination); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java deleted file mode 100644 index 636afafeca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import java.util.List; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.Persistence2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * <code>persistence.xml</code> file - * <br> - * <code>persistence</code> element - */ -public class GenericPersistence - extends AbstractPersistenceXmlContextNode - implements Persistence2_0 -{ - protected final XmlPersistence xmlPersistence; - - // The implementation here is a single persistence unit, although the API - // is for a list. We want to support multiple persistence units someday.... - protected PersistenceUnit persistenceUnit; - - - public GenericPersistence(PersistenceXml parent, XmlPersistence xmlPersistence) { - super(parent); - this.xmlPersistence = xmlPersistence; - this.initializePersistenceUnits(); - } - - - // ********** synchronize/update ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.syncPersistenceUnits(); - } - - @Override - public void update() { - super.update(); - this.updateNodes(this.getPersistenceUnits()); - } - - - // ********** persistence units ********** - - public ListIterable<PersistenceUnit> getPersistenceUnits() { - return (this.persistenceUnit == null) ? EmptyListIterable.<PersistenceUnit>instance() : this.getPersistenceUnits_(); - } - - protected ListIterable<PersistenceUnit> getPersistenceUnits_() { - return new SingleElementListIterable<PersistenceUnit>(this.persistenceUnit); - } - - public int getPersistenceUnitsSize() { - return (this.persistenceUnit == null) ? 0 : 1; - } - - public PersistenceUnit getPersistenceUnit(int index) { - if ((index != 0) || (this.persistenceUnit == null)) { - throw this.buildIOOBE(index); - } - return this.persistenceUnit; - } - - protected IndexOutOfBoundsException buildIOOBE(int index) { - return new IndexOutOfBoundsException("index: " + index); //$NON-NLS-1$ - } - - public PersistenceUnit addPersistenceUnit() { - return this.addPersistenceUnit(this.getPersistenceUnitsSize()); - } - - public PersistenceUnit addPersistenceUnit(int index) { - if ((index != 0) || (this.persistenceUnit != null)) { - throw this.buildIOOBE(index); - } - XmlPersistenceUnit xmlPersistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit(); - this.persistenceUnit = this.buildPersistenceUnit(xmlPersistenceUnit); - this.xmlPersistence.getPersistenceUnits().add(xmlPersistenceUnit); - this.fireItemAdded(PERSISTENCE_UNITS_LIST, index, this.persistenceUnit); - this.persistenceUnit.setName(this.getJpaProject().getName()); // default to the project name - return this.persistenceUnit; - } - - public void removePersistenceUnit(PersistenceUnit pu) { - if (pu != this.persistenceUnit) { - throw new IllegalArgumentException("Invalid persistence unit: " + pu); //$NON-NLS-1$ - } - this.removePersistenceUnit(0); - } - - public void removePersistenceUnit(int index) { - if ((index != 0) || (this.persistenceUnit == null)) { - throw this.buildIOOBE(index); - } - PersistenceUnit old = this.persistenceUnit; - this.persistenceUnit.dispose(); - this.persistenceUnit = null; - this.xmlPersistence.getPersistenceUnits().remove(index); - this.fireItemRemoved(PERSISTENCE_UNITS_LIST, index, old); - } - - // only building one here, until we support multiple persistence units... - protected void initializePersistenceUnits() { - XmlPersistenceUnit xmlPersistenceUnit = this.getXmlPersistenceUnit(); - if (xmlPersistenceUnit != null) { - this.persistenceUnit = this.buildPersistenceUnit(xmlPersistenceUnit); - } - } - - protected void syncPersistenceUnits() { - XmlPersistenceUnit xmlPersistenceUnit = this.getXmlPersistenceUnit(); - if (this.persistenceUnit == null) { - if (xmlPersistenceUnit != null) { - this.addPersistenceUnit_(this.buildPersistenceUnit(xmlPersistenceUnit)); - } - } else { - if (xmlPersistenceUnit == null) { - this.removePersistenceUnit_(); - } else { - if (this.persistenceUnit.getXmlPersistenceUnit() == xmlPersistenceUnit) { - this.persistenceUnit.synchronizeWithResourceModel(); - } else { - this.removePersistenceUnit_(); - this.addPersistenceUnit_(this.buildPersistenceUnit(xmlPersistenceUnit)); - } - } - } - } - - protected XmlPersistenceUnit getXmlPersistenceUnit() { - List<XmlPersistenceUnit> xmlPersistenceUnits = this.xmlPersistence.getPersistenceUnits(); - return xmlPersistenceUnits.isEmpty() ? null : xmlPersistenceUnits.get(0); - } - - protected void addPersistenceUnit_(PersistenceUnit pu) { - this.persistenceUnit = pu; - this.fireItemAdded(PERSISTENCE_UNITS_LIST, 0, pu); - } - - protected void removePersistenceUnit_() { - PersistenceUnit old = this.persistenceUnit; - this.persistenceUnit = null; - old.dispose(); - this.fireItemRemoved(PERSISTENCE_UNITS_LIST, 0, old); - } - - protected PersistenceUnit buildPersistenceUnit(XmlPersistenceUnit xmlPersistenceUnit) { - return this.getContextNodeFactory().buildPersistenceUnit(this, xmlPersistenceUnit); - } - - // ********** metamodel ********** - - public void initializeMetamodel() { - for (PersistenceUnit pu : this.getPersistenceUnits()) { - ((PersistenceUnit2_0) pu).initializeMetamodel(); - } - } - - public IStatus synchronizeMetamodel(IProgressMonitor monitor) { - for (PersistenceUnit pu : this.getPersistenceUnits()) { - IStatus status = ((PersistenceUnit2_0) pu).synchronizeMetamodel(monitor); - if (status.getSeverity() == IStatus.CANCEL) { - return status; // seems reasonable... - } - } - return Status.OK_STATUS; - } - - public void disposeMetamodel() { - for (PersistenceUnit pu : this.getPersistenceUnits()) { - ((PersistenceUnit2_0) pu).disposeMetamodel(); - } - } - - - // ********** Persistence implementation ********** - - public XmlPersistence getXmlPersistence() { - return this.xmlPersistence; - } - - public boolean containsOffset(int textOffset) { - return (this.xmlPersistence == null) ? false : this.xmlPersistence.containsOffset(textOffset); - } - - - // ********** XmlContextNode implementation ********** - - @Override - public PersistenceXml getParent() { - return (PersistenceXml) super.getParent(); - } - - public PersistenceXml getPersistenceXml() { - return this.getParent(); - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlPersistence.getValidationTextRange(); - return (textRange != null) ? textRange : this.getPersistenceXml().getValidationTextRange(); - } - - - // ********** JpaStructureNode implementation ********** - - public ContextType getContextType() { - return new ContextType(this); - } - - public Class<Persistence> getType() { - return Persistence.class; - } - - public JpaStructureNode getStructureNode(int textOffset) { - for (PersistenceUnit pu : this.getPersistenceUnits()) { - if (pu.containsOffset(textOffset)) { - return pu.getStructureNode(textOffset); - } - } - return this; - } - - public TextRange getSelectionTextRange() { - return this.xmlPersistence.getSelectionTextRange(); - } - - public void dispose() { - for (PersistenceUnit pu : this.getPersistenceUnits()) { - pu.dispose(); - } - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.validateVersion(messages); - this.checkForMultiplePersistenceUnits(messages); - this.validatePersistenceUnit(messages, reporter); - } - - protected void validateVersion(List<IMessage> messages) { - if (! this.getLatestDocumentVersion().equals(this.xmlPersistence.getVersion())) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.LOW_SEVERITY, - JpaValidationMessages.XML_VERSION_NOT_LATEST, - this, - this.xmlPersistence.getVersionTextRange())); - } - } - - protected String getLatestDocumentVersion() { - return this.getJpaPlatform().getMostRecentSupportedResourceType( - JptJpaCorePlugin.PERSISTENCE_XML_CONTENT_TYPE).getVersion(); - } - - /** - * extraneous persistence units can be - * accessed through the XmlPersistence resource object - */ - protected void checkForMultiplePersistenceUnits(List<IMessage> messages) { - if (this.xmlPersistence.getPersistenceUnits().size() > 1) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.NORMAL_SEVERITY, - JpaValidationMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS, - this, - this.getValidationTextRange() - ) - ); - } - } - - protected void validatePersistenceUnit(List<IMessage> messages, IReporter reporter) { - if (this.persistenceUnit == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENCE_NO_PERSISTENCE_UNIT, - this, - this.getValidationTextRange() - ) - ); - return; - } - this.persistenceUnit.validate(messages, reporter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnit.java deleted file mode 100644 index 9e4a3fa8a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnit.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import java.util.List; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.internal.GenericJpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit; -import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * generic <code>persistence-unit</code> - */ -public class GenericPersistenceUnit - extends AbstractPersistenceUnit -{ - public GenericPersistenceUnit(Persistence parent, XmlPersistenceUnit xmlPersistenceUnit) { - super(parent, xmlPersistenceUnit); - } - - public JpaJpqlQueryHelper createJpqlQueryHelper() { - return new GenericJpaJpqlQueryHelper(this.getJpaPlatform().getJpqlGrammar()); - } - - @Override - protected void validateProperties(List<IMessage> messages, IReporter reporter) { - // do nothing - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java deleted file mode 100644 index 66e1110763..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.Tools; -import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperty; -import org.eclipse.text.edits.ReplaceEdit; - -/** - * Straightforward implementation of the persistence unit property. - * Notifies the persistence unit of any changes to the property. - */ -public class GenericPersistenceUnitProperty - extends AbstractPersistenceXmlContextNode - implements PersistenceUnit.Property -{ - protected final XmlProperty xmlProperty; - protected String name; - protected String value; - - - public GenericPersistenceUnitProperty(PersistenceUnit parent, XmlProperty xmlProperty) { - super(parent); - this.xmlProperty = xmlProperty; - this.name = xmlProperty.getName(); - this.value = xmlProperty.getValue(); - } - - @Override - public PersistenceUnit getParent() { - return (PersistenceUnit) super.getParent(); - } - - public XmlProperty getXmlProperty() { - return this.xmlProperty; - } - - - // ********** synchronize ********** - - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - this.setName_(this.xmlProperty.getName()); - this.setValue_(this.xmlProperty.getValue()); - } - - - // ********** name ********** - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.setName_(name); - this.xmlProperty.setName(name); - } - - protected void setName_(String name) { - String old = this.name; - this.name = name; - if (this.firePropertyChanged(NAME_PROPERTY, old, name)) { - this.getPersistenceUnit().propertyNameChanged(old, name, this.value); - } - } - - - // ********** value ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - this.setValue_(value); - this.xmlProperty.setValue(value); - } - - protected void setValue_(String value) { - String old = this.value; - this.value = value; - if (this.firePropertyChanged(VALUE_PROPERTY, old, value)) { - this.getPersistenceUnit().propertyValueChanged(this.name, value); - } - } - - protected String getValuePackageName() { - return (this.value == null) ? null : this.getValuePackageName_(); - } - - /** - * pre-condition: {@link #value} is not <code>null</code> - */ - protected String getValuePackageName_() { - int lastPeriod = this.value.lastIndexOf('.'); - return (lastPeriod == -1) ? null : this.value.substring(0, lastPeriod); - } - - - // ********** validation ********** - - public TextRange getValidationTextRange() { - TextRange textRange = this.xmlProperty.getValidationTextRange(); - return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); - } - - - // ********** refactoring ********** - - public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) { - return Tools.valuesAreEqual(this.value, originalType.getFullyQualifiedName('.')) ? - new SingleElementIterable<ReplaceEdit>(this.createRenameTypeEdit(originalType, newName)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createRenameTypeEdit(IType originalType, String newName) { - return this.xmlProperty.createRenameTypeEdit(originalType, newName); - } - - public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - return Tools.valuesAreEqual(this.value, originalType.getFullyQualifiedName('.')) ? - new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName())) : - EmptyIterable.<ReplaceEdit>instance(); - } - - public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) { - return Tools.valuesAreEqual(this.getValuePackageName(), originalPackage.getElementName()) ? - new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName)) : - EmptyIterable.<ReplaceEdit>instance(); - } - - protected ReplaceEdit createRenamePackageEdit(String newName) { - return this.xmlProperty.createRenamePackageEdit(newName); - } - - - // ********** misc ********** - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - sb.append(" = "); //$NON-NLS-1$ - sb.append(this.value); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java deleted file mode 100644 index 37bcb619c5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java +++ /dev/null @@ -1,261 +0,0 @@ -/******************************************************************************* - * 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. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import java.util.List; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.JpaFile; -import org.eclipse.jpt.jpa.core.JpaStructureNode; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.JpaRootContextNode; -import org.eclipse.jpt.jpa.core.context.persistence.Persistence; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode; -import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.Persistence2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceXml2_0; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence; -import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * context model <code>persistence.xml</code> file - */ -public class GenericPersistenceXml - extends AbstractPersistenceXmlContextNode - implements PersistenceXml2_0 -{ - /** - * If the XML resource's content type changes, the root context - * node will throw out its current persistence XML. - */ - protected final JpaXmlResource xmlResource; // never null - - /** - * The resource type will only change if the XML file's version changes - * (since, if the content type changes, we get garbage-collected). - */ - protected JptResourceType resourceType; - - /** - * The root element of the <code>persistence.xml</code> file. - */ - protected Persistence persistence; - - - public GenericPersistenceXml(JpaRootContextNode parent, JpaXmlResource xmlResource) { - super(parent); - this.checkXmlResource(xmlResource); - this.xmlResource = xmlResource; - this.resourceType = xmlResource.getResourceType(); - - XmlPersistence xmlPersistence = (XmlPersistence) xmlResource.getRootObject(); - if (xmlPersistence != null) { - this.persistence = this.buildPersistence(xmlPersistence); - } - } - - - // ********** synchronize/update ********** - - /** - * @see org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml#synchronizeWithResourceModel() - */ - @Override - public void synchronizeWithResourceModel() { - super.synchronizeWithResourceModel(); - XmlPersistence oldXmlPersistence = (this.persistence == null) ? null : this.persistence.getXmlPersistence(); - XmlPersistence newXmlPersistence = (XmlPersistence) this.xmlResource.getRootObject(); - JptResourceType newResourceType = this.xmlResource.getResourceType(); - - // If the old and new XML persistences are different instances, - // we scrap the old context persistence and rebuild. - // (This can happen when the resource model changes drastically, - // such as a CVS checkout or an edit reversion.) - if ((oldXmlPersistence != newXmlPersistence) || - (newXmlPersistence == null) || - this.valuesAreDifferent(this.resourceType, newResourceType) - ) { - if (this.persistence != null) { - this.unregisterRootStructureNode(); - this.persistence.dispose(); - this.setPersistence(null); - } - } - - this.resourceType = newResourceType; - - if (newXmlPersistence != null) { - if (this.persistence == null) { - this.setPersistence(this.buildPersistence(newXmlPersistence)); - } else { - // the context persistence already holds the XML persistence - this.persistence.synchronizeWithResourceModel(); - } - } - } - - @Override - public void update() { - super.update(); - if (this.persistence != null) { - this.persistence.update(); - // this will happen redundantly - need to hold JpaFile? - this.registerRootStructureNode(); - } - } - - - // ********** persistence ********** - - public Persistence getPersistence() { - return this.persistence; - } - - protected void setPersistence(Persistence persistence) { - Persistence old = this.persistence; - this.persistence = persistence; - this.firePropertyChanged(PERSISTENCE_PROPERTY, old, persistence); - } - - protected Persistence buildPersistence(XmlPersistence xmlPersistence) { - return this.getContextNodeFactory().buildPersistence(this, xmlPersistence); - } - - - // ********** misc ********** - - protected void checkXmlResource(JpaXmlResource resource) { - if (resource == null) { - throw new NullPointerException(); - } - if ( ! resource.getContentType().isKindOf(JptJpaCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { - throw new IllegalArgumentException("Content type is not 'persistence': " + resource); //$NON-NLS-1$ - } - } - - public JpaXmlResource getXmlResource() { - return this.xmlResource; - } - - @Override - public IResource getResource() { - return this.xmlResource.getFile(); - } - - @Override - public JptResourceType getResourceType() { - return this.xmlResource.getResourceType(); - } - - protected JpaFile getJpaFile() { - return this.getJpaFile(this.xmlResource.getFile()); - } - - public boolean isLatestSupportedVersion() { - return XmlFile_.isLatestSupportedVersion(this); - } - - - // ********** metamodel ********** - - public void initializeMetamodel() { - if (this.persistence != null) { - ((Persistence2_0) this.persistence).initializeMetamodel(); - } - } - - public IStatus synchronizeMetamodel(IProgressMonitor monitor) { - return (this.persistence != null) ? - ((Persistence2_0) this.persistence).synchronizeMetamodel(monitor) : - Status.OK_STATUS; - } - - public void disposeMetamodel() { - if (this.persistence != null) { - ((Persistence2_0) this.persistence).disposeMetamodel(); - } - } - - - // ********** JpaStructureNode implementation ********** - - public ContextType getContextType() { - return new ContextType(this); - } - - public Class<PersistenceXml> getType() { - return PersistenceXml.class; - } - - public JpaStructureNode getStructureNode(int textOffset) { - if (this.persistence.containsOffset(textOffset)) { - return this.persistence.getStructureNode(textOffset); - } - return this; - } - - // never actually selected - public TextRange getSelectionTextRange() { - return TextRange.Empty.instance(); - } - - public void dispose() { - if (this.persistence != null) { - JpaFile jpaFile = this.getJpaFile(); - if (jpaFile != null) { - this.unregisterRootStructureNode(); - } - this.persistence.dispose(); - } - } - - // TODO hold the JpaFile? - protected void registerRootStructureNode() { - this.getJpaFile().addRootStructureNode(this.xmlResource, this.persistence); - } - - protected void unregisterRootStructureNode() { - this.getJpaFile().removeRootStructureNode(this.xmlResource, this.persistence); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - - if (this.persistence == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.PERSISTENCE_XML_INVALID_CONTENT, - this - ) - ); - return; - } - - this.persistence.validate(messages, reporter); - } - - public TextRange getValidationTextRange() { - // since this is the entire file, point to the top of the file - return TextRange.Empty.instance(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXmlDefinition.java deleted file mode 100644 index 57d9a22b6e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXmlDefinition.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlContextNodeFactory; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlDefinition; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlDefinition; -import org.eclipse.jpt.jpa.core.internal.context.persistence.GenericPersistenceXmlContextNodeFactory; -import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory; - -public class GenericPersistenceXmlDefinition - extends AbstractPersistenceXmlDefinition -{ - // singleton - private static final PersistenceXmlDefinition INSTANCE = new GenericPersistenceXmlDefinition(); - - /** - * Return the singleton - */ - public static PersistenceXmlDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private GenericPersistenceXmlDefinition() { - super(); - } - - public JptResourceType getResourceType() { - return JptJpaCorePlugin.PERSISTENCE_XML_1_0_RESOURCE_TYPE; - } - - public EFactory getResourceNodeFactory() { - return PersistenceFactory.eINSTANCE; - } - - @Override - protected PersistenceXmlContextNodeFactory buildContextNodeFactory() { - return new GenericPersistenceXmlContextNodeFactory(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/ImpliedMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/ImpliedMappingFileRef.java deleted file mode 100644 index dca36559d9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/ImpliedMappingFileRef.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractMappingFileRef; -import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.text.edits.ReplaceEdit; - -/** - * Used by the persistence unit for the - * <code>META-INF/orm.xml</code> file when it is not explicitly listed - * in the <code>persistence.xml</code> file. - */ -public class ImpliedMappingFileRef - extends AbstractMappingFileRef -{ - - // ********** construction/initialization ********** - - public ImpliedMappingFileRef(PersistenceUnit parent, String fileName) { - super(parent, fileName); - } - - - // ********** MappingFileRef implementation ********** - - public XmlMappingFileRef getXmlMappingFileRef() { - throw new UnsupportedOperationException(); - } - - public boolean isImplied() { - return true; - } - - public void setFileName(String fileName) { - throw new UnsupportedOperationException("Cannot set an implied mapping file ref's 'fileName': " + fileName); //$NON-NLS-1$ - } - - public boolean containsOffset(int textOffset) { - return false; - } - - - // ********** JpaStructureNode implementation ********** - - public TextRange getSelectionTextRange() { - return null; - } - - - // ********** XmlContextNode implementation ********** - - public TextRange getValidationTextRange() { - return this.getPersistenceUnit().getValidationTextRange(); - } - - - // ********** refactoring ********** - - public Iterable<DeleteEdit> createDeleteMappingFileEdits(IFile file) { - throw new IllegalStateException("This reference cannot be deleted - it is implied"); //$NON-NLS-1$ - } - - public Iterable<ReplaceEdit> createRenameFolderEdits(IFolder originalFolder, String newName) { - throw new IllegalStateException("This reference cannot be moved - it is implied"); //$NON-NLS-1$ - } - - @Override - protected ReplaceEdit createRenameEdit(IFile originalFile, String newName) { - return this.createReplaceEdit(this.fileName.substring(0, this.fileName.lastIndexOf('/') + 1) + newName); - } - - @Override - protected ReplaceEdit createMoveEdit(IFile originalFile, IPath runtimeDestination) { - return this.createReplaceEdit(runtimeDestination.append(originalFile.getName()).toString()); - } - - protected ReplaceEdit createReplaceEdit(String newMappingFileName) { - StringBuilder sb = new StringBuilder(); - sb.append(StringTools.CR); - sb.append("\t\t<mapping-file>"); //$NON-NLS-1$ - sb.append(newMappingFileName); - sb.append("</mapping-file>"); //$NON-NLS-1$ - int offset = this.getPersistenceUnit().findInsertLocationForMappingFileRef(); - return new ReplaceEdit(offset, 0, sb.toString()); - } - - public Iterable<ReplaceEdit> createMoveFolderEdits(IFolder originalFolder, IPath runtimeDestination) { - throw new IllegalStateException("This reference cannot be moved - it is implied"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryAssociationOverride1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryAssociationOverride1_0Annotation.java deleted file mode 100644 index a9e3b009a8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryAssociationOverride1_0Annotation.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.common.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.jpa.core.internal.resource.java.binary.BinaryAssociationOverrideAnnotation; - -/** - * javax.persistence.AssociationOverride - */ -public final class BinaryAssociationOverride1_0Annotation - extends BinaryAssociationOverrideAnnotation -{ - - public BinaryAssociationOverride1_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java deleted file mode 100644 index 34bd911323..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinaryNamedQuery1_0Annotation.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 2011 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.common.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.jpa.core.internal.resource.java.binary.BinaryNamedQueryAnnotation; - -/** - * javax.persistence.NamedQuery - */ -public final class BinaryNamedQuery1_0Annotation - extends BinaryNamedQueryAnnotation -{ - - public BinaryNamedQuery1_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinarySequenceGenerator1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinarySequenceGenerator1_0Annotation.java deleted file mode 100644 index 8079c4b62b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/binary/BinarySequenceGenerator1_0Annotation.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.common.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.jpa.core.internal.resource.java.binary.BinarySequenceGeneratorAnnotation; - -/** - * javax.persistence.SequenceGenerator - */ -public final class BinarySequenceGenerator1_0Annotation - extends BinarySequenceGeneratorAnnotation -{ - - public BinarySequenceGenerator1_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceAssociationOverride1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceAssociationOverride1_0Annotation.java deleted file mode 100644 index 987867e3c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceAssociationOverride1_0Annotation.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.source; - -import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.common.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.common.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAssociationOverrideAnnotation; - -/** - * <code>javax.persistence.AssociationOverride</code> - */ -public final class SourceAssociationOverride1_0Annotation - extends SourceAssociationOverrideAnnotation -{ - - public static SourceAssociationOverride1_0Annotation buildSourceAssociationOverrideAnnotation( - JavaResourceNode parent, - AnnotatedElement element) { - - return new SourceAssociationOverride1_0Annotation(parent, element, DECLARATION_ANNOTATION_ADAPTER); - } - - public static SourceAssociationOverride1_0Annotation buildSourceAssociationOverrideAnnotation( - JavaResourceAnnotatedElement parent, - AnnotatedElement annotatedElement, - int index) { - IndexedDeclarationAnnotationAdapter idaa = buildAssociationOverrideDeclarationAnnotationAdapter(index); - IndexedAnnotationAdapter iaa = buildAssociationOverrideAnnotationAdapter(annotatedElement, idaa); - return new SourceAssociationOverride1_0Annotation( - parent, - annotatedElement, - idaa, - iaa); - } - - public static SourceAssociationOverride1_0Annotation buildNestedSourceAssociationOverrideAnnotation( - JavaResourceNode parent, - AnnotatedElement element, - IndexedDeclarationAnnotationAdapter idaa) { - - return new SourceAssociationOverride1_0Annotation(parent, element, idaa); - } - - private SourceAssociationOverride1_0Annotation( - JavaResourceNode parent, - AnnotatedElement element, - DeclarationAnnotationAdapter daa) { - - this(parent, element, daa, new ElementAnnotationAdapter(element, daa)); - } - - private SourceAssociationOverride1_0Annotation( - JavaResourceNode parent, - AnnotatedElement element, - IndexedDeclarationAnnotationAdapter idaa) { - - this(parent, element, idaa, new ElementIndexedAnnotationAdapter(element, idaa)); - } - - private SourceAssociationOverride1_0Annotation(JavaResourceNode parent, AnnotatedElement element, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, element, daa, annotationAdapter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java deleted file mode 100644 index 3ce0b644b0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceNamedQuery1_0Annotation.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* -* Copyright (c) 2009, 2011 Oracle. All rights reserved. -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0, which accompanies this distribution -* and is available at http://www.eclipse.org/legal/epl-v10.html. -* -* Contributors: -* Oracle - initial API and implementation -*******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.source; - -import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceNamedQueryAnnotation; - -/** - * <code>javax.persistence.NamedQuery</code> - */ -public final class SourceNamedQuery1_0Annotation - extends SourceNamedQueryAnnotation -{ - public static SourceNamedQuery1_0Annotation buildSourceNamedQueryAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index) { - IndexedDeclarationAnnotationAdapter idaa = buildNamedQueryDeclarationAnnotationAdapter(index); - IndexedAnnotationAdapter iaa = buildNamedQueryAnnotationAdapter(annotatedElement, idaa); - return new SourceNamedQuery1_0Annotation( - parent, - annotatedElement, - idaa, - iaa); - } - - private SourceNamedQuery1_0Annotation( - JavaResourceAnnotatedElement parent, - AnnotatedElement annotatedElement, - IndexedDeclarationAnnotationAdapter daa, - IndexedAnnotationAdapter annotationAdapter) { - super(parent, annotatedElement, daa, annotationAdapter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceSequenceGenerator1_0Annotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceSequenceGenerator1_0Annotation.java deleted file mode 100644 index 99cc3b6c72..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/resource/java/source/SourceSequenceGenerator1_0Annotation.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.internal.jpa1.resource.java.source; - -import org.eclipse.jpt.common.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceSequenceGeneratorAnnotation; - -/** - * javax.persistence.SequenceGenerator - */ -public final class SourceSequenceGenerator1_0Annotation - extends SourceSequenceGeneratorAnnotation -{ - - public SourceSequenceGenerator1_0Annotation(JavaResourceNode parent, AnnotatedElement element) { - super(parent, element); - } - -} |